babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  686. static readonly GEQUAL: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = nearest */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Class 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. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  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. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4907. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * @returns the stride in float32 units
  6314. * @deprecated Please use byteStride instead.
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * @returns the stride in float32 units
  6444. * @deprecated Please use byteStride instead.
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * @returns the offset in bytes
  6450. * @deprecated Please use byteOffset instead.
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light textures.
  10227. * @param effect The effect to update
  10228. * @param lightIndex The index of the light in the effect to update
  10229. * @returns The light
  10230. */
  10231. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10232. /**
  10233. * Binds the lights information from the scene to the effect for the given mesh.
  10234. * @param lightIndex Light index
  10235. * @param scene The scene where the light belongs to
  10236. * @param effect The effect we are binding the data to
  10237. * @param useSpecular Defines if specular is supported
  10238. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10239. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10240. */
  10241. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10242. /**
  10243. * Sets the passed Effect "effect" with the Light information.
  10244. * @param effect The effect to update
  10245. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10246. * @returns The light
  10247. */
  10248. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10249. /**
  10250. * Returns the string "Light".
  10251. * @returns the class name
  10252. */
  10253. getClassName(): string;
  10254. /** @hidden */
  10255. readonly _isLight: boolean;
  10256. /**
  10257. * Converts the light information to a readable string for debug purpose.
  10258. * @param fullDetails Supports for multiple levels of logging within scene loading
  10259. * @returns the human readable light info
  10260. */
  10261. toString(fullDetails?: boolean): string;
  10262. /** @hidden */
  10263. protected _syncParentEnabledState(): void;
  10264. /**
  10265. * Set the enabled state of this node.
  10266. * @param value - the new enabled state
  10267. */
  10268. setEnabled(value: boolean): void;
  10269. /**
  10270. * Returns the Light associated shadow generator if any.
  10271. * @return the associated shadow generator.
  10272. */
  10273. getShadowGenerator(): Nullable<IShadowGenerator>;
  10274. /**
  10275. * Returns a Vector3, the absolute light position in the World.
  10276. * @returns the world space position of the light
  10277. */
  10278. getAbsolutePosition(): Vector3;
  10279. /**
  10280. * Specifies if the light will affect the passed mesh.
  10281. * @param mesh The mesh to test against the light
  10282. * @return true the mesh is affected otherwise, false.
  10283. */
  10284. canAffectMesh(mesh: AbstractMesh): boolean;
  10285. /**
  10286. * Sort function to order lights for rendering.
  10287. * @param a First Light object to compare to second.
  10288. * @param b Second Light object to compare first.
  10289. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10290. */
  10291. static CompareLightsPriority(a: Light, b: Light): number;
  10292. /**
  10293. * Releases resources associated with this node.
  10294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10296. */
  10297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10298. /**
  10299. * Returns the light type ID (integer).
  10300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10301. */
  10302. getTypeID(): number;
  10303. /**
  10304. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10305. * @returns the scaled intensity in intensity mode unit
  10306. */
  10307. getScaledIntensity(): number;
  10308. /**
  10309. * Returns a new Light object, named "name", from the current one.
  10310. * @param name The name of the cloned light
  10311. * @returns the new created light
  10312. */
  10313. clone(name: string): Nullable<Light>;
  10314. /**
  10315. * Serializes the current light into a Serialization object.
  10316. * @returns the serialized object.
  10317. */
  10318. serialize(): any;
  10319. /**
  10320. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10321. * This new light is named "name" and added to the passed scene.
  10322. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10323. * @param name The friendly name of the light
  10324. * @param scene The scene the new light will belong to
  10325. * @returns the constructor function
  10326. */
  10327. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10328. /**
  10329. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10330. * @param parsedLight The JSON representation of the light
  10331. * @param scene The scene to create the parsed light in
  10332. * @returns the created light after parsing
  10333. */
  10334. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10335. private _hookArrayForExcluded;
  10336. private _hookArrayForIncludedOnly;
  10337. private _resyncMeshes;
  10338. /**
  10339. * Forces the meshes to update their light related information in their rendering used effects
  10340. * @hidden Internal Use Only
  10341. */
  10342. _markMeshesAsLightDirty(): void;
  10343. /**
  10344. * Recomputes the cached photometric scale if needed.
  10345. */
  10346. private _computePhotometricScale;
  10347. /**
  10348. * Returns the Photometric Scale according to the light type and intensity mode.
  10349. */
  10350. private _getPhotometricScale;
  10351. /**
  10352. * Reorder the light in the scene according to their defined priority.
  10353. * @hidden Internal Use Only
  10354. */
  10355. _reorderLightsInScene(): void;
  10356. /**
  10357. * Prepares the list of defines specific to the light type.
  10358. * @param defines the list of defines
  10359. * @param lightIndex defines the index of the light for the effect
  10360. */
  10361. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10362. }
  10363. }
  10364. declare module "babylonjs/Actions/action" {
  10365. import { Observable } from "babylonjs/Misc/observable";
  10366. import { Condition } from "babylonjs/Actions/condition";
  10367. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10368. import { ActionManager } from "babylonjs/Actions/actionManager";
  10369. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10370. /**
  10371. * Interface used to define Action
  10372. */
  10373. export interface IAction {
  10374. /**
  10375. * Trigger for the action
  10376. */
  10377. trigger: number;
  10378. /** Options of the trigger */
  10379. triggerOptions: any;
  10380. /**
  10381. * Gets the trigger parameters
  10382. * @returns the trigger parameters
  10383. */
  10384. getTriggerParameter(): any;
  10385. /**
  10386. * Internal only - executes current action event
  10387. * @hidden
  10388. */
  10389. _executeCurrent(evt?: ActionEvent): void;
  10390. /**
  10391. * Serialize placeholder for child classes
  10392. * @param parent of child
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. /**
  10397. * Internal only
  10398. * @hidden
  10399. */
  10400. _prepare(): void;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: AbstractActionManager;
  10406. /**
  10407. * Adds action to chain of actions, may be a DoNothingAction
  10408. * @param action defines the next action to execute
  10409. * @returns The action passed in
  10410. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10411. */
  10412. then(action: IAction): IAction;
  10413. }
  10414. /**
  10415. * The action to be carried out following a trigger
  10416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10417. */
  10418. export class Action implements IAction {
  10419. /** the trigger, with or without parameters, for the action */
  10420. triggerOptions: any;
  10421. /**
  10422. * Trigger for the action
  10423. */
  10424. trigger: number;
  10425. /**
  10426. * Internal only - manager for action
  10427. * @hidden
  10428. */
  10429. _actionManager: ActionManager;
  10430. private _nextActiveAction;
  10431. private _child;
  10432. private _condition?;
  10433. private _triggerParameter;
  10434. /**
  10435. * An event triggered prior to action being executed.
  10436. */
  10437. onBeforeExecuteObservable: Observable<Action>;
  10438. /**
  10439. * Creates a new Action
  10440. * @param triggerOptions the trigger, with or without parameters, for the action
  10441. * @param condition an optional determinant of action
  10442. */
  10443. constructor(
  10444. /** the trigger, with or without parameters, for the action */
  10445. triggerOptions: any, condition?: Condition);
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. _prepare(): void;
  10451. /**
  10452. * Gets the trigger parameters
  10453. * @returns the trigger parameters
  10454. */
  10455. getTriggerParameter(): any;
  10456. /**
  10457. * Internal only - executes current action event
  10458. * @hidden
  10459. */
  10460. _executeCurrent(evt?: ActionEvent): void;
  10461. /**
  10462. * Execute placeholder for child classes
  10463. * @param evt optional action event
  10464. */
  10465. execute(evt?: ActionEvent): void;
  10466. /**
  10467. * Skips to next active action
  10468. */
  10469. skipToNextActiveAction(): void;
  10470. /**
  10471. * Adds action to chain of actions, may be a DoNothingAction
  10472. * @param action defines the next action to execute
  10473. * @returns The action passed in
  10474. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10475. */
  10476. then(action: Action): Action;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getProperty(propertyPath: string): string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getEffectiveTarget(target: any, propertyPath: string): any;
  10487. /**
  10488. * Serialize placeholder for child classes
  10489. * @param parent of child
  10490. * @returns the serialized object
  10491. */
  10492. serialize(parent: any): any;
  10493. /**
  10494. * Internal only called by serialize
  10495. * @hidden
  10496. */
  10497. protected _serialize(serializedAction: any, parent?: any): any;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. static _SerializeValueAsString: (value: any) => string;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10508. name: string;
  10509. targetType: string;
  10510. value: string;
  10511. };
  10512. }
  10513. }
  10514. declare module "babylonjs/Actions/condition" {
  10515. import { ActionManager } from "babylonjs/Actions/actionManager";
  10516. /**
  10517. * A Condition applied to an Action
  10518. */
  10519. export class Condition {
  10520. /**
  10521. * Internal only - manager for action
  10522. * @hidden
  10523. */
  10524. _actionManager: ActionManager;
  10525. /**
  10526. * Internal only
  10527. * @hidden
  10528. */
  10529. _evaluationId: number;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _currentResult: boolean;
  10535. /**
  10536. * Creates a new Condition
  10537. * @param actionManager the manager of the action the condition is applied to
  10538. */
  10539. constructor(actionManager: ActionManager);
  10540. /**
  10541. * Check if the current condition is valid
  10542. * @returns a boolean
  10543. */
  10544. isValid(): boolean;
  10545. /**
  10546. * Internal only
  10547. * @hidden
  10548. */
  10549. _getProperty(propertyPath: string): string;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */
  10554. _getEffectiveTarget(target: any, propertyPath: string): any;
  10555. /**
  10556. * Serialize placeholder for child classes
  10557. * @returns the serialized object
  10558. */
  10559. serialize(): any;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. protected _serialize(serializedCondition: any): any;
  10565. }
  10566. /**
  10567. * Defines specific conditional operators as extensions of Condition
  10568. */
  10569. export class ValueCondition extends Condition {
  10570. /** path to specify the property of the target the conditional operator uses */
  10571. propertyPath: string;
  10572. /** the value compared by the conditional operator against the current value of the property */
  10573. value: any;
  10574. /** the conditional operator, default ValueCondition.IsEqual */
  10575. operator: number;
  10576. /**
  10577. * Internal only
  10578. * @hidden
  10579. */
  10580. private static _IsEqual;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsDifferent;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsGreater;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. private static _IsLesser;
  10596. /**
  10597. * returns the number for IsEqual
  10598. */
  10599. static readonly IsEqual: number;
  10600. /**
  10601. * Returns the number for IsDifferent
  10602. */
  10603. static readonly IsDifferent: number;
  10604. /**
  10605. * Returns the number for IsGreater
  10606. */
  10607. static readonly IsGreater: number;
  10608. /**
  10609. * Returns the number for IsLesser
  10610. */
  10611. static readonly IsLesser: number;
  10612. /**
  10613. * Internal only The action manager for the condition
  10614. * @hidden
  10615. */
  10616. _actionManager: ActionManager;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. private _target;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _effectiveTarget;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. private _property;
  10632. /**
  10633. * Creates a new ValueCondition
  10634. * @param actionManager manager for the action the condition applies to
  10635. * @param target for the action
  10636. * @param propertyPath path to specify the property of the target the conditional operator uses
  10637. * @param value the value compared by the conditional operator against the current value of the property
  10638. * @param operator the conditional operator, default ValueCondition.IsEqual
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** path to specify the property of the target the conditional operator uses */
  10642. propertyPath: string,
  10643. /** the value compared by the conditional operator against the current value of the property */
  10644. value: any,
  10645. /** the conditional operator, default ValueCondition.IsEqual */
  10646. operator?: number);
  10647. /**
  10648. * Compares the given value with the property value for the specified conditional operator
  10649. * @returns the result of the comparison
  10650. */
  10651. isValid(): boolean;
  10652. /**
  10653. * Serialize the ValueCondition into a JSON compatible object
  10654. * @returns serialization object
  10655. */
  10656. serialize(): any;
  10657. /**
  10658. * Gets the name of the conditional operator for the ValueCondition
  10659. * @param operator the conditional operator
  10660. * @returns the name
  10661. */
  10662. static GetOperatorName(operator: number): string;
  10663. }
  10664. /**
  10665. * Defines a predicate condition as an extension of Condition
  10666. */
  10667. export class PredicateCondition extends Condition {
  10668. /** defines the predicate function used to validate the condition */
  10669. predicate: () => boolean;
  10670. /**
  10671. * Internal only - manager for action
  10672. * @hidden
  10673. */
  10674. _actionManager: ActionManager;
  10675. /**
  10676. * Creates a new PredicateCondition
  10677. * @param actionManager manager for the action the condition applies to
  10678. * @param predicate defines the predicate function used to validate the condition
  10679. */
  10680. constructor(actionManager: ActionManager,
  10681. /** defines the predicate function used to validate the condition */
  10682. predicate: () => boolean);
  10683. /**
  10684. * @returns the validity of the predicate condition
  10685. */
  10686. isValid(): boolean;
  10687. }
  10688. /**
  10689. * Defines a state condition as an extension of Condition
  10690. */
  10691. export class StateCondition extends Condition {
  10692. /** Value to compare with target state */
  10693. value: string;
  10694. /**
  10695. * Internal only - manager for action
  10696. * @hidden
  10697. */
  10698. _actionManager: ActionManager;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. private _target;
  10704. /**
  10705. * Creates a new StateCondition
  10706. * @param actionManager manager for the action the condition applies to
  10707. * @param target of the condition
  10708. * @param value to compare with target state
  10709. */
  10710. constructor(actionManager: ActionManager, target: any,
  10711. /** Value to compare with target state */
  10712. value: string);
  10713. /**
  10714. * Gets a boolean indicating if the current condition is met
  10715. * @returns the validity of the state
  10716. */
  10717. isValid(): boolean;
  10718. /**
  10719. * Serialize the StateCondition into a JSON compatible object
  10720. * @returns serialization object
  10721. */
  10722. serialize(): any;
  10723. }
  10724. }
  10725. declare module "babylonjs/Actions/directActions" {
  10726. import { Action } from "babylonjs/Actions/action";
  10727. import { Condition } from "babylonjs/Actions/condition";
  10728. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10729. /**
  10730. * This defines an action responsible to toggle a boolean once triggered.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10732. */
  10733. export class SwitchBooleanAction extends Action {
  10734. /**
  10735. * The path to the boolean property in the target object
  10736. */
  10737. propertyPath: string;
  10738. private _target;
  10739. private _effectiveTarget;
  10740. private _property;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the object containing the boolean
  10745. * @param propertyPath defines the path to the boolean property in the target object
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10749. /** @hidden */
  10750. _prepare(): void;
  10751. /**
  10752. * Execute the action toggle the boolean value.
  10753. */
  10754. execute(): void;
  10755. /**
  10756. * Serializes the actions and its related information.
  10757. * @param parent defines the object to serialize in
  10758. * @returns the serialized object
  10759. */
  10760. serialize(parent: any): any;
  10761. }
  10762. /**
  10763. * This defines an action responsible to set a the state field of the target
  10764. * to a desired value once triggered.
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class SetStateAction extends Action {
  10768. /**
  10769. * The value to store in the state field.
  10770. */
  10771. value: string;
  10772. private _target;
  10773. /**
  10774. * Instantiate the action
  10775. * @param triggerOptions defines the trigger options
  10776. * @param target defines the object containing the state property
  10777. * @param value defines the value to store in the state field
  10778. * @param condition defines the trigger related conditions
  10779. */
  10780. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10781. /**
  10782. * Execute the action and store the value on the target state property.
  10783. */
  10784. execute(): void;
  10785. /**
  10786. * Serializes the actions and its related information.
  10787. * @param parent defines the object to serialize in
  10788. * @returns the serialized object
  10789. */
  10790. serialize(parent: any): any;
  10791. }
  10792. /**
  10793. * This defines an action responsible to set a property of the target
  10794. * to a desired value once triggered.
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10796. */
  10797. export class SetValueAction extends Action {
  10798. /**
  10799. * The path of the property to set in the target.
  10800. */
  10801. propertyPath: string;
  10802. /**
  10803. * The value to set in the property
  10804. */
  10805. value: any;
  10806. private _target;
  10807. private _effectiveTarget;
  10808. private _property;
  10809. /**
  10810. * Instantiate the action
  10811. * @param triggerOptions defines the trigger options
  10812. * @param target defines the object containing the property
  10813. * @param propertyPath defines the path of the property to set in the target
  10814. * @param value defines the value to set in the property
  10815. * @param condition defines the trigger related conditions
  10816. */
  10817. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10818. /** @hidden */
  10819. _prepare(): void;
  10820. /**
  10821. * Execute the action and set the targetted property to the desired value.
  10822. */
  10823. execute(): void;
  10824. /**
  10825. * Serializes the actions and its related information.
  10826. * @param parent defines the object to serialize in
  10827. * @returns the serialized object
  10828. */
  10829. serialize(parent: any): any;
  10830. }
  10831. /**
  10832. * This defines an action responsible to increment the target value
  10833. * to a desired value once triggered.
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10835. */
  10836. export class IncrementValueAction extends Action {
  10837. /**
  10838. * The path of the property to increment in the target.
  10839. */
  10840. propertyPath: string;
  10841. /**
  10842. * The value we should increment the property by.
  10843. */
  10844. value: any;
  10845. private _target;
  10846. private _effectiveTarget;
  10847. private _property;
  10848. /**
  10849. * Instantiate the action
  10850. * @param triggerOptions defines the trigger options
  10851. * @param target defines the object containing the property
  10852. * @param propertyPath defines the path of the property to increment in the target
  10853. * @param value defines the value value we should increment the property by
  10854. * @param condition defines the trigger related conditions
  10855. */
  10856. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10857. /** @hidden */
  10858. _prepare(): void;
  10859. /**
  10860. * Execute the action and increment the target of the value amount.
  10861. */
  10862. execute(): void;
  10863. /**
  10864. * Serializes the actions and its related information.
  10865. * @param parent defines the object to serialize in
  10866. * @returns the serialized object
  10867. */
  10868. serialize(parent: any): any;
  10869. }
  10870. /**
  10871. * This defines an action responsible to start an animation once triggered.
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10873. */
  10874. export class PlayAnimationAction extends Action {
  10875. /**
  10876. * Where the animation should start (animation frame)
  10877. */
  10878. from: number;
  10879. /**
  10880. * Where the animation should stop (animation frame)
  10881. */
  10882. to: number;
  10883. /**
  10884. * Define if the animation should loop or stop after the first play.
  10885. */
  10886. loop?: boolean;
  10887. private _target;
  10888. /**
  10889. * Instantiate the action
  10890. * @param triggerOptions defines the trigger options
  10891. * @param target defines the target animation or animation name
  10892. * @param from defines from where the animation should start (animation frame)
  10893. * @param end defines where the animation should stop (animation frame)
  10894. * @param loop defines if the animation should loop or stop after the first play
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and play the animation.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. /**
  10912. * This defines an action responsible to stop an animation once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class StopAnimationAction extends Action {
  10916. private _target;
  10917. /**
  10918. * Instantiate the action
  10919. * @param triggerOptions defines the trigger options
  10920. * @param target defines the target animation or animation name
  10921. * @param condition defines the trigger related conditions
  10922. */
  10923. constructor(triggerOptions: any, target: any, condition?: Condition);
  10924. /** @hidden */
  10925. _prepare(): void;
  10926. /**
  10927. * Execute the action and stop the animation.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible that does nothing once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class DoNothingAction extends Action {
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param condition defines the trigger related conditions
  10946. */
  10947. constructor(triggerOptions?: any, condition?: Condition);
  10948. /**
  10949. * Execute the action and do nothing.
  10950. */
  10951. execute(): void;
  10952. /**
  10953. * Serializes the actions and its related information.
  10954. * @param parent defines the object to serialize in
  10955. * @returns the serialized object
  10956. */
  10957. serialize(parent: any): any;
  10958. }
  10959. /**
  10960. * This defines an action responsible to trigger several actions once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class CombineAction extends Action {
  10964. /**
  10965. * The list of aggregated animations to run.
  10966. */
  10967. children: Action[];
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param children defines the list of aggregated animations to run
  10972. * @param condition defines the trigger related conditions
  10973. */
  10974. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10975. /** @hidden */
  10976. _prepare(): void;
  10977. /**
  10978. * Execute the action and executes all the aggregated actions.
  10979. */
  10980. execute(evt: ActionEvent): void;
  10981. /**
  10982. * Serializes the actions and its related information.
  10983. * @param parent defines the object to serialize in
  10984. * @returns the serialized object
  10985. */
  10986. serialize(parent: any): any;
  10987. }
  10988. /**
  10989. * This defines an action responsible to run code (external event) once triggered.
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10991. */
  10992. export class ExecuteCodeAction extends Action {
  10993. /**
  10994. * The callback function to run.
  10995. */
  10996. func: (evt: ActionEvent) => void;
  10997. /**
  10998. * Instantiate the action
  10999. * @param triggerOptions defines the trigger options
  11000. * @param func defines the callback function to run
  11001. * @param condition defines the trigger related conditions
  11002. */
  11003. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11004. /**
  11005. * Execute the action and run the attached code.
  11006. */
  11007. execute(evt: ActionEvent): void;
  11008. }
  11009. /**
  11010. * This defines an action responsible to set the parent property of the target once triggered.
  11011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11012. */
  11013. export class SetParentAction extends Action {
  11014. private _parent;
  11015. private _target;
  11016. /**
  11017. * Instantiate the action
  11018. * @param triggerOptions defines the trigger options
  11019. * @param target defines the target containing the parent property
  11020. * @param parent defines from where the animation should start (animation frame)
  11021. * @param condition defines the trigger related conditions
  11022. */
  11023. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11024. /** @hidden */
  11025. _prepare(): void;
  11026. /**
  11027. * Execute the action and set the parent property.
  11028. */
  11029. execute(): void;
  11030. /**
  11031. * Serializes the actions and its related information.
  11032. * @param parent defines the object to serialize in
  11033. * @returns the serialized object
  11034. */
  11035. serialize(parent: any): any;
  11036. }
  11037. }
  11038. declare module "babylonjs/Actions/actionManager" {
  11039. import { Nullable } from "babylonjs/types";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Scene } from "babylonjs/scene";
  11042. import { IAction } from "babylonjs/Actions/action";
  11043. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11044. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11045. /**
  11046. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11047. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11049. */
  11050. export class ActionManager extends AbstractActionManager {
  11051. /**
  11052. * Nothing
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11054. */
  11055. static readonly NothingTrigger: number;
  11056. /**
  11057. * On pick
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly OnPickTrigger: number;
  11061. /**
  11062. * On left pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnLeftPickTrigger: number;
  11066. /**
  11067. * On right pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnRightPickTrigger: number;
  11071. /**
  11072. * On center pick
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnCenterPickTrigger: number;
  11076. /**
  11077. * On pick down
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnPickDownTrigger: number;
  11081. /**
  11082. * On double pick
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnDoublePickTrigger: number;
  11086. /**
  11087. * On pick up
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnPickUpTrigger: number;
  11091. /**
  11092. * On pick out.
  11093. * This trigger will only be raised if you also declared a OnPickDown
  11094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11095. */
  11096. static readonly OnPickOutTrigger: number;
  11097. /**
  11098. * On long press
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnLongPressTrigger: number;
  11102. /**
  11103. * On pointer over
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnPointerOverTrigger: number;
  11107. /**
  11108. * On pointer out
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnPointerOutTrigger: number;
  11112. /**
  11113. * On every frame
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnEveryFrameTrigger: number;
  11117. /**
  11118. * On intersection enter
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnIntersectionEnterTrigger: number;
  11122. /**
  11123. * On intersection exit
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnIntersectionExitTrigger: number;
  11127. /**
  11128. * On key down
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnKeyDownTrigger: number;
  11132. /**
  11133. * On key up
  11134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11135. */
  11136. static readonly OnKeyUpTrigger: number;
  11137. private _scene;
  11138. /**
  11139. * Creates a new action manager
  11140. * @param scene defines the hosting scene
  11141. */
  11142. constructor(scene: Scene);
  11143. /**
  11144. * Releases all associated resources
  11145. */
  11146. dispose(): void;
  11147. /**
  11148. * Gets hosting scene
  11149. * @returns the hosting scene
  11150. */
  11151. getScene(): Scene;
  11152. /**
  11153. * Does this action manager handles actions of any of the given triggers
  11154. * @param triggers defines the triggers to be tested
  11155. * @return a boolean indicating whether one (or more) of the triggers is handled
  11156. */
  11157. hasSpecificTriggers(triggers: number[]): boolean;
  11158. /**
  11159. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11160. * speed.
  11161. * @param triggerA defines the trigger to be tested
  11162. * @param triggerB defines the trigger to be tested
  11163. * @return a boolean indicating whether one (or more) of the triggers is handled
  11164. */
  11165. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11166. /**
  11167. * Does this action manager handles actions of a given trigger
  11168. * @param trigger defines the trigger to be tested
  11169. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11170. * @return whether the trigger is handled
  11171. */
  11172. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11173. /**
  11174. * Does this action manager has pointer triggers
  11175. */
  11176. readonly hasPointerTriggers: boolean;
  11177. /**
  11178. * Does this action manager has pick triggers
  11179. */
  11180. readonly hasPickTriggers: boolean;
  11181. /**
  11182. * Registers an action to this action manager
  11183. * @param action defines the action to be registered
  11184. * @return the action amended (prepared) after registration
  11185. */
  11186. registerAction(action: IAction): Nullable<IAction>;
  11187. /**
  11188. * Unregisters an action to this action manager
  11189. * @param action defines the action to be unregistered
  11190. * @return a boolean indicating whether the action has been unregistered
  11191. */
  11192. unregisterAction(action: IAction): Boolean;
  11193. /**
  11194. * Process a specific trigger
  11195. * @param trigger defines the trigger to process
  11196. * @param evt defines the event details to be processed
  11197. */
  11198. processTrigger(trigger: number, evt?: IActionEvent): void;
  11199. /** @hidden */
  11200. _getEffectiveTarget(target: any, propertyPath: string): any;
  11201. /** @hidden */
  11202. _getProperty(propertyPath: string): string;
  11203. /**
  11204. * Serialize this manager to a JSON object
  11205. * @param name defines the property name to store this manager
  11206. * @returns a JSON representation of this manager
  11207. */
  11208. serialize(name: string): any;
  11209. /**
  11210. * Creates a new ActionManager from a JSON data
  11211. * @param parsedActions defines the JSON data to read from
  11212. * @param object defines the hosting mesh
  11213. * @param scene defines the hosting scene
  11214. */
  11215. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11216. /**
  11217. * Get a trigger name by index
  11218. * @param trigger defines the trigger index
  11219. * @returns a trigger name
  11220. */
  11221. static GetTriggerName(trigger: number): string;
  11222. }
  11223. }
  11224. declare module "babylonjs/Culling/ray" {
  11225. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11228. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11229. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11230. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11232. import { Plane } from "babylonjs/Maths/math.plane";
  11233. /**
  11234. * Class representing a ray with position and direction
  11235. */
  11236. export class Ray {
  11237. /** origin point */
  11238. origin: Vector3;
  11239. /** direction */
  11240. direction: Vector3;
  11241. /** length of the ray */
  11242. length: number;
  11243. private static readonly TmpVector3;
  11244. private _tmpRay;
  11245. /**
  11246. * Creates a new ray
  11247. * @param origin origin point
  11248. * @param direction direction
  11249. * @param length length of the ray
  11250. */
  11251. constructor(
  11252. /** origin point */
  11253. origin: Vector3,
  11254. /** direction */
  11255. direction: Vector3,
  11256. /** length of the ray */
  11257. length?: number);
  11258. /**
  11259. * Checks if the ray intersects a box
  11260. * @param minimum bound of the box
  11261. * @param maximum bound of the box
  11262. * @param intersectionTreshold extra extend to be added to the box in all direction
  11263. * @returns if the box was hit
  11264. */
  11265. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11266. /**
  11267. * Checks if the ray intersects a box
  11268. * @param box the bounding box to check
  11269. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11270. * @returns if the box was hit
  11271. */
  11272. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11273. /**
  11274. * If the ray hits a sphere
  11275. * @param sphere the bounding sphere to check
  11276. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11277. * @returns true if it hits the sphere
  11278. */
  11279. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11280. /**
  11281. * If the ray hits a triange
  11282. * @param vertex0 triangle vertex
  11283. * @param vertex1 triangle vertex
  11284. * @param vertex2 triangle vertex
  11285. * @returns intersection information if hit
  11286. */
  11287. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11288. /**
  11289. * Checks if ray intersects a plane
  11290. * @param plane the plane to check
  11291. * @returns the distance away it was hit
  11292. */
  11293. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11294. /**
  11295. * Calculate the intercept of a ray on a given axis
  11296. * @param axis to check 'x' | 'y' | 'z'
  11297. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11298. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11299. */
  11300. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11301. /**
  11302. * Checks if ray intersects a mesh
  11303. * @param mesh the mesh to check
  11304. * @param fastCheck if only the bounding box should checked
  11305. * @returns picking info of the intersecton
  11306. */
  11307. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11308. /**
  11309. * Checks if ray intersects a mesh
  11310. * @param meshes the meshes to check
  11311. * @param fastCheck if only the bounding box should checked
  11312. * @param results array to store result in
  11313. * @returns Array of picking infos
  11314. */
  11315. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11316. private _comparePickingInfo;
  11317. private static smallnum;
  11318. private static rayl;
  11319. /**
  11320. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11321. * @param sega the first point of the segment to test the intersection against
  11322. * @param segb the second point of the segment to test the intersection against
  11323. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11324. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11325. */
  11326. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11327. /**
  11328. * Update the ray from viewport position
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns this ray updated
  11337. */
  11338. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * Creates a ray with origin and direction of 0,0,0
  11341. * @returns the new ray
  11342. */
  11343. static Zero(): Ray;
  11344. /**
  11345. * Creates a new ray from screen space and viewport
  11346. * @param x position
  11347. * @param y y position
  11348. * @param viewportWidth viewport width
  11349. * @param viewportHeight viewport height
  11350. * @param world world matrix
  11351. * @param view view matrix
  11352. * @param projection projection matrix
  11353. * @returns new ray
  11354. */
  11355. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11356. /**
  11357. * 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
  11358. * transformed to the given world matrix.
  11359. * @param origin The origin point
  11360. * @param end The end point
  11361. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11362. * @returns the new ray
  11363. */
  11364. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11365. /**
  11366. * Transforms a ray by a matrix
  11367. * @param ray ray to transform
  11368. * @param matrix matrix to apply
  11369. * @returns the resulting new ray
  11370. */
  11371. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11372. /**
  11373. * Transforms a ray by a matrix
  11374. * @param ray ray to transform
  11375. * @param matrix matrix to apply
  11376. * @param result ray to store result in
  11377. */
  11378. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11379. /**
  11380. * Unproject a ray from screen space to object space
  11381. * @param sourceX defines the screen space x coordinate to use
  11382. * @param sourceY defines the screen space y coordinate to use
  11383. * @param viewportWidth defines the current width of the viewport
  11384. * @param viewportHeight defines the current height of the viewport
  11385. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11386. * @param view defines the view matrix to use
  11387. * @param projection defines the projection matrix to use
  11388. */
  11389. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11390. }
  11391. /**
  11392. * Type used to define predicate used to select faces when a mesh intersection is detected
  11393. */
  11394. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11395. module "babylonjs/scene" {
  11396. interface Scene {
  11397. /** @hidden */
  11398. _tempPickingRay: Nullable<Ray>;
  11399. /** @hidden */
  11400. _cachedRayForTransform: Ray;
  11401. /** @hidden */
  11402. _pickWithRayInverseMatrix: Matrix;
  11403. /** @hidden */
  11404. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11405. /** @hidden */
  11406. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11407. }
  11408. }
  11409. }
  11410. declare module "babylonjs/sceneComponent" {
  11411. import { Scene } from "babylonjs/scene";
  11412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11414. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11415. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11416. import { Nullable } from "babylonjs/types";
  11417. import { Camera } from "babylonjs/Cameras/camera";
  11418. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11419. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11420. import { AbstractScene } from "babylonjs/abstractScene";
  11421. import { Mesh } from "babylonjs/Meshes/mesh";
  11422. /**
  11423. * Groups all the scene component constants in one place to ease maintenance.
  11424. * @hidden
  11425. */
  11426. export class SceneComponentConstants {
  11427. static readonly NAME_EFFECTLAYER: string;
  11428. static readonly NAME_LAYER: string;
  11429. static readonly NAME_LENSFLARESYSTEM: string;
  11430. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11431. static readonly NAME_PARTICLESYSTEM: string;
  11432. static readonly NAME_GAMEPAD: string;
  11433. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11434. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11435. static readonly NAME_DEPTHRENDERER: string;
  11436. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11437. static readonly NAME_SPRITE: string;
  11438. static readonly NAME_OUTLINERENDERER: string;
  11439. static readonly NAME_PROCEDURALTEXTURE: string;
  11440. static readonly NAME_SHADOWGENERATOR: string;
  11441. static readonly NAME_OCTREE: string;
  11442. static readonly NAME_PHYSICSENGINE: string;
  11443. static readonly NAME_AUDIO: string;
  11444. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11445. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11446. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11447. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11448. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11449. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11450. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11451. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11452. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11453. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11454. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11455. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11456. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11457. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11458. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11459. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11460. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11461. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11462. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11463. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11464. static readonly STEP_AFTERRENDER_AUDIO: number;
  11465. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11466. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11467. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11468. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11469. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11470. static readonly STEP_POINTERMOVE_SPRITE: number;
  11471. static readonly STEP_POINTERDOWN_SPRITE: number;
  11472. static readonly STEP_POINTERUP_SPRITE: number;
  11473. }
  11474. /**
  11475. * This represents a scene component.
  11476. *
  11477. * This is used to decouple the dependency the scene is having on the different workloads like
  11478. * layers, post processes...
  11479. */
  11480. export interface ISceneComponent {
  11481. /**
  11482. * The name of the component. Each component must have a unique name.
  11483. */
  11484. name: string;
  11485. /**
  11486. * The scene the component belongs to.
  11487. */
  11488. scene: Scene;
  11489. /**
  11490. * Register the component to one instance of a scene.
  11491. */
  11492. register(): void;
  11493. /**
  11494. * Rebuilds the elements related to this component in case of
  11495. * context lost for instance.
  11496. */
  11497. rebuild(): void;
  11498. /**
  11499. * Disposes the component and the associated ressources.
  11500. */
  11501. dispose(): void;
  11502. }
  11503. /**
  11504. * This represents a SERIALIZABLE scene component.
  11505. *
  11506. * This extends Scene Component to add Serialization methods on top.
  11507. */
  11508. export interface ISceneSerializableComponent extends ISceneComponent {
  11509. /**
  11510. * Adds all the elements from the container to the scene
  11511. * @param container the container holding the elements
  11512. */
  11513. addFromContainer(container: AbstractScene): void;
  11514. /**
  11515. * Removes all the elements in the container from the scene
  11516. * @param container contains the elements to remove
  11517. * @param dispose if the removed element should be disposed (default: false)
  11518. */
  11519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11520. /**
  11521. * Serializes the component data to the specified json object
  11522. * @param serializationObject The object to serialize to
  11523. */
  11524. serialize(serializationObject: any): void;
  11525. }
  11526. /**
  11527. * Strong typing of a Mesh related stage step action
  11528. */
  11529. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11530. /**
  11531. * Strong typing of a Evaluate Sub Mesh related stage step action
  11532. */
  11533. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11534. /**
  11535. * Strong typing of a Active Mesh related stage step action
  11536. */
  11537. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11538. /**
  11539. * Strong typing of a Camera related stage step action
  11540. */
  11541. export type CameraStageAction = (camera: Camera) => void;
  11542. /**
  11543. * Strong typing of a Camera Frame buffer related stage step action
  11544. */
  11545. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11546. /**
  11547. * Strong typing of a Render Target related stage step action
  11548. */
  11549. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11550. /**
  11551. * Strong typing of a RenderingGroup related stage step action
  11552. */
  11553. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11554. /**
  11555. * Strong typing of a Mesh Render related stage step action
  11556. */
  11557. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11558. /**
  11559. * Strong typing of a simple stage step action
  11560. */
  11561. export type SimpleStageAction = () => void;
  11562. /**
  11563. * Strong typing of a render target action.
  11564. */
  11565. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11566. /**
  11567. * Strong typing of a pointer move action.
  11568. */
  11569. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11570. /**
  11571. * Strong typing of a pointer up/down action.
  11572. */
  11573. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11574. /**
  11575. * Representation of a stage in the scene (Basically a list of ordered steps)
  11576. * @hidden
  11577. */
  11578. export class Stage<T extends Function> extends Array<{
  11579. index: number;
  11580. component: ISceneComponent;
  11581. action: T;
  11582. }> {
  11583. /**
  11584. * Hide ctor from the rest of the world.
  11585. * @param items The items to add.
  11586. */
  11587. private constructor();
  11588. /**
  11589. * Creates a new Stage.
  11590. * @returns A new instance of a Stage
  11591. */
  11592. static Create<T extends Function>(): Stage<T>;
  11593. /**
  11594. * Registers a step in an ordered way in the targeted stage.
  11595. * @param index Defines the position to register the step in
  11596. * @param component Defines the component attached to the step
  11597. * @param action Defines the action to launch during the step
  11598. */
  11599. registerStep(index: number, component: ISceneComponent, action: T): void;
  11600. /**
  11601. * Clears all the steps from the stage.
  11602. */
  11603. clear(): void;
  11604. }
  11605. }
  11606. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11607. import { Nullable } from "babylonjs/types";
  11608. import { Observable } from "babylonjs/Misc/observable";
  11609. import { Scene } from "babylonjs/scene";
  11610. import { Sprite } from "babylonjs/Sprites/sprite";
  11611. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11612. import { Ray } from "babylonjs/Culling/ray";
  11613. import { Camera } from "babylonjs/Cameras/camera";
  11614. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11615. import { ISceneComponent } from "babylonjs/sceneComponent";
  11616. module "babylonjs/scene" {
  11617. interface Scene {
  11618. /** @hidden */
  11619. _pointerOverSprite: Nullable<Sprite>;
  11620. /** @hidden */
  11621. _pickedDownSprite: Nullable<Sprite>;
  11622. /** @hidden */
  11623. _tempSpritePickingRay: Nullable<Ray>;
  11624. /**
  11625. * All of the sprite managers added to this scene
  11626. * @see http://doc.babylonjs.com/babylon101/sprites
  11627. */
  11628. spriteManagers: Array<ISpriteManager>;
  11629. /**
  11630. * An event triggered when sprites rendering is about to start
  11631. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11632. */
  11633. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11634. /**
  11635. * An event triggered when sprites rendering is done
  11636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11637. */
  11638. onAfterSpritesRenderingObservable: Observable<Scene>;
  11639. /** @hidden */
  11640. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** Launch a ray to try to pick a sprite in the scene
  11642. * @param x position on screen
  11643. * @param y position on screen
  11644. * @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
  11645. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11646. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11647. * @returns a PickingInfo
  11648. */
  11649. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11650. /** Use the given ray to pick a sprite in the scene
  11651. * @param ray The ray (in world space) to use to pick meshes
  11652. * @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
  11653. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo
  11656. */
  11657. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11658. /** @hidden */
  11659. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11660. /** Launch a ray to try to pick sprites in the scene
  11661. * @param x position on screen
  11662. * @param y position on screen
  11663. * @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
  11664. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11665. * @returns a PickingInfo array
  11666. */
  11667. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11668. /** Use the given ray to pick sprites in the scene
  11669. * @param ray The ray (in world space) to use to pick meshes
  11670. * @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
  11671. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11672. * @returns a PickingInfo array
  11673. */
  11674. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11675. /**
  11676. * Force the sprite under the pointer
  11677. * @param sprite defines the sprite to use
  11678. */
  11679. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11680. /**
  11681. * Gets the sprite under the pointer
  11682. * @returns a Sprite or null if no sprite is under the pointer
  11683. */
  11684. getPointerOverSprite(): Nullable<Sprite>;
  11685. }
  11686. }
  11687. /**
  11688. * Defines the sprite scene component responsible to manage sprites
  11689. * in a given scene.
  11690. */
  11691. export class SpriteSceneComponent implements ISceneComponent {
  11692. /**
  11693. * The component name helpfull to identify the component in the list of scene components.
  11694. */
  11695. readonly name: string;
  11696. /**
  11697. * The scene the component belongs to.
  11698. */
  11699. scene: Scene;
  11700. /** @hidden */
  11701. private _spritePredicate;
  11702. /**
  11703. * Creates a new instance of the component for the given scene
  11704. * @param scene Defines the scene to register the component in
  11705. */
  11706. constructor(scene: Scene);
  11707. /**
  11708. * Registers the component in a given scene
  11709. */
  11710. register(): void;
  11711. /**
  11712. * Rebuilds the elements related to this component in case of
  11713. * context lost for instance.
  11714. */
  11715. rebuild(): void;
  11716. /**
  11717. * Disposes the component and the associated ressources.
  11718. */
  11719. dispose(): void;
  11720. private _pickSpriteButKeepRay;
  11721. private _pointerMove;
  11722. private _pointerDown;
  11723. private _pointerUp;
  11724. }
  11725. }
  11726. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11727. /** @hidden */
  11728. export var fogFragmentDeclaration: {
  11729. name: string;
  11730. shader: string;
  11731. };
  11732. }
  11733. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11734. /** @hidden */
  11735. export var fogFragment: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Shaders/sprites.fragment" {
  11741. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11742. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11743. /** @hidden */
  11744. export var spritesPixelShader: {
  11745. name: string;
  11746. shader: string;
  11747. };
  11748. }
  11749. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11750. /** @hidden */
  11751. export var fogVertexDeclaration: {
  11752. name: string;
  11753. shader: string;
  11754. };
  11755. }
  11756. declare module "babylonjs/Shaders/sprites.vertex" {
  11757. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11758. /** @hidden */
  11759. export var spritesVertexShader: {
  11760. name: string;
  11761. shader: string;
  11762. };
  11763. }
  11764. declare module "babylonjs/Sprites/spriteManager" {
  11765. import { IDisposable, Scene } from "babylonjs/scene";
  11766. import { Nullable } from "babylonjs/types";
  11767. import { Observable } from "babylonjs/Misc/observable";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11770. import { Camera } from "babylonjs/Cameras/camera";
  11771. import { Texture } from "babylonjs/Materials/Textures/texture";
  11772. import "babylonjs/Shaders/sprites.fragment";
  11773. import "babylonjs/Shaders/sprites.vertex";
  11774. import { Ray } from "babylonjs/Culling/ray";
  11775. /**
  11776. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11777. */
  11778. export interface ISpriteManager extends IDisposable {
  11779. /**
  11780. * Restricts the camera to viewing objects with the same layerMask.
  11781. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11782. */
  11783. layerMask: number;
  11784. /**
  11785. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11786. */
  11787. isPickable: boolean;
  11788. /**
  11789. * Specifies the rendering group id for this mesh (0 by default)
  11790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11791. */
  11792. renderingGroupId: number;
  11793. /**
  11794. * Defines the list of sprites managed by the manager.
  11795. */
  11796. sprites: Array<Sprite>;
  11797. /**
  11798. * Tests the intersection of a sprite with a specific ray.
  11799. * @param ray The ray we are sending to test the collision
  11800. * @param camera The camera space we are sending rays in
  11801. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11802. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11803. * @returns picking info or null.
  11804. */
  11805. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11806. /**
  11807. * Intersects the sprites with a ray
  11808. * @param ray defines the ray to intersect with
  11809. * @param camera defines the current active camera
  11810. * @param predicate defines a predicate used to select candidate sprites
  11811. * @returns null if no hit or a PickingInfo array
  11812. */
  11813. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11814. /**
  11815. * Renders the list of sprites on screen.
  11816. */
  11817. render(): void;
  11818. }
  11819. /**
  11820. * Class used to manage multiple sprites on the same spritesheet
  11821. * @see http://doc.babylonjs.com/babylon101/sprites
  11822. */
  11823. export class SpriteManager implements ISpriteManager {
  11824. /** defines the manager's name */
  11825. name: string;
  11826. /** Gets the list of sprites */
  11827. sprites: Sprite[];
  11828. /** Gets or sets the rendering group id (0 by default) */
  11829. renderingGroupId: number;
  11830. /** Gets or sets camera layer mask */
  11831. layerMask: number;
  11832. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11833. fogEnabled: boolean;
  11834. /** Gets or sets a boolean indicating if the sprites are pickable */
  11835. isPickable: boolean;
  11836. /** Defines the default width of a cell in the spritesheet */
  11837. cellWidth: number;
  11838. /** Defines the default height of a cell in the spritesheet */
  11839. cellHeight: number;
  11840. /** Associative array from JSON sprite data file */
  11841. private _cellData;
  11842. /** Array of sprite names from JSON sprite data file */
  11843. private _spriteMap;
  11844. /** True when packed cell data from JSON file is ready*/
  11845. private _packedAndReady;
  11846. /**
  11847. * An event triggered when the manager is disposed.
  11848. */
  11849. onDisposeObservable: Observable<SpriteManager>;
  11850. private _onDisposeObserver;
  11851. /**
  11852. * Callback called when the manager is disposed
  11853. */
  11854. onDispose: () => void;
  11855. private _capacity;
  11856. private _fromPacked;
  11857. private _spriteTexture;
  11858. private _epsilon;
  11859. private _scene;
  11860. private _vertexData;
  11861. private _buffer;
  11862. private _vertexBuffers;
  11863. private _indexBuffer;
  11864. private _effectBase;
  11865. private _effectFog;
  11866. /**
  11867. * Gets or sets the spritesheet texture
  11868. */
  11869. texture: Texture;
  11870. /**
  11871. * Creates a new sprite manager
  11872. * @param name defines the manager's name
  11873. * @param imgUrl defines the sprite sheet url
  11874. * @param capacity defines the maximum allowed number of sprites
  11875. * @param cellSize defines the size of a sprite cell
  11876. * @param scene defines the hosting scene
  11877. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11878. * @param samplingMode defines the smapling mode to use with spritesheet
  11879. * @param fromPacked set to false; do not alter
  11880. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11881. */
  11882. constructor(
  11883. /** defines the manager's name */
  11884. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11885. private _makePacked;
  11886. private _appendSpriteVertex;
  11887. /**
  11888. * Intersects the sprites with a ray
  11889. * @param ray defines the ray to intersect with
  11890. * @param camera defines the current active camera
  11891. * @param predicate defines a predicate used to select candidate sprites
  11892. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11893. * @returns null if no hit or a PickingInfo
  11894. */
  11895. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11896. /**
  11897. * Intersects the sprites with a ray
  11898. * @param ray defines the ray to intersect with
  11899. * @param camera defines the current active camera
  11900. * @param predicate defines a predicate used to select candidate sprites
  11901. * @returns null if no hit or a PickingInfo array
  11902. */
  11903. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11904. /**
  11905. * Render all child sprites
  11906. */
  11907. render(): void;
  11908. /**
  11909. * Release associated resources
  11910. */
  11911. dispose(): void;
  11912. }
  11913. }
  11914. declare module "babylonjs/Sprites/sprite" {
  11915. import { Vector3 } from "babylonjs/Maths/math.vector";
  11916. import { Nullable } from "babylonjs/types";
  11917. import { ActionManager } from "babylonjs/Actions/actionManager";
  11918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11919. import { Color4 } from "babylonjs/Maths/math.color";
  11920. /**
  11921. * Class used to represent a sprite
  11922. * @see http://doc.babylonjs.com/babylon101/sprites
  11923. */
  11924. export class Sprite {
  11925. /** defines the name */
  11926. name: string;
  11927. /** Gets or sets the current world position */
  11928. position: Vector3;
  11929. /** Gets or sets the main color */
  11930. color: Color4;
  11931. /** Gets or sets the width */
  11932. width: number;
  11933. /** Gets or sets the height */
  11934. height: number;
  11935. /** Gets or sets rotation angle */
  11936. angle: number;
  11937. /** Gets or sets the cell index in the sprite sheet */
  11938. cellIndex: number;
  11939. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11940. cellRef: string;
  11941. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11942. invertU: number;
  11943. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11944. invertV: number;
  11945. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11946. disposeWhenFinishedAnimating: boolean;
  11947. /** Gets the list of attached animations */
  11948. animations: Animation[];
  11949. /** Gets or sets a boolean indicating if the sprite can be picked */
  11950. isPickable: boolean;
  11951. /**
  11952. * Gets or sets the associated action manager
  11953. */
  11954. actionManager: Nullable<ActionManager>;
  11955. private _animationStarted;
  11956. private _loopAnimation;
  11957. private _fromIndex;
  11958. private _toIndex;
  11959. private _delay;
  11960. private _direction;
  11961. private _manager;
  11962. private _time;
  11963. private _onAnimationEnd;
  11964. /**
  11965. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11966. */
  11967. isVisible: boolean;
  11968. /**
  11969. * Gets or sets the sprite size
  11970. */
  11971. size: number;
  11972. /**
  11973. * Creates a new Sprite
  11974. * @param name defines the name
  11975. * @param manager defines the manager
  11976. */
  11977. constructor(
  11978. /** defines the name */
  11979. name: string, manager: ISpriteManager);
  11980. /**
  11981. * Starts an animation
  11982. * @param from defines the initial key
  11983. * @param to defines the end key
  11984. * @param loop defines if the animation must loop
  11985. * @param delay defines the start delay (in ms)
  11986. * @param onAnimationEnd defines a callback to call when animation ends
  11987. */
  11988. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11989. /** Stops current animation (if any) */
  11990. stopAnimation(): void;
  11991. /** @hidden */
  11992. _animate(deltaTime: number): void;
  11993. /** Release associated resources */
  11994. dispose(): void;
  11995. }
  11996. }
  11997. declare module "babylonjs/Collisions/pickingInfo" {
  11998. import { Nullable } from "babylonjs/types";
  11999. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12001. import { Sprite } from "babylonjs/Sprites/sprite";
  12002. import { Ray } from "babylonjs/Culling/ray";
  12003. /**
  12004. * Information about the result of picking within a scene
  12005. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12006. */
  12007. export class PickingInfo {
  12008. /** @hidden */
  12009. _pickingUnavailable: boolean;
  12010. /**
  12011. * If the pick collided with an object
  12012. */
  12013. hit: boolean;
  12014. /**
  12015. * Distance away where the pick collided
  12016. */
  12017. distance: number;
  12018. /**
  12019. * The location of pick collision
  12020. */
  12021. pickedPoint: Nullable<Vector3>;
  12022. /**
  12023. * The mesh corresponding the the pick collision
  12024. */
  12025. pickedMesh: Nullable<AbstractMesh>;
  12026. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12027. bu: number;
  12028. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12029. bv: number;
  12030. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12031. faceId: number;
  12032. /** Id of the the submesh that was picked */
  12033. subMeshId: number;
  12034. /** If a sprite was picked, this will be the sprite the pick collided with */
  12035. pickedSprite: Nullable<Sprite>;
  12036. /**
  12037. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12038. */
  12039. originMesh: Nullable<AbstractMesh>;
  12040. /**
  12041. * The ray that was used to perform the picking.
  12042. */
  12043. ray: Nullable<Ray>;
  12044. /**
  12045. * Gets the normal correspodning to the face the pick collided with
  12046. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12047. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12048. * @returns The normal correspodning to the face the pick collided with
  12049. */
  12050. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12051. /**
  12052. * Gets the texture coordinates of where the pick occured
  12053. * @returns the vector containing the coordnates of the texture
  12054. */
  12055. getTextureCoordinates(): Nullable<Vector2>;
  12056. }
  12057. }
  12058. declare module "babylonjs/Events/pointerEvents" {
  12059. import { Nullable } from "babylonjs/types";
  12060. import { Vector2 } from "babylonjs/Maths/math.vector";
  12061. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12062. import { Ray } from "babylonjs/Culling/ray";
  12063. /**
  12064. * Gather the list of pointer event types as constants.
  12065. */
  12066. export class PointerEventTypes {
  12067. /**
  12068. * 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.
  12069. */
  12070. static readonly POINTERDOWN: number;
  12071. /**
  12072. * The pointerup event is fired when a pointer is no longer active.
  12073. */
  12074. static readonly POINTERUP: number;
  12075. /**
  12076. * The pointermove event is fired when a pointer changes coordinates.
  12077. */
  12078. static readonly POINTERMOVE: number;
  12079. /**
  12080. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12081. */
  12082. static readonly POINTERWHEEL: number;
  12083. /**
  12084. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12085. */
  12086. static readonly POINTERPICK: number;
  12087. /**
  12088. * The pointertap event is fired when a the object has been touched and released without drag.
  12089. */
  12090. static readonly POINTERTAP: number;
  12091. /**
  12092. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12093. */
  12094. static readonly POINTERDOUBLETAP: number;
  12095. }
  12096. /**
  12097. * Base class of pointer info types.
  12098. */
  12099. export class PointerInfoBase {
  12100. /**
  12101. * Defines the type of event (PointerEventTypes)
  12102. */
  12103. type: number;
  12104. /**
  12105. * Defines the related dom event
  12106. */
  12107. event: PointerEvent | MouseWheelEvent;
  12108. /**
  12109. * Instantiates the base class of pointers info.
  12110. * @param type Defines the type of event (PointerEventTypes)
  12111. * @param event Defines the related dom event
  12112. */
  12113. constructor(
  12114. /**
  12115. * Defines the type of event (PointerEventTypes)
  12116. */
  12117. type: number,
  12118. /**
  12119. * Defines the related dom event
  12120. */
  12121. event: PointerEvent | MouseWheelEvent);
  12122. }
  12123. /**
  12124. * This class is used to store pointer related info for the onPrePointerObservable event.
  12125. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12126. */
  12127. export class PointerInfoPre extends PointerInfoBase {
  12128. /**
  12129. * Ray from a pointer if availible (eg. 6dof controller)
  12130. */
  12131. ray: Nullable<Ray>;
  12132. /**
  12133. * Defines the local position of the pointer on the canvas.
  12134. */
  12135. localPosition: Vector2;
  12136. /**
  12137. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12138. */
  12139. skipOnPointerObservable: boolean;
  12140. /**
  12141. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12142. * @param type Defines the type of event (PointerEventTypes)
  12143. * @param event Defines the related dom event
  12144. * @param localX Defines the local x coordinates of the pointer when the event occured
  12145. * @param localY Defines the local y coordinates of the pointer when the event occured
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12148. }
  12149. /**
  12150. * This type contains all the data related to a pointer event in Babylon.js.
  12151. * 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.
  12152. */
  12153. export class PointerInfo extends PointerInfoBase {
  12154. /**
  12155. * Defines the picking info associated to the info (if any)\
  12156. */
  12157. pickInfo: Nullable<PickingInfo>;
  12158. /**
  12159. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12160. * @param type Defines the type of event (PointerEventTypes)
  12161. * @param event Defines the related dom event
  12162. * @param pickInfo Defines the picking info associated to the info (if any)\
  12163. */
  12164. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12165. /**
  12166. * Defines the picking info associated to the info (if any)\
  12167. */
  12168. pickInfo: Nullable<PickingInfo>);
  12169. }
  12170. /**
  12171. * Data relating to a touch event on the screen.
  12172. */
  12173. export interface PointerTouch {
  12174. /**
  12175. * X coordinate of touch.
  12176. */
  12177. x: number;
  12178. /**
  12179. * Y coordinate of touch.
  12180. */
  12181. y: number;
  12182. /**
  12183. * Id of touch. Unique for each finger.
  12184. */
  12185. pointerId: number;
  12186. /**
  12187. * Event type passed from DOM.
  12188. */
  12189. type: any;
  12190. }
  12191. }
  12192. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12193. import { Observable } from "babylonjs/Misc/observable";
  12194. import { Nullable } from "babylonjs/types";
  12195. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  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. */
  12201. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12202. /**
  12203. * Define if touch is enabled in the mouse input
  12204. */
  12205. touchEnabled: boolean;
  12206. /**
  12207. * Defines the camera the input is attached to.
  12208. */
  12209. camera: FreeCamera;
  12210. /**
  12211. * Defines the buttons associated with the input to handle camera move.
  12212. */
  12213. buttons: number[];
  12214. /**
  12215. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12216. */
  12217. angularSensibility: number;
  12218. private _pointerInput;
  12219. private _onMouseMove;
  12220. private _observer;
  12221. private previousPosition;
  12222. /**
  12223. * Observable for when a pointer move event occurs containing the move offset
  12224. */
  12225. onPointerMovedObservable: Observable<{
  12226. offsetX: number;
  12227. offsetY: number;
  12228. }>;
  12229. /**
  12230. * @hidden
  12231. * If the camera should be rotated automatically based on pointer movement
  12232. */
  12233. _allowCameraRotation: boolean;
  12234. /**
  12235. * Manage the mouse inputs to control the movement of a free camera.
  12236. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12237. * @param touchEnabled Defines if touch is enabled or not
  12238. */
  12239. constructor(
  12240. /**
  12241. * Define if touch is enabled in the mouse input
  12242. */
  12243. touchEnabled?: boolean);
  12244. /**
  12245. * Attach the input controls to a specific dom element to get the input from.
  12246. * @param element Defines the element the controls should be listened from
  12247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12248. */
  12249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12250. /**
  12251. * Called on JS contextmenu event.
  12252. * Override this method to provide functionality.
  12253. */
  12254. protected onContextMenu(evt: PointerEvent): void;
  12255. /**
  12256. * Detach the current controls from the specified dom element.
  12257. * @param element Defines the element to stop listening the inputs from
  12258. */
  12259. detachControl(element: Nullable<HTMLElement>): void;
  12260. /**
  12261. * Gets the class name of the current intput.
  12262. * @returns the class name
  12263. */
  12264. getClassName(): string;
  12265. /**
  12266. * Get the friendly name associated with the input class.
  12267. * @returns the input friendly name
  12268. */
  12269. getSimpleName(): string;
  12270. }
  12271. }
  12272. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12273. import { Nullable } from "babylonjs/types";
  12274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12276. /**
  12277. * Manage the touch inputs to control the movement of a free camera.
  12278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12279. */
  12280. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12281. /**
  12282. * Defines the camera the input is attached to.
  12283. */
  12284. camera: FreeCamera;
  12285. /**
  12286. * Defines the touch sensibility for rotation.
  12287. * The higher the faster.
  12288. */
  12289. touchAngularSensibility: number;
  12290. /**
  12291. * Defines the touch sensibility for move.
  12292. * The higher the faster.
  12293. */
  12294. touchMoveSensibility: number;
  12295. private _offsetX;
  12296. private _offsetY;
  12297. private _pointerPressed;
  12298. private _pointerInput;
  12299. private _observer;
  12300. private _onLostFocus;
  12301. /**
  12302. * Attach the input controls to a specific dom element to get the input from.
  12303. * @param element Defines the element the controls should be listened from
  12304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12305. */
  12306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12307. /**
  12308. * Detach the current controls from the specified dom element.
  12309. * @param element Defines the element to stop listening the inputs from
  12310. */
  12311. detachControl(element: Nullable<HTMLElement>): void;
  12312. /**
  12313. * Update the current camera state depending on the inputs that have been used this frame.
  12314. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12315. */
  12316. checkInputs(): void;
  12317. /**
  12318. * Gets the class name of the current intput.
  12319. * @returns the class name
  12320. */
  12321. getClassName(): string;
  12322. /**
  12323. * Get the friendly name associated with the input class.
  12324. * @returns the input friendly name
  12325. */
  12326. getSimpleName(): string;
  12327. }
  12328. }
  12329. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12331. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12332. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12333. import { Nullable } from "babylonjs/types";
  12334. /**
  12335. * Default Inputs manager for the FreeCamera.
  12336. * It groups all the default supported inputs for ease of use.
  12337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12338. */
  12339. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12340. /**
  12341. * @hidden
  12342. */
  12343. _mouseInput: Nullable<FreeCameraMouseInput>;
  12344. /**
  12345. * Instantiates a new FreeCameraInputsManager.
  12346. * @param camera Defines the camera the inputs belong to
  12347. */
  12348. constructor(camera: FreeCamera);
  12349. /**
  12350. * Add keyboard input support to the input manager.
  12351. * @returns the current input manager
  12352. */
  12353. addKeyboard(): FreeCameraInputsManager;
  12354. /**
  12355. * Add mouse input support to the input manager.
  12356. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12357. * @returns the current input manager
  12358. */
  12359. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12360. /**
  12361. * Removes the mouse input support from the manager
  12362. * @returns the current input manager
  12363. */
  12364. removeMouse(): FreeCameraInputsManager;
  12365. /**
  12366. * Add touch input support to the input manager.
  12367. * @returns the current input manager
  12368. */
  12369. addTouch(): FreeCameraInputsManager;
  12370. /**
  12371. * Remove all attached input methods from a camera
  12372. */
  12373. clear(): void;
  12374. }
  12375. }
  12376. declare module "babylonjs/Cameras/freeCamera" {
  12377. import { Vector3 } from "babylonjs/Maths/math.vector";
  12378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12379. import { Scene } from "babylonjs/scene";
  12380. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12381. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12382. /**
  12383. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12384. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12386. */
  12387. export class FreeCamera extends TargetCamera {
  12388. /**
  12389. * Define the collision ellipsoid of the camera.
  12390. * This is helpful to simulate a camera body like the player body around the camera
  12391. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12392. */
  12393. ellipsoid: Vector3;
  12394. /**
  12395. * Define an offset for the position of the ellipsoid around the camera.
  12396. * This can be helpful to determine the center of the body near the gravity center of the body
  12397. * instead of its head.
  12398. */
  12399. ellipsoidOffset: Vector3;
  12400. /**
  12401. * Enable or disable collisions of the camera with the rest of the scene objects.
  12402. */
  12403. checkCollisions: boolean;
  12404. /**
  12405. * Enable or disable gravity on the camera.
  12406. */
  12407. applyGravity: boolean;
  12408. /**
  12409. * Define the input manager associated to the camera.
  12410. */
  12411. inputs: FreeCameraInputsManager;
  12412. /**
  12413. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12414. * Higher values reduce sensitivity.
  12415. */
  12416. /**
  12417. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12418. * Higher values reduce sensitivity.
  12419. */
  12420. angularSensibility: number;
  12421. /**
  12422. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12423. */
  12424. keysUp: number[];
  12425. /**
  12426. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12427. */
  12428. keysDown: number[];
  12429. /**
  12430. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12431. */
  12432. keysLeft: number[];
  12433. /**
  12434. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12435. */
  12436. keysRight: number[];
  12437. /**
  12438. * Event raised when the camera collide with a mesh in the scene.
  12439. */
  12440. onCollide: (collidedMesh: AbstractMesh) => void;
  12441. private _collider;
  12442. private _needMoveForGravity;
  12443. private _oldPosition;
  12444. private _diffPosition;
  12445. private _newPosition;
  12446. /** @hidden */
  12447. _localDirection: Vector3;
  12448. /** @hidden */
  12449. _transformedDirection: Vector3;
  12450. /**
  12451. * Instantiates a Free Camera.
  12452. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12453. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12454. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12455. * @param name Define the name of the camera in the scene
  12456. * @param position Define the start position of the camera in the scene
  12457. * @param scene Define the scene the camera belongs to
  12458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12459. */
  12460. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12461. /**
  12462. * Attached controls to the current camera.
  12463. * @param element Defines the element the controls should be listened from
  12464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12465. */
  12466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12467. /**
  12468. * Detach the current controls from the camera.
  12469. * The camera will stop reacting to inputs.
  12470. * @param element Defines the element to stop listening the inputs from
  12471. */
  12472. detachControl(element: HTMLElement): void;
  12473. private _collisionMask;
  12474. /**
  12475. * Define a collision mask to limit the list of object the camera can collide with
  12476. */
  12477. collisionMask: number;
  12478. /** @hidden */
  12479. _collideWithWorld(displacement: Vector3): void;
  12480. private _onCollisionPositionChange;
  12481. /** @hidden */
  12482. _checkInputs(): void;
  12483. /** @hidden */
  12484. _decideIfNeedsToMove(): boolean;
  12485. /** @hidden */
  12486. _updatePosition(): void;
  12487. /**
  12488. * Destroy the camera and release the current resources hold by it.
  12489. */
  12490. dispose(): void;
  12491. /**
  12492. * Gets the current object class name.
  12493. * @return the class name
  12494. */
  12495. getClassName(): string;
  12496. }
  12497. }
  12498. declare module "babylonjs/Gamepads/gamepad" {
  12499. import { Observable } from "babylonjs/Misc/observable";
  12500. /**
  12501. * Represents a gamepad control stick position
  12502. */
  12503. export class StickValues {
  12504. /**
  12505. * The x component of the control stick
  12506. */
  12507. x: number;
  12508. /**
  12509. * The y component of the control stick
  12510. */
  12511. y: number;
  12512. /**
  12513. * Initializes the gamepad x and y control stick values
  12514. * @param x The x component of the gamepad control stick value
  12515. * @param y The y component of the gamepad control stick value
  12516. */
  12517. constructor(
  12518. /**
  12519. * The x component of the control stick
  12520. */
  12521. x: number,
  12522. /**
  12523. * The y component of the control stick
  12524. */
  12525. y: number);
  12526. }
  12527. /**
  12528. * An interface which manages callbacks for gamepad button changes
  12529. */
  12530. export interface GamepadButtonChanges {
  12531. /**
  12532. * Called when a gamepad has been changed
  12533. */
  12534. changed: boolean;
  12535. /**
  12536. * Called when a gamepad press event has been triggered
  12537. */
  12538. pressChanged: boolean;
  12539. /**
  12540. * Called when a touch event has been triggered
  12541. */
  12542. touchChanged: boolean;
  12543. /**
  12544. * Called when a value has changed
  12545. */
  12546. valueChanged: boolean;
  12547. }
  12548. /**
  12549. * Represents a gamepad
  12550. */
  12551. export class Gamepad {
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string;
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number;
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any;
  12564. /**
  12565. * Specifies what type of gamepad this represents
  12566. */
  12567. type: number;
  12568. private _leftStick;
  12569. private _rightStick;
  12570. /** @hidden */
  12571. _isConnected: boolean;
  12572. private _leftStickAxisX;
  12573. private _leftStickAxisY;
  12574. private _rightStickAxisX;
  12575. private _rightStickAxisY;
  12576. /**
  12577. * Triggered when the left control stick has been changed
  12578. */
  12579. private _onleftstickchanged;
  12580. /**
  12581. * Triggered when the right control stick has been changed
  12582. */
  12583. private _onrightstickchanged;
  12584. /**
  12585. * Represents a gamepad controller
  12586. */
  12587. static GAMEPAD: number;
  12588. /**
  12589. * Represents a generic controller
  12590. */
  12591. static GENERIC: number;
  12592. /**
  12593. * Represents an XBox controller
  12594. */
  12595. static XBOX: number;
  12596. /**
  12597. * Represents a pose-enabled controller
  12598. */
  12599. static POSE_ENABLED: number;
  12600. /**
  12601. * Represents an Dual Shock controller
  12602. */
  12603. static DUALSHOCK: number;
  12604. /**
  12605. * Specifies whether the left control stick should be Y-inverted
  12606. */
  12607. protected _invertLeftStickY: boolean;
  12608. /**
  12609. * Specifies if the gamepad has been connected
  12610. */
  12611. readonly isConnected: boolean;
  12612. /**
  12613. * Initializes the gamepad
  12614. * @param id The id of the gamepad
  12615. * @param index The index of the gamepad
  12616. * @param browserGamepad The browser gamepad
  12617. * @param leftStickX The x component of the left joystick
  12618. * @param leftStickY The y component of the left joystick
  12619. * @param rightStickX The x component of the right joystick
  12620. * @param rightStickY The y component of the right joystick
  12621. */
  12622. constructor(
  12623. /**
  12624. * The id of the gamepad
  12625. */
  12626. id: string,
  12627. /**
  12628. * The index of the gamepad
  12629. */
  12630. index: number,
  12631. /**
  12632. * The browser gamepad
  12633. */
  12634. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12635. /**
  12636. * Callback triggered when the left joystick has changed
  12637. * @param callback
  12638. */
  12639. onleftstickchanged(callback: (values: StickValues) => void): void;
  12640. /**
  12641. * Callback triggered when the right joystick has changed
  12642. * @param callback
  12643. */
  12644. onrightstickchanged(callback: (values: StickValues) => void): void;
  12645. /**
  12646. * Gets the left joystick
  12647. */
  12648. /**
  12649. * Sets the left joystick values
  12650. */
  12651. leftStick: StickValues;
  12652. /**
  12653. * Gets the right joystick
  12654. */
  12655. /**
  12656. * Sets the right joystick value
  12657. */
  12658. rightStick: StickValues;
  12659. /**
  12660. * Updates the gamepad joystick positions
  12661. */
  12662. update(): void;
  12663. /**
  12664. * Disposes the gamepad
  12665. */
  12666. dispose(): void;
  12667. }
  12668. /**
  12669. * Represents a generic gamepad
  12670. */
  12671. export class GenericPad extends Gamepad {
  12672. private _buttons;
  12673. private _onbuttondown;
  12674. private _onbuttonup;
  12675. /**
  12676. * Observable triggered when a button has been pressed
  12677. */
  12678. onButtonDownObservable: Observable<number>;
  12679. /**
  12680. * Observable triggered when a button has been released
  12681. */
  12682. onButtonUpObservable: Observable<number>;
  12683. /**
  12684. * Callback triggered when a button has been pressed
  12685. * @param callback Called when a button has been pressed
  12686. */
  12687. onbuttondown(callback: (buttonPressed: number) => void): void;
  12688. /**
  12689. * Callback triggered when a button has been released
  12690. * @param callback Called when a button has been released
  12691. */
  12692. onbuttonup(callback: (buttonReleased: number) => void): void;
  12693. /**
  12694. * Initializes the generic gamepad
  12695. * @param id The id of the generic gamepad
  12696. * @param index The index of the generic gamepad
  12697. * @param browserGamepad The browser gamepad
  12698. */
  12699. constructor(id: string, index: number, browserGamepad: any);
  12700. private _setButtonValue;
  12701. /**
  12702. * Updates the generic gamepad
  12703. */
  12704. update(): void;
  12705. /**
  12706. * Disposes the generic gamepad
  12707. */
  12708. dispose(): void;
  12709. }
  12710. }
  12711. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12712. import { Nullable } from "babylonjs/types";
  12713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12714. import { Scene } from "babylonjs/scene";
  12715. module "babylonjs/Engines/engine" {
  12716. interface Engine {
  12717. /**
  12718. * Creates a raw texture
  12719. * @param data defines the data to store in the texture
  12720. * @param width defines the width of the texture
  12721. * @param height defines the height of the texture
  12722. * @param format defines the format of the data
  12723. * @param generateMipMaps defines if the engine should generate the mip levels
  12724. * @param invertY defines if data must be stored with Y axis inverted
  12725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12726. * @param compression defines the compression used (null by default)
  12727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12728. * @returns the raw texture inside an InternalTexture
  12729. */
  12730. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12731. /**
  12732. * Update a raw texture
  12733. * @param texture defines the texture to update
  12734. * @param data defines the data to store in the texture
  12735. * @param format defines the format of the data
  12736. * @param invertY defines if data must be stored with Y axis inverted
  12737. */
  12738. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12739. /**
  12740. * Update a raw texture
  12741. * @param texture defines the texture to update
  12742. * @param data defines the data to store in the texture
  12743. * @param format defines the format of the data
  12744. * @param invertY defines if data must be stored with Y axis inverted
  12745. * @param compression defines the compression used (null by default)
  12746. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12747. */
  12748. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12749. /**
  12750. * Creates a new raw cube texture
  12751. * @param data defines the array of data to use to create each face
  12752. * @param size defines the size of the textures
  12753. * @param format defines the format of the data
  12754. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12755. * @param generateMipMaps defines if the engine should generate the mip levels
  12756. * @param invertY defines if data must be stored with Y axis inverted
  12757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12758. * @param compression defines the compression used (null by default)
  12759. * @returns the cube texture as an InternalTexture
  12760. */
  12761. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12762. /**
  12763. * Update a raw cube texture
  12764. * @param texture defines the texture to udpdate
  12765. * @param data defines the data to store
  12766. * @param format defines the data format
  12767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12768. * @param invertY defines if data must be stored with Y axis inverted
  12769. */
  12770. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12771. /**
  12772. * Update a raw cube texture
  12773. * @param texture defines the texture to udpdate
  12774. * @param data defines the data to store
  12775. * @param format defines the data format
  12776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12777. * @param invertY defines if data must be stored with Y axis inverted
  12778. * @param compression defines the compression used (null by default)
  12779. */
  12780. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12781. /**
  12782. * Update a raw cube texture
  12783. * @param texture defines the texture to udpdate
  12784. * @param data defines the data to store
  12785. * @param format defines the data format
  12786. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12787. * @param invertY defines if data must be stored with Y axis inverted
  12788. * @param compression defines the compression used (null by default)
  12789. * @param level defines which level of the texture to update
  12790. */
  12791. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12792. /**
  12793. * Creates a new raw cube texture from a specified url
  12794. * @param url defines the url where the data is located
  12795. * @param scene defines the current scene
  12796. * @param size defines the size of the textures
  12797. * @param format defines the format of the data
  12798. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12799. * @param noMipmap defines if the engine should avoid generating the mip levels
  12800. * @param callback defines a callback used to extract texture data from loaded data
  12801. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12802. * @param onLoad defines a callback called when texture is loaded
  12803. * @param onError defines a callback called if there is an error
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12807. /**
  12808. * Creates a new raw cube texture from a specified url
  12809. * @param url defines the url where the data is located
  12810. * @param scene defines the current scene
  12811. * @param size defines the size of the textures
  12812. * @param format defines the format of the data
  12813. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12814. * @param noMipmap defines if the engine should avoid generating the mip levels
  12815. * @param callback defines a callback used to extract texture data from loaded data
  12816. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12817. * @param onLoad defines a callback called when texture is loaded
  12818. * @param onError defines a callback called if there is an error
  12819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12820. * @param invertY defines if data must be stored with Y axis inverted
  12821. * @returns the cube texture as an InternalTexture
  12822. */
  12823. 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;
  12824. /**
  12825. * Creates a new raw 3D texture
  12826. * @param data defines the data used to create the texture
  12827. * @param width defines the width of the texture
  12828. * @param height defines the height of the texture
  12829. * @param depth defines the depth of the texture
  12830. * @param format defines the format of the texture
  12831. * @param generateMipMaps defines if the engine must generate mip levels
  12832. * @param invertY defines if data must be stored with Y axis inverted
  12833. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12834. * @param compression defines the compressed used (can be null)
  12835. * @param textureType defines the compressed used (can be null)
  12836. * @returns a new raw 3D texture (stored in an InternalTexture)
  12837. */
  12838. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12839. /**
  12840. * Update a raw 3D texture
  12841. * @param texture defines the texture to update
  12842. * @param data defines the data to store
  12843. * @param format defines the data format
  12844. * @param invertY defines if data must be stored with Y axis inverted
  12845. */
  12846. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12847. /**
  12848. * Update a raw 3D texture
  12849. * @param texture defines the texture to update
  12850. * @param data defines the data to store
  12851. * @param format defines the data format
  12852. * @param invertY defines if data must be stored with Y axis inverted
  12853. * @param compression defines the used compression (can be null)
  12854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12855. */
  12856. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12857. /**
  12858. * Creates a new raw 2D array texture
  12859. * @param data defines the data used to create the texture
  12860. * @param width defines the width of the texture
  12861. * @param height defines the height of the texture
  12862. * @param depth defines the number of layers of the texture
  12863. * @param format defines the format of the texture
  12864. * @param generateMipMaps defines if the engine must generate mip levels
  12865. * @param invertY defines if data must be stored with Y axis inverted
  12866. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12867. * @param compression defines the compressed used (can be null)
  12868. * @param textureType defines the compressed used (can be null)
  12869. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12870. */
  12871. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12872. /**
  12873. * Update a raw 2D array texture
  12874. * @param texture defines the texture to update
  12875. * @param data defines the data to store
  12876. * @param format defines the data format
  12877. * @param invertY defines if data must be stored with Y axis inverted
  12878. */
  12879. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12880. /**
  12881. * Update a raw 2D array texture
  12882. * @param texture defines the texture to update
  12883. * @param data defines the data to store
  12884. * @param format defines the data format
  12885. * @param invertY defines if data must be stored with Y axis inverted
  12886. * @param compression defines the used compression (can be null)
  12887. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12888. */
  12889. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12890. }
  12891. }
  12892. }
  12893. declare module "babylonjs/Materials/Textures/rawTexture" {
  12894. import { Scene } from "babylonjs/scene";
  12895. import { Texture } from "babylonjs/Materials/Textures/texture";
  12896. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12897. /**
  12898. * Raw texture can help creating a texture directly from an array of data.
  12899. * This can be super useful if you either get the data from an uncompressed source or
  12900. * if you wish to create your texture pixel by pixel.
  12901. */
  12902. export class RawTexture extends Texture {
  12903. /**
  12904. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12905. */
  12906. format: number;
  12907. private _engine;
  12908. /**
  12909. * Instantiates a new RawTexture.
  12910. * Raw texture can help creating a texture directly from an array of data.
  12911. * This can be super useful if you either get the data from an uncompressed source or
  12912. * if you wish to create your texture pixel by pixel.
  12913. * @param data define the array of data to use to create the texture
  12914. * @param width define the width of the texture
  12915. * @param height define the height of the texture
  12916. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12917. * @param scene define the scene the texture belongs to
  12918. * @param generateMipMaps define whether mip maps should be generated or not
  12919. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12920. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12921. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12922. */
  12923. constructor(data: ArrayBufferView, width: number, height: number,
  12924. /**
  12925. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12926. */
  12927. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12928. /**
  12929. * Updates the texture underlying data.
  12930. * @param data Define the new data of the texture
  12931. */
  12932. update(data: ArrayBufferView): void;
  12933. /**
  12934. * Creates a luminance texture from some data.
  12935. * @param data Define the texture data
  12936. * @param width Define the width of the texture
  12937. * @param height Define the height of the texture
  12938. * @param scene Define the scene the texture belongs to
  12939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12942. * @returns the luminance texture
  12943. */
  12944. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12945. /**
  12946. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  12955. */
  12956. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12957. /**
  12958. * Creates an alpha texture from some data.
  12959. * @param data Define the texture data
  12960. * @param width Define the width of the texture
  12961. * @param height Define the height of the texture
  12962. * @param scene Define the scene the texture belongs to
  12963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12966. * @returns the alpha texture
  12967. */
  12968. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12969. /**
  12970. * Creates a RGB texture from some data.
  12971. * @param data Define the texture data
  12972. * @param width Define the width of the texture
  12973. * @param height Define the height of the texture
  12974. * @param scene Define the scene the texture belongs to
  12975. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12976. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12977. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12978. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12979. * @returns the RGB alpha texture
  12980. */
  12981. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12982. /**
  12983. * Creates a RGBA texture from some data.
  12984. * @param data Define the texture data
  12985. * @param width Define the width of the texture
  12986. * @param height Define the height of the texture
  12987. * @param scene Define the scene the texture belongs to
  12988. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12989. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12990. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12991. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12992. * @returns the RGBA texture
  12993. */
  12994. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12995. /**
  12996. * Creates a R texture from some data.
  12997. * @param data Define the texture data
  12998. * @param width Define the width of the texture
  12999. * @param height Define the height of the texture
  13000. * @param scene Define the scene the texture belongs to
  13001. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13002. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13003. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13004. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13005. * @returns the R texture
  13006. */
  13007. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13008. }
  13009. }
  13010. declare module "babylonjs/Maths/math.size" {
  13011. /**
  13012. * Interface for the size containing width and height
  13013. */
  13014. export interface ISize {
  13015. /**
  13016. * Width
  13017. */
  13018. width: number;
  13019. /**
  13020. * Heighht
  13021. */
  13022. height: number;
  13023. }
  13024. /**
  13025. * Size containing widht and height
  13026. */
  13027. export class Size implements ISize {
  13028. /**
  13029. * Width
  13030. */
  13031. width: number;
  13032. /**
  13033. * Height
  13034. */
  13035. height: number;
  13036. /**
  13037. * Creates a Size object from the given width and height (floats).
  13038. * @param width width of the new size
  13039. * @param height height of the new size
  13040. */
  13041. constructor(width: number, height: number);
  13042. /**
  13043. * Returns a string with the Size width and height
  13044. * @returns a string with the Size width and height
  13045. */
  13046. toString(): string;
  13047. /**
  13048. * "Size"
  13049. * @returns the string "Size"
  13050. */
  13051. getClassName(): string;
  13052. /**
  13053. * Returns the Size hash code.
  13054. * @returns a hash code for a unique width and height
  13055. */
  13056. getHashCode(): number;
  13057. /**
  13058. * Updates the current size from the given one.
  13059. * @param src the given size
  13060. */
  13061. copyFrom(src: Size): void;
  13062. /**
  13063. * Updates in place the current Size from the given floats.
  13064. * @param width width of the new size
  13065. * @param height height of the new size
  13066. * @returns the updated Size.
  13067. */
  13068. copyFromFloats(width: number, height: number): Size;
  13069. /**
  13070. * Updates in place the current Size from the given floats.
  13071. * @param width width to set
  13072. * @param height height to set
  13073. * @returns the updated Size.
  13074. */
  13075. set(width: number, height: number): Size;
  13076. /**
  13077. * Multiplies the width and height by numbers
  13078. * @param w factor to multiple the width by
  13079. * @param h factor to multiple the height by
  13080. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13081. */
  13082. multiplyByFloats(w: number, h: number): Size;
  13083. /**
  13084. * Clones the size
  13085. * @returns a new Size copied from the given one.
  13086. */
  13087. clone(): Size;
  13088. /**
  13089. * True if the current Size and the given one width and height are strictly equal.
  13090. * @param other the other size to compare against
  13091. * @returns True if the current Size and the given one width and height are strictly equal.
  13092. */
  13093. equals(other: Size): boolean;
  13094. /**
  13095. * The surface of the Size : width * height (float).
  13096. */
  13097. readonly surface: number;
  13098. /**
  13099. * Create a new size of zero
  13100. * @returns a new Size set to (0.0, 0.0)
  13101. */
  13102. static Zero(): Size;
  13103. /**
  13104. * Sums the width and height of two sizes
  13105. * @param otherSize size to add to this size
  13106. * @returns a new Size set as the addition result of the current Size and the given one.
  13107. */
  13108. add(otherSize: Size): Size;
  13109. /**
  13110. * Subtracts the width and height of two
  13111. * @param otherSize size to subtract to this size
  13112. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13113. */
  13114. subtract(otherSize: Size): Size;
  13115. /**
  13116. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13117. * @param start starting size to lerp between
  13118. * @param end end size to lerp between
  13119. * @param amount amount to lerp between the start and end values
  13120. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13121. */
  13122. static Lerp(start: Size, end: Size, amount: number): Size;
  13123. }
  13124. }
  13125. declare module "babylonjs/Animations/runtimeAnimation" {
  13126. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13127. import { Animatable } from "babylonjs/Animations/animatable";
  13128. import { Scene } from "babylonjs/scene";
  13129. /**
  13130. * Defines a runtime animation
  13131. */
  13132. export class RuntimeAnimation {
  13133. private _events;
  13134. /**
  13135. * The current frame of the runtime animation
  13136. */
  13137. private _currentFrame;
  13138. /**
  13139. * The animation used by the runtime animation
  13140. */
  13141. private _animation;
  13142. /**
  13143. * The target of the runtime animation
  13144. */
  13145. private _target;
  13146. /**
  13147. * The initiating animatable
  13148. */
  13149. private _host;
  13150. /**
  13151. * The original value of the runtime animation
  13152. */
  13153. private _originalValue;
  13154. /**
  13155. * The original blend value of the runtime animation
  13156. */
  13157. private _originalBlendValue;
  13158. /**
  13159. * The offsets cache of the runtime animation
  13160. */
  13161. private _offsetsCache;
  13162. /**
  13163. * The high limits cache of the runtime animation
  13164. */
  13165. private _highLimitsCache;
  13166. /**
  13167. * Specifies if the runtime animation has been stopped
  13168. */
  13169. private _stopped;
  13170. /**
  13171. * The blending factor of the runtime animation
  13172. */
  13173. private _blendingFactor;
  13174. /**
  13175. * The BabylonJS scene
  13176. */
  13177. private _scene;
  13178. /**
  13179. * The current value of the runtime animation
  13180. */
  13181. private _currentValue;
  13182. /** @hidden */
  13183. _animationState: _IAnimationState;
  13184. /**
  13185. * The active target of the runtime animation
  13186. */
  13187. private _activeTargets;
  13188. private _currentActiveTarget;
  13189. private _directTarget;
  13190. /**
  13191. * The target path of the runtime animation
  13192. */
  13193. private _targetPath;
  13194. /**
  13195. * The weight of the runtime animation
  13196. */
  13197. private _weight;
  13198. /**
  13199. * The ratio offset of the runtime animation
  13200. */
  13201. private _ratioOffset;
  13202. /**
  13203. * The previous delay of the runtime animation
  13204. */
  13205. private _previousDelay;
  13206. /**
  13207. * The previous ratio of the runtime animation
  13208. */
  13209. private _previousRatio;
  13210. private _enableBlending;
  13211. private _keys;
  13212. private _minFrame;
  13213. private _maxFrame;
  13214. private _minValue;
  13215. private _maxValue;
  13216. private _targetIsArray;
  13217. /**
  13218. * Gets the current frame of the runtime animation
  13219. */
  13220. readonly currentFrame: number;
  13221. /**
  13222. * Gets the weight of the runtime animation
  13223. */
  13224. readonly weight: number;
  13225. /**
  13226. * Gets the current value of the runtime animation
  13227. */
  13228. readonly currentValue: any;
  13229. /**
  13230. * Gets the target path of the runtime animation
  13231. */
  13232. readonly targetPath: string;
  13233. /**
  13234. * Gets the actual target of the runtime animation
  13235. */
  13236. readonly target: any;
  13237. /** @hidden */
  13238. _onLoop: () => void;
  13239. /**
  13240. * Create a new RuntimeAnimation object
  13241. * @param target defines the target of the animation
  13242. * @param animation defines the source animation object
  13243. * @param scene defines the hosting scene
  13244. * @param host defines the initiating Animatable
  13245. */
  13246. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13247. private _preparePath;
  13248. /**
  13249. * Gets the animation from the runtime animation
  13250. */
  13251. readonly animation: Animation;
  13252. /**
  13253. * Resets the runtime animation to the beginning
  13254. * @param restoreOriginal defines whether to restore the target property to the original value
  13255. */
  13256. reset(restoreOriginal?: boolean): void;
  13257. /**
  13258. * Specifies if the runtime animation is stopped
  13259. * @returns Boolean specifying if the runtime animation is stopped
  13260. */
  13261. isStopped(): boolean;
  13262. /**
  13263. * Disposes of the runtime animation
  13264. */
  13265. dispose(): void;
  13266. /**
  13267. * Apply the interpolated value to the target
  13268. * @param currentValue defines the value computed by the animation
  13269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13270. */
  13271. setValue(currentValue: any, weight: number): void;
  13272. private _getOriginalValues;
  13273. private _setValue;
  13274. /**
  13275. * Gets the loop pmode of the runtime animation
  13276. * @returns Loop Mode
  13277. */
  13278. private _getCorrectLoopMode;
  13279. /**
  13280. * Move the current animation to a given frame
  13281. * @param frame defines the frame to move to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * @hidden Internal use only
  13286. */
  13287. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13288. /**
  13289. * Execute the current animation
  13290. * @param delay defines the delay to add to the current frame
  13291. * @param from defines the lower bound of the animation range
  13292. * @param to defines the upper bound of the animation range
  13293. * @param loop defines if the current animation must loop
  13294. * @param speedRatio defines the current speed ratio
  13295. * @param weight defines the weight of the animation (default is -1 so no weight)
  13296. * @param onLoop optional callback called when animation loops
  13297. * @returns a boolean indicating if the animation is running
  13298. */
  13299. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13300. }
  13301. }
  13302. declare module "babylonjs/Animations/animatable" {
  13303. import { Animation } from "babylonjs/Animations/animation";
  13304. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13305. import { Nullable } from "babylonjs/types";
  13306. import { Observable } from "babylonjs/Misc/observable";
  13307. import { Scene } from "babylonjs/scene";
  13308. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13309. import { Node } from "babylonjs/node";
  13310. /**
  13311. * Class used to store an actual running animation
  13312. */
  13313. export class Animatable {
  13314. /** defines the target object */
  13315. target: any;
  13316. /** defines the starting frame number (default is 0) */
  13317. fromFrame: number;
  13318. /** defines the ending frame number (default is 100) */
  13319. toFrame: number;
  13320. /** defines if the animation must loop (default is false) */
  13321. loopAnimation: boolean;
  13322. /** defines a callback to call when animation ends if it is not looping */
  13323. onAnimationEnd?: (() => void) | null | undefined;
  13324. /** defines a callback to call when animation loops */
  13325. onAnimationLoop?: (() => void) | null | undefined;
  13326. private _localDelayOffset;
  13327. private _pausedDelay;
  13328. private _runtimeAnimations;
  13329. private _paused;
  13330. private _scene;
  13331. private _speedRatio;
  13332. private _weight;
  13333. private _syncRoot;
  13334. /**
  13335. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13336. * This will only apply for non looping animation (default is true)
  13337. */
  13338. disposeOnEnd: boolean;
  13339. /**
  13340. * Gets a boolean indicating if the animation has started
  13341. */
  13342. animationStarted: boolean;
  13343. /**
  13344. * Observer raised when the animation ends
  13345. */
  13346. onAnimationEndObservable: Observable<Animatable>;
  13347. /**
  13348. * Observer raised when the animation loops
  13349. */
  13350. onAnimationLoopObservable: Observable<Animatable>;
  13351. /**
  13352. * Gets the root Animatable used to synchronize and normalize animations
  13353. */
  13354. readonly syncRoot: Nullable<Animatable>;
  13355. /**
  13356. * Gets the current frame of the first RuntimeAnimation
  13357. * Used to synchronize Animatables
  13358. */
  13359. readonly masterFrame: number;
  13360. /**
  13361. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13362. */
  13363. weight: number;
  13364. /**
  13365. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13366. */
  13367. speedRatio: number;
  13368. /**
  13369. * Creates a new Animatable
  13370. * @param scene defines the hosting scene
  13371. * @param target defines the target object
  13372. * @param fromFrame defines the starting frame number (default is 0)
  13373. * @param toFrame defines the ending frame number (default is 100)
  13374. * @param loopAnimation defines if the animation must loop (default is false)
  13375. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13376. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13377. * @param animations defines a group of animation to add to the new Animatable
  13378. * @param onAnimationLoop defines a callback to call when animation loops
  13379. */
  13380. constructor(scene: Scene,
  13381. /** defines the target object */
  13382. target: any,
  13383. /** defines the starting frame number (default is 0) */
  13384. fromFrame?: number,
  13385. /** defines the ending frame number (default is 100) */
  13386. toFrame?: number,
  13387. /** defines if the animation must loop (default is false) */
  13388. loopAnimation?: boolean, speedRatio?: number,
  13389. /** defines a callback to call when animation ends if it is not looping */
  13390. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13391. /** defines a callback to call when animation loops */
  13392. onAnimationLoop?: (() => void) | null | undefined);
  13393. /**
  13394. * Synchronize and normalize current Animatable with a source Animatable
  13395. * This is useful when using animation weights and when animations are not of the same length
  13396. * @param root defines the root Animatable to synchronize with
  13397. * @returns the current Animatable
  13398. */
  13399. syncWith(root: Animatable): Animatable;
  13400. /**
  13401. * Gets the list of runtime animations
  13402. * @returns an array of RuntimeAnimation
  13403. */
  13404. getAnimations(): RuntimeAnimation[];
  13405. /**
  13406. * Adds more animations to the current animatable
  13407. * @param target defines the target of the animations
  13408. * @param animations defines the new animations to add
  13409. */
  13410. appendAnimations(target: any, animations: Animation[]): void;
  13411. /**
  13412. * Gets the source animation for a specific property
  13413. * @param property defines the propertyu to look for
  13414. * @returns null or the source animation for the given property
  13415. */
  13416. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13417. /**
  13418. * Gets the runtime animation for a specific property
  13419. * @param property defines the propertyu to look for
  13420. * @returns null or the runtime animation for the given property
  13421. */
  13422. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13423. /**
  13424. * Resets the animatable to its original state
  13425. */
  13426. reset(): void;
  13427. /**
  13428. * Allows the animatable to blend with current running animations
  13429. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13430. * @param blendingSpeed defines the blending speed to use
  13431. */
  13432. enableBlending(blendingSpeed: number): void;
  13433. /**
  13434. * Disable animation blending
  13435. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13436. */
  13437. disableBlending(): void;
  13438. /**
  13439. * Jump directly to a given frame
  13440. * @param frame defines the frame to jump to
  13441. */
  13442. goToFrame(frame: number): void;
  13443. /**
  13444. * Pause the animation
  13445. */
  13446. pause(): void;
  13447. /**
  13448. * Restart the animation
  13449. */
  13450. restart(): void;
  13451. private _raiseOnAnimationEnd;
  13452. /**
  13453. * Stop and delete the current animation
  13454. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13455. * @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)
  13456. */
  13457. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13458. /**
  13459. * Wait asynchronously for the animation to end
  13460. * @returns a promise which will be fullfilled when the animation ends
  13461. */
  13462. waitAsync(): Promise<Animatable>;
  13463. /** @hidden */
  13464. _animate(delay: number): boolean;
  13465. }
  13466. module "babylonjs/scene" {
  13467. interface Scene {
  13468. /** @hidden */
  13469. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13470. /** @hidden */
  13471. _processLateAnimationBindingsForMatrices(holder: {
  13472. totalWeight: number;
  13473. animations: RuntimeAnimation[];
  13474. originalValue: Matrix;
  13475. }): any;
  13476. /** @hidden */
  13477. _processLateAnimationBindingsForQuaternions(holder: {
  13478. totalWeight: number;
  13479. animations: RuntimeAnimation[];
  13480. originalValue: Quaternion;
  13481. }, refQuaternion: Quaternion): Quaternion;
  13482. /** @hidden */
  13483. _processLateAnimationBindings(): void;
  13484. /**
  13485. * Will start the animation sequence of a given target
  13486. * @param target defines the target
  13487. * @param from defines from which frame should animation start
  13488. * @param to defines until which frame should animation run.
  13489. * @param weight defines the weight to apply to the animation (1.0 by default)
  13490. * @param loop defines if the animation loops
  13491. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13492. * @param onAnimationEnd defines the function to be executed when the animation ends
  13493. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13494. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13495. * @param onAnimationLoop defines the callback to call when an animation loops
  13496. * @returns the animatable object created for this animation
  13497. */
  13498. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13499. /**
  13500. * Will start the animation sequence of a given target
  13501. * @param target defines the target
  13502. * @param from defines from which frame should animation start
  13503. * @param to defines until which frame should animation run.
  13504. * @param loop defines if the animation loops
  13505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13506. * @param onAnimationEnd defines the function to be executed when the animation ends
  13507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13509. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13510. * @param onAnimationLoop defines the callback to call when an animation loops
  13511. * @returns the animatable object created for this animation
  13512. */
  13513. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13514. /**
  13515. * Will start the animation sequence of a given target and its hierarchy
  13516. * @param target defines the target
  13517. * @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.
  13518. * @param from defines from which frame should animation start
  13519. * @param to defines until which frame should animation run.
  13520. * @param loop defines if the animation loops
  13521. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13522. * @param onAnimationEnd defines the function to be executed when the animation ends
  13523. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13524. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13525. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13526. * @param onAnimationLoop defines the callback to call when an animation loops
  13527. * @returns the list of created animatables
  13528. */
  13529. 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[];
  13530. /**
  13531. * Begin a new animation on a given node
  13532. * @param target defines the target where the animation will take place
  13533. * @param animations defines the list of animations to start
  13534. * @param from defines the initial value
  13535. * @param to defines the final value
  13536. * @param loop defines if you want animation to loop (off by default)
  13537. * @param speedRatio defines the speed ratio to apply to all animations
  13538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13539. * @param onAnimationLoop defines the callback to call when an animation loops
  13540. * @returns the list of created animatables
  13541. */
  13542. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13543. /**
  13544. * Begin a new animation on a given node and its hierarchy
  13545. * @param target defines the root node where the animation will take place
  13546. * @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.
  13547. * @param animations defines the list of animations to start
  13548. * @param from defines the initial value
  13549. * @param to defines the final value
  13550. * @param loop defines if you want animation to loop (off by default)
  13551. * @param speedRatio defines the speed ratio to apply to all animations
  13552. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13553. * @param onAnimationLoop defines the callback to call when an animation loops
  13554. * @returns the list of animatables created for all nodes
  13555. */
  13556. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13557. /**
  13558. * Gets the animatable associated with a specific target
  13559. * @param target defines the target of the animatable
  13560. * @returns the required animatable if found
  13561. */
  13562. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13563. /**
  13564. * Gets all animatables associated with a given target
  13565. * @param target defines the target to look animatables for
  13566. * @returns an array of Animatables
  13567. */
  13568. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13569. /**
  13570. * Stops and removes all animations that have been applied to the scene
  13571. */
  13572. stopAllAnimations(): void;
  13573. /**
  13574. * Gets the current delta time used by animation engine
  13575. */
  13576. deltaTime: number;
  13577. }
  13578. }
  13579. module "babylonjs/Bones/bone" {
  13580. interface Bone {
  13581. /**
  13582. * Copy an animation range from another bone
  13583. * @param source defines the source bone
  13584. * @param rangeName defines the range name to copy
  13585. * @param frameOffset defines the frame offset
  13586. * @param rescaleAsRequired defines if rescaling must be applied if required
  13587. * @param skelDimensionsRatio defines the scaling ratio
  13588. * @returns true if operation was successful
  13589. */
  13590. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13591. }
  13592. }
  13593. }
  13594. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13595. /**
  13596. * Class used to override all child animations of a given target
  13597. */
  13598. export class AnimationPropertiesOverride {
  13599. /**
  13600. * Gets or sets a value indicating if animation blending must be used
  13601. */
  13602. enableBlending: boolean;
  13603. /**
  13604. * Gets or sets the blending speed to use when enableBlending is true
  13605. */
  13606. blendingSpeed: number;
  13607. /**
  13608. * Gets or sets the default loop mode to use
  13609. */
  13610. loopMode: number;
  13611. }
  13612. }
  13613. declare module "babylonjs/Bones/skeleton" {
  13614. import { Bone } from "babylonjs/Bones/bone";
  13615. import { Observable } from "babylonjs/Misc/observable";
  13616. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13617. import { Scene } from "babylonjs/scene";
  13618. import { Nullable } from "babylonjs/types";
  13619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13620. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13621. import { Animatable } from "babylonjs/Animations/animatable";
  13622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13623. import { Animation } from "babylonjs/Animations/animation";
  13624. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13625. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13626. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13627. /**
  13628. * Class used to handle skinning animations
  13629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13630. */
  13631. export class Skeleton implements IAnimatable {
  13632. /** defines the skeleton name */
  13633. name: string;
  13634. /** defines the skeleton Id */
  13635. id: string;
  13636. /**
  13637. * Defines the list of child bones
  13638. */
  13639. bones: Bone[];
  13640. /**
  13641. * Defines an estimate of the dimension of the skeleton at rest
  13642. */
  13643. dimensionsAtRest: Vector3;
  13644. /**
  13645. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13646. */
  13647. needInitialSkinMatrix: boolean;
  13648. /**
  13649. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13650. */
  13651. overrideMesh: Nullable<AbstractMesh>;
  13652. /**
  13653. * Gets the list of animations attached to this skeleton
  13654. */
  13655. animations: Array<Animation>;
  13656. private _scene;
  13657. private _isDirty;
  13658. private _transformMatrices;
  13659. private _transformMatrixTexture;
  13660. private _meshesWithPoseMatrix;
  13661. private _animatables;
  13662. private _identity;
  13663. private _synchronizedWithMesh;
  13664. private _ranges;
  13665. private _lastAbsoluteTransformsUpdateId;
  13666. private _canUseTextureForBones;
  13667. private _uniqueId;
  13668. /** @hidden */
  13669. _numBonesWithLinkedTransformNode: number;
  13670. /** @hidden */
  13671. _hasWaitingData: Nullable<boolean>;
  13672. /**
  13673. * Specifies if the skeleton should be serialized
  13674. */
  13675. doNotSerialize: boolean;
  13676. private _useTextureToStoreBoneMatrices;
  13677. /**
  13678. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13679. * Please note that this option is not available if the hardware does not support it
  13680. */
  13681. useTextureToStoreBoneMatrices: boolean;
  13682. private _animationPropertiesOverride;
  13683. /**
  13684. * Gets or sets the animation properties override
  13685. */
  13686. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13687. /**
  13688. * List of inspectable custom properties (used by the Inspector)
  13689. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13690. */
  13691. inspectableCustomProperties: IInspectable[];
  13692. /**
  13693. * An observable triggered before computing the skeleton's matrices
  13694. */
  13695. onBeforeComputeObservable: Observable<Skeleton>;
  13696. /**
  13697. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13698. */
  13699. readonly isUsingTextureForMatrices: boolean;
  13700. /**
  13701. * Gets the unique ID of this skeleton
  13702. */
  13703. readonly uniqueId: number;
  13704. /**
  13705. * Creates a new skeleton
  13706. * @param name defines the skeleton name
  13707. * @param id defines the skeleton Id
  13708. * @param scene defines the hosting scene
  13709. */
  13710. constructor(
  13711. /** defines the skeleton name */
  13712. name: string,
  13713. /** defines the skeleton Id */
  13714. id: string, scene: Scene);
  13715. /**
  13716. * Gets the current object class name.
  13717. * @return the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13727. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13728. * @returns a Float32Array containing matrices data
  13729. */
  13730. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13731. /**
  13732. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13733. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13734. * @returns a raw texture containing the data
  13735. */
  13736. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13737. /**
  13738. * Gets the current hosting scene
  13739. * @returns a scene object
  13740. */
  13741. getScene(): Scene;
  13742. /**
  13743. * Gets a string representing the current skeleton data
  13744. * @param fullDetails defines a boolean indicating if we want a verbose version
  13745. * @returns a string representing the current skeleton data
  13746. */
  13747. toString(fullDetails?: boolean): string;
  13748. /**
  13749. * Get bone's index searching by name
  13750. * @param name defines bone's name to search for
  13751. * @return the indice of the bone. Returns -1 if not found
  13752. */
  13753. getBoneIndexByName(name: string): number;
  13754. /**
  13755. * Creater a new animation range
  13756. * @param name defines the name of the range
  13757. * @param from defines the start key
  13758. * @param to defines the end key
  13759. */
  13760. createAnimationRange(name: string, from: number, to: number): void;
  13761. /**
  13762. * Delete a specific animation range
  13763. * @param name defines the name of the range
  13764. * @param deleteFrames defines if frames must be removed as well
  13765. */
  13766. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13767. /**
  13768. * Gets a specific animation range
  13769. * @param name defines the name of the range to look for
  13770. * @returns the requested animation range or null if not found
  13771. */
  13772. getAnimationRange(name: string): Nullable<AnimationRange>;
  13773. /**
  13774. * Gets the list of all animation ranges defined on this skeleton
  13775. * @returns an array
  13776. */
  13777. getAnimationRanges(): Nullable<AnimationRange>[];
  13778. /**
  13779. * Copy animation range from a source skeleton.
  13780. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13781. * @param source defines the source skeleton
  13782. * @param name defines the name of the range to copy
  13783. * @param rescaleAsRequired defines if rescaling must be applied if required
  13784. * @returns true if operation was successful
  13785. */
  13786. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13787. /**
  13788. * Forces the skeleton to go to rest pose
  13789. */
  13790. returnToRest(): void;
  13791. private _getHighestAnimationFrame;
  13792. /**
  13793. * Begin a specific animation range
  13794. * @param name defines the name of the range to start
  13795. * @param loop defines if looping must be turned on (false by default)
  13796. * @param speedRatio defines the speed ratio to apply (1 by default)
  13797. * @param onAnimationEnd defines a callback which will be called when animation will end
  13798. * @returns a new animatable
  13799. */
  13800. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13801. /** @hidden */
  13802. _markAsDirty(): void;
  13803. /** @hidden */
  13804. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13805. /** @hidden */
  13806. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13807. private _computeTransformMatrices;
  13808. /**
  13809. * Build all resources required to render a skeleton
  13810. */
  13811. prepare(): void;
  13812. /**
  13813. * Gets the list of animatables currently running for this skeleton
  13814. * @returns an array of animatables
  13815. */
  13816. getAnimatables(): IAnimatable[];
  13817. /**
  13818. * Clone the current skeleton
  13819. * @param name defines the name of the new skeleton
  13820. * @param id defines the id of the new skeleton
  13821. * @returns the new skeleton
  13822. */
  13823. clone(name: string, id?: string): Skeleton;
  13824. /**
  13825. * Enable animation blending for this skeleton
  13826. * @param blendingSpeed defines the blending speed to apply
  13827. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13828. */
  13829. enableBlending(blendingSpeed?: number): void;
  13830. /**
  13831. * Releases all resources associated with the current skeleton
  13832. */
  13833. dispose(): void;
  13834. /**
  13835. * Serialize the skeleton in a JSON object
  13836. * @returns a JSON object
  13837. */
  13838. serialize(): any;
  13839. /**
  13840. * Creates a new skeleton from serialized data
  13841. * @param parsedSkeleton defines the serialized data
  13842. * @param scene defines the hosting scene
  13843. * @returns a new skeleton
  13844. */
  13845. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13846. /**
  13847. * Compute all node absolute transforms
  13848. * @param forceUpdate defines if computation must be done even if cache is up to date
  13849. */
  13850. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13851. /**
  13852. * Gets the root pose matrix
  13853. * @returns a matrix
  13854. */
  13855. getPoseMatrix(): Nullable<Matrix>;
  13856. /**
  13857. * Sorts bones per internal index
  13858. */
  13859. sortBones(): void;
  13860. private _sortBones;
  13861. }
  13862. }
  13863. declare module "babylonjs/Bones/bone" {
  13864. import { Skeleton } from "babylonjs/Bones/skeleton";
  13865. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13866. import { Nullable } from "babylonjs/types";
  13867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13868. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13869. import { Node } from "babylonjs/node";
  13870. import { Space } from "babylonjs/Maths/math.axis";
  13871. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13872. /**
  13873. * Class used to store bone information
  13874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13875. */
  13876. export class Bone extends Node {
  13877. /**
  13878. * defines the bone name
  13879. */
  13880. name: string;
  13881. private static _tmpVecs;
  13882. private static _tmpQuat;
  13883. private static _tmpMats;
  13884. /**
  13885. * Gets the list of child bones
  13886. */
  13887. children: Bone[];
  13888. /** Gets the animations associated with this bone */
  13889. animations: import("babylonjs/Animations/animation").Animation[];
  13890. /**
  13891. * Gets or sets bone length
  13892. */
  13893. length: number;
  13894. /**
  13895. * @hidden Internal only
  13896. * Set this value to map this bone to a different index in the transform matrices
  13897. * Set this value to -1 to exclude the bone from the transform matrices
  13898. */
  13899. _index: Nullable<number>;
  13900. private _skeleton;
  13901. private _localMatrix;
  13902. private _restPose;
  13903. private _baseMatrix;
  13904. private _absoluteTransform;
  13905. private _invertedAbsoluteTransform;
  13906. private _parent;
  13907. private _scalingDeterminant;
  13908. private _worldTransform;
  13909. private _localScaling;
  13910. private _localRotation;
  13911. private _localPosition;
  13912. private _needToDecompose;
  13913. private _needToCompose;
  13914. /** @hidden */
  13915. _linkedTransformNode: Nullable<TransformNode>;
  13916. /** @hidden */
  13917. _waitingTransformNodeId: Nullable<string>;
  13918. /** @hidden */
  13919. /** @hidden */
  13920. _matrix: Matrix;
  13921. /**
  13922. * Create a new bone
  13923. * @param name defines the bone name
  13924. * @param skeleton defines the parent skeleton
  13925. * @param parentBone defines the parent (can be null if the bone is the root)
  13926. * @param localMatrix defines the local matrix
  13927. * @param restPose defines the rest pose matrix
  13928. * @param baseMatrix defines the base matrix
  13929. * @param index defines index of the bone in the hiearchy
  13930. */
  13931. constructor(
  13932. /**
  13933. * defines the bone name
  13934. */
  13935. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13936. /**
  13937. * Gets the current object class name.
  13938. * @return the class name
  13939. */
  13940. getClassName(): string;
  13941. /**
  13942. * Gets the parent skeleton
  13943. * @returns a skeleton
  13944. */
  13945. getSkeleton(): Skeleton;
  13946. /**
  13947. * Gets parent bone
  13948. * @returns a bone or null if the bone is the root of the bone hierarchy
  13949. */
  13950. getParent(): Nullable<Bone>;
  13951. /**
  13952. * Returns an array containing the root bones
  13953. * @returns an array containing the root bones
  13954. */
  13955. getChildren(): Array<Bone>;
  13956. /**
  13957. * Gets the node index in matrix array generated for rendering
  13958. * @returns the node index
  13959. */
  13960. getIndex(): number;
  13961. /**
  13962. * Sets the parent bone
  13963. * @param parent defines the parent (can be null if the bone is the root)
  13964. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13965. */
  13966. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13967. /**
  13968. * Gets the local matrix
  13969. * @returns a matrix
  13970. */
  13971. getLocalMatrix(): Matrix;
  13972. /**
  13973. * Gets the base matrix (initial matrix which remains unchanged)
  13974. * @returns a matrix
  13975. */
  13976. getBaseMatrix(): Matrix;
  13977. /**
  13978. * Gets the rest pose matrix
  13979. * @returns a matrix
  13980. */
  13981. getRestPose(): Matrix;
  13982. /**
  13983. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13984. */
  13985. getWorldMatrix(): Matrix;
  13986. /**
  13987. * Sets the local matrix to rest pose matrix
  13988. */
  13989. returnToRest(): void;
  13990. /**
  13991. * Gets the inverse of the absolute transform matrix.
  13992. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13993. * @returns a matrix
  13994. */
  13995. getInvertedAbsoluteTransform(): Matrix;
  13996. /**
  13997. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13998. * @returns a matrix
  13999. */
  14000. getAbsoluteTransform(): Matrix;
  14001. /**
  14002. * Links with the given transform node.
  14003. * The local matrix of this bone is copied from the transform node every frame.
  14004. * @param transformNode defines the transform node to link to
  14005. */
  14006. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14007. /**
  14008. * Gets the node used to drive the bone's transformation
  14009. * @returns a transform node or null
  14010. */
  14011. getTransformNode(): Nullable<TransformNode>;
  14012. /** Gets or sets current position (in local space) */
  14013. position: Vector3;
  14014. /** Gets or sets current rotation (in local space) */
  14015. rotation: Vector3;
  14016. /** Gets or sets current rotation quaternion (in local space) */
  14017. rotationQuaternion: Quaternion;
  14018. /** Gets or sets current scaling (in local space) */
  14019. scaling: Vector3;
  14020. /**
  14021. * Gets the animation properties override
  14022. */
  14023. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14024. private _decompose;
  14025. private _compose;
  14026. /**
  14027. * Update the base and local matrices
  14028. * @param matrix defines the new base or local matrix
  14029. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14030. * @param updateLocalMatrix defines if the local matrix should be updated
  14031. */
  14032. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14033. /** @hidden */
  14034. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14035. /**
  14036. * Flag the bone as dirty (Forcing it to update everything)
  14037. */
  14038. markAsDirty(): void;
  14039. /** @hidden */
  14040. _markAsDirtyAndCompose(): void;
  14041. private _markAsDirtyAndDecompose;
  14042. /**
  14043. * Translate the bone in local or world space
  14044. * @param vec The amount to translate the bone
  14045. * @param space The space that the translation is in
  14046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14047. */
  14048. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14049. /**
  14050. * Set the postion of the bone in local or world space
  14051. * @param position The position to set the bone
  14052. * @param space The space that the position is in
  14053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14054. */
  14055. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14056. /**
  14057. * Set the absolute position of the bone (world space)
  14058. * @param position The position to set the bone
  14059. * @param mesh The mesh that this bone is attached to
  14060. */
  14061. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14062. /**
  14063. * Scale the bone on the x, y and z axes (in local space)
  14064. * @param x The amount to scale the bone on the x axis
  14065. * @param y The amount to scale the bone on the y axis
  14066. * @param z The amount to scale the bone on the z axis
  14067. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14068. */
  14069. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14070. /**
  14071. * Set the bone scaling in local space
  14072. * @param scale defines the scaling vector
  14073. */
  14074. setScale(scale: Vector3): void;
  14075. /**
  14076. * Gets the current scaling in local space
  14077. * @returns the current scaling vector
  14078. */
  14079. getScale(): Vector3;
  14080. /**
  14081. * Gets the current scaling in local space and stores it in a target vector
  14082. * @param result defines the target vector
  14083. */
  14084. getScaleToRef(result: Vector3): void;
  14085. /**
  14086. * Set the yaw, pitch, and roll of the bone in local or world space
  14087. * @param yaw The rotation of the bone on the y axis
  14088. * @param pitch The rotation of the bone on the x axis
  14089. * @param roll The rotation of the bone on the z axis
  14090. * @param space The space that the axes of rotation are in
  14091. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14092. */
  14093. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14094. /**
  14095. * Add a rotation to the bone on an axis in local or world space
  14096. * @param axis The axis to rotate the bone on
  14097. * @param amount The amount to rotate the bone
  14098. * @param space The space that the axis is in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. */
  14101. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14102. /**
  14103. * Set the rotation of the bone to a particular axis angle in local or world space
  14104. * @param axis The axis to rotate the bone on
  14105. * @param angle The angle that the bone should be rotated to
  14106. * @param space The space that the axis is in
  14107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14108. */
  14109. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14110. /**
  14111. * Set the euler rotation of the bone in local of world space
  14112. * @param rotation The euler rotation that the bone should be set to
  14113. * @param space The space that the rotation is in
  14114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14115. */
  14116. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14117. /**
  14118. * Set the quaternion rotation of the bone in local of world space
  14119. * @param quat The quaternion rotation that the bone should be set to
  14120. * @param space The space that the rotation is in
  14121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14122. */
  14123. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14124. /**
  14125. * Set the rotation matrix of the bone in local of world space
  14126. * @param rotMat The rotation matrix that the bone should be set to
  14127. * @param space The space that the rotation is in
  14128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14129. */
  14130. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14131. private _rotateWithMatrix;
  14132. private _getNegativeRotationToRef;
  14133. /**
  14134. * Get the position of the bone in local or world space
  14135. * @param space The space that the returned position is in
  14136. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14137. * @returns The position of the bone
  14138. */
  14139. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14140. /**
  14141. * Copy the position of the bone to a vector3 in local or world space
  14142. * @param space The space that the returned position is in
  14143. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14144. * @param result The vector3 to copy the position to
  14145. */
  14146. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14147. /**
  14148. * Get the absolute position of the bone (world space)
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The absolute position of the bone
  14151. */
  14152. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the absolute position of the bone (world space) to the result param
  14155. * @param mesh The mesh that this bone is attached to
  14156. * @param result The vector3 to copy the absolute position to
  14157. */
  14158. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14159. /**
  14160. * Compute the absolute transforms of this bone and its children
  14161. */
  14162. computeAbsoluteTransforms(): void;
  14163. /**
  14164. * Get the world direction from an axis that is in the local space of the bone
  14165. * @param localAxis The local direction that is used to compute the world direction
  14166. * @param mesh The mesh that this bone is attached to
  14167. * @returns The world direction
  14168. */
  14169. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14170. /**
  14171. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14172. * @param localAxis The local direction that is used to compute the world direction
  14173. * @param mesh The mesh that this bone is attached to
  14174. * @param result The vector3 that the world direction will be copied to
  14175. */
  14176. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14177. /**
  14178. * Get the euler rotation of the bone in local or world space
  14179. * @param space The space that the rotation should be in
  14180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14181. * @returns The euler rotation
  14182. */
  14183. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14184. /**
  14185. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14186. * @param space The space that the rotation should be in
  14187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14188. * @param result The vector3 that the rotation should be copied to
  14189. */
  14190. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14191. /**
  14192. * Get the quaternion rotation of the bone in either local or world space
  14193. * @param space The space that the rotation should be in
  14194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14195. * @returns The quaternion rotation
  14196. */
  14197. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14198. /**
  14199. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14200. * @param space The space that the rotation should be in
  14201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14202. * @param result The quaternion that the rotation should be copied to
  14203. */
  14204. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14205. /**
  14206. * Get the rotation matrix of the bone in local or world space
  14207. * @param space The space that the rotation should be in
  14208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14209. * @returns The rotation matrix
  14210. */
  14211. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14212. /**
  14213. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14214. * @param space The space that the rotation should be in
  14215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14216. * @param result The quaternion that the rotation should be copied to
  14217. */
  14218. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14219. /**
  14220. * Get the world position of a point that is in the local space of the bone
  14221. * @param position The local position
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @returns The world position
  14224. */
  14225. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14226. /**
  14227. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14228. * @param position The local position
  14229. * @param mesh The mesh that this bone is attached to
  14230. * @param result The vector3 that the world position should be copied to
  14231. */
  14232. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14233. /**
  14234. * Get the local position of a point that is in world space
  14235. * @param position The world position
  14236. * @param mesh The mesh that this bone is attached to
  14237. * @returns The local position
  14238. */
  14239. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14240. /**
  14241. * Get the local position of a point that is in world space and copy it to the result param
  14242. * @param position The world position
  14243. * @param mesh The mesh that this bone is attached to
  14244. * @param result The vector3 that the local position should be copied to
  14245. */
  14246. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14247. }
  14248. }
  14249. declare module "babylonjs/Meshes/transformNode" {
  14250. import { DeepImmutable } from "babylonjs/types";
  14251. import { Observable } from "babylonjs/Misc/observable";
  14252. import { Nullable } from "babylonjs/types";
  14253. import { Camera } from "babylonjs/Cameras/camera";
  14254. import { Scene } from "babylonjs/scene";
  14255. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14256. import { Node } from "babylonjs/node";
  14257. import { Bone } from "babylonjs/Bones/bone";
  14258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14259. import { Space } from "babylonjs/Maths/math.axis";
  14260. /**
  14261. * 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.
  14262. * @see https://doc.babylonjs.com/how_to/transformnode
  14263. */
  14264. export class TransformNode extends Node {
  14265. /**
  14266. * Object will not rotate to face the camera
  14267. */
  14268. static BILLBOARDMODE_NONE: number;
  14269. /**
  14270. * Object will rotate to face the camera but only on the x axis
  14271. */
  14272. static BILLBOARDMODE_X: number;
  14273. /**
  14274. * Object will rotate to face the camera but only on the y axis
  14275. */
  14276. static BILLBOARDMODE_Y: number;
  14277. /**
  14278. * Object will rotate to face the camera but only on the z axis
  14279. */
  14280. static BILLBOARDMODE_Z: number;
  14281. /**
  14282. * Object will rotate to face the camera
  14283. */
  14284. static BILLBOARDMODE_ALL: number;
  14285. /**
  14286. * Object will rotate to face the camera's position instead of orientation
  14287. */
  14288. static BILLBOARDMODE_USE_POSITION: number;
  14289. private _forward;
  14290. private _forwardInverted;
  14291. private _up;
  14292. private _right;
  14293. private _rightInverted;
  14294. private _position;
  14295. private _rotation;
  14296. private _rotationQuaternion;
  14297. protected _scaling: Vector3;
  14298. protected _isDirty: boolean;
  14299. private _transformToBoneReferal;
  14300. private _isAbsoluteSynced;
  14301. private _billboardMode;
  14302. /**
  14303. * Gets or sets the billboard mode. Default is 0.
  14304. *
  14305. * | Value | Type | Description |
  14306. * | --- | --- | --- |
  14307. * | 0 | BILLBOARDMODE_NONE | |
  14308. * | 1 | BILLBOARDMODE_X | |
  14309. * | 2 | BILLBOARDMODE_Y | |
  14310. * | 4 | BILLBOARDMODE_Z | |
  14311. * | 7 | BILLBOARDMODE_ALL | |
  14312. *
  14313. */
  14314. billboardMode: number;
  14315. private _preserveParentRotationForBillboard;
  14316. /**
  14317. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14318. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14319. */
  14320. preserveParentRotationForBillboard: boolean;
  14321. /**
  14322. * 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
  14323. */
  14324. scalingDeterminant: number;
  14325. private _infiniteDistance;
  14326. /**
  14327. * Gets or sets the distance of the object to max, often used by skybox
  14328. */
  14329. infiniteDistance: boolean;
  14330. /**
  14331. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14332. * By default the system will update normals to compensate
  14333. */
  14334. ignoreNonUniformScaling: boolean;
  14335. /**
  14336. * 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
  14337. */
  14338. reIntegrateRotationIntoRotationQuaternion: boolean;
  14339. /** @hidden */
  14340. _poseMatrix: Nullable<Matrix>;
  14341. /** @hidden */
  14342. _localMatrix: Matrix;
  14343. private _usePivotMatrix;
  14344. private _absolutePosition;
  14345. private _absoluteScaling;
  14346. private _absoluteRotationQuaternion;
  14347. private _pivotMatrix;
  14348. private _pivotMatrixInverse;
  14349. protected _postMultiplyPivotMatrix: boolean;
  14350. protected _isWorldMatrixFrozen: boolean;
  14351. /** @hidden */
  14352. _indexInSceneTransformNodesArray: number;
  14353. /**
  14354. * An event triggered after the world matrix is updated
  14355. */
  14356. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14357. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14358. /**
  14359. * Gets a string identifying the name of the class
  14360. * @returns "TransformNode" string
  14361. */
  14362. getClassName(): string;
  14363. /**
  14364. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14365. */
  14366. position: Vector3;
  14367. /**
  14368. * 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)).
  14369. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14370. */
  14371. rotation: Vector3;
  14372. /**
  14373. * 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)).
  14374. */
  14375. scaling: Vector3;
  14376. /**
  14377. * 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).
  14378. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14379. */
  14380. rotationQuaternion: Nullable<Quaternion>;
  14381. /**
  14382. * The forward direction of that transform in world space.
  14383. */
  14384. readonly forward: Vector3;
  14385. /**
  14386. * The up direction of that transform in world space.
  14387. */
  14388. readonly up: Vector3;
  14389. /**
  14390. * The right direction of that transform in world space.
  14391. */
  14392. readonly right: Vector3;
  14393. /**
  14394. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14395. * @param matrix the matrix to copy the pose from
  14396. * @returns this TransformNode.
  14397. */
  14398. updatePoseMatrix(matrix: Matrix): TransformNode;
  14399. /**
  14400. * Returns the mesh Pose matrix.
  14401. * @returns the pose matrix
  14402. */
  14403. getPoseMatrix(): Matrix;
  14404. /** @hidden */
  14405. _isSynchronized(): boolean;
  14406. /** @hidden */
  14407. _initCache(): void;
  14408. /**
  14409. * Flag the transform node as dirty (Forcing it to update everything)
  14410. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14411. * @returns this transform node
  14412. */
  14413. markAsDirty(property: string): TransformNode;
  14414. /**
  14415. * Returns the current mesh absolute position.
  14416. * Returns a Vector3.
  14417. */
  14418. readonly absolutePosition: Vector3;
  14419. /**
  14420. * Returns the current mesh absolute scaling.
  14421. * Returns a Vector3.
  14422. */
  14423. readonly absoluteScaling: Vector3;
  14424. /**
  14425. * Returns the current mesh absolute rotation.
  14426. * Returns a Quaternion.
  14427. */
  14428. readonly absoluteRotationQuaternion: Quaternion;
  14429. /**
  14430. * Sets a new matrix to apply before all other transformation
  14431. * @param matrix defines the transform matrix
  14432. * @returns the current TransformNode
  14433. */
  14434. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14435. /**
  14436. * Sets a new pivot matrix to the current node
  14437. * @param matrix defines the new pivot matrix to use
  14438. * @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
  14439. * @returns the current TransformNode
  14440. */
  14441. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14442. /**
  14443. * Returns the mesh pivot matrix.
  14444. * Default : Identity.
  14445. * @returns the matrix
  14446. */
  14447. getPivotMatrix(): Matrix;
  14448. /**
  14449. * Instantiate (when possible) or clone that node with its hierarchy
  14450. * @param newParent defines the new parent to use for the instance (or clone)
  14451. * @param options defines options to configure how copy is done
  14452. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14453. * @returns an instance (or a clone) of the current node with its hiearchy
  14454. */
  14455. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14456. doNotInstantiate: boolean;
  14457. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14458. /**
  14459. * Prevents the World matrix to be computed any longer
  14460. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14461. * @returns the TransformNode.
  14462. */
  14463. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14464. /**
  14465. * Allows back the World matrix computation.
  14466. * @returns the TransformNode.
  14467. */
  14468. unfreezeWorldMatrix(): this;
  14469. /**
  14470. * True if the World matrix has been frozen.
  14471. */
  14472. readonly isWorldMatrixFrozen: boolean;
  14473. /**
  14474. * Retuns the mesh absolute position in the World.
  14475. * @returns a Vector3.
  14476. */
  14477. getAbsolutePosition(): Vector3;
  14478. /**
  14479. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14480. * @param absolutePosition the absolute position to set
  14481. * @returns the TransformNode.
  14482. */
  14483. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14484. /**
  14485. * Sets the mesh position in its local space.
  14486. * @param vector3 the position to set in localspace
  14487. * @returns the TransformNode.
  14488. */
  14489. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14490. /**
  14491. * Returns the mesh position in the local space from the current World matrix values.
  14492. * @returns a new Vector3.
  14493. */
  14494. getPositionExpressedInLocalSpace(): Vector3;
  14495. /**
  14496. * Translates the mesh along the passed Vector3 in its local space.
  14497. * @param vector3 the distance to translate in localspace
  14498. * @returns the TransformNode.
  14499. */
  14500. locallyTranslate(vector3: Vector3): TransformNode;
  14501. private static _lookAtVectorCache;
  14502. /**
  14503. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14504. * @param targetPoint the position (must be in same space as current mesh) to look at
  14505. * @param yawCor optional yaw (y-axis) correction in radians
  14506. * @param pitchCor optional pitch (x-axis) correction in radians
  14507. * @param rollCor optional roll (z-axis) correction in radians
  14508. * @param space the choosen space of the target
  14509. * @returns the TransformNode.
  14510. */
  14511. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14512. /**
  14513. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14514. * This Vector3 is expressed in the World space.
  14515. * @param localAxis axis to rotate
  14516. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14517. */
  14518. getDirection(localAxis: Vector3): Vector3;
  14519. /**
  14520. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14521. * localAxis is expressed in the mesh local space.
  14522. * result is computed in the Wordl space from the mesh World matrix.
  14523. * @param localAxis axis to rotate
  14524. * @param result the resulting transformnode
  14525. * @returns this TransformNode.
  14526. */
  14527. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14528. /**
  14529. * Sets this transform node rotation to the given local axis.
  14530. * @param localAxis the axis in local space
  14531. * @param yawCor optional yaw (y-axis) correction in radians
  14532. * @param pitchCor optional pitch (x-axis) correction in radians
  14533. * @param rollCor optional roll (z-axis) correction in radians
  14534. * @returns this TransformNode
  14535. */
  14536. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14537. /**
  14538. * Sets a new pivot point to the current node
  14539. * @param point defines the new pivot point to use
  14540. * @param space defines if the point is in world or local space (local by default)
  14541. * @returns the current TransformNode
  14542. */
  14543. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14544. /**
  14545. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14546. * @returns the pivot point
  14547. */
  14548. getPivotPoint(): Vector3;
  14549. /**
  14550. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14551. * @param result the vector3 to store the result
  14552. * @returns this TransformNode.
  14553. */
  14554. getPivotPointToRef(result: Vector3): TransformNode;
  14555. /**
  14556. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14557. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14558. */
  14559. getAbsolutePivotPoint(): Vector3;
  14560. /**
  14561. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14562. * @param result vector3 to store the result
  14563. * @returns this TransformNode.
  14564. */
  14565. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14566. /**
  14567. * Defines the passed node as the parent of the current node.
  14568. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14569. * @see https://doc.babylonjs.com/how_to/parenting
  14570. * @param node the node ot set as the parent
  14571. * @returns this TransformNode.
  14572. */
  14573. setParent(node: Nullable<Node>): TransformNode;
  14574. private _nonUniformScaling;
  14575. /**
  14576. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14577. */
  14578. readonly nonUniformScaling: boolean;
  14579. /** @hidden */
  14580. _updateNonUniformScalingState(value: boolean): boolean;
  14581. /**
  14582. * Attach the current TransformNode to another TransformNode associated with a bone
  14583. * @param bone Bone affecting the TransformNode
  14584. * @param affectedTransformNode TransformNode associated with the bone
  14585. * @returns this object
  14586. */
  14587. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14588. /**
  14589. * Detach the transform node if its associated with a bone
  14590. * @returns this object
  14591. */
  14592. detachFromBone(): TransformNode;
  14593. private static _rotationAxisCache;
  14594. /**
  14595. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14596. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14597. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14598. * The passed axis is also normalized.
  14599. * @param axis the axis to rotate around
  14600. * @param amount the amount to rotate in radians
  14601. * @param space Space to rotate in (Default: local)
  14602. * @returns the TransformNode.
  14603. */
  14604. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14605. /**
  14606. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14607. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14608. * The passed axis is also normalized. .
  14609. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14610. * @param point the point to rotate around
  14611. * @param axis the axis to rotate around
  14612. * @param amount the amount to rotate in radians
  14613. * @returns the TransformNode
  14614. */
  14615. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14616. /**
  14617. * Translates the mesh along the axis vector for the passed distance in the given space.
  14618. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14619. * @param axis the axis to translate in
  14620. * @param distance the distance to translate
  14621. * @param space Space to rotate in (Default: local)
  14622. * @returns the TransformNode.
  14623. */
  14624. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14625. /**
  14626. * Adds a rotation step to the mesh current rotation.
  14627. * x, y, z are Euler angles expressed in radians.
  14628. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14629. * This means this rotation is made in the mesh local space only.
  14630. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14631. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14632. * ```javascript
  14633. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14634. * ```
  14635. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14636. * 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.
  14637. * @param x Rotation to add
  14638. * @param y Rotation to add
  14639. * @param z Rotation to add
  14640. * @returns the TransformNode.
  14641. */
  14642. addRotation(x: number, y: number, z: number): TransformNode;
  14643. /**
  14644. * @hidden
  14645. */
  14646. protected _getEffectiveParent(): Nullable<Node>;
  14647. /**
  14648. * Computes the world matrix of the node
  14649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14650. * @returns the world matrix
  14651. */
  14652. computeWorldMatrix(force?: boolean): Matrix;
  14653. protected _afterComputeWorldMatrix(): void;
  14654. /**
  14655. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14656. * @param func callback function to add
  14657. *
  14658. * @returns the TransformNode.
  14659. */
  14660. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14661. /**
  14662. * Removes a registered callback function.
  14663. * @param func callback function to remove
  14664. * @returns the TransformNode.
  14665. */
  14666. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14667. /**
  14668. * Gets the position of the current mesh in camera space
  14669. * @param camera defines the camera to use
  14670. * @returns a position
  14671. */
  14672. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14673. /**
  14674. * Returns the distance from the mesh to the active camera
  14675. * @param camera defines the camera to use
  14676. * @returns the distance
  14677. */
  14678. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14679. /**
  14680. * Clone the current transform node
  14681. * @param name Name of the new clone
  14682. * @param newParent New parent for the clone
  14683. * @param doNotCloneChildren Do not clone children hierarchy
  14684. * @returns the new transform node
  14685. */
  14686. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14687. /**
  14688. * Serializes the objects information.
  14689. * @param currentSerializationObject defines the object to serialize in
  14690. * @returns the serialized object
  14691. */
  14692. serialize(currentSerializationObject?: any): any;
  14693. /**
  14694. * Returns a new TransformNode object parsed from the source provided.
  14695. * @param parsedTransformNode is the source.
  14696. * @param scene the scne the object belongs to
  14697. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14698. * @returns a new TransformNode object parsed from the source provided.
  14699. */
  14700. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14701. /**
  14702. * Get all child-transformNodes of this node
  14703. * @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
  14704. * @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
  14705. * @returns an array of TransformNode
  14706. */
  14707. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14708. /**
  14709. * Releases resources associated with this transform node.
  14710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14712. */
  14713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14714. /**
  14715. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14716. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14717. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14718. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14719. * @returns the current mesh
  14720. */
  14721. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14722. private _syncAbsoluteScalingAndRotation;
  14723. }
  14724. }
  14725. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14726. import { Observable } from "babylonjs/Misc/observable";
  14727. import { Nullable } from "babylonjs/types";
  14728. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14729. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14731. import { Ray } from "babylonjs/Culling/ray";
  14732. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14733. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14734. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14735. /**
  14736. * Defines the types of pose enabled controllers that are supported
  14737. */
  14738. export enum PoseEnabledControllerType {
  14739. /**
  14740. * HTC Vive
  14741. */
  14742. VIVE = 0,
  14743. /**
  14744. * Oculus Rift
  14745. */
  14746. OCULUS = 1,
  14747. /**
  14748. * Windows mixed reality
  14749. */
  14750. WINDOWS = 2,
  14751. /**
  14752. * Samsung gear VR
  14753. */
  14754. GEAR_VR = 3,
  14755. /**
  14756. * Google Daydream
  14757. */
  14758. DAYDREAM = 4,
  14759. /**
  14760. * Generic
  14761. */
  14762. GENERIC = 5
  14763. }
  14764. /**
  14765. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14766. */
  14767. export interface MutableGamepadButton {
  14768. /**
  14769. * Value of the button/trigger
  14770. */
  14771. value: number;
  14772. /**
  14773. * If the button/trigger is currently touched
  14774. */
  14775. touched: boolean;
  14776. /**
  14777. * If the button/trigger is currently pressed
  14778. */
  14779. pressed: boolean;
  14780. }
  14781. /**
  14782. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14783. * @hidden
  14784. */
  14785. export interface ExtendedGamepadButton extends GamepadButton {
  14786. /**
  14787. * If the button/trigger is currently pressed
  14788. */
  14789. readonly pressed: boolean;
  14790. /**
  14791. * If the button/trigger is currently touched
  14792. */
  14793. readonly touched: boolean;
  14794. /**
  14795. * Value of the button/trigger
  14796. */
  14797. readonly value: number;
  14798. }
  14799. /** @hidden */
  14800. export interface _GamePadFactory {
  14801. /**
  14802. * Returns wether or not the current gamepad can be created for this type of controller.
  14803. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14804. * @returns true if it can be created, otherwise false
  14805. */
  14806. canCreate(gamepadInfo: any): boolean;
  14807. /**
  14808. * Creates a new instance of the Gamepad.
  14809. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14810. * @returns the new gamepad instance
  14811. */
  14812. create(gamepadInfo: any): Gamepad;
  14813. }
  14814. /**
  14815. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14816. */
  14817. export class PoseEnabledControllerHelper {
  14818. /** @hidden */
  14819. static _ControllerFactories: _GamePadFactory[];
  14820. /** @hidden */
  14821. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14822. /**
  14823. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14824. * @param vrGamepad the gamepad to initialized
  14825. * @returns a vr controller of the type the gamepad identified as
  14826. */
  14827. static InitiateController(vrGamepad: any): Gamepad;
  14828. }
  14829. /**
  14830. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14831. */
  14832. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14833. /**
  14834. * If the controller is used in a webXR session
  14835. */
  14836. isXR: boolean;
  14837. private _deviceRoomPosition;
  14838. private _deviceRoomRotationQuaternion;
  14839. /**
  14840. * The device position in babylon space
  14841. */
  14842. devicePosition: Vector3;
  14843. /**
  14844. * The device rotation in babylon space
  14845. */
  14846. deviceRotationQuaternion: Quaternion;
  14847. /**
  14848. * The scale factor of the device in babylon space
  14849. */
  14850. deviceScaleFactor: number;
  14851. /**
  14852. * (Likely devicePosition should be used instead) The device position in its room space
  14853. */
  14854. position: Vector3;
  14855. /**
  14856. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14857. */
  14858. rotationQuaternion: Quaternion;
  14859. /**
  14860. * The type of controller (Eg. Windows mixed reality)
  14861. */
  14862. controllerType: PoseEnabledControllerType;
  14863. protected _calculatedPosition: Vector3;
  14864. private _calculatedRotation;
  14865. /**
  14866. * The raw pose from the device
  14867. */
  14868. rawPose: DevicePose;
  14869. private _trackPosition;
  14870. private _maxRotationDistFromHeadset;
  14871. private _draggedRoomRotation;
  14872. /**
  14873. * @hidden
  14874. */
  14875. _disableTrackPosition(fixedPosition: Vector3): void;
  14876. /**
  14877. * Internal, the mesh attached to the controller
  14878. * @hidden
  14879. */
  14880. _mesh: Nullable<AbstractMesh>;
  14881. private _poseControlledCamera;
  14882. private _leftHandSystemQuaternion;
  14883. /**
  14884. * Internal, matrix used to convert room space to babylon space
  14885. * @hidden
  14886. */
  14887. _deviceToWorld: Matrix;
  14888. /**
  14889. * Node to be used when casting a ray from the controller
  14890. * @hidden
  14891. */
  14892. _pointingPoseNode: Nullable<TransformNode>;
  14893. /**
  14894. * Name of the child mesh that can be used to cast a ray from the controller
  14895. */
  14896. static readonly POINTING_POSE: string;
  14897. /**
  14898. * Creates a new PoseEnabledController from a gamepad
  14899. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14900. */
  14901. constructor(browserGamepad: any);
  14902. private _workingMatrix;
  14903. /**
  14904. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14905. */
  14906. update(): void;
  14907. /**
  14908. * Updates only the pose device and mesh without doing any button event checking
  14909. */
  14910. protected _updatePoseAndMesh(): void;
  14911. /**
  14912. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14913. * @param poseData raw pose fromthe device
  14914. */
  14915. updateFromDevice(poseData: DevicePose): void;
  14916. /**
  14917. * @hidden
  14918. */
  14919. _meshAttachedObservable: Observable<AbstractMesh>;
  14920. /**
  14921. * Attaches a mesh to the controller
  14922. * @param mesh the mesh to be attached
  14923. */
  14924. attachToMesh(mesh: AbstractMesh): void;
  14925. /**
  14926. * Attaches the controllers mesh to a camera
  14927. * @param camera the camera the mesh should be attached to
  14928. */
  14929. attachToPoseControlledCamera(camera: TargetCamera): void;
  14930. /**
  14931. * Disposes of the controller
  14932. */
  14933. dispose(): void;
  14934. /**
  14935. * The mesh that is attached to the controller
  14936. */
  14937. readonly mesh: Nullable<AbstractMesh>;
  14938. /**
  14939. * Gets the ray of the controller in the direction the controller is pointing
  14940. * @param length the length the resulting ray should be
  14941. * @returns a ray in the direction the controller is pointing
  14942. */
  14943. getForwardRay(length?: number): Ray;
  14944. }
  14945. }
  14946. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14947. import { Observable } from "babylonjs/Misc/observable";
  14948. import { Scene } from "babylonjs/scene";
  14949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14950. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14951. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14952. import { Nullable } from "babylonjs/types";
  14953. /**
  14954. * Defines the WebVRController object that represents controllers tracked in 3D space
  14955. */
  14956. export abstract class WebVRController extends PoseEnabledController {
  14957. /**
  14958. * Internal, the default controller model for the controller
  14959. */
  14960. protected _defaultModel: Nullable<AbstractMesh>;
  14961. /**
  14962. * Fired when the trigger state has changed
  14963. */
  14964. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14965. /**
  14966. * Fired when the main button state has changed
  14967. */
  14968. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14969. /**
  14970. * Fired when the secondary button state has changed
  14971. */
  14972. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14973. /**
  14974. * Fired when the pad state has changed
  14975. */
  14976. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14977. /**
  14978. * Fired when controllers stick values have changed
  14979. */
  14980. onPadValuesChangedObservable: Observable<StickValues>;
  14981. /**
  14982. * Array of button availible on the controller
  14983. */
  14984. protected _buttons: Array<MutableGamepadButton>;
  14985. private _onButtonStateChange;
  14986. /**
  14987. * Fired when a controller button's state has changed
  14988. * @param callback the callback containing the button that was modified
  14989. */
  14990. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14991. /**
  14992. * X and Y axis corresponding to the controllers joystick
  14993. */
  14994. pad: StickValues;
  14995. /**
  14996. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14997. */
  14998. hand: string;
  14999. /**
  15000. * The default controller model for the controller
  15001. */
  15002. readonly defaultModel: Nullable<AbstractMesh>;
  15003. /**
  15004. * Creates a new WebVRController from a gamepad
  15005. * @param vrGamepad the gamepad that the WebVRController should be created from
  15006. */
  15007. constructor(vrGamepad: any);
  15008. /**
  15009. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15010. */
  15011. update(): void;
  15012. /**
  15013. * Function to be called when a button is modified
  15014. */
  15015. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15016. /**
  15017. * Loads a mesh and attaches it to the controller
  15018. * @param scene the scene the mesh should be added to
  15019. * @param meshLoaded callback for when the mesh has been loaded
  15020. */
  15021. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15022. private _setButtonValue;
  15023. private _changes;
  15024. private _checkChanges;
  15025. /**
  15026. * Disposes of th webVRCOntroller
  15027. */
  15028. dispose(): void;
  15029. }
  15030. }
  15031. declare module "babylonjs/Lights/hemisphericLight" {
  15032. import { Nullable } from "babylonjs/types";
  15033. import { Scene } from "babylonjs/scene";
  15034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15035. import { Color3 } from "babylonjs/Maths/math.color";
  15036. import { Effect } from "babylonjs/Materials/effect";
  15037. import { Light } from "babylonjs/Lights/light";
  15038. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15039. /**
  15040. * The HemisphericLight simulates the ambient environment light,
  15041. * so the passed direction is the light reflection direction, not the incoming direction.
  15042. */
  15043. export class HemisphericLight extends Light {
  15044. /**
  15045. * The groundColor is the light in the opposite direction to the one specified during creation.
  15046. * 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.
  15047. */
  15048. groundColor: Color3;
  15049. /**
  15050. * The light reflection direction, not the incoming direction.
  15051. */
  15052. direction: Vector3;
  15053. /**
  15054. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15055. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15056. * The HemisphericLight can't cast shadows.
  15057. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15058. * @param name The friendly name of the light
  15059. * @param direction The direction of the light reflection
  15060. * @param scene The scene the light belongs to
  15061. */
  15062. constructor(name: string, direction: Vector3, scene: Scene);
  15063. protected _buildUniformLayout(): void;
  15064. /**
  15065. * Returns the string "HemisphericLight".
  15066. * @return The class name
  15067. */
  15068. getClassName(): string;
  15069. /**
  15070. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15071. * Returns the updated direction.
  15072. * @param target The target the direction should point to
  15073. * @return The computed direction
  15074. */
  15075. setDirectionToTarget(target: Vector3): Vector3;
  15076. /**
  15077. * Returns the shadow generator associated to the light.
  15078. * @returns Always null for hemispheric lights because it does not support shadows.
  15079. */
  15080. getShadowGenerator(): Nullable<IShadowGenerator>;
  15081. /**
  15082. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15083. * @param effect The effect to update
  15084. * @param lightIndex The index of the light in the effect to update
  15085. * @returns The hemispheric light
  15086. */
  15087. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15088. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15089. /**
  15090. * Computes the world matrix of the node
  15091. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15092. * @param useWasUpdatedFlag defines a reserved property
  15093. * @returns the world matrix
  15094. */
  15095. computeWorldMatrix(): Matrix;
  15096. /**
  15097. * Returns the integer 3.
  15098. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15099. */
  15100. getTypeID(): number;
  15101. /**
  15102. * Prepares the list of defines specific to the light type.
  15103. * @param defines the list of defines
  15104. * @param lightIndex defines the index of the light for the effect
  15105. */
  15106. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15107. }
  15108. }
  15109. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15110. /** @hidden */
  15111. export var vrMultiviewToSingleviewPixelShader: {
  15112. name: string;
  15113. shader: string;
  15114. };
  15115. }
  15116. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15117. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15118. import { Scene } from "babylonjs/scene";
  15119. /**
  15120. * Renders to multiple views with a single draw call
  15121. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15122. */
  15123. export class MultiviewRenderTarget extends RenderTargetTexture {
  15124. /**
  15125. * Creates a multiview render target
  15126. * @param scene scene used with the render target
  15127. * @param size the size of the render target (used for each view)
  15128. */
  15129. constructor(scene: Scene, size?: number | {
  15130. width: number;
  15131. height: number;
  15132. } | {
  15133. ratio: number;
  15134. });
  15135. /**
  15136. * @hidden
  15137. * @param faceIndex the face index, if its a cube texture
  15138. */
  15139. _bindFrameBuffer(faceIndex?: number): void;
  15140. /**
  15141. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15142. * @returns the view count
  15143. */
  15144. getViewCount(): number;
  15145. }
  15146. }
  15147. declare module "babylonjs/Maths/math.frustum" {
  15148. import { Matrix } from "babylonjs/Maths/math.vector";
  15149. import { DeepImmutable } from "babylonjs/types";
  15150. import { Plane } from "babylonjs/Maths/math.plane";
  15151. /**
  15152. * Represents a camera frustum
  15153. */
  15154. export class Frustum {
  15155. /**
  15156. * Gets the planes representing the frustum
  15157. * @param transform matrix to be applied to the returned planes
  15158. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15159. */
  15160. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15161. /**
  15162. * Gets the near frustum plane transformed by the transform matrix
  15163. * @param transform transformation matrix to be applied to the resulting frustum plane
  15164. * @param frustumPlane the resuling frustum plane
  15165. */
  15166. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15167. /**
  15168. * Gets the far frustum plane transformed by the transform matrix
  15169. * @param transform transformation matrix to be applied to the resulting frustum plane
  15170. * @param frustumPlane the resuling frustum plane
  15171. */
  15172. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15173. /**
  15174. * Gets the left frustum plane transformed by the transform matrix
  15175. * @param transform transformation matrix to be applied to the resulting frustum plane
  15176. * @param frustumPlane the resuling frustum plane
  15177. */
  15178. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15179. /**
  15180. * Gets the right frustum plane transformed by the transform matrix
  15181. * @param transform transformation matrix to be applied to the resulting frustum plane
  15182. * @param frustumPlane the resuling frustum plane
  15183. */
  15184. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15185. /**
  15186. * Gets the top frustum plane transformed by the transform matrix
  15187. * @param transform transformation matrix to be applied to the resulting frustum plane
  15188. * @param frustumPlane the resuling frustum plane
  15189. */
  15190. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15191. /**
  15192. * Gets the bottom frustum plane transformed by the transform matrix
  15193. * @param transform transformation matrix to be applied to the resulting frustum plane
  15194. * @param frustumPlane the resuling frustum plane
  15195. */
  15196. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15197. /**
  15198. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15199. * @param transform transformation matrix to be applied to the resulting frustum planes
  15200. * @param frustumPlanes the resuling frustum planes
  15201. */
  15202. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15203. }
  15204. }
  15205. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15206. import { Camera } from "babylonjs/Cameras/camera";
  15207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15208. import { Nullable } from "babylonjs/types";
  15209. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15210. import { Matrix } from "babylonjs/Maths/math.vector";
  15211. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15212. module "babylonjs/Engines/engine" {
  15213. interface Engine {
  15214. /**
  15215. * Creates a new multiview render target
  15216. * @param width defines the width of the texture
  15217. * @param height defines the height of the texture
  15218. * @returns the created multiview texture
  15219. */
  15220. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15221. /**
  15222. * Binds a multiview framebuffer to be drawn to
  15223. * @param multiviewTexture texture to bind
  15224. */
  15225. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15226. }
  15227. }
  15228. module "babylonjs/Cameras/camera" {
  15229. interface Camera {
  15230. /**
  15231. * @hidden
  15232. * 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)
  15233. */
  15234. _useMultiviewToSingleView: boolean;
  15235. /**
  15236. * @hidden
  15237. * 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)
  15238. */
  15239. _multiviewTexture: Nullable<RenderTargetTexture>;
  15240. /**
  15241. * @hidden
  15242. * ensures the multiview texture of the camera exists and has the specified width/height
  15243. * @param width height to set on the multiview texture
  15244. * @param height width to set on the multiview texture
  15245. */
  15246. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15247. }
  15248. }
  15249. module "babylonjs/scene" {
  15250. interface Scene {
  15251. /** @hidden */
  15252. _transformMatrixR: Matrix;
  15253. /** @hidden */
  15254. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15255. /** @hidden */
  15256. _createMultiviewUbo(): void;
  15257. /** @hidden */
  15258. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15259. /** @hidden */
  15260. _renderMultiviewToSingleView(camera: Camera): void;
  15261. }
  15262. }
  15263. }
  15264. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15265. import { Camera } from "babylonjs/Cameras/camera";
  15266. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15267. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15268. import "babylonjs/Engines/Extensions/engine.multiview";
  15269. /**
  15270. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15271. * This will not be used for webXR as it supports displaying texture arrays directly
  15272. */
  15273. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15274. /**
  15275. * Initializes a VRMultiviewToSingleview
  15276. * @param name name of the post process
  15277. * @param camera camera to be applied to
  15278. * @param scaleFactor scaling factor to the size of the output texture
  15279. */
  15280. constructor(name: string, camera: Camera, scaleFactor: number);
  15281. }
  15282. }
  15283. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15284. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15285. import { Nullable } from "babylonjs/types";
  15286. import { Size } from "babylonjs/Maths/math.size";
  15287. import { Observable } from "babylonjs/Misc/observable";
  15288. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15289. /**
  15290. * Interface used to define additional presentation attributes
  15291. */
  15292. export interface IVRPresentationAttributes {
  15293. /**
  15294. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15295. */
  15296. highRefreshRate: boolean;
  15297. /**
  15298. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15299. */
  15300. foveationLevel: number;
  15301. }
  15302. module "babylonjs/Engines/engine" {
  15303. interface Engine {
  15304. /** @hidden */
  15305. _vrDisplay: any;
  15306. /** @hidden */
  15307. _vrSupported: boolean;
  15308. /** @hidden */
  15309. _oldSize: Size;
  15310. /** @hidden */
  15311. _oldHardwareScaleFactor: number;
  15312. /** @hidden */
  15313. _vrExclusivePointerMode: boolean;
  15314. /** @hidden */
  15315. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15316. /** @hidden */
  15317. _onVRDisplayPointerRestricted: () => void;
  15318. /** @hidden */
  15319. _onVRDisplayPointerUnrestricted: () => void;
  15320. /** @hidden */
  15321. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15322. /** @hidden */
  15323. _onVrDisplayDisconnect: Nullable<() => void>;
  15324. /** @hidden */
  15325. _onVrDisplayPresentChange: Nullable<() => void>;
  15326. /**
  15327. * Observable signaled when VR display mode changes
  15328. */
  15329. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15330. /**
  15331. * Observable signaled when VR request present is complete
  15332. */
  15333. onVRRequestPresentComplete: Observable<boolean>;
  15334. /**
  15335. * Observable signaled when VR request present starts
  15336. */
  15337. onVRRequestPresentStart: Observable<Engine>;
  15338. /**
  15339. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15340. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15341. */
  15342. isInVRExclusivePointerMode: boolean;
  15343. /**
  15344. * Gets a boolean indicating if a webVR device was detected
  15345. * @returns true if a webVR device was detected
  15346. */
  15347. isVRDevicePresent(): boolean;
  15348. /**
  15349. * Gets the current webVR device
  15350. * @returns the current webVR device (or null)
  15351. */
  15352. getVRDevice(): any;
  15353. /**
  15354. * Initializes a webVR display and starts listening to display change events
  15355. * The onVRDisplayChangedObservable will be notified upon these changes
  15356. * @returns A promise containing a VRDisplay and if vr is supported
  15357. */
  15358. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15359. /** @hidden */
  15360. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15361. /**
  15362. * Gets or sets the presentation attributes used to configure VR rendering
  15363. */
  15364. vrPresentationAttributes?: IVRPresentationAttributes;
  15365. /**
  15366. * Call this function to switch to webVR mode
  15367. * Will do nothing if webVR is not supported or if there is no webVR device
  15368. * @param options the webvr options provided to the camera. mainly used for multiview
  15369. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15370. */
  15371. enableVR(options: WebVROptions): void;
  15372. /** @hidden */
  15373. _onVRFullScreenTriggered(): void;
  15374. }
  15375. }
  15376. }
  15377. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15378. import { Nullable } from "babylonjs/types";
  15379. import { Observable } from "babylonjs/Misc/observable";
  15380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15381. import { Scene } from "babylonjs/scene";
  15382. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15383. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15384. import { Node } from "babylonjs/node";
  15385. import { Ray } from "babylonjs/Culling/ray";
  15386. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15387. import "babylonjs/Engines/Extensions/engine.webVR";
  15388. /**
  15389. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15390. * IMPORTANT!! The data is right-hand data.
  15391. * @export
  15392. * @interface DevicePose
  15393. */
  15394. export interface DevicePose {
  15395. /**
  15396. * The position of the device, values in array are [x,y,z].
  15397. */
  15398. readonly position: Nullable<Float32Array>;
  15399. /**
  15400. * The linearVelocity of the device, values in array are [x,y,z].
  15401. */
  15402. readonly linearVelocity: Nullable<Float32Array>;
  15403. /**
  15404. * The linearAcceleration of the device, values in array are [x,y,z].
  15405. */
  15406. readonly linearAcceleration: Nullable<Float32Array>;
  15407. /**
  15408. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15409. */
  15410. readonly orientation: Nullable<Float32Array>;
  15411. /**
  15412. * The angularVelocity of the device, values in array are [x,y,z].
  15413. */
  15414. readonly angularVelocity: Nullable<Float32Array>;
  15415. /**
  15416. * The angularAcceleration of the device, values in array are [x,y,z].
  15417. */
  15418. readonly angularAcceleration: Nullable<Float32Array>;
  15419. }
  15420. /**
  15421. * Interface representing a pose controlled object in Babylon.
  15422. * A pose controlled object has both regular pose values as well as pose values
  15423. * from an external device such as a VR head mounted display
  15424. */
  15425. export interface PoseControlled {
  15426. /**
  15427. * The position of the object in babylon space.
  15428. */
  15429. position: Vector3;
  15430. /**
  15431. * The rotation quaternion of the object in babylon space.
  15432. */
  15433. rotationQuaternion: Quaternion;
  15434. /**
  15435. * The position of the device in babylon space.
  15436. */
  15437. devicePosition?: Vector3;
  15438. /**
  15439. * The rotation quaternion of the device in babylon space.
  15440. */
  15441. deviceRotationQuaternion: Quaternion;
  15442. /**
  15443. * The raw pose coming from the device.
  15444. */
  15445. rawPose: Nullable<DevicePose>;
  15446. /**
  15447. * The scale of the device to be used when translating from device space to babylon space.
  15448. */
  15449. deviceScaleFactor: number;
  15450. /**
  15451. * Updates the poseControlled values based on the input device pose.
  15452. * @param poseData the pose data to update the object with
  15453. */
  15454. updateFromDevice(poseData: DevicePose): void;
  15455. }
  15456. /**
  15457. * Set of options to customize the webVRCamera
  15458. */
  15459. export interface WebVROptions {
  15460. /**
  15461. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15462. */
  15463. trackPosition?: boolean;
  15464. /**
  15465. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15466. */
  15467. positionScale?: number;
  15468. /**
  15469. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15470. */
  15471. displayName?: string;
  15472. /**
  15473. * Should the native controller meshes be initialized. (default: true)
  15474. */
  15475. controllerMeshes?: boolean;
  15476. /**
  15477. * Creating a default HemiLight only on controllers. (default: true)
  15478. */
  15479. defaultLightingOnControllers?: boolean;
  15480. /**
  15481. * If you don't want to use the default VR button of the helper. (default: false)
  15482. */
  15483. useCustomVRButton?: boolean;
  15484. /**
  15485. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15486. */
  15487. customVRButton?: HTMLButtonElement;
  15488. /**
  15489. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15490. */
  15491. rayLength?: number;
  15492. /**
  15493. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15494. */
  15495. defaultHeight?: number;
  15496. /**
  15497. * If multiview should be used if availible (default: false)
  15498. */
  15499. useMultiview?: boolean;
  15500. }
  15501. /**
  15502. * This represents a WebVR camera.
  15503. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15504. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15505. */
  15506. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15507. private webVROptions;
  15508. /**
  15509. * @hidden
  15510. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15511. */
  15512. _vrDevice: any;
  15513. /**
  15514. * The rawPose of the vrDevice.
  15515. */
  15516. rawPose: Nullable<DevicePose>;
  15517. private _onVREnabled;
  15518. private _specsVersion;
  15519. private _attached;
  15520. private _frameData;
  15521. protected _descendants: Array<Node>;
  15522. private _deviceRoomPosition;
  15523. /** @hidden */
  15524. _deviceRoomRotationQuaternion: Quaternion;
  15525. private _standingMatrix;
  15526. /**
  15527. * Represents device position in babylon space.
  15528. */
  15529. devicePosition: Vector3;
  15530. /**
  15531. * Represents device rotation in babylon space.
  15532. */
  15533. deviceRotationQuaternion: Quaternion;
  15534. /**
  15535. * The scale of the device to be used when translating from device space to babylon space.
  15536. */
  15537. deviceScaleFactor: number;
  15538. private _deviceToWorld;
  15539. private _worldToDevice;
  15540. /**
  15541. * References to the webVR controllers for the vrDevice.
  15542. */
  15543. controllers: Array<WebVRController>;
  15544. /**
  15545. * Emits an event when a controller is attached.
  15546. */
  15547. onControllersAttachedObservable: Observable<WebVRController[]>;
  15548. /**
  15549. * Emits an event when a controller's mesh has been loaded;
  15550. */
  15551. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15552. /**
  15553. * Emits an event when the HMD's pose has been updated.
  15554. */
  15555. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15556. private _poseSet;
  15557. /**
  15558. * If the rig cameras be used as parent instead of this camera.
  15559. */
  15560. rigParenting: boolean;
  15561. private _lightOnControllers;
  15562. private _defaultHeight?;
  15563. /**
  15564. * Instantiates a WebVRFreeCamera.
  15565. * @param name The name of the WebVRFreeCamera
  15566. * @param position The starting anchor position for the camera
  15567. * @param scene The scene the camera belongs to
  15568. * @param webVROptions a set of customizable options for the webVRCamera
  15569. */
  15570. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15571. /**
  15572. * Gets the device distance from the ground in meters.
  15573. * @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.
  15574. */
  15575. deviceDistanceToRoomGround(): number;
  15576. /**
  15577. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15578. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15579. */
  15580. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15581. /**
  15582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15583. * @returns A promise with a boolean set to if the standing matrix is supported.
  15584. */
  15585. useStandingMatrixAsync(): Promise<boolean>;
  15586. /**
  15587. * Disposes the camera
  15588. */
  15589. dispose(): void;
  15590. /**
  15591. * Gets a vrController by name.
  15592. * @param name The name of the controller to retreive
  15593. * @returns the controller matching the name specified or null if not found
  15594. */
  15595. getControllerByName(name: string): Nullable<WebVRController>;
  15596. private _leftController;
  15597. /**
  15598. * The controller corresponding to the users left hand.
  15599. */
  15600. readonly leftController: Nullable<WebVRController>;
  15601. private _rightController;
  15602. /**
  15603. * The controller corresponding to the users right hand.
  15604. */
  15605. readonly rightController: Nullable<WebVRController>;
  15606. /**
  15607. * Casts a ray forward from the vrCamera's gaze.
  15608. * @param length Length of the ray (default: 100)
  15609. * @returns the ray corresponding to the gaze
  15610. */
  15611. getForwardRay(length?: number): Ray;
  15612. /**
  15613. * @hidden
  15614. * Updates the camera based on device's frame data
  15615. */
  15616. _checkInputs(): void;
  15617. /**
  15618. * Updates the poseControlled values based on the input device pose.
  15619. * @param poseData Pose coming from the device
  15620. */
  15621. updateFromDevice(poseData: DevicePose): void;
  15622. private _htmlElementAttached;
  15623. private _detachIfAttached;
  15624. /**
  15625. * WebVR's attach control will start broadcasting frames to the device.
  15626. * Note that in certain browsers (chrome for example) this function must be called
  15627. * within a user-interaction callback. Example:
  15628. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15629. *
  15630. * @param element html element to attach the vrDevice to
  15631. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15632. */
  15633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15634. /**
  15635. * Detaches the camera from the html element and disables VR
  15636. *
  15637. * @param element html element to detach from
  15638. */
  15639. detachControl(element: HTMLElement): void;
  15640. /**
  15641. * @returns the name of this class
  15642. */
  15643. getClassName(): string;
  15644. /**
  15645. * Calls resetPose on the vrDisplay
  15646. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15647. */
  15648. resetToCurrentRotation(): void;
  15649. /**
  15650. * @hidden
  15651. * Updates the rig cameras (left and right eye)
  15652. */
  15653. _updateRigCameras(): void;
  15654. private _workingVector;
  15655. private _oneVector;
  15656. private _workingMatrix;
  15657. private updateCacheCalled;
  15658. private _correctPositionIfNotTrackPosition;
  15659. /**
  15660. * @hidden
  15661. * Updates the cached values of the camera
  15662. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15663. */
  15664. _updateCache(ignoreParentClass?: boolean): void;
  15665. /**
  15666. * @hidden
  15667. * Get current device position in babylon world
  15668. */
  15669. _computeDevicePosition(): void;
  15670. /**
  15671. * Updates the current device position and rotation in the babylon world
  15672. */
  15673. update(): void;
  15674. /**
  15675. * @hidden
  15676. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15677. * @returns an identity matrix
  15678. */
  15679. _getViewMatrix(): Matrix;
  15680. private _tmpMatrix;
  15681. /**
  15682. * This function is called by the two RIG cameras.
  15683. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15684. * @hidden
  15685. */
  15686. _getWebVRViewMatrix(): Matrix;
  15687. /** @hidden */
  15688. _getWebVRProjectionMatrix(): Matrix;
  15689. private _onGamepadConnectedObserver;
  15690. private _onGamepadDisconnectedObserver;
  15691. private _updateCacheWhenTrackingDisabledObserver;
  15692. /**
  15693. * Initializes the controllers and their meshes
  15694. */
  15695. initControllers(): void;
  15696. }
  15697. }
  15698. declare module "babylonjs/PostProcesses/postProcess" {
  15699. import { Nullable } from "babylonjs/types";
  15700. import { SmartArray } from "babylonjs/Misc/smartArray";
  15701. import { Observable } from "babylonjs/Misc/observable";
  15702. import { Vector2 } from "babylonjs/Maths/math.vector";
  15703. import { Camera } from "babylonjs/Cameras/camera";
  15704. import { Effect } from "babylonjs/Materials/effect";
  15705. import "babylonjs/Shaders/postprocess.vertex";
  15706. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15707. import { Engine } from "babylonjs/Engines/engine";
  15708. import { Color4 } from "babylonjs/Maths/math.color";
  15709. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15711. /**
  15712. * Size options for a post process
  15713. */
  15714. export type PostProcessOptions = {
  15715. width: number;
  15716. height: number;
  15717. };
  15718. /**
  15719. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15721. */
  15722. export class PostProcess {
  15723. /** Name of the PostProcess. */
  15724. name: string;
  15725. /**
  15726. * Gets or sets the unique id of the post process
  15727. */
  15728. uniqueId: number;
  15729. /**
  15730. * Width of the texture to apply the post process on
  15731. */
  15732. width: number;
  15733. /**
  15734. * Height of the texture to apply the post process on
  15735. */
  15736. height: number;
  15737. /**
  15738. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15739. * @hidden
  15740. */
  15741. _outputTexture: Nullable<InternalTexture>;
  15742. /**
  15743. * Sampling mode used by the shader
  15744. * See https://doc.babylonjs.com/classes/3.1/texture
  15745. */
  15746. renderTargetSamplingMode: number;
  15747. /**
  15748. * Clear color to use when screen clearing
  15749. */
  15750. clearColor: Color4;
  15751. /**
  15752. * If the buffer needs to be cleared before applying the post process. (default: true)
  15753. * Should be set to false if shader will overwrite all previous pixels.
  15754. */
  15755. autoClear: boolean;
  15756. /**
  15757. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15758. */
  15759. alphaMode: number;
  15760. /**
  15761. * Sets the setAlphaBlendConstants of the babylon engine
  15762. */
  15763. alphaConstants: Color4;
  15764. /**
  15765. * Animations to be used for the post processing
  15766. */
  15767. animations: import("babylonjs/Animations/animation").Animation[];
  15768. /**
  15769. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15770. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15771. */
  15772. enablePixelPerfectMode: boolean;
  15773. /**
  15774. * Force the postprocess to be applied without taking in account viewport
  15775. */
  15776. forceFullscreenViewport: boolean;
  15777. /**
  15778. * List of inspectable custom properties (used by the Inspector)
  15779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15780. */
  15781. inspectableCustomProperties: IInspectable[];
  15782. /**
  15783. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15784. *
  15785. * | Value | Type | Description |
  15786. * | ----- | ----------------------------------- | ----------- |
  15787. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15788. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15789. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15790. *
  15791. */
  15792. scaleMode: number;
  15793. /**
  15794. * Force textures to be a power of two (default: false)
  15795. */
  15796. alwaysForcePOT: boolean;
  15797. private _samples;
  15798. /**
  15799. * Number of sample textures (default: 1)
  15800. */
  15801. samples: number;
  15802. /**
  15803. * Modify the scale of the post process to be the same as the viewport (default: false)
  15804. */
  15805. adaptScaleToCurrentViewport: boolean;
  15806. private _camera;
  15807. private _scene;
  15808. private _engine;
  15809. private _options;
  15810. private _reusable;
  15811. private _textureType;
  15812. /**
  15813. * Smart array of input and output textures for the post process.
  15814. * @hidden
  15815. */
  15816. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15817. /**
  15818. * The index in _textures that corresponds to the output texture.
  15819. * @hidden
  15820. */
  15821. _currentRenderTextureInd: number;
  15822. private _effect;
  15823. private _samplers;
  15824. private _fragmentUrl;
  15825. private _vertexUrl;
  15826. private _parameters;
  15827. private _scaleRatio;
  15828. protected _indexParameters: any;
  15829. private _shareOutputWithPostProcess;
  15830. private _texelSize;
  15831. private _forcedOutputTexture;
  15832. /**
  15833. * Returns the fragment url or shader name used in the post process.
  15834. * @returns the fragment url or name in the shader store.
  15835. */
  15836. getEffectName(): string;
  15837. /**
  15838. * An event triggered when the postprocess is activated.
  15839. */
  15840. onActivateObservable: Observable<Camera>;
  15841. private _onActivateObserver;
  15842. /**
  15843. * A function that is added to the onActivateObservable
  15844. */
  15845. onActivate: Nullable<(camera: Camera) => void>;
  15846. /**
  15847. * An event triggered when the postprocess changes its size.
  15848. */
  15849. onSizeChangedObservable: Observable<PostProcess>;
  15850. private _onSizeChangedObserver;
  15851. /**
  15852. * A function that is added to the onSizeChangedObservable
  15853. */
  15854. onSizeChanged: (postProcess: PostProcess) => void;
  15855. /**
  15856. * An event triggered when the postprocess applies its effect.
  15857. */
  15858. onApplyObservable: Observable<Effect>;
  15859. private _onApplyObserver;
  15860. /**
  15861. * A function that is added to the onApplyObservable
  15862. */
  15863. onApply: (effect: Effect) => void;
  15864. /**
  15865. * An event triggered before rendering the postprocess
  15866. */
  15867. onBeforeRenderObservable: Observable<Effect>;
  15868. private _onBeforeRenderObserver;
  15869. /**
  15870. * A function that is added to the onBeforeRenderObservable
  15871. */
  15872. onBeforeRender: (effect: Effect) => void;
  15873. /**
  15874. * An event triggered after rendering the postprocess
  15875. */
  15876. onAfterRenderObservable: Observable<Effect>;
  15877. private _onAfterRenderObserver;
  15878. /**
  15879. * A function that is added to the onAfterRenderObservable
  15880. */
  15881. onAfterRender: (efect: Effect) => void;
  15882. /**
  15883. * 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
  15884. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15885. */
  15886. inputTexture: InternalTexture;
  15887. /**
  15888. * Gets the camera which post process is applied to.
  15889. * @returns The camera the post process is applied to.
  15890. */
  15891. getCamera(): Camera;
  15892. /**
  15893. * Gets the texel size of the postprocess.
  15894. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15895. */
  15896. readonly texelSize: Vector2;
  15897. /**
  15898. * Creates a new instance PostProcess
  15899. * @param name The name of the PostProcess.
  15900. * @param fragmentUrl The url of the fragment shader to be used.
  15901. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15902. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15903. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15904. * @param camera The camera to apply the render pass to.
  15905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15906. * @param engine The engine which the post process will be applied. (default: current engine)
  15907. * @param reusable If the post process can be reused on the same frame. (default: false)
  15908. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15909. * @param textureType Type of textures used when performing the post process. (default: 0)
  15910. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15911. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15912. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15913. */
  15914. constructor(
  15915. /** Name of the PostProcess. */
  15916. 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);
  15917. /**
  15918. * Gets a string idenfifying the name of the class
  15919. * @returns "PostProcess" string
  15920. */
  15921. getClassName(): string;
  15922. /**
  15923. * Gets the engine which this post process belongs to.
  15924. * @returns The engine the post process was enabled with.
  15925. */
  15926. getEngine(): Engine;
  15927. /**
  15928. * The effect that is created when initializing the post process.
  15929. * @returns The created effect corresponding the the postprocess.
  15930. */
  15931. getEffect(): Effect;
  15932. /**
  15933. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15934. * @param postProcess The post process to share the output with.
  15935. * @returns This post process.
  15936. */
  15937. shareOutputWith(postProcess: PostProcess): PostProcess;
  15938. /**
  15939. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15940. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15941. */
  15942. useOwnOutput(): void;
  15943. /**
  15944. * Updates the effect with the current post process compile time values and recompiles the shader.
  15945. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15946. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15947. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15948. * @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
  15949. * @param onCompiled Called when the shader has been compiled.
  15950. * @param onError Called if there is an error when compiling a shader.
  15951. */
  15952. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15953. /**
  15954. * The post process is reusable if it can be used multiple times within one frame.
  15955. * @returns If the post process is reusable
  15956. */
  15957. isReusable(): boolean;
  15958. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15959. markTextureDirty(): void;
  15960. /**
  15961. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15962. * 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.
  15963. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15964. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15965. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15966. * @returns The target texture that was bound to be written to.
  15967. */
  15968. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15969. /**
  15970. * If the post process is supported.
  15971. */
  15972. readonly isSupported: boolean;
  15973. /**
  15974. * The aspect ratio of the output texture.
  15975. */
  15976. readonly aspectRatio: number;
  15977. /**
  15978. * Get a value indicating if the post-process is ready to be used
  15979. * @returns true if the post-process is ready (shader is compiled)
  15980. */
  15981. isReady(): boolean;
  15982. /**
  15983. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15984. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15985. */
  15986. apply(): Nullable<Effect>;
  15987. private _disposeTextures;
  15988. /**
  15989. * Disposes the post process.
  15990. * @param camera The camera to dispose the post process on.
  15991. */
  15992. dispose(camera?: Camera): void;
  15993. }
  15994. }
  15995. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15996. /** @hidden */
  15997. export var kernelBlurVaryingDeclaration: {
  15998. name: string;
  15999. shader: string;
  16000. };
  16001. }
  16002. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16003. /** @hidden */
  16004. export var kernelBlurFragment: {
  16005. name: string;
  16006. shader: string;
  16007. };
  16008. }
  16009. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16010. /** @hidden */
  16011. export var kernelBlurFragment2: {
  16012. name: string;
  16013. shader: string;
  16014. };
  16015. }
  16016. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16017. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16018. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16020. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16021. /** @hidden */
  16022. export var kernelBlurPixelShader: {
  16023. name: string;
  16024. shader: string;
  16025. };
  16026. }
  16027. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16028. /** @hidden */
  16029. export var kernelBlurVertex: {
  16030. name: string;
  16031. shader: string;
  16032. };
  16033. }
  16034. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16035. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16036. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16037. /** @hidden */
  16038. export var kernelBlurVertexShader: {
  16039. name: string;
  16040. shader: string;
  16041. };
  16042. }
  16043. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16044. import { Vector2 } from "babylonjs/Maths/math.vector";
  16045. import { Nullable } from "babylonjs/types";
  16046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16047. import { Camera } from "babylonjs/Cameras/camera";
  16048. import { Effect } from "babylonjs/Materials/effect";
  16049. import { Engine } from "babylonjs/Engines/engine";
  16050. import "babylonjs/Shaders/kernelBlur.fragment";
  16051. import "babylonjs/Shaders/kernelBlur.vertex";
  16052. /**
  16053. * The Blur Post Process which blurs an image based on a kernel and direction.
  16054. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16055. */
  16056. export class BlurPostProcess extends PostProcess {
  16057. /** The direction in which to blur the image. */
  16058. direction: Vector2;
  16059. private blockCompilation;
  16060. protected _kernel: number;
  16061. protected _idealKernel: number;
  16062. protected _packedFloat: boolean;
  16063. private _staticDefines;
  16064. /**
  16065. * Sets the length in pixels of the blur sample region
  16066. */
  16067. /**
  16068. * Gets the length in pixels of the blur sample region
  16069. */
  16070. kernel: number;
  16071. /**
  16072. * Sets wether or not the blur needs to unpack/repack floats
  16073. */
  16074. /**
  16075. * Gets wether or not the blur is unpacking/repacking floats
  16076. */
  16077. packedFloat: boolean;
  16078. /**
  16079. * Creates a new instance BlurPostProcess
  16080. * @param name The name of the effect.
  16081. * @param direction The direction in which to blur the image.
  16082. * @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.
  16083. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16084. * @param camera The camera to apply the render pass to.
  16085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16086. * @param engine The engine which the post process will be applied. (default: current engine)
  16087. * @param reusable If the post process can be reused on the same frame. (default: false)
  16088. * @param textureType Type of textures used when performing the post process. (default: 0)
  16089. * @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)
  16090. */
  16091. constructor(name: string,
  16092. /** The direction in which to blur the image. */
  16093. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16094. /**
  16095. * Updates the effect with the current post process compile time values and recompiles the shader.
  16096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16099. * @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
  16100. * @param onCompiled Called when the shader has been compiled.
  16101. * @param onError Called if there is an error when compiling a shader.
  16102. */
  16103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16104. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16105. /**
  16106. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16107. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16108. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16109. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16110. * The gaps between physical kernels are compensated for in the weighting of the samples
  16111. * @param idealKernel Ideal blur kernel.
  16112. * @return Nearest best kernel.
  16113. */
  16114. protected _nearestBestKernel(idealKernel: number): number;
  16115. /**
  16116. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16117. * @param x The point on the Gaussian distribution to sample.
  16118. * @return the value of the Gaussian function at x.
  16119. */
  16120. protected _gaussianWeight(x: number): number;
  16121. /**
  16122. * Generates a string that can be used as a floating point number in GLSL.
  16123. * @param x Value to print.
  16124. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16125. * @return GLSL float string.
  16126. */
  16127. protected _glslFloat(x: number, decimalFigures?: number): string;
  16128. }
  16129. }
  16130. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16131. import { Scene } from "babylonjs/scene";
  16132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16133. import { Plane } from "babylonjs/Maths/math.plane";
  16134. /**
  16135. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16136. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16137. * You can then easily use it as a reflectionTexture on a flat surface.
  16138. * In case the surface is not a plane, please consider relying on reflection probes.
  16139. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16140. */
  16141. export class MirrorTexture extends RenderTargetTexture {
  16142. private scene;
  16143. /**
  16144. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16145. * 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.
  16146. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16147. */
  16148. mirrorPlane: Plane;
  16149. /**
  16150. * Define the blur ratio used to blur the reflection if needed.
  16151. */
  16152. blurRatio: number;
  16153. /**
  16154. * Define the adaptive blur kernel used to blur the reflection if needed.
  16155. * This will autocompute the closest best match for the `blurKernel`
  16156. */
  16157. adaptiveBlurKernel: number;
  16158. /**
  16159. * Define the blur kernel used to blur the reflection if needed.
  16160. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16161. */
  16162. blurKernel: number;
  16163. /**
  16164. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16165. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16166. */
  16167. blurKernelX: number;
  16168. /**
  16169. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16171. */
  16172. blurKernelY: number;
  16173. private _autoComputeBlurKernel;
  16174. protected _onRatioRescale(): void;
  16175. private _updateGammaSpace;
  16176. private _imageProcessingConfigChangeObserver;
  16177. private _transformMatrix;
  16178. private _mirrorMatrix;
  16179. private _savedViewMatrix;
  16180. private _blurX;
  16181. private _blurY;
  16182. private _adaptiveBlurKernel;
  16183. private _blurKernelX;
  16184. private _blurKernelY;
  16185. private _blurRatio;
  16186. /**
  16187. * Instantiates a Mirror Texture.
  16188. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16189. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16190. * You can then easily use it as a reflectionTexture on a flat surface.
  16191. * In case the surface is not a plane, please consider relying on reflection probes.
  16192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16193. * @param name
  16194. * @param size
  16195. * @param scene
  16196. * @param generateMipMaps
  16197. * @param type
  16198. * @param samplingMode
  16199. * @param generateDepthBuffer
  16200. */
  16201. constructor(name: string, size: number | {
  16202. width: number;
  16203. height: number;
  16204. } | {
  16205. ratio: number;
  16206. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16207. private _preparePostProcesses;
  16208. /**
  16209. * Clone the mirror texture.
  16210. * @returns the cloned texture
  16211. */
  16212. clone(): MirrorTexture;
  16213. /**
  16214. * Serialize the texture to a JSON representation you could use in Parse later on
  16215. * @returns the serialized JSON representation
  16216. */
  16217. serialize(): any;
  16218. /**
  16219. * Dispose the texture and release its associated resources.
  16220. */
  16221. dispose(): void;
  16222. }
  16223. }
  16224. declare module "babylonjs/Materials/Textures/texture" {
  16225. import { Observable } from "babylonjs/Misc/observable";
  16226. import { Nullable } from "babylonjs/types";
  16227. import { Matrix } from "babylonjs/Maths/math.vector";
  16228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16229. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16230. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16231. import { Scene } from "babylonjs/scene";
  16232. /**
  16233. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16234. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16235. */
  16236. export class Texture extends BaseTexture {
  16237. /**
  16238. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16239. */
  16240. static SerializeBuffers: boolean;
  16241. /** @hidden */
  16242. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16243. /** @hidden */
  16244. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16245. /** @hidden */
  16246. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16247. /** nearest is mag = nearest and min = nearest and mip = linear */
  16248. static readonly NEAREST_SAMPLINGMODE: number;
  16249. /** nearest is mag = nearest and min = nearest and mip = linear */
  16250. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16251. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16252. static readonly BILINEAR_SAMPLINGMODE: number;
  16253. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16254. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16255. /** Trilinear is mag = linear and min = linear and mip = linear */
  16256. static readonly TRILINEAR_SAMPLINGMODE: number;
  16257. /** Trilinear is mag = linear and min = linear and mip = linear */
  16258. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16259. /** mag = nearest and min = nearest and mip = nearest */
  16260. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16261. /** mag = nearest and min = linear and mip = nearest */
  16262. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16263. /** mag = nearest and min = linear and mip = linear */
  16264. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16265. /** mag = nearest and min = linear and mip = none */
  16266. static readonly NEAREST_LINEAR: number;
  16267. /** mag = nearest and min = nearest and mip = none */
  16268. static readonly NEAREST_NEAREST: number;
  16269. /** mag = linear and min = nearest and mip = nearest */
  16270. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16271. /** mag = linear and min = nearest and mip = linear */
  16272. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16273. /** mag = linear and min = linear and mip = none */
  16274. static readonly LINEAR_LINEAR: number;
  16275. /** mag = linear and min = nearest and mip = none */
  16276. static readonly LINEAR_NEAREST: number;
  16277. /** Explicit coordinates mode */
  16278. static readonly EXPLICIT_MODE: number;
  16279. /** Spherical coordinates mode */
  16280. static readonly SPHERICAL_MODE: number;
  16281. /** Planar coordinates mode */
  16282. static readonly PLANAR_MODE: number;
  16283. /** Cubic coordinates mode */
  16284. static readonly CUBIC_MODE: number;
  16285. /** Projection coordinates mode */
  16286. static readonly PROJECTION_MODE: number;
  16287. /** Inverse Cubic coordinates mode */
  16288. static readonly SKYBOX_MODE: number;
  16289. /** Inverse Cubic coordinates mode */
  16290. static readonly INVCUBIC_MODE: number;
  16291. /** Equirectangular coordinates mode */
  16292. static readonly EQUIRECTANGULAR_MODE: number;
  16293. /** Equirectangular Fixed coordinates mode */
  16294. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16295. /** Equirectangular Fixed Mirrored coordinates mode */
  16296. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16297. /** Texture is not repeating outside of 0..1 UVs */
  16298. static readonly CLAMP_ADDRESSMODE: number;
  16299. /** Texture is repeating outside of 0..1 UVs */
  16300. static readonly WRAP_ADDRESSMODE: number;
  16301. /** Texture is repeating and mirrored */
  16302. static readonly MIRROR_ADDRESSMODE: number;
  16303. /**
  16304. * 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
  16305. */
  16306. static UseSerializedUrlIfAny: boolean;
  16307. /**
  16308. * Define the url of the texture.
  16309. */
  16310. url: Nullable<string>;
  16311. /**
  16312. * Define an offset on the texture to offset the u coordinates of the UVs
  16313. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16314. */
  16315. uOffset: number;
  16316. /**
  16317. * Define an offset on the texture to offset the v coordinates of the UVs
  16318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16319. */
  16320. vOffset: number;
  16321. /**
  16322. * Define an offset on the texture to scale the u coordinates of the UVs
  16323. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16324. */
  16325. uScale: number;
  16326. /**
  16327. * Define an offset on the texture to scale the v coordinates of the UVs
  16328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16329. */
  16330. vScale: number;
  16331. /**
  16332. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16333. * @see http://doc.babylonjs.com/how_to/more_materials
  16334. */
  16335. uAng: number;
  16336. /**
  16337. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16338. * @see http://doc.babylonjs.com/how_to/more_materials
  16339. */
  16340. vAng: number;
  16341. /**
  16342. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16343. * @see http://doc.babylonjs.com/how_to/more_materials
  16344. */
  16345. wAng: number;
  16346. /**
  16347. * Defines the center of rotation (U)
  16348. */
  16349. uRotationCenter: number;
  16350. /**
  16351. * Defines the center of rotation (V)
  16352. */
  16353. vRotationCenter: number;
  16354. /**
  16355. * Defines the center of rotation (W)
  16356. */
  16357. wRotationCenter: number;
  16358. /**
  16359. * Are mip maps generated for this texture or not.
  16360. */
  16361. readonly noMipmap: boolean;
  16362. /**
  16363. * List of inspectable custom properties (used by the Inspector)
  16364. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16365. */
  16366. inspectableCustomProperties: Nullable<IInspectable[]>;
  16367. private _noMipmap;
  16368. /** @hidden */
  16369. _invertY: boolean;
  16370. private _rowGenerationMatrix;
  16371. private _cachedTextureMatrix;
  16372. private _projectionModeMatrix;
  16373. private _t0;
  16374. private _t1;
  16375. private _t2;
  16376. private _cachedUOffset;
  16377. private _cachedVOffset;
  16378. private _cachedUScale;
  16379. private _cachedVScale;
  16380. private _cachedUAng;
  16381. private _cachedVAng;
  16382. private _cachedWAng;
  16383. private _cachedProjectionMatrixId;
  16384. private _cachedCoordinatesMode;
  16385. /** @hidden */
  16386. protected _initialSamplingMode: number;
  16387. /** @hidden */
  16388. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16389. private _deleteBuffer;
  16390. protected _format: Nullable<number>;
  16391. private _delayedOnLoad;
  16392. private _delayedOnError;
  16393. private _mimeType?;
  16394. /**
  16395. * Observable triggered once the texture has been loaded.
  16396. */
  16397. onLoadObservable: Observable<Texture>;
  16398. protected _isBlocking: boolean;
  16399. /**
  16400. * Is the texture preventing material to render while loading.
  16401. * If false, a default texture will be used instead of the loading one during the preparation step.
  16402. */
  16403. isBlocking: boolean;
  16404. /**
  16405. * Get the current sampling mode associated with the texture.
  16406. */
  16407. readonly samplingMode: number;
  16408. /**
  16409. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16410. */
  16411. readonly invertY: boolean;
  16412. /**
  16413. * Instantiates a new texture.
  16414. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16415. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16416. * @param url defines the url of the picture to load as a texture
  16417. * @param scene defines the scene or engine the texture will belong to
  16418. * @param noMipmap defines if the texture will require mip maps or not
  16419. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16420. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16421. * @param onLoad defines a callback triggered when the texture has been loaded
  16422. * @param onError defines a callback triggered when an error occurred during the loading session
  16423. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16424. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16425. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16426. * @param mimeType defines an optional mime type information
  16427. */
  16428. 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);
  16429. /**
  16430. * Update the url (and optional buffer) of this texture if url was null during construction.
  16431. * @param url the url of the texture
  16432. * @param buffer the buffer of the texture (defaults to null)
  16433. * @param onLoad callback called when the texture is loaded (defaults to null)
  16434. */
  16435. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16436. /**
  16437. * Finish the loading sequence of a texture flagged as delayed load.
  16438. * @hidden
  16439. */
  16440. delayLoad(): void;
  16441. private _prepareRowForTextureGeneration;
  16442. /**
  16443. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16444. * @returns the transform matrix of the texture.
  16445. */
  16446. getTextureMatrix(uBase?: number): Matrix;
  16447. /**
  16448. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16449. * @returns The reflection texture transform
  16450. */
  16451. getReflectionTextureMatrix(): Matrix;
  16452. /**
  16453. * Clones the texture.
  16454. * @returns the cloned texture
  16455. */
  16456. clone(): Texture;
  16457. /**
  16458. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16459. * @returns The JSON representation of the texture
  16460. */
  16461. serialize(): any;
  16462. /**
  16463. * Get the current class name of the texture useful for serialization or dynamic coding.
  16464. * @returns "Texture"
  16465. */
  16466. getClassName(): string;
  16467. /**
  16468. * Dispose the texture and release its associated resources.
  16469. */
  16470. dispose(): void;
  16471. /**
  16472. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16473. * @param parsedTexture Define the JSON representation of the texture
  16474. * @param scene Define the scene the parsed texture should be instantiated in
  16475. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16476. * @returns The parsed texture if successful
  16477. */
  16478. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16479. /**
  16480. * Creates a texture from its base 64 representation.
  16481. * @param data Define the base64 payload without the data: prefix
  16482. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16483. * @param scene Define the scene the texture should belong to
  16484. * @param noMipmap Forces the texture to not create mip map information if true
  16485. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16486. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16487. * @param onLoad define a callback triggered when the texture has been loaded
  16488. * @param onError define a callback triggered when an error occurred during the loading session
  16489. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16490. * @returns the created texture
  16491. */
  16492. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16493. /**
  16494. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16495. * @param data Define the base64 payload without the data: prefix
  16496. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16497. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16498. * @param scene Define the scene the texture should belong to
  16499. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16500. * @param noMipmap Forces the texture to not create mip map information if true
  16501. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16502. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16503. * @param onLoad define a callback triggered when the texture has been loaded
  16504. * @param onError define a callback triggered when an error occurred during the loading session
  16505. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16506. * @returns the created texture
  16507. */
  16508. 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;
  16509. }
  16510. }
  16511. declare module "babylonjs/PostProcesses/postProcessManager" {
  16512. import { Nullable } from "babylonjs/types";
  16513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16514. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16515. import { Scene } from "babylonjs/scene";
  16516. /**
  16517. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16518. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16519. */
  16520. export class PostProcessManager {
  16521. private _scene;
  16522. private _indexBuffer;
  16523. private _vertexBuffers;
  16524. /**
  16525. * Creates a new instance PostProcess
  16526. * @param scene The scene that the post process is associated with.
  16527. */
  16528. constructor(scene: Scene);
  16529. private _prepareBuffers;
  16530. private _buildIndexBuffer;
  16531. /**
  16532. * Rebuilds the vertex buffers of the manager.
  16533. * @hidden
  16534. */
  16535. _rebuild(): void;
  16536. /**
  16537. * Prepares a frame to be run through a post process.
  16538. * @param sourceTexture The input texture to the post procesess. (default: null)
  16539. * @param postProcesses An array of post processes to be run. (default: null)
  16540. * @returns True if the post processes were able to be run.
  16541. * @hidden
  16542. */
  16543. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16544. /**
  16545. * Manually render a set of post processes to a texture.
  16546. * @param postProcesses An array of post processes to be run.
  16547. * @param targetTexture The target texture to render to.
  16548. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16549. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16550. * @param lodLevel defines which lod of the texture to render to
  16551. */
  16552. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16553. /**
  16554. * Finalize the result of the output of the postprocesses.
  16555. * @param doNotPresent If true the result will not be displayed to the screen.
  16556. * @param targetTexture The target texture to render to.
  16557. * @param faceIndex The index of the face to bind the target texture to.
  16558. * @param postProcesses The array of post processes to render.
  16559. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16560. * @hidden
  16561. */
  16562. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16563. /**
  16564. * Disposes of the post process manager.
  16565. */
  16566. dispose(): void;
  16567. }
  16568. }
  16569. declare module "babylonjs/Misc/gradients" {
  16570. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16571. /** Interface used by value gradients (color, factor, ...) */
  16572. export interface IValueGradient {
  16573. /**
  16574. * Gets or sets the gradient value (between 0 and 1)
  16575. */
  16576. gradient: number;
  16577. }
  16578. /** Class used to store color4 gradient */
  16579. export class ColorGradient implements IValueGradient {
  16580. /**
  16581. * Gets or sets the gradient value (between 0 and 1)
  16582. */
  16583. gradient: number;
  16584. /**
  16585. * Gets or sets first associated color
  16586. */
  16587. color1: Color4;
  16588. /**
  16589. * Gets or sets second associated color
  16590. */
  16591. color2?: Color4;
  16592. /**
  16593. * Will get a color picked randomly between color1 and color2.
  16594. * If color2 is undefined then color1 will be used
  16595. * @param result defines the target Color4 to store the result in
  16596. */
  16597. getColorToRef(result: Color4): void;
  16598. }
  16599. /** Class used to store color 3 gradient */
  16600. export class Color3Gradient implements IValueGradient {
  16601. /**
  16602. * Gets or sets the gradient value (between 0 and 1)
  16603. */
  16604. gradient: number;
  16605. /**
  16606. * Gets or sets the associated color
  16607. */
  16608. color: Color3;
  16609. }
  16610. /** Class used to store factor gradient */
  16611. export class FactorGradient implements IValueGradient {
  16612. /**
  16613. * Gets or sets the gradient value (between 0 and 1)
  16614. */
  16615. gradient: number;
  16616. /**
  16617. * Gets or sets first associated factor
  16618. */
  16619. factor1: number;
  16620. /**
  16621. * Gets or sets second associated factor
  16622. */
  16623. factor2?: number;
  16624. /**
  16625. * Will get a number picked randomly between factor1 and factor2.
  16626. * If factor2 is undefined then factor1 will be used
  16627. * @returns the picked number
  16628. */
  16629. getFactor(): number;
  16630. }
  16631. /**
  16632. * Helper used to simplify some generic gradient tasks
  16633. */
  16634. export class GradientHelper {
  16635. /**
  16636. * Gets the current gradient from an array of IValueGradient
  16637. * @param ratio defines the current ratio to get
  16638. * @param gradients defines the array of IValueGradient
  16639. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16640. */
  16641. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16642. }
  16643. }
  16644. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16645. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16646. import { Nullable } from "babylonjs/types";
  16647. module "babylonjs/Engines/thinEngine" {
  16648. interface ThinEngine {
  16649. /**
  16650. * Creates a dynamic texture
  16651. * @param width defines the width of the texture
  16652. * @param height defines the height of the texture
  16653. * @param generateMipMaps defines if the engine should generate the mip levels
  16654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16655. * @returns the dynamic texture inside an InternalTexture
  16656. */
  16657. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16658. /**
  16659. * Update the content of a dynamic texture
  16660. * @param texture defines the texture to update
  16661. * @param canvas defines the canvas containing the source
  16662. * @param invertY defines if data must be stored with Y axis inverted
  16663. * @param premulAlpha defines if alpha is stored as premultiplied
  16664. * @param format defines the format of the data
  16665. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16666. */
  16667. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16668. }
  16669. }
  16670. }
  16671. declare module "babylonjs/Misc/canvasGenerator" {
  16672. /**
  16673. * Helper class used to generate a canvas to manipulate images
  16674. */
  16675. export class CanvasGenerator {
  16676. /**
  16677. * Create a new canvas (or offscreen canvas depending on the context)
  16678. * @param width defines the expected width
  16679. * @param height defines the expected height
  16680. * @return a new canvas or offscreen canvas
  16681. */
  16682. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16683. }
  16684. }
  16685. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16686. import { Scene } from "babylonjs/scene";
  16687. import { Texture } from "babylonjs/Materials/Textures/texture";
  16688. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16689. /**
  16690. * A class extending Texture allowing drawing on a texture
  16691. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16692. */
  16693. export class DynamicTexture extends Texture {
  16694. private _generateMipMaps;
  16695. private _canvas;
  16696. private _context;
  16697. private _engine;
  16698. /**
  16699. * Creates a DynamicTexture
  16700. * @param name defines the name of the texture
  16701. * @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
  16702. * @param scene defines the scene where you want the texture
  16703. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16704. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16705. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16706. */
  16707. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16708. /**
  16709. * Get the current class name of the texture useful for serialization or dynamic coding.
  16710. * @returns "DynamicTexture"
  16711. */
  16712. getClassName(): string;
  16713. /**
  16714. * Gets the current state of canRescale
  16715. */
  16716. readonly canRescale: boolean;
  16717. private _recreate;
  16718. /**
  16719. * Scales the texture
  16720. * @param ratio the scale factor to apply to both width and height
  16721. */
  16722. scale(ratio: number): void;
  16723. /**
  16724. * Resizes the texture
  16725. * @param width the new width
  16726. * @param height the new height
  16727. */
  16728. scaleTo(width: number, height: number): void;
  16729. /**
  16730. * Gets the context of the canvas used by the texture
  16731. * @returns the canvas context of the dynamic texture
  16732. */
  16733. getContext(): CanvasRenderingContext2D;
  16734. /**
  16735. * Clears the texture
  16736. */
  16737. clear(): void;
  16738. /**
  16739. * Updates the texture
  16740. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16741. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16742. */
  16743. update(invertY?: boolean, premulAlpha?: boolean): void;
  16744. /**
  16745. * Draws text onto the texture
  16746. * @param text defines the text to be drawn
  16747. * @param x defines the placement of the text from the left
  16748. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16749. * @param font defines the font to be used with font-style, font-size, font-name
  16750. * @param color defines the color used for the text
  16751. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16752. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16753. * @param update defines whether texture is immediately update (default is true)
  16754. */
  16755. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16756. /**
  16757. * Clones the texture
  16758. * @returns the clone of the texture.
  16759. */
  16760. clone(): DynamicTexture;
  16761. /**
  16762. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16763. * @returns a serialized dynamic texture object
  16764. */
  16765. serialize(): any;
  16766. /** @hidden */
  16767. _rebuild(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16771. import { Scene } from "babylonjs/scene";
  16772. import { ISceneComponent } from "babylonjs/sceneComponent";
  16773. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16774. module "babylonjs/abstractScene" {
  16775. interface AbstractScene {
  16776. /**
  16777. * The list of procedural textures added to the scene
  16778. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16779. */
  16780. proceduralTextures: Array<ProceduralTexture>;
  16781. }
  16782. }
  16783. /**
  16784. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16785. * in a given scene.
  16786. */
  16787. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16788. /**
  16789. * The component name helpfull to identify the component in the list of scene components.
  16790. */
  16791. readonly name: string;
  16792. /**
  16793. * The scene the component belongs to.
  16794. */
  16795. scene: Scene;
  16796. /**
  16797. * Creates a new instance of the component for the given scene
  16798. * @param scene Defines the scene to register the component in
  16799. */
  16800. constructor(scene: Scene);
  16801. /**
  16802. * Registers the component in a given scene
  16803. */
  16804. register(): void;
  16805. /**
  16806. * Rebuilds the elements related to this component in case of
  16807. * context lost for instance.
  16808. */
  16809. rebuild(): void;
  16810. /**
  16811. * Disposes the component and the associated ressources.
  16812. */
  16813. dispose(): void;
  16814. private _beforeClear;
  16815. }
  16816. }
  16817. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16818. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16819. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16820. module "babylonjs/Engines/thinEngine" {
  16821. interface ThinEngine {
  16822. /**
  16823. * Creates a new render target cube texture
  16824. * @param size defines the size of the texture
  16825. * @param options defines the options used to create the texture
  16826. * @returns a new render target cube texture stored in an InternalTexture
  16827. */
  16828. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16829. }
  16830. }
  16831. }
  16832. declare module "babylonjs/Shaders/procedural.vertex" {
  16833. /** @hidden */
  16834. export var proceduralVertexShader: {
  16835. name: string;
  16836. shader: string;
  16837. };
  16838. }
  16839. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16840. import { Observable } from "babylonjs/Misc/observable";
  16841. import { Nullable } from "babylonjs/types";
  16842. import { Scene } from "babylonjs/scene";
  16843. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16844. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16845. import { Effect } from "babylonjs/Materials/effect";
  16846. import { Texture } from "babylonjs/Materials/Textures/texture";
  16847. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16848. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16849. import "babylonjs/Shaders/procedural.vertex";
  16850. /**
  16851. * 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.
  16852. * This is the base class of any Procedural texture and contains most of the shareable code.
  16853. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16854. */
  16855. export class ProceduralTexture extends Texture {
  16856. isCube: boolean;
  16857. /**
  16858. * Define if the texture is enabled or not (disabled texture will not render)
  16859. */
  16860. isEnabled: boolean;
  16861. /**
  16862. * Define if the texture must be cleared before rendering (default is true)
  16863. */
  16864. autoClear: boolean;
  16865. /**
  16866. * Callback called when the texture is generated
  16867. */
  16868. onGenerated: () => void;
  16869. /**
  16870. * Event raised when the texture is generated
  16871. */
  16872. onGeneratedObservable: Observable<ProceduralTexture>;
  16873. /** @hidden */
  16874. _generateMipMaps: boolean;
  16875. /** @hidden **/
  16876. _effect: Effect;
  16877. /** @hidden */
  16878. _textures: {
  16879. [key: string]: Texture;
  16880. };
  16881. private _size;
  16882. private _currentRefreshId;
  16883. private _refreshRate;
  16884. private _vertexBuffers;
  16885. private _indexBuffer;
  16886. private _uniforms;
  16887. private _samplers;
  16888. private _fragment;
  16889. private _floats;
  16890. private _ints;
  16891. private _floatsArrays;
  16892. private _colors3;
  16893. private _colors4;
  16894. private _vectors2;
  16895. private _vectors3;
  16896. private _matrices;
  16897. private _fallbackTexture;
  16898. private _fallbackTextureUsed;
  16899. private _engine;
  16900. private _cachedDefines;
  16901. private _contentUpdateId;
  16902. private _contentData;
  16903. /**
  16904. * Instantiates a new procedural texture.
  16905. * 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.
  16906. * This is the base class of any Procedural texture and contains most of the shareable code.
  16907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16908. * @param name Define the name of the texture
  16909. * @param size Define the size of the texture to create
  16910. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16911. * @param scene Define the scene the texture belongs to
  16912. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16913. * @param generateMipMaps Define if the texture should creates mip maps or not
  16914. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16915. */
  16916. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16917. /**
  16918. * The effect that is created when initializing the post process.
  16919. * @returns The created effect corresponding the the postprocess.
  16920. */
  16921. getEffect(): Effect;
  16922. /**
  16923. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16924. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16925. */
  16926. getContent(): Nullable<ArrayBufferView>;
  16927. private _createIndexBuffer;
  16928. /** @hidden */
  16929. _rebuild(): void;
  16930. /**
  16931. * Resets the texture in order to recreate its associated resources.
  16932. * This can be called in case of context loss
  16933. */
  16934. reset(): void;
  16935. protected _getDefines(): string;
  16936. /**
  16937. * Is the texture ready to be used ? (rendered at least once)
  16938. * @returns true if ready, otherwise, false.
  16939. */
  16940. isReady(): boolean;
  16941. /**
  16942. * Resets the refresh counter of the texture and start bak from scratch.
  16943. * Could be useful to regenerate the texture if it is setup to render only once.
  16944. */
  16945. resetRefreshCounter(): void;
  16946. /**
  16947. * Set the fragment shader to use in order to render the texture.
  16948. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16949. */
  16950. setFragment(fragment: any): void;
  16951. /**
  16952. * Define the refresh rate of the texture or the rendering frequency.
  16953. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16954. */
  16955. refreshRate: number;
  16956. /** @hidden */
  16957. _shouldRender(): boolean;
  16958. /**
  16959. * Get the size the texture is rendering at.
  16960. * @returns the size (texture is always squared)
  16961. */
  16962. getRenderSize(): number;
  16963. /**
  16964. * Resize the texture to new value.
  16965. * @param size Define the new size the texture should have
  16966. * @param generateMipMaps Define whether the new texture should create mip maps
  16967. */
  16968. resize(size: number, generateMipMaps: boolean): void;
  16969. private _checkUniform;
  16970. /**
  16971. * Set a texture in the shader program used to render.
  16972. * @param name Define the name of the uniform samplers as defined in the shader
  16973. * @param texture Define the texture to bind to this sampler
  16974. * @return the texture itself allowing "fluent" like uniform updates
  16975. */
  16976. setTexture(name: string, texture: Texture): ProceduralTexture;
  16977. /**
  16978. * Set a float in the shader.
  16979. * @param name Define the name of the uniform as defined in the shader
  16980. * @param value Define the value to give to the uniform
  16981. * @return the texture itself allowing "fluent" like uniform updates
  16982. */
  16983. setFloat(name: string, value: number): ProceduralTexture;
  16984. /**
  16985. * Set a int in the shader.
  16986. * @param name Define the name of the uniform as defined in the shader
  16987. * @param value Define the value to give to the uniform
  16988. * @return the texture itself allowing "fluent" like uniform updates
  16989. */
  16990. setInt(name: string, value: number): ProceduralTexture;
  16991. /**
  16992. * Set an array of floats in the shader.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the texture itself allowing "fluent" like uniform updates
  16996. */
  16997. setFloats(name: string, value: number[]): ProceduralTexture;
  16998. /**
  16999. * Set a vec3 in the shader from a Color3.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the texture itself allowing "fluent" like uniform updates
  17003. */
  17004. setColor3(name: string, value: Color3): ProceduralTexture;
  17005. /**
  17006. * Set a vec4 in the shader from a Color4.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the texture itself allowing "fluent" like uniform updates
  17010. */
  17011. setColor4(name: string, value: Color4): ProceduralTexture;
  17012. /**
  17013. * Set a vec2 in the shader from a Vector2.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the texture itself allowing "fluent" like uniform updates
  17017. */
  17018. setVector2(name: string, value: Vector2): ProceduralTexture;
  17019. /**
  17020. * Set a vec3 in the shader from a Vector3.
  17021. * @param name Define the name of the uniform as defined in the shader
  17022. * @param value Define the value to give to the uniform
  17023. * @return the texture itself allowing "fluent" like uniform updates
  17024. */
  17025. setVector3(name: string, value: Vector3): ProceduralTexture;
  17026. /**
  17027. * Set a mat4 in the shader from a MAtrix.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the texture itself allowing "fluent" like uniform updates
  17031. */
  17032. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17033. /**
  17034. * Render the texture to its associated render target.
  17035. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17036. */
  17037. render(useCameraPostProcess?: boolean): void;
  17038. /**
  17039. * Clone the texture.
  17040. * @returns the cloned texture
  17041. */
  17042. clone(): ProceduralTexture;
  17043. /**
  17044. * Dispose the texture and release its asoociated resources.
  17045. */
  17046. dispose(): void;
  17047. }
  17048. }
  17049. declare module "babylonjs/Particles/baseParticleSystem" {
  17050. import { Nullable } from "babylonjs/types";
  17051. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17053. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17054. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17055. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17056. import { Scene } from "babylonjs/scene";
  17057. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17058. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17059. import { Texture } from "babylonjs/Materials/Textures/texture";
  17060. import { Color4 } from "babylonjs/Maths/math.color";
  17061. import { Animation } from "babylonjs/Animations/animation";
  17062. /**
  17063. * This represents the base class for particle system in Babylon.
  17064. * 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.
  17065. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17066. * @example https://doc.babylonjs.com/babylon101/particles
  17067. */
  17068. export class BaseParticleSystem {
  17069. /**
  17070. * Source color is added to the destination color without alpha affecting the result
  17071. */
  17072. static BLENDMODE_ONEONE: number;
  17073. /**
  17074. * Blend current color and particle color using particle’s alpha
  17075. */
  17076. static BLENDMODE_STANDARD: number;
  17077. /**
  17078. * Add current color and particle color multiplied by particle’s alpha
  17079. */
  17080. static BLENDMODE_ADD: number;
  17081. /**
  17082. * Multiply current color with particle color
  17083. */
  17084. static BLENDMODE_MULTIPLY: number;
  17085. /**
  17086. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17087. */
  17088. static BLENDMODE_MULTIPLYADD: number;
  17089. /**
  17090. * List of animations used by the particle system.
  17091. */
  17092. animations: Animation[];
  17093. /**
  17094. * The id of the Particle system.
  17095. */
  17096. id: string;
  17097. /**
  17098. * The friendly name of the Particle system.
  17099. */
  17100. name: string;
  17101. /**
  17102. * The rendering group used by the Particle system to chose when to render.
  17103. */
  17104. renderingGroupId: number;
  17105. /**
  17106. * The emitter represents the Mesh or position we are attaching the particle system to.
  17107. */
  17108. emitter: Nullable<AbstractMesh | Vector3>;
  17109. /**
  17110. * The maximum number of particles to emit per frame
  17111. */
  17112. emitRate: number;
  17113. /**
  17114. * If you want to launch only a few particles at once, that can be done, as well.
  17115. */
  17116. manualEmitCount: number;
  17117. /**
  17118. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17119. */
  17120. updateSpeed: number;
  17121. /**
  17122. * The amount of time the particle system is running (depends of the overall update speed).
  17123. */
  17124. targetStopDuration: number;
  17125. /**
  17126. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17127. */
  17128. disposeOnStop: boolean;
  17129. /**
  17130. * Minimum power of emitting particles.
  17131. */
  17132. minEmitPower: number;
  17133. /**
  17134. * Maximum power of emitting particles.
  17135. */
  17136. maxEmitPower: number;
  17137. /**
  17138. * Minimum life time of emitting particles.
  17139. */
  17140. minLifeTime: number;
  17141. /**
  17142. * Maximum life time of emitting particles.
  17143. */
  17144. maxLifeTime: number;
  17145. /**
  17146. * Minimum Size of emitting particles.
  17147. */
  17148. minSize: number;
  17149. /**
  17150. * Maximum Size of emitting particles.
  17151. */
  17152. maxSize: number;
  17153. /**
  17154. * Minimum scale of emitting particles on X axis.
  17155. */
  17156. minScaleX: number;
  17157. /**
  17158. * Maximum scale of emitting particles on X axis.
  17159. */
  17160. maxScaleX: number;
  17161. /**
  17162. * Minimum scale of emitting particles on Y axis.
  17163. */
  17164. minScaleY: number;
  17165. /**
  17166. * Maximum scale of emitting particles on Y axis.
  17167. */
  17168. maxScaleY: number;
  17169. /**
  17170. * Gets or sets the minimal initial rotation in radians.
  17171. */
  17172. minInitialRotation: number;
  17173. /**
  17174. * Gets or sets the maximal initial rotation in radians.
  17175. */
  17176. maxInitialRotation: number;
  17177. /**
  17178. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17179. */
  17180. minAngularSpeed: number;
  17181. /**
  17182. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17183. */
  17184. maxAngularSpeed: number;
  17185. /**
  17186. * The texture used to render each particle. (this can be a spritesheet)
  17187. */
  17188. particleTexture: Nullable<Texture>;
  17189. /**
  17190. * The layer mask we are rendering the particles through.
  17191. */
  17192. layerMask: number;
  17193. /**
  17194. * This can help using your own shader to render the particle system.
  17195. * The according effect will be created
  17196. */
  17197. customShader: any;
  17198. /**
  17199. * By default particle system starts as soon as they are created. This prevents the
  17200. * automatic start to happen and let you decide when to start emitting particles.
  17201. */
  17202. preventAutoStart: boolean;
  17203. private _noiseTexture;
  17204. /**
  17205. * Gets or sets a texture used to add random noise to particle positions
  17206. */
  17207. noiseTexture: Nullable<ProceduralTexture>;
  17208. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17209. noiseStrength: Vector3;
  17210. /**
  17211. * Callback triggered when the particle animation is ending.
  17212. */
  17213. onAnimationEnd: Nullable<() => void>;
  17214. /**
  17215. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17216. */
  17217. blendMode: number;
  17218. /**
  17219. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17220. * to override the particles.
  17221. */
  17222. forceDepthWrite: boolean;
  17223. /** 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 */
  17224. preWarmCycles: number;
  17225. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17226. preWarmStepOffset: number;
  17227. /**
  17228. * 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)
  17229. */
  17230. spriteCellChangeSpeed: number;
  17231. /**
  17232. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17233. */
  17234. startSpriteCellID: number;
  17235. /**
  17236. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17237. */
  17238. endSpriteCellID: number;
  17239. /**
  17240. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17241. */
  17242. spriteCellWidth: number;
  17243. /**
  17244. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17245. */
  17246. spriteCellHeight: number;
  17247. /**
  17248. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17249. */
  17250. spriteRandomStartCell: boolean;
  17251. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17252. translationPivot: Vector2;
  17253. /** @hidden */
  17254. protected _isAnimationSheetEnabled: boolean;
  17255. /**
  17256. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17257. */
  17258. beginAnimationOnStart: boolean;
  17259. /**
  17260. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17261. */
  17262. beginAnimationFrom: number;
  17263. /**
  17264. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17265. */
  17266. beginAnimationTo: number;
  17267. /**
  17268. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17269. */
  17270. beginAnimationLoop: boolean;
  17271. /**
  17272. * Gets or sets a world offset applied to all particles
  17273. */
  17274. worldOffset: Vector3;
  17275. /**
  17276. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17277. */
  17278. isAnimationSheetEnabled: boolean;
  17279. /**
  17280. * Get hosting scene
  17281. * @returns the scene
  17282. */
  17283. getScene(): Scene;
  17284. /**
  17285. * You can use gravity if you want to give an orientation to your particles.
  17286. */
  17287. gravity: Vector3;
  17288. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17289. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17290. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17291. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17292. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17293. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17294. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17295. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17296. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17297. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17298. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17299. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17300. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17301. /**
  17302. * Defines the delay in milliseconds before starting the system (0 by default)
  17303. */
  17304. startDelay: number;
  17305. /**
  17306. * Gets the current list of drag gradients.
  17307. * You must use addDragGradient and removeDragGradient to udpate this list
  17308. * @returns the list of drag gradients
  17309. */
  17310. getDragGradients(): Nullable<Array<FactorGradient>>;
  17311. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17312. limitVelocityDamping: number;
  17313. /**
  17314. * Gets the current list of limit velocity gradients.
  17315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17316. * @returns the list of limit velocity gradients
  17317. */
  17318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17319. /**
  17320. * Gets the current list of color gradients.
  17321. * You must use addColorGradient and removeColorGradient to udpate this list
  17322. * @returns the list of color gradients
  17323. */
  17324. getColorGradients(): Nullable<Array<ColorGradient>>;
  17325. /**
  17326. * Gets the current list of size gradients.
  17327. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17328. * @returns the list of size gradients
  17329. */
  17330. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17331. /**
  17332. * Gets the current list of color remap gradients.
  17333. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17334. * @returns the list of color remap gradients
  17335. */
  17336. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17337. /**
  17338. * Gets the current list of alpha remap gradients.
  17339. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17340. * @returns the list of alpha remap gradients
  17341. */
  17342. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17343. /**
  17344. * Gets the current list of life time gradients.
  17345. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17346. * @returns the list of life time gradients
  17347. */
  17348. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17349. /**
  17350. * Gets the current list of angular speed gradients.
  17351. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17352. * @returns the list of angular speed gradients
  17353. */
  17354. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17355. /**
  17356. * Gets the current list of velocity gradients.
  17357. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17358. * @returns the list of velocity gradients
  17359. */
  17360. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17361. /**
  17362. * Gets the current list of start size gradients.
  17363. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17364. * @returns the list of start size gradients
  17365. */
  17366. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17367. /**
  17368. * Gets the current list of emit rate gradients.
  17369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17370. * @returns the list of emit rate gradients
  17371. */
  17372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17373. /**
  17374. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17375. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17376. */
  17377. direction1: Vector3;
  17378. /**
  17379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17381. */
  17382. direction2: Vector3;
  17383. /**
  17384. * 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.
  17385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17386. */
  17387. minEmitBox: Vector3;
  17388. /**
  17389. * 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.
  17390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17391. */
  17392. maxEmitBox: Vector3;
  17393. /**
  17394. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17395. */
  17396. color1: Color4;
  17397. /**
  17398. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17399. */
  17400. color2: Color4;
  17401. /**
  17402. * Color the particle will have at the end of its lifetime
  17403. */
  17404. colorDead: Color4;
  17405. /**
  17406. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17407. */
  17408. textureMask: Color4;
  17409. /**
  17410. * The particle emitter type defines the emitter used by the particle system.
  17411. * It can be for example box, sphere, or cone...
  17412. */
  17413. particleEmitterType: IParticleEmitterType;
  17414. /** @hidden */
  17415. _isSubEmitter: boolean;
  17416. /**
  17417. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17418. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17419. */
  17420. billboardMode: number;
  17421. protected _isBillboardBased: boolean;
  17422. /**
  17423. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17424. */
  17425. isBillboardBased: boolean;
  17426. /**
  17427. * The scene the particle system belongs to.
  17428. */
  17429. protected _scene: Scene;
  17430. /**
  17431. * Local cache of defines for image processing.
  17432. */
  17433. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17434. /**
  17435. * Default configuration related to image processing available in the standard Material.
  17436. */
  17437. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17438. /**
  17439. * Gets the image processing configuration used either in this material.
  17440. */
  17441. /**
  17442. * Sets the Default image processing configuration used either in the this material.
  17443. *
  17444. * If sets to null, the scene one is in use.
  17445. */
  17446. imageProcessingConfiguration: ImageProcessingConfiguration;
  17447. /**
  17448. * Attaches a new image processing configuration to the Standard Material.
  17449. * @param configuration
  17450. */
  17451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17452. /** @hidden */
  17453. protected _reset(): void;
  17454. /** @hidden */
  17455. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17456. /**
  17457. * Instantiates a particle system.
  17458. * 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.
  17459. * @param name The name of the particle system
  17460. */
  17461. constructor(name: string);
  17462. /**
  17463. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17466. * @returns the emitter
  17467. */
  17468. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17469. /**
  17470. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17471. * @param radius The radius of the hemisphere to emit from
  17472. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17473. * @returns the emitter
  17474. */
  17475. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17476. /**
  17477. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17478. * @param radius The radius of the sphere to emit from
  17479. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17480. * @returns the emitter
  17481. */
  17482. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17483. /**
  17484. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the sphere to emit from
  17486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17488. * @returns the emitter
  17489. */
  17490. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17491. /**
  17492. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17493. * @param radius The radius of the emission cylinder
  17494. * @param height The height of the emission cylinder
  17495. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17496. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17497. * @returns the emitter
  17498. */
  17499. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17500. /**
  17501. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17502. * @param radius The radius of the cylinder to emit from
  17503. * @param height The height of the emission cylinder
  17504. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17507. * @returns the emitter
  17508. */
  17509. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17510. /**
  17511. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17512. * @param radius The radius of the cone to emit from
  17513. * @param angle The base angle of the cone
  17514. * @returns the emitter
  17515. */
  17516. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17517. /**
  17518. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17521. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17522. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17523. * @returns the emitter
  17524. */
  17525. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17526. }
  17527. }
  17528. declare module "babylonjs/Particles/subEmitter" {
  17529. import { Scene } from "babylonjs/scene";
  17530. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17531. /**
  17532. * Type of sub emitter
  17533. */
  17534. export enum SubEmitterType {
  17535. /**
  17536. * Attached to the particle over it's lifetime
  17537. */
  17538. ATTACHED = 0,
  17539. /**
  17540. * Created when the particle dies
  17541. */
  17542. END = 1
  17543. }
  17544. /**
  17545. * Sub emitter class used to emit particles from an existing particle
  17546. */
  17547. export class SubEmitter {
  17548. /**
  17549. * the particle system to be used by the sub emitter
  17550. */
  17551. particleSystem: ParticleSystem;
  17552. /**
  17553. * Type of the submitter (Default: END)
  17554. */
  17555. type: SubEmitterType;
  17556. /**
  17557. * 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)
  17558. * Note: This only is supported when using an emitter of type Mesh
  17559. */
  17560. inheritDirection: boolean;
  17561. /**
  17562. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17563. */
  17564. inheritedVelocityAmount: number;
  17565. /**
  17566. * Creates a sub emitter
  17567. * @param particleSystem the particle system to be used by the sub emitter
  17568. */
  17569. constructor(
  17570. /**
  17571. * the particle system to be used by the sub emitter
  17572. */
  17573. particleSystem: ParticleSystem);
  17574. /**
  17575. * Clones the sub emitter
  17576. * @returns the cloned sub emitter
  17577. */
  17578. clone(): SubEmitter;
  17579. /**
  17580. * Serialize current object to a JSON object
  17581. * @returns the serialized object
  17582. */
  17583. serialize(): any;
  17584. /** @hidden */
  17585. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17586. /**
  17587. * Creates a new SubEmitter from a serialized JSON version
  17588. * @param serializationObject defines the JSON object to read from
  17589. * @param scene defines the hosting scene
  17590. * @param rootUrl defines the rootUrl for data loading
  17591. * @returns a new SubEmitter
  17592. */
  17593. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17594. /** Release associated resources */
  17595. dispose(): void;
  17596. }
  17597. }
  17598. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17599. /** @hidden */
  17600. export var clipPlaneFragmentDeclaration: {
  17601. name: string;
  17602. shader: string;
  17603. };
  17604. }
  17605. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17606. /** @hidden */
  17607. export var imageProcessingDeclaration: {
  17608. name: string;
  17609. shader: string;
  17610. };
  17611. }
  17612. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17613. /** @hidden */
  17614. export var imageProcessingFunctions: {
  17615. name: string;
  17616. shader: string;
  17617. };
  17618. }
  17619. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17620. /** @hidden */
  17621. export var clipPlaneFragment: {
  17622. name: string;
  17623. shader: string;
  17624. };
  17625. }
  17626. declare module "babylonjs/Shaders/particles.fragment" {
  17627. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17628. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17629. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17630. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17631. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17632. /** @hidden */
  17633. export var particlesPixelShader: {
  17634. name: string;
  17635. shader: string;
  17636. };
  17637. }
  17638. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17639. /** @hidden */
  17640. export var clipPlaneVertexDeclaration: {
  17641. name: string;
  17642. shader: string;
  17643. };
  17644. }
  17645. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17646. /** @hidden */
  17647. export var clipPlaneVertex: {
  17648. name: string;
  17649. shader: string;
  17650. };
  17651. }
  17652. declare module "babylonjs/Shaders/particles.vertex" {
  17653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17654. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17655. /** @hidden */
  17656. export var particlesVertexShader: {
  17657. name: string;
  17658. shader: string;
  17659. };
  17660. }
  17661. declare module "babylonjs/Particles/particleSystem" {
  17662. import { Nullable } from "babylonjs/types";
  17663. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17664. import { Observable } from "babylonjs/Misc/observable";
  17665. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17666. import { Effect } from "babylonjs/Materials/effect";
  17667. import { Scene, IDisposable } from "babylonjs/scene";
  17668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17669. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17670. import { Particle } from "babylonjs/Particles/particle";
  17671. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17672. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17673. import "babylonjs/Shaders/particles.fragment";
  17674. import "babylonjs/Shaders/particles.vertex";
  17675. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17676. /**
  17677. * This represents a particle system in Babylon.
  17678. * 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.
  17679. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17680. * @example https://doc.babylonjs.com/babylon101/particles
  17681. */
  17682. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17683. /**
  17684. * Billboard mode will only apply to Y axis
  17685. */
  17686. static readonly BILLBOARDMODE_Y: number;
  17687. /**
  17688. * Billboard mode will apply to all axes
  17689. */
  17690. static readonly BILLBOARDMODE_ALL: number;
  17691. /**
  17692. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17693. */
  17694. static readonly BILLBOARDMODE_STRETCHED: number;
  17695. /**
  17696. * This function can be defined to provide custom update for active particles.
  17697. * This function will be called instead of regular update (age, position, color, etc.).
  17698. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17699. */
  17700. updateFunction: (particles: Particle[]) => void;
  17701. private _emitterWorldMatrix;
  17702. /**
  17703. * This function can be defined to specify initial direction for every new particle.
  17704. * It by default use the emitterType defined function
  17705. */
  17706. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17707. /**
  17708. * This function can be defined to specify initial position for every new particle.
  17709. * It by default use the emitterType defined function
  17710. */
  17711. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17712. /**
  17713. * @hidden
  17714. */
  17715. _inheritedVelocityOffset: Vector3;
  17716. /**
  17717. * An event triggered when the system is disposed
  17718. */
  17719. onDisposeObservable: Observable<ParticleSystem>;
  17720. private _onDisposeObserver;
  17721. /**
  17722. * Sets a callback that will be triggered when the system is disposed
  17723. */
  17724. onDispose: () => void;
  17725. private _particles;
  17726. private _epsilon;
  17727. private _capacity;
  17728. private _stockParticles;
  17729. private _newPartsExcess;
  17730. private _vertexData;
  17731. private _vertexBuffer;
  17732. private _vertexBuffers;
  17733. private _spriteBuffer;
  17734. private _indexBuffer;
  17735. private _effect;
  17736. private _customEffect;
  17737. private _cachedDefines;
  17738. private _scaledColorStep;
  17739. private _colorDiff;
  17740. private _scaledDirection;
  17741. private _scaledGravity;
  17742. private _currentRenderId;
  17743. private _alive;
  17744. private _useInstancing;
  17745. private _started;
  17746. private _stopped;
  17747. private _actualFrame;
  17748. private _scaledUpdateSpeed;
  17749. private _vertexBufferSize;
  17750. /** @hidden */
  17751. _currentEmitRateGradient: Nullable<FactorGradient>;
  17752. /** @hidden */
  17753. _currentEmitRate1: number;
  17754. /** @hidden */
  17755. _currentEmitRate2: number;
  17756. /** @hidden */
  17757. _currentStartSizeGradient: Nullable<FactorGradient>;
  17758. /** @hidden */
  17759. _currentStartSize1: number;
  17760. /** @hidden */
  17761. _currentStartSize2: number;
  17762. private readonly _rawTextureWidth;
  17763. private _rampGradientsTexture;
  17764. private _useRampGradients;
  17765. /** Gets or sets a boolean indicating that ramp gradients must be used
  17766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17767. */
  17768. useRampGradients: boolean;
  17769. /**
  17770. * 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.
  17771. * 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: [])
  17772. */
  17773. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17774. private _subEmitters;
  17775. /**
  17776. * @hidden
  17777. * If the particle systems emitter should be disposed when the particle system is disposed
  17778. */
  17779. _disposeEmitterOnDispose: boolean;
  17780. /**
  17781. * The current active Sub-systems, this property is used by the root particle system only.
  17782. */
  17783. activeSubSystems: Array<ParticleSystem>;
  17784. private _rootParticleSystem;
  17785. /**
  17786. * Gets the current list of active particles
  17787. */
  17788. readonly particles: Particle[];
  17789. /**
  17790. * Returns the string "ParticleSystem"
  17791. * @returns a string containing the class name
  17792. */
  17793. getClassName(): string;
  17794. /**
  17795. * Instantiates a particle system.
  17796. * 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.
  17797. * @param name The name of the particle system
  17798. * @param capacity The max number of particles alive at the same time
  17799. * @param scene The scene the particle system belongs to
  17800. * @param customEffect a custom effect used to change the way particles are rendered by default
  17801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17802. * @param epsilon Offset used to render the particles
  17803. */
  17804. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17805. private _addFactorGradient;
  17806. private _removeFactorGradient;
  17807. /**
  17808. * Adds a new life time gradient
  17809. * @param gradient defines the gradient to use (between 0 and 1)
  17810. * @param factor defines the life time factor to affect to the specified gradient
  17811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17812. * @returns the current particle system
  17813. */
  17814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17815. /**
  17816. * Remove a specific life time gradient
  17817. * @param gradient defines the gradient to remove
  17818. * @returns the current particle system
  17819. */
  17820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17821. /**
  17822. * Adds a new size gradient
  17823. * @param gradient defines the gradient to use (between 0 and 1)
  17824. * @param factor defines the size factor to affect to the specified gradient
  17825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17826. * @returns the current particle system
  17827. */
  17828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17829. /**
  17830. * Remove a specific size gradient
  17831. * @param gradient defines the gradient to remove
  17832. * @returns the current particle system
  17833. */
  17834. removeSizeGradient(gradient: number): IParticleSystem;
  17835. /**
  17836. * Adds a new color remap gradient
  17837. * @param gradient defines the gradient to use (between 0 and 1)
  17838. * @param min defines the color remap minimal range
  17839. * @param max defines the color remap maximal range
  17840. * @returns the current particle system
  17841. */
  17842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17843. /**
  17844. * Remove a specific color remap gradient
  17845. * @param gradient defines the gradient to remove
  17846. * @returns the current particle system
  17847. */
  17848. removeColorRemapGradient(gradient: number): IParticleSystem;
  17849. /**
  17850. * Adds a new alpha remap gradient
  17851. * @param gradient defines the gradient to use (between 0 and 1)
  17852. * @param min defines the alpha remap minimal range
  17853. * @param max defines the alpha remap maximal range
  17854. * @returns the current particle system
  17855. */
  17856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17857. /**
  17858. * Remove a specific alpha remap gradient
  17859. * @param gradient defines the gradient to remove
  17860. * @returns the current particle system
  17861. */
  17862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17863. /**
  17864. * Adds a new angular speed gradient
  17865. * @param gradient defines the gradient to use (between 0 and 1)
  17866. * @param factor defines the angular speed to affect to the specified gradient
  17867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17868. * @returns the current particle system
  17869. */
  17870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17871. /**
  17872. * Remove a specific angular speed gradient
  17873. * @param gradient defines the gradient to remove
  17874. * @returns the current particle system
  17875. */
  17876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17877. /**
  17878. * Adds a new velocity gradient
  17879. * @param gradient defines the gradient to use (between 0 and 1)
  17880. * @param factor defines the velocity to affect to the specified gradient
  17881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17882. * @returns the current particle system
  17883. */
  17884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17885. /**
  17886. * Remove a specific velocity gradient
  17887. * @param gradient defines the gradient to remove
  17888. * @returns the current particle system
  17889. */
  17890. removeVelocityGradient(gradient: number): IParticleSystem;
  17891. /**
  17892. * Adds a new limit velocity gradient
  17893. * @param gradient defines the gradient to use (between 0 and 1)
  17894. * @param factor defines the limit velocity value to affect to the specified gradient
  17895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17896. * @returns the current particle system
  17897. */
  17898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17899. /**
  17900. * Remove a specific limit velocity gradient
  17901. * @param gradient defines the gradient to remove
  17902. * @returns the current particle system
  17903. */
  17904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17905. /**
  17906. * Adds a new drag gradient
  17907. * @param gradient defines the gradient to use (between 0 and 1)
  17908. * @param factor defines the drag value to affect to the specified gradient
  17909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17910. * @returns the current particle system
  17911. */
  17912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17913. /**
  17914. * Remove a specific drag gradient
  17915. * @param gradient defines the gradient to remove
  17916. * @returns the current particle system
  17917. */
  17918. removeDragGradient(gradient: number): IParticleSystem;
  17919. /**
  17920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17921. * @param gradient defines the gradient to use (between 0 and 1)
  17922. * @param factor defines the emit rate value to affect to the specified gradient
  17923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17924. * @returns the current particle system
  17925. */
  17926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17927. /**
  17928. * Remove a specific emit rate gradient
  17929. * @param gradient defines the gradient to remove
  17930. * @returns the current particle system
  17931. */
  17932. removeEmitRateGradient(gradient: number): IParticleSystem;
  17933. /**
  17934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17935. * @param gradient defines the gradient to use (between 0 and 1)
  17936. * @param factor defines the start size value to affect to the specified gradient
  17937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17938. * @returns the current particle system
  17939. */
  17940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17941. /**
  17942. * Remove a specific start size gradient
  17943. * @param gradient defines the gradient to remove
  17944. * @returns the current particle system
  17945. */
  17946. removeStartSizeGradient(gradient: number): IParticleSystem;
  17947. private _createRampGradientTexture;
  17948. /**
  17949. * Gets the current list of ramp gradients.
  17950. * You must use addRampGradient and removeRampGradient to udpate this list
  17951. * @returns the list of ramp gradients
  17952. */
  17953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17954. /**
  17955. * Adds a new ramp gradient used to remap particle colors
  17956. * @param gradient defines the gradient to use (between 0 and 1)
  17957. * @param color defines the color to affect to the specified gradient
  17958. * @returns the current particle system
  17959. */
  17960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17961. /**
  17962. * Remove a specific ramp gradient
  17963. * @param gradient defines the gradient to remove
  17964. * @returns the current particle system
  17965. */
  17966. removeRampGradient(gradient: number): ParticleSystem;
  17967. /**
  17968. * Adds a new color gradient
  17969. * @param gradient defines the gradient to use (between 0 and 1)
  17970. * @param color1 defines the color to affect to the specified gradient
  17971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17972. * @returns this particle system
  17973. */
  17974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17975. /**
  17976. * Remove a specific color gradient
  17977. * @param gradient defines the gradient to remove
  17978. * @returns this particle system
  17979. */
  17980. removeColorGradient(gradient: number): IParticleSystem;
  17981. private _fetchR;
  17982. protected _reset(): void;
  17983. private _resetEffect;
  17984. private _createVertexBuffers;
  17985. private _createIndexBuffer;
  17986. /**
  17987. * Gets the maximum number of particles active at the same time.
  17988. * @returns The max number of active particles.
  17989. */
  17990. getCapacity(): number;
  17991. /**
  17992. * Gets whether there are still active particles in the system.
  17993. * @returns True if it is alive, otherwise false.
  17994. */
  17995. isAlive(): boolean;
  17996. /**
  17997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17998. * @returns True if it has been started, otherwise false.
  17999. */
  18000. isStarted(): boolean;
  18001. private _prepareSubEmitterInternalArray;
  18002. /**
  18003. * Starts the particle system and begins to emit
  18004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18005. */
  18006. start(delay?: number): void;
  18007. /**
  18008. * Stops the particle system.
  18009. * @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.
  18010. */
  18011. stop(stopSubEmitters?: boolean): void;
  18012. /**
  18013. * Remove all active particles
  18014. */
  18015. reset(): void;
  18016. /**
  18017. * @hidden (for internal use only)
  18018. */
  18019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18020. /**
  18021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18022. * Its lifetime will start back at 0.
  18023. */
  18024. recycleParticle: (particle: Particle) => void;
  18025. private _stopSubEmitters;
  18026. private _createParticle;
  18027. private _removeFromRoot;
  18028. private _emitFromParticle;
  18029. private _update;
  18030. /** @hidden */
  18031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18032. /** @hidden */
  18033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18034. /** @hidden */
  18035. private _getEffect;
  18036. /**
  18037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18039. */
  18040. animate(preWarmOnly?: boolean): void;
  18041. private _appendParticleVertices;
  18042. /**
  18043. * Rebuilds the particle system.
  18044. */
  18045. rebuild(): void;
  18046. /**
  18047. * Is this system ready to be used/rendered
  18048. * @return true if the system is ready
  18049. */
  18050. isReady(): boolean;
  18051. private _render;
  18052. /**
  18053. * Renders the particle system in its current state.
  18054. * @returns the current number of particles
  18055. */
  18056. render(): number;
  18057. /**
  18058. * Disposes the particle system and free the associated resources
  18059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18060. */
  18061. dispose(disposeTexture?: boolean): void;
  18062. /**
  18063. * Clones the particle system.
  18064. * @param name The name of the cloned object
  18065. * @param newEmitter The new emitter to use
  18066. * @returns the cloned particle system
  18067. */
  18068. clone(name: string, newEmitter: any): ParticleSystem;
  18069. /**
  18070. * Serializes the particle system to a JSON object.
  18071. * @returns the JSON object
  18072. */
  18073. serialize(): any;
  18074. /** @hidden */
  18075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18076. /** @hidden */
  18077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18078. /**
  18079. * Parses a JSON object to create a particle system.
  18080. * @param parsedParticleSystem The JSON object to parse
  18081. * @param scene The scene to create the particle system in
  18082. * @param rootUrl The root url to use to load external dependencies like texture
  18083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18084. * @returns the Parsed particle system
  18085. */
  18086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18087. }
  18088. }
  18089. declare module "babylonjs/Particles/particle" {
  18090. import { Nullable } from "babylonjs/types";
  18091. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18092. import { Color4 } from "babylonjs/Maths/math.color";
  18093. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18094. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18095. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18096. /**
  18097. * A particle represents one of the element emitted by a particle system.
  18098. * This is mainly define by its coordinates, direction, velocity and age.
  18099. */
  18100. export class Particle {
  18101. /**
  18102. * The particle system the particle belongs to.
  18103. */
  18104. particleSystem: ParticleSystem;
  18105. private static _Count;
  18106. /**
  18107. * Unique ID of the particle
  18108. */
  18109. id: number;
  18110. /**
  18111. * The world position of the particle in the scene.
  18112. */
  18113. position: Vector3;
  18114. /**
  18115. * The world direction of the particle in the scene.
  18116. */
  18117. direction: Vector3;
  18118. /**
  18119. * The color of the particle.
  18120. */
  18121. color: Color4;
  18122. /**
  18123. * The color change of the particle per step.
  18124. */
  18125. colorStep: Color4;
  18126. /**
  18127. * Defines how long will the life of the particle be.
  18128. */
  18129. lifeTime: number;
  18130. /**
  18131. * The current age of the particle.
  18132. */
  18133. age: number;
  18134. /**
  18135. * The current size of the particle.
  18136. */
  18137. size: number;
  18138. /**
  18139. * The current scale of the particle.
  18140. */
  18141. scale: Vector2;
  18142. /**
  18143. * The current angle of the particle.
  18144. */
  18145. angle: number;
  18146. /**
  18147. * Defines how fast is the angle changing.
  18148. */
  18149. angularSpeed: number;
  18150. /**
  18151. * Defines the cell index used by the particle to be rendered from a sprite.
  18152. */
  18153. cellIndex: number;
  18154. /**
  18155. * The information required to support color remapping
  18156. */
  18157. remapData: Vector4;
  18158. /** @hidden */
  18159. _randomCellOffset?: number;
  18160. /** @hidden */
  18161. _initialDirection: Nullable<Vector3>;
  18162. /** @hidden */
  18163. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18164. /** @hidden */
  18165. _initialStartSpriteCellID: number;
  18166. /** @hidden */
  18167. _initialEndSpriteCellID: number;
  18168. /** @hidden */
  18169. _currentColorGradient: Nullable<ColorGradient>;
  18170. /** @hidden */
  18171. _currentColor1: Color4;
  18172. /** @hidden */
  18173. _currentColor2: Color4;
  18174. /** @hidden */
  18175. _currentSizeGradient: Nullable<FactorGradient>;
  18176. /** @hidden */
  18177. _currentSize1: number;
  18178. /** @hidden */
  18179. _currentSize2: number;
  18180. /** @hidden */
  18181. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18182. /** @hidden */
  18183. _currentAngularSpeed1: number;
  18184. /** @hidden */
  18185. _currentAngularSpeed2: number;
  18186. /** @hidden */
  18187. _currentVelocityGradient: Nullable<FactorGradient>;
  18188. /** @hidden */
  18189. _currentVelocity1: number;
  18190. /** @hidden */
  18191. _currentVelocity2: number;
  18192. /** @hidden */
  18193. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18194. /** @hidden */
  18195. _currentLimitVelocity1: number;
  18196. /** @hidden */
  18197. _currentLimitVelocity2: number;
  18198. /** @hidden */
  18199. _currentDragGradient: Nullable<FactorGradient>;
  18200. /** @hidden */
  18201. _currentDrag1: number;
  18202. /** @hidden */
  18203. _currentDrag2: number;
  18204. /** @hidden */
  18205. _randomNoiseCoordinates1: Vector3;
  18206. /** @hidden */
  18207. _randomNoiseCoordinates2: Vector3;
  18208. /**
  18209. * Creates a new instance Particle
  18210. * @param particleSystem the particle system the particle belongs to
  18211. */
  18212. constructor(
  18213. /**
  18214. * The particle system the particle belongs to.
  18215. */
  18216. particleSystem: ParticleSystem);
  18217. private updateCellInfoFromSystem;
  18218. /**
  18219. * Defines how the sprite cell index is updated for the particle
  18220. */
  18221. updateCellIndex(): void;
  18222. /** @hidden */
  18223. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18224. /** @hidden */
  18225. _inheritParticleInfoToSubEmitters(): void;
  18226. /** @hidden */
  18227. _reset(): void;
  18228. /**
  18229. * Copy the properties of particle to another one.
  18230. * @param other the particle to copy the information to.
  18231. */
  18232. copyTo(other: Particle): void;
  18233. }
  18234. }
  18235. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18236. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18237. import { Effect } from "babylonjs/Materials/effect";
  18238. import { Particle } from "babylonjs/Particles/particle";
  18239. /**
  18240. * Particle emitter represents a volume emitting particles.
  18241. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18242. */
  18243. export interface IParticleEmitterType {
  18244. /**
  18245. * Called by the particle System when the direction is computed for the created particle.
  18246. * @param worldMatrix is the world matrix of the particle system
  18247. * @param directionToUpdate is the direction vector to update with the result
  18248. * @param particle is the particle we are computed the direction for
  18249. */
  18250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18251. /**
  18252. * Called by the particle System when the position is computed for the created particle.
  18253. * @param worldMatrix is the world matrix of the particle system
  18254. * @param positionToUpdate is the position vector to update with the result
  18255. * @param particle is the particle we are computed the position for
  18256. */
  18257. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18258. /**
  18259. * Clones the current emitter and returns a copy of it
  18260. * @returns the new emitter
  18261. */
  18262. clone(): IParticleEmitterType;
  18263. /**
  18264. * Called by the GPUParticleSystem to setup the update shader
  18265. * @param effect defines the update shader
  18266. */
  18267. applyToShader(effect: Effect): void;
  18268. /**
  18269. * Returns a string to use to update the GPU particles update shader
  18270. * @returns the effect defines string
  18271. */
  18272. getEffectDefines(): string;
  18273. /**
  18274. * Returns a string representing the class name
  18275. * @returns a string containing the class name
  18276. */
  18277. getClassName(): string;
  18278. /**
  18279. * Serializes the particle system to a JSON object.
  18280. * @returns the JSON object
  18281. */
  18282. serialize(): any;
  18283. /**
  18284. * Parse properties from a JSON object
  18285. * @param serializationObject defines the JSON object
  18286. */
  18287. parse(serializationObject: any): void;
  18288. }
  18289. }
  18290. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18291. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18292. import { Effect } from "babylonjs/Materials/effect";
  18293. import { Particle } from "babylonjs/Particles/particle";
  18294. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18295. /**
  18296. * Particle emitter emitting particles from the inside of a box.
  18297. * It emits the particles randomly between 2 given directions.
  18298. */
  18299. export class BoxParticleEmitter implements IParticleEmitterType {
  18300. /**
  18301. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18302. */
  18303. direction1: Vector3;
  18304. /**
  18305. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18306. */
  18307. direction2: Vector3;
  18308. /**
  18309. * 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.
  18310. */
  18311. minEmitBox: Vector3;
  18312. /**
  18313. * 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.
  18314. */
  18315. maxEmitBox: Vector3;
  18316. /**
  18317. * Creates a new instance BoxParticleEmitter
  18318. */
  18319. constructor();
  18320. /**
  18321. * Called by the particle System when the direction is computed for the created particle.
  18322. * @param worldMatrix is the world matrix of the particle system
  18323. * @param directionToUpdate is the direction vector to update with the result
  18324. * @param particle is the particle we are computed the direction for
  18325. */
  18326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18327. /**
  18328. * Called by the particle System when the position is computed for the created particle.
  18329. * @param worldMatrix is the world matrix of the particle system
  18330. * @param positionToUpdate is the position vector to update with the result
  18331. * @param particle is the particle we are computed the position for
  18332. */
  18333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18334. /**
  18335. * Clones the current emitter and returns a copy of it
  18336. * @returns the new emitter
  18337. */
  18338. clone(): BoxParticleEmitter;
  18339. /**
  18340. * Called by the GPUParticleSystem to setup the update shader
  18341. * @param effect defines the update shader
  18342. */
  18343. applyToShader(effect: Effect): void;
  18344. /**
  18345. * Returns a string to use to update the GPU particles update shader
  18346. * @returns a string containng the defines string
  18347. */
  18348. getEffectDefines(): string;
  18349. /**
  18350. * Returns the string "BoxParticleEmitter"
  18351. * @returns a string containing the class name
  18352. */
  18353. getClassName(): string;
  18354. /**
  18355. * Serializes the particle system to a JSON object.
  18356. * @returns the JSON object
  18357. */
  18358. serialize(): any;
  18359. /**
  18360. * Parse properties from a JSON object
  18361. * @param serializationObject defines the JSON object
  18362. */
  18363. parse(serializationObject: any): void;
  18364. }
  18365. }
  18366. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18367. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18368. import { Effect } from "babylonjs/Materials/effect";
  18369. import { Particle } from "babylonjs/Particles/particle";
  18370. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18371. /**
  18372. * Particle emitter emitting particles from the inside of a cone.
  18373. * It emits the particles alongside the cone volume from the base to the particle.
  18374. * The emission direction might be randomized.
  18375. */
  18376. export class ConeParticleEmitter implements IParticleEmitterType {
  18377. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18378. directionRandomizer: number;
  18379. private _radius;
  18380. private _angle;
  18381. private _height;
  18382. /**
  18383. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18384. */
  18385. radiusRange: number;
  18386. /**
  18387. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18388. */
  18389. heightRange: number;
  18390. /**
  18391. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18392. */
  18393. emitFromSpawnPointOnly: boolean;
  18394. /**
  18395. * Gets or sets the radius of the emission cone
  18396. */
  18397. radius: number;
  18398. /**
  18399. * Gets or sets the angle of the emission cone
  18400. */
  18401. angle: number;
  18402. private _buildHeight;
  18403. /**
  18404. * Creates a new instance ConeParticleEmitter
  18405. * @param radius the radius of the emission cone (1 by default)
  18406. * @param angle the cone base angle (PI by default)
  18407. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18408. */
  18409. constructor(radius?: number, angle?: number,
  18410. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18411. directionRandomizer?: number);
  18412. /**
  18413. * Called by the particle System when the direction is computed for the created particle.
  18414. * @param worldMatrix is the world matrix of the particle system
  18415. * @param directionToUpdate is the direction vector to update with the result
  18416. * @param particle is the particle we are computed the direction for
  18417. */
  18418. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18419. /**
  18420. * Called by the particle System when the position is computed for the created particle.
  18421. * @param worldMatrix is the world matrix of the particle system
  18422. * @param positionToUpdate is the position vector to update with the result
  18423. * @param particle is the particle we are computed the position for
  18424. */
  18425. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18426. /**
  18427. * Clones the current emitter and returns a copy of it
  18428. * @returns the new emitter
  18429. */
  18430. clone(): ConeParticleEmitter;
  18431. /**
  18432. * Called by the GPUParticleSystem to setup the update shader
  18433. * @param effect defines the update shader
  18434. */
  18435. applyToShader(effect: Effect): void;
  18436. /**
  18437. * Returns a string to use to update the GPU particles update shader
  18438. * @returns a string containng the defines string
  18439. */
  18440. getEffectDefines(): string;
  18441. /**
  18442. * Returns the string "ConeParticleEmitter"
  18443. * @returns a string containing the class name
  18444. */
  18445. getClassName(): string;
  18446. /**
  18447. * Serializes the particle system to a JSON object.
  18448. * @returns the JSON object
  18449. */
  18450. serialize(): any;
  18451. /**
  18452. * Parse properties from a JSON object
  18453. * @param serializationObject defines the JSON object
  18454. */
  18455. parse(serializationObject: any): void;
  18456. }
  18457. }
  18458. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18459. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18460. import { Effect } from "babylonjs/Materials/effect";
  18461. import { Particle } from "babylonjs/Particles/particle";
  18462. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18463. /**
  18464. * Particle emitter emitting particles from the inside of a cylinder.
  18465. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18466. */
  18467. export class CylinderParticleEmitter implements IParticleEmitterType {
  18468. /**
  18469. * The radius of the emission cylinder.
  18470. */
  18471. radius: number;
  18472. /**
  18473. * The height of the emission cylinder.
  18474. */
  18475. height: number;
  18476. /**
  18477. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18478. */
  18479. radiusRange: number;
  18480. /**
  18481. * How much to randomize the particle direction [0-1].
  18482. */
  18483. directionRandomizer: number;
  18484. /**
  18485. * Creates a new instance CylinderParticleEmitter
  18486. * @param radius the radius of the emission cylinder (1 by default)
  18487. * @param height the height of the emission cylinder (1 by default)
  18488. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18489. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18490. */
  18491. constructor(
  18492. /**
  18493. * The radius of the emission cylinder.
  18494. */
  18495. radius?: number,
  18496. /**
  18497. * The height of the emission cylinder.
  18498. */
  18499. height?: number,
  18500. /**
  18501. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18502. */
  18503. radiusRange?: number,
  18504. /**
  18505. * How much to randomize the particle direction [0-1].
  18506. */
  18507. directionRandomizer?: number);
  18508. /**
  18509. * Called by the particle System when the direction is computed for the created particle.
  18510. * @param worldMatrix is the world matrix of the particle system
  18511. * @param directionToUpdate is the direction vector to update with the result
  18512. * @param particle is the particle we are computed the direction for
  18513. */
  18514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18515. /**
  18516. * Called by the particle System when the position is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param positionToUpdate is the position vector to update with the result
  18519. * @param particle is the particle we are computed the position for
  18520. */
  18521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Clones the current emitter and returns a copy of it
  18524. * @returns the new emitter
  18525. */
  18526. clone(): CylinderParticleEmitter;
  18527. /**
  18528. * Called by the GPUParticleSystem to setup the update shader
  18529. * @param effect defines the update shader
  18530. */
  18531. applyToShader(effect: Effect): void;
  18532. /**
  18533. * Returns a string to use to update the GPU particles update shader
  18534. * @returns a string containng the defines string
  18535. */
  18536. getEffectDefines(): string;
  18537. /**
  18538. * Returns the string "CylinderParticleEmitter"
  18539. * @returns a string containing the class name
  18540. */
  18541. getClassName(): string;
  18542. /**
  18543. * Serializes the particle system to a JSON object.
  18544. * @returns the JSON object
  18545. */
  18546. serialize(): any;
  18547. /**
  18548. * Parse properties from a JSON object
  18549. * @param serializationObject defines the JSON object
  18550. */
  18551. parse(serializationObject: any): void;
  18552. }
  18553. /**
  18554. * Particle emitter emitting particles from the inside of a cylinder.
  18555. * It emits the particles randomly between two vectors.
  18556. */
  18557. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1: Vector3;
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2: Vector3;
  18566. /**
  18567. * Creates a new instance CylinderDirectedParticleEmitter
  18568. * @param radius the radius of the emission cylinder (1 by default)
  18569. * @param height the height of the emission cylinder (1 by default)
  18570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18571. * @param direction1 the min limit of the emission direction (up vector by default)
  18572. * @param direction2 the max limit of the emission direction (up vector by default)
  18573. */
  18574. constructor(radius?: number, height?: number, radiusRange?: number,
  18575. /**
  18576. * The min limit of the emission direction.
  18577. */
  18578. direction1?: Vector3,
  18579. /**
  18580. * The max limit of the emission direction.
  18581. */
  18582. direction2?: Vector3);
  18583. /**
  18584. * Called by the particle System when the direction is computed for the created particle.
  18585. * @param worldMatrix is the world matrix of the particle system
  18586. * @param directionToUpdate is the direction vector to update with the result
  18587. * @param particle is the particle we are computed the direction for
  18588. */
  18589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18590. /**
  18591. * Clones the current emitter and returns a copy of it
  18592. * @returns the new emitter
  18593. */
  18594. clone(): CylinderDirectedParticleEmitter;
  18595. /**
  18596. * Called by the GPUParticleSystem to setup the update shader
  18597. * @param effect defines the update shader
  18598. */
  18599. applyToShader(effect: Effect): void;
  18600. /**
  18601. * Returns a string to use to update the GPU particles update shader
  18602. * @returns a string containng the defines string
  18603. */
  18604. getEffectDefines(): string;
  18605. /**
  18606. * Returns the string "CylinderDirectedParticleEmitter"
  18607. * @returns a string containing the class name
  18608. */
  18609. getClassName(): string;
  18610. /**
  18611. * Serializes the particle system to a JSON object.
  18612. * @returns the JSON object
  18613. */
  18614. serialize(): any;
  18615. /**
  18616. * Parse properties from a JSON object
  18617. * @param serializationObject defines the JSON object
  18618. */
  18619. parse(serializationObject: any): void;
  18620. }
  18621. }
  18622. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18623. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18624. import { Effect } from "babylonjs/Materials/effect";
  18625. import { Particle } from "babylonjs/Particles/particle";
  18626. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18627. /**
  18628. * Particle emitter emitting particles from the inside of a hemisphere.
  18629. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18630. */
  18631. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18632. /**
  18633. * The radius of the emission hemisphere.
  18634. */
  18635. radius: number;
  18636. /**
  18637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18638. */
  18639. radiusRange: number;
  18640. /**
  18641. * How much to randomize the particle direction [0-1].
  18642. */
  18643. directionRandomizer: number;
  18644. /**
  18645. * Creates a new instance HemisphericParticleEmitter
  18646. * @param radius the radius of the emission hemisphere (1 by default)
  18647. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18649. */
  18650. constructor(
  18651. /**
  18652. * The radius of the emission hemisphere.
  18653. */
  18654. radius?: number,
  18655. /**
  18656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18657. */
  18658. radiusRange?: number,
  18659. /**
  18660. * How much to randomize the particle direction [0-1].
  18661. */
  18662. directionRandomizer?: number);
  18663. /**
  18664. * Called by the particle System when the direction is computed for the created particle.
  18665. * @param worldMatrix is the world matrix of the particle system
  18666. * @param directionToUpdate is the direction vector to update with the result
  18667. * @param particle is the particle we are computed the direction for
  18668. */
  18669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18670. /**
  18671. * Called by the particle System when the position is computed for the created particle.
  18672. * @param worldMatrix is the world matrix of the particle system
  18673. * @param positionToUpdate is the position vector to update with the result
  18674. * @param particle is the particle we are computed the position for
  18675. */
  18676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18677. /**
  18678. * Clones the current emitter and returns a copy of it
  18679. * @returns the new emitter
  18680. */
  18681. clone(): HemisphericParticleEmitter;
  18682. /**
  18683. * Called by the GPUParticleSystem to setup the update shader
  18684. * @param effect defines the update shader
  18685. */
  18686. applyToShader(effect: Effect): void;
  18687. /**
  18688. * Returns a string to use to update the GPU particles update shader
  18689. * @returns a string containng the defines string
  18690. */
  18691. getEffectDefines(): string;
  18692. /**
  18693. * Returns the string "HemisphericParticleEmitter"
  18694. * @returns a string containing the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Serializes the particle system to a JSON object.
  18699. * @returns the JSON object
  18700. */
  18701. serialize(): any;
  18702. /**
  18703. * Parse properties from a JSON object
  18704. * @param serializationObject defines the JSON object
  18705. */
  18706. parse(serializationObject: any): void;
  18707. }
  18708. }
  18709. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18710. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18711. import { Effect } from "babylonjs/Materials/effect";
  18712. import { Particle } from "babylonjs/Particles/particle";
  18713. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18714. /**
  18715. * Particle emitter emitting particles from a point.
  18716. * It emits the particles randomly between 2 given directions.
  18717. */
  18718. export class PointParticleEmitter implements IParticleEmitterType {
  18719. /**
  18720. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18721. */
  18722. direction1: Vector3;
  18723. /**
  18724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18725. */
  18726. direction2: Vector3;
  18727. /**
  18728. * Creates a new instance PointParticleEmitter
  18729. */
  18730. constructor();
  18731. /**
  18732. * Called by the particle System when the direction is computed for the created particle.
  18733. * @param worldMatrix is the world matrix of the particle system
  18734. * @param directionToUpdate is the direction vector to update with the result
  18735. * @param particle is the particle we are computed the direction for
  18736. */
  18737. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18738. /**
  18739. * Called by the particle System when the position is computed for the created particle.
  18740. * @param worldMatrix is the world matrix of the particle system
  18741. * @param positionToUpdate is the position vector to update with the result
  18742. * @param particle is the particle we are computed the position for
  18743. */
  18744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18745. /**
  18746. * Clones the current emitter and returns a copy of it
  18747. * @returns the new emitter
  18748. */
  18749. clone(): PointParticleEmitter;
  18750. /**
  18751. * Called by the GPUParticleSystem to setup the update shader
  18752. * @param effect defines the update shader
  18753. */
  18754. applyToShader(effect: Effect): void;
  18755. /**
  18756. * Returns a string to use to update the GPU particles update shader
  18757. * @returns a string containng the defines string
  18758. */
  18759. getEffectDefines(): string;
  18760. /**
  18761. * Returns the string "PointParticleEmitter"
  18762. * @returns a string containing the class name
  18763. */
  18764. getClassName(): string;
  18765. /**
  18766. * Serializes the particle system to a JSON object.
  18767. * @returns the JSON object
  18768. */
  18769. serialize(): any;
  18770. /**
  18771. * Parse properties from a JSON object
  18772. * @param serializationObject defines the JSON object
  18773. */
  18774. parse(serializationObject: any): void;
  18775. }
  18776. }
  18777. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18778. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18779. import { Effect } from "babylonjs/Materials/effect";
  18780. import { Particle } from "babylonjs/Particles/particle";
  18781. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18782. /**
  18783. * Particle emitter emitting particles from the inside of a sphere.
  18784. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18785. */
  18786. export class SphereParticleEmitter implements IParticleEmitterType {
  18787. /**
  18788. * The radius of the emission sphere.
  18789. */
  18790. radius: number;
  18791. /**
  18792. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18793. */
  18794. radiusRange: number;
  18795. /**
  18796. * How much to randomize the particle direction [0-1].
  18797. */
  18798. directionRandomizer: number;
  18799. /**
  18800. * Creates a new instance SphereParticleEmitter
  18801. * @param radius the radius of the emission sphere (1 by default)
  18802. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18803. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18804. */
  18805. constructor(
  18806. /**
  18807. * The radius of the emission sphere.
  18808. */
  18809. radius?: number,
  18810. /**
  18811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18812. */
  18813. radiusRange?: number,
  18814. /**
  18815. * How much to randomize the particle direction [0-1].
  18816. */
  18817. directionRandomizer?: number);
  18818. /**
  18819. * Called by the particle System when the direction is computed for the created particle.
  18820. * @param worldMatrix is the world matrix of the particle system
  18821. * @param directionToUpdate is the direction vector to update with the result
  18822. * @param particle is the particle we are computed the direction for
  18823. */
  18824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18825. /**
  18826. * Called by the particle System when the position is computed for the created particle.
  18827. * @param worldMatrix is the world matrix of the particle system
  18828. * @param positionToUpdate is the position vector to update with the result
  18829. * @param particle is the particle we are computed the position for
  18830. */
  18831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18832. /**
  18833. * Clones the current emitter and returns a copy of it
  18834. * @returns the new emitter
  18835. */
  18836. clone(): SphereParticleEmitter;
  18837. /**
  18838. * Called by the GPUParticleSystem to setup the update shader
  18839. * @param effect defines the update shader
  18840. */
  18841. applyToShader(effect: Effect): void;
  18842. /**
  18843. * Returns a string to use to update the GPU particles update shader
  18844. * @returns a string containng the defines string
  18845. */
  18846. getEffectDefines(): string;
  18847. /**
  18848. * Returns the string "SphereParticleEmitter"
  18849. * @returns a string containing the class name
  18850. */
  18851. getClassName(): string;
  18852. /**
  18853. * Serializes the particle system to a JSON object.
  18854. * @returns the JSON object
  18855. */
  18856. serialize(): any;
  18857. /**
  18858. * Parse properties from a JSON object
  18859. * @param serializationObject defines the JSON object
  18860. */
  18861. parse(serializationObject: any): void;
  18862. }
  18863. /**
  18864. * Particle emitter emitting particles from the inside of a sphere.
  18865. * It emits the particles randomly between two vectors.
  18866. */
  18867. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18868. /**
  18869. * The min limit of the emission direction.
  18870. */
  18871. direction1: Vector3;
  18872. /**
  18873. * The max limit of the emission direction.
  18874. */
  18875. direction2: Vector3;
  18876. /**
  18877. * Creates a new instance SphereDirectedParticleEmitter
  18878. * @param radius the radius of the emission sphere (1 by default)
  18879. * @param direction1 the min limit of the emission direction (up vector by default)
  18880. * @param direction2 the max limit of the emission direction (up vector by default)
  18881. */
  18882. constructor(radius?: number,
  18883. /**
  18884. * The min limit of the emission direction.
  18885. */
  18886. direction1?: Vector3,
  18887. /**
  18888. * The max limit of the emission direction.
  18889. */
  18890. direction2?: Vector3);
  18891. /**
  18892. * Called by the particle System when the direction is computed for the created particle.
  18893. * @param worldMatrix is the world matrix of the particle system
  18894. * @param directionToUpdate is the direction vector to update with the result
  18895. * @param particle is the particle we are computed the direction for
  18896. */
  18897. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18898. /**
  18899. * Clones the current emitter and returns a copy of it
  18900. * @returns the new emitter
  18901. */
  18902. clone(): SphereDirectedParticleEmitter;
  18903. /**
  18904. * Called by the GPUParticleSystem to setup the update shader
  18905. * @param effect defines the update shader
  18906. */
  18907. applyToShader(effect: Effect): void;
  18908. /**
  18909. * Returns a string to use to update the GPU particles update shader
  18910. * @returns a string containng the defines string
  18911. */
  18912. getEffectDefines(): string;
  18913. /**
  18914. * Returns the string "SphereDirectedParticleEmitter"
  18915. * @returns a string containing the class name
  18916. */
  18917. getClassName(): string;
  18918. /**
  18919. * Serializes the particle system to a JSON object.
  18920. * @returns the JSON object
  18921. */
  18922. serialize(): any;
  18923. /**
  18924. * Parse properties from a JSON object
  18925. * @param serializationObject defines the JSON object
  18926. */
  18927. parse(serializationObject: any): void;
  18928. }
  18929. }
  18930. declare module "babylonjs/Particles/EmitterTypes/index" {
  18931. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18932. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18933. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18934. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18935. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18936. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18937. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18938. }
  18939. declare module "babylonjs/Particles/IParticleSystem" {
  18940. import { Nullable } from "babylonjs/types";
  18941. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18942. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18945. import { Texture } from "babylonjs/Materials/Textures/texture";
  18946. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18947. import { Scene } from "babylonjs/scene";
  18948. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18949. import { Animation } from "babylonjs/Animations/animation";
  18950. /**
  18951. * Interface representing a particle system in Babylon.js.
  18952. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18953. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18954. */
  18955. export interface IParticleSystem {
  18956. /**
  18957. * List of animations used by the particle system.
  18958. */
  18959. animations: Animation[];
  18960. /**
  18961. * The id of the Particle system.
  18962. */
  18963. id: string;
  18964. /**
  18965. * The name of the Particle system.
  18966. */
  18967. name: string;
  18968. /**
  18969. * The emitter represents the Mesh or position we are attaching the particle system to.
  18970. */
  18971. emitter: Nullable<AbstractMesh | Vector3>;
  18972. /**
  18973. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18974. */
  18975. isBillboardBased: boolean;
  18976. /**
  18977. * The rendering group used by the Particle system to chose when to render.
  18978. */
  18979. renderingGroupId: number;
  18980. /**
  18981. * The layer mask we are rendering the particles through.
  18982. */
  18983. layerMask: number;
  18984. /**
  18985. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18986. */
  18987. updateSpeed: number;
  18988. /**
  18989. * The amount of time the particle system is running (depends of the overall update speed).
  18990. */
  18991. targetStopDuration: number;
  18992. /**
  18993. * The texture used to render each particle. (this can be a spritesheet)
  18994. */
  18995. particleTexture: Nullable<Texture>;
  18996. /**
  18997. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18998. */
  18999. blendMode: number;
  19000. /**
  19001. * Minimum life time of emitting particles.
  19002. */
  19003. minLifeTime: number;
  19004. /**
  19005. * Maximum life time of emitting particles.
  19006. */
  19007. maxLifeTime: number;
  19008. /**
  19009. * Minimum Size of emitting particles.
  19010. */
  19011. minSize: number;
  19012. /**
  19013. * Maximum Size of emitting particles.
  19014. */
  19015. maxSize: number;
  19016. /**
  19017. * Minimum scale of emitting particles on X axis.
  19018. */
  19019. minScaleX: number;
  19020. /**
  19021. * Maximum scale of emitting particles on X axis.
  19022. */
  19023. maxScaleX: number;
  19024. /**
  19025. * Minimum scale of emitting particles on Y axis.
  19026. */
  19027. minScaleY: number;
  19028. /**
  19029. * Maximum scale of emitting particles on Y axis.
  19030. */
  19031. maxScaleY: number;
  19032. /**
  19033. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19034. */
  19035. color1: Color4;
  19036. /**
  19037. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19038. */
  19039. color2: Color4;
  19040. /**
  19041. * Color the particle will have at the end of its lifetime.
  19042. */
  19043. colorDead: Color4;
  19044. /**
  19045. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19046. */
  19047. emitRate: number;
  19048. /**
  19049. * You can use gravity if you want to give an orientation to your particles.
  19050. */
  19051. gravity: Vector3;
  19052. /**
  19053. * Minimum power of emitting particles.
  19054. */
  19055. minEmitPower: number;
  19056. /**
  19057. * Maximum power of emitting particles.
  19058. */
  19059. maxEmitPower: number;
  19060. /**
  19061. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19062. */
  19063. minAngularSpeed: number;
  19064. /**
  19065. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19066. */
  19067. maxAngularSpeed: number;
  19068. /**
  19069. * Gets or sets the minimal initial rotation in radians.
  19070. */
  19071. minInitialRotation: number;
  19072. /**
  19073. * Gets or sets the maximal initial rotation in radians.
  19074. */
  19075. maxInitialRotation: number;
  19076. /**
  19077. * The particle emitter type defines the emitter used by the particle system.
  19078. * It can be for example box, sphere, or cone...
  19079. */
  19080. particleEmitterType: Nullable<IParticleEmitterType>;
  19081. /**
  19082. * Defines the delay in milliseconds before starting the system (0 by default)
  19083. */
  19084. startDelay: number;
  19085. /**
  19086. * 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
  19087. */
  19088. preWarmCycles: number;
  19089. /**
  19090. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19091. */
  19092. preWarmStepOffset: number;
  19093. /**
  19094. * 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)
  19095. */
  19096. spriteCellChangeSpeed: number;
  19097. /**
  19098. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19099. */
  19100. startSpriteCellID: number;
  19101. /**
  19102. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19103. */
  19104. endSpriteCellID: number;
  19105. /**
  19106. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19107. */
  19108. spriteCellWidth: number;
  19109. /**
  19110. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19111. */
  19112. spriteCellHeight: number;
  19113. /**
  19114. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19115. */
  19116. spriteRandomStartCell: boolean;
  19117. /**
  19118. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19119. */
  19120. isAnimationSheetEnabled: boolean;
  19121. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19122. translationPivot: Vector2;
  19123. /**
  19124. * Gets or sets a texture used to add random noise to particle positions
  19125. */
  19126. noiseTexture: Nullable<BaseTexture>;
  19127. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19128. noiseStrength: Vector3;
  19129. /**
  19130. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19131. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19132. */
  19133. billboardMode: number;
  19134. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19135. limitVelocityDamping: number;
  19136. /**
  19137. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19138. */
  19139. beginAnimationOnStart: boolean;
  19140. /**
  19141. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19142. */
  19143. beginAnimationFrom: number;
  19144. /**
  19145. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19146. */
  19147. beginAnimationTo: number;
  19148. /**
  19149. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19150. */
  19151. beginAnimationLoop: boolean;
  19152. /**
  19153. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19154. */
  19155. disposeOnStop: boolean;
  19156. /**
  19157. * Gets the maximum number of particles active at the same time.
  19158. * @returns The max number of active particles.
  19159. */
  19160. getCapacity(): number;
  19161. /**
  19162. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19163. * @returns True if it has been started, otherwise false.
  19164. */
  19165. isStarted(): boolean;
  19166. /**
  19167. * Animates the particle system for this frame.
  19168. */
  19169. animate(): void;
  19170. /**
  19171. * Renders the particle system in its current state.
  19172. * @returns the current number of particles
  19173. */
  19174. render(): number;
  19175. /**
  19176. * Dispose the particle system and frees its associated resources.
  19177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19178. */
  19179. dispose(disposeTexture?: boolean): void;
  19180. /**
  19181. * Clones the particle system.
  19182. * @param name The name of the cloned object
  19183. * @param newEmitter The new emitter to use
  19184. * @returns the cloned particle system
  19185. */
  19186. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19187. /**
  19188. * Serializes the particle system to a JSON object.
  19189. * @returns the JSON object
  19190. */
  19191. serialize(): any;
  19192. /**
  19193. * Rebuild the particle system
  19194. */
  19195. rebuild(): void;
  19196. /**
  19197. * Starts the particle system and begins to emit
  19198. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19199. */
  19200. start(delay?: number): void;
  19201. /**
  19202. * Stops the particle system.
  19203. */
  19204. stop(): void;
  19205. /**
  19206. * Remove all active particles
  19207. */
  19208. reset(): void;
  19209. /**
  19210. * Is this system ready to be used/rendered
  19211. * @return true if the system is ready
  19212. */
  19213. isReady(): boolean;
  19214. /**
  19215. * Adds a new color gradient
  19216. * @param gradient defines the gradient to use (between 0 and 1)
  19217. * @param color1 defines the color to affect to the specified gradient
  19218. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19219. * @returns the current particle system
  19220. */
  19221. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19222. /**
  19223. * Remove a specific color gradient
  19224. * @param gradient defines the gradient to remove
  19225. * @returns the current particle system
  19226. */
  19227. removeColorGradient(gradient: number): IParticleSystem;
  19228. /**
  19229. * Adds a new size gradient
  19230. * @param gradient defines the gradient to use (between 0 and 1)
  19231. * @param factor defines the size factor to affect to the specified gradient
  19232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19233. * @returns the current particle system
  19234. */
  19235. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19236. /**
  19237. * Remove a specific size gradient
  19238. * @param gradient defines the gradient to remove
  19239. * @returns the current particle system
  19240. */
  19241. removeSizeGradient(gradient: number): IParticleSystem;
  19242. /**
  19243. * Gets the current list of color gradients.
  19244. * You must use addColorGradient and removeColorGradient to udpate this list
  19245. * @returns the list of color gradients
  19246. */
  19247. getColorGradients(): Nullable<Array<ColorGradient>>;
  19248. /**
  19249. * Gets the current list of size gradients.
  19250. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19251. * @returns the list of size gradients
  19252. */
  19253. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19254. /**
  19255. * Gets the current list of angular speed gradients.
  19256. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19257. * @returns the list of angular speed gradients
  19258. */
  19259. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19260. /**
  19261. * Adds a new angular speed gradient
  19262. * @param gradient defines the gradient to use (between 0 and 1)
  19263. * @param factor defines the angular speed to affect to the specified gradient
  19264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19265. * @returns the current particle system
  19266. */
  19267. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19268. /**
  19269. * Remove a specific angular speed gradient
  19270. * @param gradient defines the gradient to remove
  19271. * @returns the current particle system
  19272. */
  19273. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19274. /**
  19275. * Gets the current list of velocity gradients.
  19276. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19277. * @returns the list of velocity gradients
  19278. */
  19279. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19280. /**
  19281. * Adds a new velocity gradient
  19282. * @param gradient defines the gradient to use (between 0 and 1)
  19283. * @param factor defines the velocity to affect to the specified gradient
  19284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19285. * @returns the current particle system
  19286. */
  19287. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19288. /**
  19289. * Remove a specific velocity gradient
  19290. * @param gradient defines the gradient to remove
  19291. * @returns the current particle system
  19292. */
  19293. removeVelocityGradient(gradient: number): IParticleSystem;
  19294. /**
  19295. * Gets the current list of limit velocity gradients.
  19296. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19297. * @returns the list of limit velocity gradients
  19298. */
  19299. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19300. /**
  19301. * Adds a new limit velocity gradient
  19302. * @param gradient defines the gradient to use (between 0 and 1)
  19303. * @param factor defines the limit velocity to affect to the specified gradient
  19304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19305. * @returns the current particle system
  19306. */
  19307. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19308. /**
  19309. * Remove a specific limit velocity gradient
  19310. * @param gradient defines the gradient to remove
  19311. * @returns the current particle system
  19312. */
  19313. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19314. /**
  19315. * Adds a new drag gradient
  19316. * @param gradient defines the gradient to use (between 0 and 1)
  19317. * @param factor defines the drag to affect to the specified gradient
  19318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19319. * @returns the current particle system
  19320. */
  19321. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19322. /**
  19323. * Remove a specific drag gradient
  19324. * @param gradient defines the gradient to remove
  19325. * @returns the current particle system
  19326. */
  19327. removeDragGradient(gradient: number): IParticleSystem;
  19328. /**
  19329. * Gets the current list of drag gradients.
  19330. * You must use addDragGradient and removeDragGradient to udpate this list
  19331. * @returns the list of drag gradients
  19332. */
  19333. getDragGradients(): Nullable<Array<FactorGradient>>;
  19334. /**
  19335. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19336. * @param gradient defines the gradient to use (between 0 and 1)
  19337. * @param factor defines the emit rate to affect to the specified gradient
  19338. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19339. * @returns the current particle system
  19340. */
  19341. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19342. /**
  19343. * Remove a specific emit rate gradient
  19344. * @param gradient defines the gradient to remove
  19345. * @returns the current particle system
  19346. */
  19347. removeEmitRateGradient(gradient: number): IParticleSystem;
  19348. /**
  19349. * Gets the current list of emit rate gradients.
  19350. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19351. * @returns the list of emit rate gradients
  19352. */
  19353. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19354. /**
  19355. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19356. * @param gradient defines the gradient to use (between 0 and 1)
  19357. * @param factor defines the start size to affect to the specified gradient
  19358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19359. * @returns the current particle system
  19360. */
  19361. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19362. /**
  19363. * Remove a specific start size gradient
  19364. * @param gradient defines the gradient to remove
  19365. * @returns the current particle system
  19366. */
  19367. removeStartSizeGradient(gradient: number): IParticleSystem;
  19368. /**
  19369. * Gets the current list of start size gradients.
  19370. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19371. * @returns the list of start size gradients
  19372. */
  19373. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19374. /**
  19375. * Adds a new life time gradient
  19376. * @param gradient defines the gradient to use (between 0 and 1)
  19377. * @param factor defines the life time factor to affect to the specified gradient
  19378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19379. * @returns the current particle system
  19380. */
  19381. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19382. /**
  19383. * Remove a specific life time gradient
  19384. * @param gradient defines the gradient to remove
  19385. * @returns the current particle system
  19386. */
  19387. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19388. /**
  19389. * Gets the current list of life time gradients.
  19390. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19391. * @returns the list of life time gradients
  19392. */
  19393. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19394. /**
  19395. * Gets the current list of color gradients.
  19396. * You must use addColorGradient and removeColorGradient to udpate this list
  19397. * @returns the list of color gradients
  19398. */
  19399. getColorGradients(): Nullable<Array<ColorGradient>>;
  19400. /**
  19401. * Adds a new ramp gradient used to remap particle colors
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param color defines the color to affect to the specified gradient
  19404. * @returns the current particle system
  19405. */
  19406. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19407. /**
  19408. * Gets the current list of ramp gradients.
  19409. * You must use addRampGradient and removeRampGradient to udpate this list
  19410. * @returns the list of ramp gradients
  19411. */
  19412. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19413. /** Gets or sets a boolean indicating that ramp gradients must be used
  19414. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19415. */
  19416. useRampGradients: boolean;
  19417. /**
  19418. * Adds a new color remap gradient
  19419. * @param gradient defines the gradient to use (between 0 and 1)
  19420. * @param min defines the color remap minimal range
  19421. * @param max defines the color remap maximal range
  19422. * @returns the current particle system
  19423. */
  19424. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19425. /**
  19426. * Gets the current list of color remap gradients.
  19427. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19428. * @returns the list of color remap gradients
  19429. */
  19430. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19431. /**
  19432. * Adds a new alpha remap gradient
  19433. * @param gradient defines the gradient to use (between 0 and 1)
  19434. * @param min defines the alpha remap minimal range
  19435. * @param max defines the alpha remap maximal range
  19436. * @returns the current particle system
  19437. */
  19438. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19439. /**
  19440. * Gets the current list of alpha remap gradients.
  19441. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19442. * @returns the list of alpha remap gradients
  19443. */
  19444. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19445. /**
  19446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19449. * @returns the emitter
  19450. */
  19451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19452. /**
  19453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19454. * @param radius The radius of the hemisphere to emit from
  19455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19456. * @returns the emitter
  19457. */
  19458. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19459. /**
  19460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19461. * @param radius The radius of the sphere to emit from
  19462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19463. * @returns the emitter
  19464. */
  19465. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19466. /**
  19467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the sphere to emit from
  19469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19471. * @returns the emitter
  19472. */
  19473. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19474. /**
  19475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19476. * @param radius The radius of the emission cylinder
  19477. * @param height The height of the emission cylinder
  19478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19480. * @returns the emitter
  19481. */
  19482. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19483. /**
  19484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19485. * @param radius The radius of the cylinder to emit from
  19486. * @param height The height of the emission cylinder
  19487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19490. * @returns the emitter
  19491. */
  19492. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19493. /**
  19494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19495. * @param radius The radius of the cone to emit from
  19496. * @param angle The base angle of the cone
  19497. * @returns the emitter
  19498. */
  19499. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19500. /**
  19501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19506. * @returns the emitter
  19507. */
  19508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19509. /**
  19510. * Get hosting scene
  19511. * @returns the scene
  19512. */
  19513. getScene(): Scene;
  19514. }
  19515. }
  19516. declare module "babylonjs/Meshes/instancedMesh" {
  19517. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19518. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19519. import { Camera } from "babylonjs/Cameras/camera";
  19520. import { Node } from "babylonjs/node";
  19521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19522. import { Mesh } from "babylonjs/Meshes/mesh";
  19523. import { Material } from "babylonjs/Materials/material";
  19524. import { Skeleton } from "babylonjs/Bones/skeleton";
  19525. import { Light } from "babylonjs/Lights/light";
  19526. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19527. /**
  19528. * Creates an instance based on a source mesh.
  19529. */
  19530. export class InstancedMesh extends AbstractMesh {
  19531. private _sourceMesh;
  19532. private _currentLOD;
  19533. /** @hidden */
  19534. _indexInSourceMeshInstanceArray: number;
  19535. constructor(name: string, source: Mesh);
  19536. /**
  19537. * Returns the string "InstancedMesh".
  19538. */
  19539. getClassName(): string;
  19540. /** Gets the list of lights affecting that mesh */
  19541. readonly lightSources: Light[];
  19542. _resyncLightSources(): void;
  19543. _resyncLightSource(light: Light): void;
  19544. _removeLightSource(light: Light, dispose: boolean): void;
  19545. /**
  19546. * If the source mesh receives shadows
  19547. */
  19548. readonly receiveShadows: boolean;
  19549. /**
  19550. * The material of the source mesh
  19551. */
  19552. readonly material: Nullable<Material>;
  19553. /**
  19554. * Visibility of the source mesh
  19555. */
  19556. readonly visibility: number;
  19557. /**
  19558. * Skeleton of the source mesh
  19559. */
  19560. readonly skeleton: Nullable<Skeleton>;
  19561. /**
  19562. * Rendering ground id of the source mesh
  19563. */
  19564. renderingGroupId: number;
  19565. /**
  19566. * Returns the total number of vertices (integer).
  19567. */
  19568. getTotalVertices(): number;
  19569. /**
  19570. * Returns a positive integer : the total number of indices in this mesh geometry.
  19571. * @returns the numner of indices or zero if the mesh has no geometry.
  19572. */
  19573. getTotalIndices(): number;
  19574. /**
  19575. * The source mesh of the instance
  19576. */
  19577. readonly sourceMesh: Mesh;
  19578. /**
  19579. * Is this node ready to be used/rendered
  19580. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19581. * @return {boolean} is it ready
  19582. */
  19583. isReady(completeCheck?: boolean): boolean;
  19584. /**
  19585. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19586. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19587. * @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.
  19588. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19589. */
  19590. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19591. /**
  19592. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19593. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19594. * The `data` are either a numeric array either a Float32Array.
  19595. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19596. * 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).
  19597. * Note that a new underlying VertexBuffer object is created each call.
  19598. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19599. *
  19600. * Possible `kind` values :
  19601. * - VertexBuffer.PositionKind
  19602. * - VertexBuffer.UVKind
  19603. * - VertexBuffer.UV2Kind
  19604. * - VertexBuffer.UV3Kind
  19605. * - VertexBuffer.UV4Kind
  19606. * - VertexBuffer.UV5Kind
  19607. * - VertexBuffer.UV6Kind
  19608. * - VertexBuffer.ColorKind
  19609. * - VertexBuffer.MatricesIndicesKind
  19610. * - VertexBuffer.MatricesIndicesExtraKind
  19611. * - VertexBuffer.MatricesWeightsKind
  19612. * - VertexBuffer.MatricesWeightsExtraKind
  19613. *
  19614. * Returns the Mesh.
  19615. */
  19616. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19617. /**
  19618. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19619. * If the mesh has no geometry, it is simply returned as it is.
  19620. * The `data` are either a numeric array either a Float32Array.
  19621. * No new underlying VertexBuffer object is created.
  19622. * 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.
  19623. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19624. *
  19625. * Possible `kind` values :
  19626. * - VertexBuffer.PositionKind
  19627. * - VertexBuffer.UVKind
  19628. * - VertexBuffer.UV2Kind
  19629. * - VertexBuffer.UV3Kind
  19630. * - VertexBuffer.UV4Kind
  19631. * - VertexBuffer.UV5Kind
  19632. * - VertexBuffer.UV6Kind
  19633. * - VertexBuffer.ColorKind
  19634. * - VertexBuffer.MatricesIndicesKind
  19635. * - VertexBuffer.MatricesIndicesExtraKind
  19636. * - VertexBuffer.MatricesWeightsKind
  19637. * - VertexBuffer.MatricesWeightsExtraKind
  19638. *
  19639. * Returns the Mesh.
  19640. */
  19641. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19642. /**
  19643. * Sets the mesh indices.
  19644. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19645. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19646. * This method creates a new index buffer each call.
  19647. * Returns the Mesh.
  19648. */
  19649. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19650. /**
  19651. * Boolean : True if the mesh owns the requested kind of data.
  19652. */
  19653. isVerticesDataPresent(kind: string): boolean;
  19654. /**
  19655. * Returns an array of indices (IndicesArray).
  19656. */
  19657. getIndices(): Nullable<IndicesArray>;
  19658. readonly _positions: Nullable<Vector3[]>;
  19659. /**
  19660. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19661. * This means the mesh underlying bounding box and sphere are recomputed.
  19662. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19663. * @returns the current mesh
  19664. */
  19665. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19666. /** @hidden */
  19667. _preActivate(): InstancedMesh;
  19668. /** @hidden */
  19669. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19670. /** @hidden */
  19671. _postActivate(): void;
  19672. getWorldMatrix(): Matrix;
  19673. readonly isAnInstance: boolean;
  19674. /**
  19675. * Returns the current associated LOD AbstractMesh.
  19676. */
  19677. getLOD(camera: Camera): AbstractMesh;
  19678. /** @hidden */
  19679. _syncSubMeshes(): InstancedMesh;
  19680. /** @hidden */
  19681. _generatePointsArray(): boolean;
  19682. /**
  19683. * Creates a new InstancedMesh from the current mesh.
  19684. * - name (string) : the cloned mesh name
  19685. * - newParent (optional Node) : the optional Node to parent the clone to.
  19686. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19687. *
  19688. * Returns the clone.
  19689. */
  19690. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19691. /**
  19692. * Disposes the InstancedMesh.
  19693. * Returns nothing.
  19694. */
  19695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19696. }
  19697. module "babylonjs/Meshes/mesh" {
  19698. interface Mesh {
  19699. /**
  19700. * Register a custom buffer that will be instanced
  19701. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19702. * @param kind defines the buffer kind
  19703. * @param stride defines the stride in floats
  19704. */
  19705. registerInstancedBuffer(kind: string, stride: number): void;
  19706. /** @hidden */
  19707. _userInstancedBuffersStorage: {
  19708. data: {
  19709. [key: string]: Float32Array;
  19710. };
  19711. sizes: {
  19712. [key: string]: number;
  19713. };
  19714. vertexBuffers: {
  19715. [key: string]: Nullable<VertexBuffer>;
  19716. };
  19717. strides: {
  19718. [key: string]: number;
  19719. };
  19720. };
  19721. }
  19722. }
  19723. module "babylonjs/Meshes/abstractMesh" {
  19724. interface AbstractMesh {
  19725. /**
  19726. * Object used to store instanced buffers defined by user
  19727. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19728. */
  19729. instancedBuffers: {
  19730. [key: string]: any;
  19731. };
  19732. }
  19733. }
  19734. }
  19735. declare module "babylonjs/Materials/shaderMaterial" {
  19736. import { Scene } from "babylonjs/scene";
  19737. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19739. import { Mesh } from "babylonjs/Meshes/mesh";
  19740. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19742. import { Texture } from "babylonjs/Materials/Textures/texture";
  19743. import { Material } from "babylonjs/Materials/material";
  19744. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19745. /**
  19746. * Defines the options associated with the creation of a shader material.
  19747. */
  19748. export interface IShaderMaterialOptions {
  19749. /**
  19750. * Does the material work in alpha blend mode
  19751. */
  19752. needAlphaBlending: boolean;
  19753. /**
  19754. * Does the material work in alpha test mode
  19755. */
  19756. needAlphaTesting: boolean;
  19757. /**
  19758. * The list of attribute names used in the shader
  19759. */
  19760. attributes: string[];
  19761. /**
  19762. * The list of unifrom names used in the shader
  19763. */
  19764. uniforms: string[];
  19765. /**
  19766. * The list of UBO names used in the shader
  19767. */
  19768. uniformBuffers: string[];
  19769. /**
  19770. * The list of sampler names used in the shader
  19771. */
  19772. samplers: string[];
  19773. /**
  19774. * The list of defines used in the shader
  19775. */
  19776. defines: string[];
  19777. }
  19778. /**
  19779. * 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.
  19780. *
  19781. * This returned material effects how the mesh will look based on the code in the shaders.
  19782. *
  19783. * @see http://doc.babylonjs.com/how_to/shader_material
  19784. */
  19785. export class ShaderMaterial extends Material {
  19786. private _shaderPath;
  19787. private _options;
  19788. private _textures;
  19789. private _textureArrays;
  19790. private _floats;
  19791. private _ints;
  19792. private _floatsArrays;
  19793. private _colors3;
  19794. private _colors3Arrays;
  19795. private _colors4;
  19796. private _colors4Arrays;
  19797. private _vectors2;
  19798. private _vectors3;
  19799. private _vectors4;
  19800. private _matrices;
  19801. private _matrixArrays;
  19802. private _matrices3x3;
  19803. private _matrices2x2;
  19804. private _vectors2Arrays;
  19805. private _vectors3Arrays;
  19806. private _vectors4Arrays;
  19807. private _cachedWorldViewMatrix;
  19808. private _cachedWorldViewProjectionMatrix;
  19809. private _renderId;
  19810. private _multiview;
  19811. /**
  19812. * Instantiate a new shader material.
  19813. * 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.
  19814. * This returned material effects how the mesh will look based on the code in the shaders.
  19815. * @see http://doc.babylonjs.com/how_to/shader_material
  19816. * @param name Define the name of the material in the scene
  19817. * @param scene Define the scene the material belongs to
  19818. * @param shaderPath Defines the route to the shader code in one of three ways:
  19819. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19820. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19821. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19822. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19823. * @param options Define the options used to create the shader
  19824. */
  19825. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19826. /**
  19827. * Gets the shader path used to define the shader code
  19828. * It can be modified to trigger a new compilation
  19829. */
  19830. /**
  19831. * Sets the shader path used to define the shader code
  19832. * It can be modified to trigger a new compilation
  19833. */
  19834. shaderPath: any;
  19835. /**
  19836. * Gets the options used to compile the shader.
  19837. * They can be modified to trigger a new compilation
  19838. */
  19839. readonly options: IShaderMaterialOptions;
  19840. /**
  19841. * Gets the current class name of the material e.g. "ShaderMaterial"
  19842. * Mainly use in serialization.
  19843. * @returns the class name
  19844. */
  19845. getClassName(): string;
  19846. /**
  19847. * Specifies if the material will require alpha blending
  19848. * @returns a boolean specifying if alpha blending is needed
  19849. */
  19850. needAlphaBlending(): boolean;
  19851. /**
  19852. * Specifies if this material should be rendered in alpha test mode
  19853. * @returns a boolean specifying if an alpha test is needed.
  19854. */
  19855. needAlphaTesting(): boolean;
  19856. private _checkUniform;
  19857. /**
  19858. * Set a texture in the shader.
  19859. * @param name Define the name of the uniform samplers as defined in the shader
  19860. * @param texture Define the texture to bind to this sampler
  19861. * @return the material itself allowing "fluent" like uniform updates
  19862. */
  19863. setTexture(name: string, texture: Texture): ShaderMaterial;
  19864. /**
  19865. * Set a texture array in the shader.
  19866. * @param name Define the name of the uniform sampler array as defined in the shader
  19867. * @param textures Define the list of textures to bind to this sampler
  19868. * @return the material itself allowing "fluent" like uniform updates
  19869. */
  19870. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19871. /**
  19872. * Set a float in the shader.
  19873. * @param name Define the name of the uniform as defined in the shader
  19874. * @param value Define the value to give to the uniform
  19875. * @return the material itself allowing "fluent" like uniform updates
  19876. */
  19877. setFloat(name: string, value: number): ShaderMaterial;
  19878. /**
  19879. * Set a int in the shader.
  19880. * @param name Define the name of the uniform as defined in the shader
  19881. * @param value Define the value to give to the uniform
  19882. * @return the material itself allowing "fluent" like uniform updates
  19883. */
  19884. setInt(name: string, value: number): ShaderMaterial;
  19885. /**
  19886. * Set an array of floats in the shader.
  19887. * @param name Define the name of the uniform as defined in the shader
  19888. * @param value Define the value to give to the uniform
  19889. * @return the material itself allowing "fluent" like uniform updates
  19890. */
  19891. setFloats(name: string, value: number[]): ShaderMaterial;
  19892. /**
  19893. * Set a vec3 in the shader from a Color3.
  19894. * @param name Define the name of the uniform as defined in the shader
  19895. * @param value Define the value to give to the uniform
  19896. * @return the material itself allowing "fluent" like uniform updates
  19897. */
  19898. setColor3(name: string, value: Color3): ShaderMaterial;
  19899. /**
  19900. * Set a vec3 array in the shader from a Color3 array.
  19901. * @param name Define the name of the uniform as defined in the shader
  19902. * @param value Define the value to give to the uniform
  19903. * @return the material itself allowing "fluent" like uniform updates
  19904. */
  19905. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19906. /**
  19907. * Set a vec4 in the shader from a Color4.
  19908. * @param name Define the name of the uniform as defined in the shader
  19909. * @param value Define the value to give to the uniform
  19910. * @return the material itself allowing "fluent" like uniform updates
  19911. */
  19912. setColor4(name: string, value: Color4): ShaderMaterial;
  19913. /**
  19914. * Set a vec4 array in the shader from a Color4 array.
  19915. * @param name Define the name of the uniform as defined in the shader
  19916. * @param value Define the value to give to the uniform
  19917. * @return the material itself allowing "fluent" like uniform updates
  19918. */
  19919. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19920. /**
  19921. * Set a vec2 in the shader from a Vector2.
  19922. * @param name Define the name of the uniform as defined in the shader
  19923. * @param value Define the value to give to the uniform
  19924. * @return the material itself allowing "fluent" like uniform updates
  19925. */
  19926. setVector2(name: string, value: Vector2): ShaderMaterial;
  19927. /**
  19928. * Set a vec3 in the shader from a Vector3.
  19929. * @param name Define the name of the uniform as defined in the shader
  19930. * @param value Define the value to give to the uniform
  19931. * @return the material itself allowing "fluent" like uniform updates
  19932. */
  19933. setVector3(name: string, value: Vector3): ShaderMaterial;
  19934. /**
  19935. * Set a vec4 in the shader from a Vector4.
  19936. * @param name Define the name of the uniform as defined in the shader
  19937. * @param value Define the value to give to the uniform
  19938. * @return the material itself allowing "fluent" like uniform updates
  19939. */
  19940. setVector4(name: string, value: Vector4): ShaderMaterial;
  19941. /**
  19942. * Set a mat4 in the shader from a Matrix.
  19943. * @param name Define the name of the uniform as defined in the shader
  19944. * @param value Define the value to give to the uniform
  19945. * @return the material itself allowing "fluent" like uniform updates
  19946. */
  19947. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19948. /**
  19949. * Set a float32Array in the shader from a matrix array.
  19950. * @param name Define the name of the uniform as defined in the shader
  19951. * @param value Define the value to give to the uniform
  19952. * @return the material itself allowing "fluent" like uniform updates
  19953. */
  19954. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19955. /**
  19956. * Set a mat3 in the shader from a Float32Array.
  19957. * @param name Define the name of the uniform as defined in the shader
  19958. * @param value Define the value to give to the uniform
  19959. * @return the material itself allowing "fluent" like uniform updates
  19960. */
  19961. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19962. /**
  19963. * Set a mat2 in the shader from a Float32Array.
  19964. * @param name Define the name of the uniform as defined in the shader
  19965. * @param value Define the value to give to the uniform
  19966. * @return the material itself allowing "fluent" like uniform updates
  19967. */
  19968. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19969. /**
  19970. * Set a vec2 array in the shader from a number array.
  19971. * @param name Define the name of the uniform as defined in the shader
  19972. * @param value Define the value to give to the uniform
  19973. * @return the material itself allowing "fluent" like uniform updates
  19974. */
  19975. setArray2(name: string, value: number[]): ShaderMaterial;
  19976. /**
  19977. * Set a vec3 array in the shader from a number array.
  19978. * @param name Define the name of the uniform as defined in the shader
  19979. * @param value Define the value to give to the uniform
  19980. * @return the material itself allowing "fluent" like uniform updates
  19981. */
  19982. setArray3(name: string, value: number[]): ShaderMaterial;
  19983. /**
  19984. * Set a vec4 array in the shader from a number array.
  19985. * @param name Define the name of the uniform as defined in the shader
  19986. * @param value Define the value to give to the uniform
  19987. * @return the material itself allowing "fluent" like uniform updates
  19988. */
  19989. setArray4(name: string, value: number[]): ShaderMaterial;
  19990. private _checkCache;
  19991. /**
  19992. * Specifies that the submesh is ready to be used
  19993. * @param mesh defines the mesh to check
  19994. * @param subMesh defines which submesh to check
  19995. * @param useInstances specifies that instances should be used
  19996. * @returns a boolean indicating that the submesh is ready or not
  19997. */
  19998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19999. /**
  20000. * Checks if the material is ready to render the requested mesh
  20001. * @param mesh Define the mesh to render
  20002. * @param useInstances Define whether or not the material is used with instances
  20003. * @returns true if ready, otherwise false
  20004. */
  20005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20006. /**
  20007. * Binds the world matrix to the material
  20008. * @param world defines the world transformation matrix
  20009. */
  20010. bindOnlyWorldMatrix(world: Matrix): void;
  20011. /**
  20012. * Binds the material to the mesh
  20013. * @param world defines the world transformation matrix
  20014. * @param mesh defines the mesh to bind the material to
  20015. */
  20016. bind(world: Matrix, mesh?: Mesh): void;
  20017. /**
  20018. * Gets the active textures from the material
  20019. * @returns an array of textures
  20020. */
  20021. getActiveTextures(): BaseTexture[];
  20022. /**
  20023. * Specifies if the material uses a texture
  20024. * @param texture defines the texture to check against the material
  20025. * @returns a boolean specifying if the material uses the texture
  20026. */
  20027. hasTexture(texture: BaseTexture): boolean;
  20028. /**
  20029. * Makes a duplicate of the material, and gives it a new name
  20030. * @param name defines the new name for the duplicated material
  20031. * @returns the cloned material
  20032. */
  20033. clone(name: string): ShaderMaterial;
  20034. /**
  20035. * Disposes the material
  20036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20038. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20039. */
  20040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20041. /**
  20042. * Serializes this material in a JSON representation
  20043. * @returns the serialized material object
  20044. */
  20045. serialize(): any;
  20046. /**
  20047. * Creates a shader material from parsed shader material data
  20048. * @param source defines the JSON represnetation of the material
  20049. * @param scene defines the hosting scene
  20050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20051. * @returns a new material
  20052. */
  20053. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20054. }
  20055. }
  20056. declare module "babylonjs/Shaders/color.fragment" {
  20057. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20058. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20059. /** @hidden */
  20060. export var colorPixelShader: {
  20061. name: string;
  20062. shader: string;
  20063. };
  20064. }
  20065. declare module "babylonjs/Shaders/color.vertex" {
  20066. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20068. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20069. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20070. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20071. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20072. /** @hidden */
  20073. export var colorVertexShader: {
  20074. name: string;
  20075. shader: string;
  20076. };
  20077. }
  20078. declare module "babylonjs/Meshes/linesMesh" {
  20079. import { Nullable } from "babylonjs/types";
  20080. import { Scene } from "babylonjs/scene";
  20081. import { Color3 } from "babylonjs/Maths/math.color";
  20082. import { Node } from "babylonjs/node";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { Mesh } from "babylonjs/Meshes/mesh";
  20085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20086. import { Effect } from "babylonjs/Materials/effect";
  20087. import { Material } from "babylonjs/Materials/material";
  20088. import "babylonjs/Shaders/color.fragment";
  20089. import "babylonjs/Shaders/color.vertex";
  20090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20091. /**
  20092. * Line mesh
  20093. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20094. */
  20095. export class LinesMesh extends Mesh {
  20096. /**
  20097. * If vertex color should be applied to the mesh
  20098. */
  20099. readonly useVertexColor?: boolean | undefined;
  20100. /**
  20101. * If vertex alpha should be applied to the mesh
  20102. */
  20103. readonly useVertexAlpha?: boolean | undefined;
  20104. /**
  20105. * Color of the line (Default: White)
  20106. */
  20107. color: Color3;
  20108. /**
  20109. * Alpha of the line (Default: 1)
  20110. */
  20111. alpha: number;
  20112. /**
  20113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20114. * This margin is expressed in world space coordinates, so its value may vary.
  20115. * Default value is 0.1
  20116. */
  20117. intersectionThreshold: number;
  20118. private _colorShader;
  20119. private color4;
  20120. /**
  20121. * Creates a new LinesMesh
  20122. * @param name defines the name
  20123. * @param scene defines the hosting scene
  20124. * @param parent defines the parent mesh if any
  20125. * @param source defines the optional source LinesMesh used to clone data from
  20126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20127. * When false, achieved by calling a clone(), also passing False.
  20128. * This will make creation of children, recursive.
  20129. * @param useVertexColor defines if this LinesMesh supports vertex color
  20130. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20131. */
  20132. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20133. /**
  20134. * If vertex color should be applied to the mesh
  20135. */
  20136. useVertexColor?: boolean | undefined,
  20137. /**
  20138. * If vertex alpha should be applied to the mesh
  20139. */
  20140. useVertexAlpha?: boolean | undefined);
  20141. private _addClipPlaneDefine;
  20142. private _removeClipPlaneDefine;
  20143. isReady(): boolean;
  20144. /**
  20145. * Returns the string "LineMesh"
  20146. */
  20147. getClassName(): string;
  20148. /**
  20149. * @hidden
  20150. */
  20151. /**
  20152. * @hidden
  20153. */
  20154. material: Material;
  20155. /**
  20156. * @hidden
  20157. */
  20158. readonly checkCollisions: boolean;
  20159. /** @hidden */
  20160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20161. /** @hidden */
  20162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20163. /**
  20164. * Disposes of the line mesh
  20165. * @param doNotRecurse If children should be disposed
  20166. */
  20167. dispose(doNotRecurse?: boolean): void;
  20168. /**
  20169. * Returns a new LineMesh object cloned from the current one.
  20170. */
  20171. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20172. /**
  20173. * Creates a new InstancedLinesMesh object from the mesh model.
  20174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20175. * @param name defines the name of the new instance
  20176. * @returns a new InstancedLinesMesh
  20177. */
  20178. createInstance(name: string): InstancedLinesMesh;
  20179. }
  20180. /**
  20181. * Creates an instance based on a source LinesMesh
  20182. */
  20183. export class InstancedLinesMesh extends InstancedMesh {
  20184. /**
  20185. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20186. * This margin is expressed in world space coordinates, so its value may vary.
  20187. * Initilized with the intersectionThreshold value of the source LinesMesh
  20188. */
  20189. intersectionThreshold: number;
  20190. constructor(name: string, source: LinesMesh);
  20191. /**
  20192. * Returns the string "InstancedLinesMesh".
  20193. */
  20194. getClassName(): string;
  20195. }
  20196. }
  20197. declare module "babylonjs/Shaders/line.fragment" {
  20198. /** @hidden */
  20199. export var linePixelShader: {
  20200. name: string;
  20201. shader: string;
  20202. };
  20203. }
  20204. declare module "babylonjs/Shaders/line.vertex" {
  20205. /** @hidden */
  20206. export var lineVertexShader: {
  20207. name: string;
  20208. shader: string;
  20209. };
  20210. }
  20211. declare module "babylonjs/Rendering/edgesRenderer" {
  20212. import { Nullable } from "babylonjs/types";
  20213. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20215. import { Vector3 } from "babylonjs/Maths/math.vector";
  20216. import { IDisposable } from "babylonjs/scene";
  20217. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20218. import "babylonjs/Shaders/line.fragment";
  20219. import "babylonjs/Shaders/line.vertex";
  20220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20221. module "babylonjs/Meshes/abstractMesh" {
  20222. interface AbstractMesh {
  20223. /**
  20224. * Gets the edgesRenderer associated with the mesh
  20225. */
  20226. edgesRenderer: Nullable<EdgesRenderer>;
  20227. }
  20228. }
  20229. module "babylonjs/Meshes/linesMesh" {
  20230. interface LinesMesh {
  20231. /**
  20232. * Enables the edge rendering mode on the mesh.
  20233. * This mode makes the mesh edges visible
  20234. * @param epsilon defines the maximal distance between two angles to detect a face
  20235. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20236. * @returns the currentAbstractMesh
  20237. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20238. */
  20239. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20240. }
  20241. }
  20242. module "babylonjs/Meshes/linesMesh" {
  20243. interface InstancedLinesMesh {
  20244. /**
  20245. * Enables the edge rendering mode on the mesh.
  20246. * This mode makes the mesh edges visible
  20247. * @param epsilon defines the maximal distance between two angles to detect a face
  20248. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20249. * @returns the current InstancedLinesMesh
  20250. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20251. */
  20252. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20253. }
  20254. }
  20255. /**
  20256. * Defines the minimum contract an Edges renderer should follow.
  20257. */
  20258. export interface IEdgesRenderer extends IDisposable {
  20259. /**
  20260. * Gets or sets a boolean indicating if the edgesRenderer is active
  20261. */
  20262. isEnabled: boolean;
  20263. /**
  20264. * Renders the edges of the attached mesh,
  20265. */
  20266. render(): void;
  20267. /**
  20268. * Checks wether or not the edges renderer is ready to render.
  20269. * @return true if ready, otherwise false.
  20270. */
  20271. isReady(): boolean;
  20272. }
  20273. /**
  20274. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20275. */
  20276. export class EdgesRenderer implements IEdgesRenderer {
  20277. /**
  20278. * Define the size of the edges with an orthographic camera
  20279. */
  20280. edgesWidthScalerForOrthographic: number;
  20281. /**
  20282. * Define the size of the edges with a perspective camera
  20283. */
  20284. edgesWidthScalerForPerspective: number;
  20285. protected _source: AbstractMesh;
  20286. protected _linesPositions: number[];
  20287. protected _linesNormals: number[];
  20288. protected _linesIndices: number[];
  20289. protected _epsilon: number;
  20290. protected _indicesCount: number;
  20291. protected _lineShader: ShaderMaterial;
  20292. protected _ib: DataBuffer;
  20293. protected _buffers: {
  20294. [key: string]: Nullable<VertexBuffer>;
  20295. };
  20296. protected _checkVerticesInsteadOfIndices: boolean;
  20297. private _meshRebuildObserver;
  20298. private _meshDisposeObserver;
  20299. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20300. isEnabled: boolean;
  20301. /**
  20302. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20303. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20304. * @param source Mesh used to create edges
  20305. * @param epsilon sum of angles in adjacency to check for edge
  20306. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20307. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20308. */
  20309. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20310. protected _prepareRessources(): void;
  20311. /** @hidden */
  20312. _rebuild(): void;
  20313. /**
  20314. * Releases the required resources for the edges renderer
  20315. */
  20316. dispose(): void;
  20317. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20318. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20319. /**
  20320. * Checks if the pair of p0 and p1 is en edge
  20321. * @param faceIndex
  20322. * @param edge
  20323. * @param faceNormals
  20324. * @param p0
  20325. * @param p1
  20326. * @private
  20327. */
  20328. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20329. /**
  20330. * push line into the position, normal and index buffer
  20331. * @protected
  20332. */
  20333. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20334. /**
  20335. * Generates lines edges from adjacencjes
  20336. * @private
  20337. */
  20338. _generateEdgesLines(): void;
  20339. /**
  20340. * Checks wether or not the edges renderer is ready to render.
  20341. * @return true if ready, otherwise false.
  20342. */
  20343. isReady(): boolean;
  20344. /**
  20345. * Renders the edges of the attached mesh,
  20346. */
  20347. render(): void;
  20348. }
  20349. /**
  20350. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20351. */
  20352. export class LineEdgesRenderer extends EdgesRenderer {
  20353. /**
  20354. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20355. * @param source LineMesh used to generate edges
  20356. * @param epsilon not important (specified angle for edge detection)
  20357. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20358. */
  20359. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20360. /**
  20361. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20362. */
  20363. _generateEdgesLines(): void;
  20364. }
  20365. }
  20366. declare module "babylonjs/Rendering/renderingGroup" {
  20367. import { SmartArray } from "babylonjs/Misc/smartArray";
  20368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20370. import { Nullable } from "babylonjs/types";
  20371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20372. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20374. import { Material } from "babylonjs/Materials/material";
  20375. import { Scene } from "babylonjs/scene";
  20376. /**
  20377. * This represents the object necessary to create a rendering group.
  20378. * This is exclusively used and created by the rendering manager.
  20379. * To modify the behavior, you use the available helpers in your scene or meshes.
  20380. * @hidden
  20381. */
  20382. export class RenderingGroup {
  20383. index: number;
  20384. private static _zeroVector;
  20385. private _scene;
  20386. private _opaqueSubMeshes;
  20387. private _transparentSubMeshes;
  20388. private _alphaTestSubMeshes;
  20389. private _depthOnlySubMeshes;
  20390. private _particleSystems;
  20391. private _spriteManagers;
  20392. private _opaqueSortCompareFn;
  20393. private _alphaTestSortCompareFn;
  20394. private _transparentSortCompareFn;
  20395. private _renderOpaque;
  20396. private _renderAlphaTest;
  20397. private _renderTransparent;
  20398. /** @hidden */
  20399. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20400. onBeforeTransparentRendering: () => void;
  20401. /**
  20402. * Set the opaque sort comparison function.
  20403. * If null the sub meshes will be render in the order they were created
  20404. */
  20405. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20406. /**
  20407. * Set the alpha test sort comparison function.
  20408. * If null the sub meshes will be render in the order they were created
  20409. */
  20410. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20411. /**
  20412. * Set the transparent sort comparison function.
  20413. * If null the sub meshes will be render in the order they were created
  20414. */
  20415. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20416. /**
  20417. * Creates a new rendering group.
  20418. * @param index The rendering group index
  20419. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20420. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20421. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20422. */
  20423. 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>);
  20424. /**
  20425. * Render all the sub meshes contained in the group.
  20426. * @param customRenderFunction Used to override the default render behaviour of the group.
  20427. * @returns true if rendered some submeshes.
  20428. */
  20429. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20430. /**
  20431. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20432. * @param subMeshes The submeshes to render
  20433. */
  20434. private renderOpaqueSorted;
  20435. /**
  20436. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20437. * @param subMeshes The submeshes to render
  20438. */
  20439. private renderAlphaTestSorted;
  20440. /**
  20441. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20442. * @param subMeshes The submeshes to render
  20443. */
  20444. private renderTransparentSorted;
  20445. /**
  20446. * Renders the submeshes in a specified order.
  20447. * @param subMeshes The submeshes to sort before render
  20448. * @param sortCompareFn The comparison function use to sort
  20449. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20450. * @param transparent Specifies to activate blending if true
  20451. */
  20452. private static renderSorted;
  20453. /**
  20454. * Renders the submeshes in the order they were dispatched (no sort applied).
  20455. * @param subMeshes The submeshes to render
  20456. */
  20457. private static renderUnsorted;
  20458. /**
  20459. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20460. * are rendered back to front if in the same alpha index.
  20461. *
  20462. * @param a The first submesh
  20463. * @param b The second submesh
  20464. * @returns The result of the comparison
  20465. */
  20466. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20467. /**
  20468. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20469. * are rendered back to front.
  20470. *
  20471. * @param a The first submesh
  20472. * @param b The second submesh
  20473. * @returns The result of the comparison
  20474. */
  20475. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20476. /**
  20477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20478. * are rendered front to back (prevent overdraw).
  20479. *
  20480. * @param a The first submesh
  20481. * @param b The second submesh
  20482. * @returns The result of the comparison
  20483. */
  20484. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20485. /**
  20486. * Resets the different lists of submeshes to prepare a new frame.
  20487. */
  20488. prepare(): void;
  20489. dispose(): void;
  20490. /**
  20491. * Inserts the submesh in its correct queue depending on its material.
  20492. * @param subMesh The submesh to dispatch
  20493. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20494. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20495. */
  20496. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20497. dispatchSprites(spriteManager: ISpriteManager): void;
  20498. dispatchParticles(particleSystem: IParticleSystem): void;
  20499. private _renderParticles;
  20500. private _renderSprites;
  20501. }
  20502. }
  20503. declare module "babylonjs/Rendering/renderingManager" {
  20504. import { Nullable } from "babylonjs/types";
  20505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20507. import { SmartArray } from "babylonjs/Misc/smartArray";
  20508. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20509. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20510. import { Material } from "babylonjs/Materials/material";
  20511. import { Scene } from "babylonjs/scene";
  20512. import { Camera } from "babylonjs/Cameras/camera";
  20513. /**
  20514. * Interface describing the different options available in the rendering manager
  20515. * regarding Auto Clear between groups.
  20516. */
  20517. export interface IRenderingManagerAutoClearSetup {
  20518. /**
  20519. * Defines whether or not autoclear is enable.
  20520. */
  20521. autoClear: boolean;
  20522. /**
  20523. * Defines whether or not to autoclear the depth buffer.
  20524. */
  20525. depth: boolean;
  20526. /**
  20527. * Defines whether or not to autoclear the stencil buffer.
  20528. */
  20529. stencil: boolean;
  20530. }
  20531. /**
  20532. * This class is used by the onRenderingGroupObservable
  20533. */
  20534. export class RenderingGroupInfo {
  20535. /**
  20536. * The Scene that being rendered
  20537. */
  20538. scene: Scene;
  20539. /**
  20540. * The camera currently used for the rendering pass
  20541. */
  20542. camera: Nullable<Camera>;
  20543. /**
  20544. * The ID of the renderingGroup being processed
  20545. */
  20546. renderingGroupId: number;
  20547. }
  20548. /**
  20549. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20550. * It is enable to manage the different groups as well as the different necessary sort functions.
  20551. * This should not be used directly aside of the few static configurations
  20552. */
  20553. export class RenderingManager {
  20554. /**
  20555. * The max id used for rendering groups (not included)
  20556. */
  20557. static MAX_RENDERINGGROUPS: number;
  20558. /**
  20559. * The min id used for rendering groups (included)
  20560. */
  20561. static MIN_RENDERINGGROUPS: number;
  20562. /**
  20563. * Used to globally prevent autoclearing scenes.
  20564. */
  20565. static AUTOCLEAR: boolean;
  20566. /**
  20567. * @hidden
  20568. */
  20569. _useSceneAutoClearSetup: boolean;
  20570. private _scene;
  20571. private _renderingGroups;
  20572. private _depthStencilBufferAlreadyCleaned;
  20573. private _autoClearDepthStencil;
  20574. private _customOpaqueSortCompareFn;
  20575. private _customAlphaTestSortCompareFn;
  20576. private _customTransparentSortCompareFn;
  20577. private _renderingGroupInfo;
  20578. /**
  20579. * Instantiates a new rendering group for a particular scene
  20580. * @param scene Defines the scene the groups belongs to
  20581. */
  20582. constructor(scene: Scene);
  20583. private _clearDepthStencilBuffer;
  20584. /**
  20585. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20586. * @hidden
  20587. */
  20588. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20589. /**
  20590. * Resets the different information of the group to prepare a new frame
  20591. * @hidden
  20592. */
  20593. reset(): void;
  20594. /**
  20595. * Dispose and release the group and its associated resources.
  20596. * @hidden
  20597. */
  20598. dispose(): void;
  20599. /**
  20600. * Clear the info related to rendering groups preventing retention points during dispose.
  20601. */
  20602. freeRenderingGroups(): void;
  20603. private _prepareRenderingGroup;
  20604. /**
  20605. * Add a sprite manager to the rendering manager in order to render it this frame.
  20606. * @param spriteManager Define the sprite manager to render
  20607. */
  20608. dispatchSprites(spriteManager: ISpriteManager): void;
  20609. /**
  20610. * Add a particle system to the rendering manager in order to render it this frame.
  20611. * @param particleSystem Define the particle system to render
  20612. */
  20613. dispatchParticles(particleSystem: IParticleSystem): void;
  20614. /**
  20615. * Add a submesh to the manager in order to render it this frame
  20616. * @param subMesh The submesh to dispatch
  20617. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20618. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20619. */
  20620. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20621. /**
  20622. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20623. * This allowed control for front to back rendering or reversly depending of the special needs.
  20624. *
  20625. * @param renderingGroupId The rendering group id corresponding to its index
  20626. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20627. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20628. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20629. */
  20630. 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;
  20631. /**
  20632. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20633. *
  20634. * @param renderingGroupId The rendering group id corresponding to its index
  20635. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20636. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20637. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20638. */
  20639. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20640. /**
  20641. * Gets the current auto clear configuration for one rendering group of the rendering
  20642. * manager.
  20643. * @param index the rendering group index to get the information for
  20644. * @returns The auto clear setup for the requested rendering group
  20645. */
  20646. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20647. }
  20648. }
  20649. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20650. import { Observable } from "babylonjs/Misc/observable";
  20651. import { SmartArray } from "babylonjs/Misc/smartArray";
  20652. import { Nullable } from "babylonjs/types";
  20653. import { Camera } from "babylonjs/Cameras/camera";
  20654. import { Scene } from "babylonjs/scene";
  20655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20656. import { Color4 } from "babylonjs/Maths/math.color";
  20657. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20661. import { Texture } from "babylonjs/Materials/Textures/texture";
  20662. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20663. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20664. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20665. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20666. import { Engine } from "babylonjs/Engines/engine";
  20667. /**
  20668. * This Helps creating a texture that will be created from a camera in your scene.
  20669. * It is basically a dynamic texture that could be used to create special effects for instance.
  20670. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20671. */
  20672. export class RenderTargetTexture extends Texture {
  20673. isCube: boolean;
  20674. /**
  20675. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20676. */
  20677. static readonly REFRESHRATE_RENDER_ONCE: number;
  20678. /**
  20679. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20680. */
  20681. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20682. /**
  20683. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20684. * the central point of your effect and can save a lot of performances.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20687. /**
  20688. * Use this predicate to dynamically define the list of mesh you want to render.
  20689. * If set, the renderList property will be overwritten.
  20690. */
  20691. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20692. private _renderList;
  20693. /**
  20694. * Use this list to define the list of mesh you want to render.
  20695. */
  20696. renderList: Nullable<Array<AbstractMesh>>;
  20697. private _hookArray;
  20698. /**
  20699. * Define if particles should be rendered in your texture.
  20700. */
  20701. renderParticles: boolean;
  20702. /**
  20703. * Define if sprites should be rendered in your texture.
  20704. */
  20705. renderSprites: boolean;
  20706. /**
  20707. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20708. */
  20709. coordinatesMode: number;
  20710. /**
  20711. * Define the camera used to render the texture.
  20712. */
  20713. activeCamera: Nullable<Camera>;
  20714. /**
  20715. * Override the render function of the texture with your own one.
  20716. */
  20717. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20718. /**
  20719. * Define if camera post processes should be use while rendering the texture.
  20720. */
  20721. useCameraPostProcesses: boolean;
  20722. /**
  20723. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20724. */
  20725. ignoreCameraViewport: boolean;
  20726. private _postProcessManager;
  20727. private _postProcesses;
  20728. private _resizeObserver;
  20729. /**
  20730. * An event triggered when the texture is unbind.
  20731. */
  20732. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20733. /**
  20734. * An event triggered when the texture is unbind.
  20735. */
  20736. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20737. private _onAfterUnbindObserver;
  20738. /**
  20739. * Set a after unbind callback in the texture.
  20740. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20741. */
  20742. onAfterUnbind: () => void;
  20743. /**
  20744. * An event triggered before rendering the texture
  20745. */
  20746. onBeforeRenderObservable: Observable<number>;
  20747. private _onBeforeRenderObserver;
  20748. /**
  20749. * Set a before render callback in the texture.
  20750. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20751. */
  20752. onBeforeRender: (faceIndex: number) => void;
  20753. /**
  20754. * An event triggered after rendering the texture
  20755. */
  20756. onAfterRenderObservable: Observable<number>;
  20757. private _onAfterRenderObserver;
  20758. /**
  20759. * Set a after render callback in the texture.
  20760. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20761. */
  20762. onAfterRender: (faceIndex: number) => void;
  20763. /**
  20764. * An event triggered after the texture clear
  20765. */
  20766. onClearObservable: Observable<Engine>;
  20767. private _onClearObserver;
  20768. /**
  20769. * Set a clear callback in the texture.
  20770. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20771. */
  20772. onClear: (Engine: Engine) => void;
  20773. /**
  20774. * An event triggered when the texture is resized.
  20775. */
  20776. onResizeObservable: Observable<RenderTargetTexture>;
  20777. /**
  20778. * Define the clear color of the Render Target if it should be different from the scene.
  20779. */
  20780. clearColor: Color4;
  20781. protected _size: number | {
  20782. width: number;
  20783. height: number;
  20784. };
  20785. protected _initialSizeParameter: number | {
  20786. width: number;
  20787. height: number;
  20788. } | {
  20789. ratio: number;
  20790. };
  20791. protected _sizeRatio: Nullable<number>;
  20792. /** @hidden */
  20793. _generateMipMaps: boolean;
  20794. protected _renderingManager: RenderingManager;
  20795. /** @hidden */
  20796. _waitingRenderList: string[];
  20797. protected _doNotChangeAspectRatio: boolean;
  20798. protected _currentRefreshId: number;
  20799. protected _refreshRate: number;
  20800. protected _textureMatrix: Matrix;
  20801. protected _samples: number;
  20802. protected _renderTargetOptions: RenderTargetCreationOptions;
  20803. /**
  20804. * Gets render target creation options that were used.
  20805. */
  20806. readonly renderTargetOptions: RenderTargetCreationOptions;
  20807. protected _engine: Engine;
  20808. protected _onRatioRescale(): void;
  20809. /**
  20810. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20811. * It must define where the camera used to render the texture is set
  20812. */
  20813. boundingBoxPosition: Vector3;
  20814. private _boundingBoxSize;
  20815. /**
  20816. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20817. * When defined, the cubemap will switch to local mode
  20818. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20819. * @example https://www.babylonjs-playground.com/#RNASML
  20820. */
  20821. boundingBoxSize: Vector3;
  20822. /**
  20823. * In case the RTT has been created with a depth texture, get the associated
  20824. * depth texture.
  20825. * Otherwise, return null.
  20826. */
  20827. depthStencilTexture: Nullable<InternalTexture>;
  20828. /**
  20829. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20830. * or used a shadow, depth texture...
  20831. * @param name The friendly name of the texture
  20832. * @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)
  20833. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20834. * @param generateMipMaps True if mip maps need to be generated after render.
  20835. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20836. * @param type The type of the buffer in the RTT (int, half float, float...)
  20837. * @param isCube True if a cube texture needs to be created
  20838. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20839. * @param generateDepthBuffer True to generate a depth buffer
  20840. * @param generateStencilBuffer True to generate a stencil buffer
  20841. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20842. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20844. */
  20845. constructor(name: string, size: number | {
  20846. width: number;
  20847. height: number;
  20848. } | {
  20849. ratio: number;
  20850. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20851. /**
  20852. * Creates a depth stencil texture.
  20853. * This is only available in WebGL 2 or with the depth texture extension available.
  20854. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20855. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20856. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20857. */
  20858. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20859. private _processSizeParameter;
  20860. /**
  20861. * Define the number of samples to use in case of MSAA.
  20862. * It defaults to one meaning no MSAA has been enabled.
  20863. */
  20864. samples: number;
  20865. /**
  20866. * Resets the refresh counter of the texture and start bak from scratch.
  20867. * Could be useful to regenerate the texture if it is setup to render only once.
  20868. */
  20869. resetRefreshCounter(): void;
  20870. /**
  20871. * Define the refresh rate of the texture or the rendering frequency.
  20872. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20873. */
  20874. refreshRate: number;
  20875. /**
  20876. * Adds a post process to the render target rendering passes.
  20877. * @param postProcess define the post process to add
  20878. */
  20879. addPostProcess(postProcess: PostProcess): void;
  20880. /**
  20881. * Clear all the post processes attached to the render target
  20882. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20883. */
  20884. clearPostProcesses(dispose?: boolean): void;
  20885. /**
  20886. * Remove one of the post process from the list of attached post processes to the texture
  20887. * @param postProcess define the post process to remove from the list
  20888. */
  20889. removePostProcess(postProcess: PostProcess): void;
  20890. /** @hidden */
  20891. _shouldRender(): boolean;
  20892. /**
  20893. * Gets the actual render size of the texture.
  20894. * @returns the width of the render size
  20895. */
  20896. getRenderSize(): number;
  20897. /**
  20898. * Gets the actual render width of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderWidth(): number;
  20902. /**
  20903. * Gets the actual render height of the texture.
  20904. * @returns the height of the render size
  20905. */
  20906. getRenderHeight(): number;
  20907. /**
  20908. * Get if the texture can be rescaled or not.
  20909. */
  20910. readonly canRescale: boolean;
  20911. /**
  20912. * Resize the texture using a ratio.
  20913. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20914. */
  20915. scale(ratio: number): void;
  20916. /**
  20917. * Get the texture reflection matrix used to rotate/transform the reflection.
  20918. * @returns the reflection matrix
  20919. */
  20920. getReflectionTextureMatrix(): Matrix;
  20921. /**
  20922. * Resize the texture to a new desired size.
  20923. * Be carrefull as it will recreate all the data in the new texture.
  20924. * @param size Define the new size. It can be:
  20925. * - a number for squared texture,
  20926. * - an object containing { width: number, height: number }
  20927. * - or an object containing a ratio { ratio: number }
  20928. */
  20929. resize(size: number | {
  20930. width: number;
  20931. height: number;
  20932. } | {
  20933. ratio: number;
  20934. }): void;
  20935. /**
  20936. * Renders all the objects from the render list into the texture.
  20937. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20938. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20939. */
  20940. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20941. private _bestReflectionRenderTargetDimension;
  20942. /**
  20943. * @hidden
  20944. * @param faceIndex face index to bind to if this is a cubetexture
  20945. */
  20946. _bindFrameBuffer(faceIndex?: number): void;
  20947. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20948. private renderToTarget;
  20949. /**
  20950. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20951. * This allowed control for front to back rendering or reversly depending of the special needs.
  20952. *
  20953. * @param renderingGroupId The rendering group id corresponding to its index
  20954. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20955. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20956. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20957. */
  20958. 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;
  20959. /**
  20960. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20961. *
  20962. * @param renderingGroupId The rendering group id corresponding to its index
  20963. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20964. */
  20965. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20966. /**
  20967. * Clones the texture.
  20968. * @returns the cloned texture
  20969. */
  20970. clone(): RenderTargetTexture;
  20971. /**
  20972. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20973. * @returns The JSON representation of the texture
  20974. */
  20975. serialize(): any;
  20976. /**
  20977. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20978. */
  20979. disposeFramebufferObjects(): void;
  20980. /**
  20981. * Dispose the texture and release its associated resources.
  20982. */
  20983. dispose(): void;
  20984. /** @hidden */
  20985. _rebuild(): void;
  20986. /**
  20987. * Clear the info related to rendering groups preventing retention point in material dispose.
  20988. */
  20989. freeRenderingGroups(): void;
  20990. /**
  20991. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20992. * @returns the view count
  20993. */
  20994. getViewCount(): number;
  20995. }
  20996. }
  20997. declare module "babylonjs/Materials/material" {
  20998. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20999. import { SmartArray } from "babylonjs/Misc/smartArray";
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { Nullable } from "babylonjs/types";
  21002. import { Scene } from "babylonjs/scene";
  21003. import { Matrix } from "babylonjs/Maths/math.vector";
  21004. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21006. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21007. import { Effect } from "babylonjs/Materials/effect";
  21008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21009. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21010. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21011. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21012. import { Mesh } from "babylonjs/Meshes/mesh";
  21013. import { Animation } from "babylonjs/Animations/animation";
  21014. /**
  21015. * Options for compiling materials.
  21016. */
  21017. export interface IMaterialCompilationOptions {
  21018. /**
  21019. * Defines whether clip planes are enabled.
  21020. */
  21021. clipPlane: boolean;
  21022. /**
  21023. * Defines whether instances are enabled.
  21024. */
  21025. useInstances: boolean;
  21026. }
  21027. /**
  21028. * Base class for the main features of a material in Babylon.js
  21029. */
  21030. export class Material implements IAnimatable {
  21031. /**
  21032. * Returns the triangle fill mode
  21033. */
  21034. static readonly TriangleFillMode: number;
  21035. /**
  21036. * Returns the wireframe mode
  21037. */
  21038. static readonly WireFrameFillMode: number;
  21039. /**
  21040. * Returns the point fill mode
  21041. */
  21042. static readonly PointFillMode: number;
  21043. /**
  21044. * Returns the point list draw mode
  21045. */
  21046. static readonly PointListDrawMode: number;
  21047. /**
  21048. * Returns the line list draw mode
  21049. */
  21050. static readonly LineListDrawMode: number;
  21051. /**
  21052. * Returns the line loop draw mode
  21053. */
  21054. static readonly LineLoopDrawMode: number;
  21055. /**
  21056. * Returns the line strip draw mode
  21057. */
  21058. static readonly LineStripDrawMode: number;
  21059. /**
  21060. * Returns the triangle strip draw mode
  21061. */
  21062. static readonly TriangleStripDrawMode: number;
  21063. /**
  21064. * Returns the triangle fan draw mode
  21065. */
  21066. static readonly TriangleFanDrawMode: number;
  21067. /**
  21068. * Stores the clock-wise side orientation
  21069. */
  21070. static readonly ClockWiseSideOrientation: number;
  21071. /**
  21072. * Stores the counter clock-wise side orientation
  21073. */
  21074. static readonly CounterClockWiseSideOrientation: number;
  21075. /**
  21076. * The dirty texture flag value
  21077. */
  21078. static readonly TextureDirtyFlag: number;
  21079. /**
  21080. * The dirty light flag value
  21081. */
  21082. static readonly LightDirtyFlag: number;
  21083. /**
  21084. * The dirty fresnel flag value
  21085. */
  21086. static readonly FresnelDirtyFlag: number;
  21087. /**
  21088. * The dirty attribute flag value
  21089. */
  21090. static readonly AttributesDirtyFlag: number;
  21091. /**
  21092. * The dirty misc flag value
  21093. */
  21094. static readonly MiscDirtyFlag: number;
  21095. /**
  21096. * The all dirty flag value
  21097. */
  21098. static readonly AllDirtyFlag: number;
  21099. /**
  21100. * The ID of the material
  21101. */
  21102. id: string;
  21103. /**
  21104. * Gets or sets the unique id of the material
  21105. */
  21106. uniqueId: number;
  21107. /**
  21108. * The name of the material
  21109. */
  21110. name: string;
  21111. /**
  21112. * Gets or sets user defined metadata
  21113. */
  21114. metadata: any;
  21115. /**
  21116. * For internal use only. Please do not use.
  21117. */
  21118. reservedDataStore: any;
  21119. /**
  21120. * Specifies if the ready state should be checked on each call
  21121. */
  21122. checkReadyOnEveryCall: boolean;
  21123. /**
  21124. * Specifies if the ready state should be checked once
  21125. */
  21126. checkReadyOnlyOnce: boolean;
  21127. /**
  21128. * The state of the material
  21129. */
  21130. state: string;
  21131. /**
  21132. * The alpha value of the material
  21133. */
  21134. protected _alpha: number;
  21135. /**
  21136. * List of inspectable custom properties (used by the Inspector)
  21137. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21138. */
  21139. inspectableCustomProperties: IInspectable[];
  21140. /**
  21141. * Sets the alpha value of the material
  21142. */
  21143. /**
  21144. * Gets the alpha value of the material
  21145. */
  21146. alpha: number;
  21147. /**
  21148. * Specifies if back face culling is enabled
  21149. */
  21150. protected _backFaceCulling: boolean;
  21151. /**
  21152. * Sets the back-face culling state
  21153. */
  21154. /**
  21155. * Gets the back-face culling state
  21156. */
  21157. backFaceCulling: boolean;
  21158. /**
  21159. * Stores the value for side orientation
  21160. */
  21161. sideOrientation: number;
  21162. /**
  21163. * Callback triggered when the material is compiled
  21164. */
  21165. onCompiled: Nullable<(effect: Effect) => void>;
  21166. /**
  21167. * Callback triggered when an error occurs
  21168. */
  21169. onError: Nullable<(effect: Effect, errors: string) => void>;
  21170. /**
  21171. * Callback triggered to get the render target textures
  21172. */
  21173. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21174. /**
  21175. * Gets a boolean indicating that current material needs to register RTT
  21176. */
  21177. readonly hasRenderTargetTextures: boolean;
  21178. /**
  21179. * Specifies if the material should be serialized
  21180. */
  21181. doNotSerialize: boolean;
  21182. /**
  21183. * @hidden
  21184. */
  21185. _storeEffectOnSubMeshes: boolean;
  21186. /**
  21187. * Stores the animations for the material
  21188. */
  21189. animations: Nullable<Array<Animation>>;
  21190. /**
  21191. * An event triggered when the material is disposed
  21192. */
  21193. onDisposeObservable: Observable<Material>;
  21194. /**
  21195. * An observer which watches for dispose events
  21196. */
  21197. private _onDisposeObserver;
  21198. private _onUnBindObservable;
  21199. /**
  21200. * Called during a dispose event
  21201. */
  21202. onDispose: () => void;
  21203. private _onBindObservable;
  21204. /**
  21205. * An event triggered when the material is bound
  21206. */
  21207. readonly onBindObservable: Observable<AbstractMesh>;
  21208. /**
  21209. * An observer which watches for bind events
  21210. */
  21211. private _onBindObserver;
  21212. /**
  21213. * Called during a bind event
  21214. */
  21215. onBind: (Mesh: AbstractMesh) => void;
  21216. /**
  21217. * An event triggered when the material is unbound
  21218. */
  21219. readonly onUnBindObservable: Observable<Material>;
  21220. /**
  21221. * Stores the value of the alpha mode
  21222. */
  21223. private _alphaMode;
  21224. /**
  21225. * Sets the value of the alpha mode.
  21226. *
  21227. * | Value | Type | Description |
  21228. * | --- | --- | --- |
  21229. * | 0 | ALPHA_DISABLE | |
  21230. * | 1 | ALPHA_ADD | |
  21231. * | 2 | ALPHA_COMBINE | |
  21232. * | 3 | ALPHA_SUBTRACT | |
  21233. * | 4 | ALPHA_MULTIPLY | |
  21234. * | 5 | ALPHA_MAXIMIZED | |
  21235. * | 6 | ALPHA_ONEONE | |
  21236. * | 7 | ALPHA_PREMULTIPLIED | |
  21237. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21238. * | 9 | ALPHA_INTERPOLATE | |
  21239. * | 10 | ALPHA_SCREENMODE | |
  21240. *
  21241. */
  21242. /**
  21243. * Gets the value of the alpha mode
  21244. */
  21245. alphaMode: number;
  21246. /**
  21247. * Stores the state of the need depth pre-pass value
  21248. */
  21249. private _needDepthPrePass;
  21250. /**
  21251. * Sets the need depth pre-pass value
  21252. */
  21253. /**
  21254. * Gets the depth pre-pass value
  21255. */
  21256. needDepthPrePass: boolean;
  21257. /**
  21258. * Specifies if depth writing should be disabled
  21259. */
  21260. disableDepthWrite: boolean;
  21261. /**
  21262. * Specifies if depth writing should be forced
  21263. */
  21264. forceDepthWrite: boolean;
  21265. /**
  21266. * Specifies the depth function that should be used. 0 means the default engine function
  21267. */
  21268. depthFunction: number;
  21269. /**
  21270. * Specifies if there should be a separate pass for culling
  21271. */
  21272. separateCullingPass: boolean;
  21273. /**
  21274. * Stores the state specifing if fog should be enabled
  21275. */
  21276. private _fogEnabled;
  21277. /**
  21278. * Sets the state for enabling fog
  21279. */
  21280. /**
  21281. * Gets the value of the fog enabled state
  21282. */
  21283. fogEnabled: boolean;
  21284. /**
  21285. * Stores the size of points
  21286. */
  21287. pointSize: number;
  21288. /**
  21289. * Stores the z offset value
  21290. */
  21291. zOffset: number;
  21292. /**
  21293. * Gets a value specifying if wireframe mode is enabled
  21294. */
  21295. /**
  21296. * Sets the state of wireframe mode
  21297. */
  21298. wireframe: boolean;
  21299. /**
  21300. * Gets the value specifying if point clouds are enabled
  21301. */
  21302. /**
  21303. * Sets the state of point cloud mode
  21304. */
  21305. pointsCloud: boolean;
  21306. /**
  21307. * Gets the material fill mode
  21308. */
  21309. /**
  21310. * Sets the material fill mode
  21311. */
  21312. fillMode: number;
  21313. /**
  21314. * @hidden
  21315. * Stores the effects for the material
  21316. */
  21317. _effect: Nullable<Effect>;
  21318. /**
  21319. * @hidden
  21320. * Specifies if the material was previously ready
  21321. */
  21322. _wasPreviouslyReady: boolean;
  21323. /**
  21324. * Specifies if uniform buffers should be used
  21325. */
  21326. private _useUBO;
  21327. /**
  21328. * Stores a reference to the scene
  21329. */
  21330. private _scene;
  21331. /**
  21332. * Stores the fill mode state
  21333. */
  21334. private _fillMode;
  21335. /**
  21336. * Specifies if the depth write state should be cached
  21337. */
  21338. private _cachedDepthWriteState;
  21339. /**
  21340. * Specifies if the depth function state should be cached
  21341. */
  21342. private _cachedDepthFunctionState;
  21343. /**
  21344. * Stores the uniform buffer
  21345. */
  21346. protected _uniformBuffer: UniformBuffer;
  21347. /** @hidden */
  21348. _indexInSceneMaterialArray: number;
  21349. /** @hidden */
  21350. meshMap: Nullable<{
  21351. [id: string]: AbstractMesh | undefined;
  21352. }>;
  21353. /**
  21354. * Creates a material instance
  21355. * @param name defines the name of the material
  21356. * @param scene defines the scene to reference
  21357. * @param doNotAdd specifies if the material should be added to the scene
  21358. */
  21359. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21360. /**
  21361. * Returns a string representation of the current material
  21362. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21363. * @returns a string with material information
  21364. */
  21365. toString(fullDetails?: boolean): string;
  21366. /**
  21367. * Gets the class name of the material
  21368. * @returns a string with the class name of the material
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Specifies if updates for the material been locked
  21373. */
  21374. readonly isFrozen: boolean;
  21375. /**
  21376. * Locks updates for the material
  21377. */
  21378. freeze(): void;
  21379. /**
  21380. * Unlocks updates for the material
  21381. */
  21382. unfreeze(): void;
  21383. /**
  21384. * Specifies if the material is ready to be used
  21385. * @param mesh defines the mesh to check
  21386. * @param useInstances specifies if instances should be used
  21387. * @returns a boolean indicating if the material is ready to be used
  21388. */
  21389. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21390. /**
  21391. * Specifies that the submesh is ready to be used
  21392. * @param mesh defines the mesh to check
  21393. * @param subMesh defines which submesh to check
  21394. * @param useInstances specifies that instances should be used
  21395. * @returns a boolean indicating that the submesh is ready or not
  21396. */
  21397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21398. /**
  21399. * Returns the material effect
  21400. * @returns the effect associated with the material
  21401. */
  21402. getEffect(): Nullable<Effect>;
  21403. /**
  21404. * Returns the current scene
  21405. * @returns a Scene
  21406. */
  21407. getScene(): Scene;
  21408. /**
  21409. * Specifies if the material will require alpha blending
  21410. * @returns a boolean specifying if alpha blending is needed
  21411. */
  21412. needAlphaBlending(): boolean;
  21413. /**
  21414. * Specifies if the mesh will require alpha blending
  21415. * @param mesh defines the mesh to check
  21416. * @returns a boolean specifying if alpha blending is needed for the mesh
  21417. */
  21418. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21419. /**
  21420. * Specifies if this material should be rendered in alpha test mode
  21421. * @returns a boolean specifying if an alpha test is needed.
  21422. */
  21423. needAlphaTesting(): boolean;
  21424. /**
  21425. * Gets the texture used for the alpha test
  21426. * @returns the texture to use for alpha testing
  21427. */
  21428. getAlphaTestTexture(): Nullable<BaseTexture>;
  21429. /**
  21430. * Marks the material to indicate that it needs to be re-calculated
  21431. */
  21432. markDirty(): void;
  21433. /** @hidden */
  21434. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21435. /**
  21436. * Binds the material to the mesh
  21437. * @param world defines the world transformation matrix
  21438. * @param mesh defines the mesh to bind the material to
  21439. */
  21440. bind(world: Matrix, mesh?: Mesh): void;
  21441. /**
  21442. * Binds the submesh to the material
  21443. * @param world defines the world transformation matrix
  21444. * @param mesh defines the mesh containing the submesh
  21445. * @param subMesh defines the submesh to bind the material to
  21446. */
  21447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21448. /**
  21449. * Binds the world matrix to the material
  21450. * @param world defines the world transformation matrix
  21451. */
  21452. bindOnlyWorldMatrix(world: Matrix): void;
  21453. /**
  21454. * Binds the scene's uniform buffer to the effect.
  21455. * @param effect defines the effect to bind to the scene uniform buffer
  21456. * @param sceneUbo defines the uniform buffer storing scene data
  21457. */
  21458. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21459. /**
  21460. * Binds the view matrix to the effect
  21461. * @param effect defines the effect to bind the view matrix to
  21462. */
  21463. bindView(effect: Effect): void;
  21464. /**
  21465. * Binds the view projection matrix to the effect
  21466. * @param effect defines the effect to bind the view projection matrix to
  21467. */
  21468. bindViewProjection(effect: Effect): void;
  21469. /**
  21470. * Specifies if material alpha testing should be turned on for the mesh
  21471. * @param mesh defines the mesh to check
  21472. */
  21473. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21474. /**
  21475. * Processes to execute after binding the material to a mesh
  21476. * @param mesh defines the rendered mesh
  21477. */
  21478. protected _afterBind(mesh?: Mesh): void;
  21479. /**
  21480. * Unbinds the material from the mesh
  21481. */
  21482. unbind(): void;
  21483. /**
  21484. * Gets the active textures from the material
  21485. * @returns an array of textures
  21486. */
  21487. getActiveTextures(): BaseTexture[];
  21488. /**
  21489. * Specifies if the material uses a texture
  21490. * @param texture defines the texture to check against the material
  21491. * @returns a boolean specifying if the material uses the texture
  21492. */
  21493. hasTexture(texture: BaseTexture): boolean;
  21494. /**
  21495. * Makes a duplicate of the material, and gives it a new name
  21496. * @param name defines the new name for the duplicated material
  21497. * @returns the cloned material
  21498. */
  21499. clone(name: string): Nullable<Material>;
  21500. /**
  21501. * Gets the meshes bound to the material
  21502. * @returns an array of meshes bound to the material
  21503. */
  21504. getBindedMeshes(): AbstractMesh[];
  21505. /**
  21506. * Force shader compilation
  21507. * @param mesh defines the mesh associated with this material
  21508. * @param onCompiled defines a function to execute once the material is compiled
  21509. * @param options defines the options to configure the compilation
  21510. * @param onError defines a function to execute if the material fails compiling
  21511. */
  21512. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21513. /**
  21514. * Force shader compilation
  21515. * @param mesh defines the mesh that will use this material
  21516. * @param options defines additional options for compiling the shaders
  21517. * @returns a promise that resolves when the compilation completes
  21518. */
  21519. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21520. private static readonly _AllDirtyCallBack;
  21521. private static readonly _ImageProcessingDirtyCallBack;
  21522. private static readonly _TextureDirtyCallBack;
  21523. private static readonly _FresnelDirtyCallBack;
  21524. private static readonly _MiscDirtyCallBack;
  21525. private static readonly _LightsDirtyCallBack;
  21526. private static readonly _AttributeDirtyCallBack;
  21527. private static _FresnelAndMiscDirtyCallBack;
  21528. private static _TextureAndMiscDirtyCallBack;
  21529. private static readonly _DirtyCallbackArray;
  21530. private static readonly _RunDirtyCallBacks;
  21531. /**
  21532. * Marks a define in the material to indicate that it needs to be re-computed
  21533. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21534. */
  21535. markAsDirty(flag: number): void;
  21536. /**
  21537. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21538. * @param func defines a function which checks material defines against the submeshes
  21539. */
  21540. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21541. /**
  21542. * Indicates that we need to re-calculated for all submeshes
  21543. */
  21544. protected _markAllSubMeshesAsAllDirty(): void;
  21545. /**
  21546. * Indicates that image processing needs to be re-calculated for all submeshes
  21547. */
  21548. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21549. /**
  21550. * Indicates that textures need to be re-calculated for all submeshes
  21551. */
  21552. protected _markAllSubMeshesAsTexturesDirty(): void;
  21553. /**
  21554. * Indicates that fresnel needs to be re-calculated for all submeshes
  21555. */
  21556. protected _markAllSubMeshesAsFresnelDirty(): void;
  21557. /**
  21558. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21559. */
  21560. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21561. /**
  21562. * Indicates that lights need to be re-calculated for all submeshes
  21563. */
  21564. protected _markAllSubMeshesAsLightsDirty(): void;
  21565. /**
  21566. * Indicates that attributes need to be re-calculated for all submeshes
  21567. */
  21568. protected _markAllSubMeshesAsAttributesDirty(): void;
  21569. /**
  21570. * Indicates that misc needs to be re-calculated for all submeshes
  21571. */
  21572. protected _markAllSubMeshesAsMiscDirty(): void;
  21573. /**
  21574. * Indicates that textures and misc need to be re-calculated for all submeshes
  21575. */
  21576. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21577. /**
  21578. * Disposes the material
  21579. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21580. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21581. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21582. */
  21583. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21584. /** @hidden */
  21585. private releaseVertexArrayObject;
  21586. /**
  21587. * Serializes this material
  21588. * @returns the serialized material object
  21589. */
  21590. serialize(): any;
  21591. /**
  21592. * Creates a material from parsed material data
  21593. * @param parsedMaterial defines parsed material data
  21594. * @param scene defines the hosting scene
  21595. * @param rootUrl defines the root URL to use to load textures
  21596. * @returns a new material
  21597. */
  21598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21599. }
  21600. }
  21601. declare module "babylonjs/Materials/multiMaterial" {
  21602. import { Nullable } from "babylonjs/types";
  21603. import { Scene } from "babylonjs/scene";
  21604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21605. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21607. import { Material } from "babylonjs/Materials/material";
  21608. /**
  21609. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21610. * separate meshes. This can be use to improve performances.
  21611. * @see http://doc.babylonjs.com/how_to/multi_materials
  21612. */
  21613. export class MultiMaterial extends Material {
  21614. private _subMaterials;
  21615. /**
  21616. * Gets or Sets the list of Materials used within the multi material.
  21617. * They need to be ordered according to the submeshes order in the associated mesh
  21618. */
  21619. subMaterials: Nullable<Material>[];
  21620. /**
  21621. * Function used to align with Node.getChildren()
  21622. * @returns the list of Materials used within the multi material
  21623. */
  21624. getChildren(): Nullable<Material>[];
  21625. /**
  21626. * Instantiates a new Multi Material
  21627. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21628. * separate meshes. This can be use to improve performances.
  21629. * @see http://doc.babylonjs.com/how_to/multi_materials
  21630. * @param name Define the name in the scene
  21631. * @param scene Define the scene the material belongs to
  21632. */
  21633. constructor(name: string, scene: Scene);
  21634. private _hookArray;
  21635. /**
  21636. * Get one of the submaterial by its index in the submaterials array
  21637. * @param index The index to look the sub material at
  21638. * @returns The Material if the index has been defined
  21639. */
  21640. getSubMaterial(index: number): Nullable<Material>;
  21641. /**
  21642. * Get the list of active textures for the whole sub materials list.
  21643. * @returns All the textures that will be used during the rendering
  21644. */
  21645. getActiveTextures(): BaseTexture[];
  21646. /**
  21647. * Gets the current class name of the material e.g. "MultiMaterial"
  21648. * Mainly use in serialization.
  21649. * @returns the class name
  21650. */
  21651. getClassName(): string;
  21652. /**
  21653. * Checks if the material is ready to render the requested sub mesh
  21654. * @param mesh Define the mesh the submesh belongs to
  21655. * @param subMesh Define the sub mesh to look readyness for
  21656. * @param useInstances Define whether or not the material is used with instances
  21657. * @returns true if ready, otherwise false
  21658. */
  21659. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21660. /**
  21661. * Clones the current material and its related sub materials
  21662. * @param name Define the name of the newly cloned material
  21663. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21664. * @returns the cloned material
  21665. */
  21666. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21667. /**
  21668. * Serializes the materials into a JSON representation.
  21669. * @returns the JSON representation
  21670. */
  21671. serialize(): any;
  21672. /**
  21673. * Dispose the material and release its associated resources
  21674. * @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)
  21675. * @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)
  21676. * @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)
  21677. */
  21678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21679. /**
  21680. * Creates a MultiMaterial from parsed MultiMaterial data.
  21681. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21682. * @param scene defines the hosting scene
  21683. * @returns a new MultiMaterial
  21684. */
  21685. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21686. }
  21687. }
  21688. declare module "babylonjs/Meshes/subMesh" {
  21689. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21690. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21691. import { Engine } from "babylonjs/Engines/engine";
  21692. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21693. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21694. import { Effect } from "babylonjs/Materials/effect";
  21695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21696. import { Plane } from "babylonjs/Maths/math.plane";
  21697. import { Collider } from "babylonjs/Collisions/collider";
  21698. import { Material } from "babylonjs/Materials/material";
  21699. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21701. import { Mesh } from "babylonjs/Meshes/mesh";
  21702. import { Ray } from "babylonjs/Culling/ray";
  21703. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21704. /**
  21705. * Base class for submeshes
  21706. */
  21707. export class BaseSubMesh {
  21708. /** @hidden */
  21709. _materialDefines: Nullable<MaterialDefines>;
  21710. /** @hidden */
  21711. _materialEffect: Nullable<Effect>;
  21712. /**
  21713. * Gets material defines used by the effect associated to the sub mesh
  21714. */
  21715. /**
  21716. * Sets material defines used by the effect associated to the sub mesh
  21717. */
  21718. materialDefines: Nullable<MaterialDefines>;
  21719. /**
  21720. * Gets associated effect
  21721. */
  21722. readonly effect: Nullable<Effect>;
  21723. /**
  21724. * Sets associated effect (effect used to render this submesh)
  21725. * @param effect defines the effect to associate with
  21726. * @param defines defines the set of defines used to compile this effect
  21727. */
  21728. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21729. }
  21730. /**
  21731. * Defines a subdivision inside a mesh
  21732. */
  21733. export class SubMesh extends BaseSubMesh implements ICullable {
  21734. /** the material index to use */
  21735. materialIndex: number;
  21736. /** vertex index start */
  21737. verticesStart: number;
  21738. /** vertices count */
  21739. verticesCount: number;
  21740. /** index start */
  21741. indexStart: number;
  21742. /** indices count */
  21743. indexCount: number;
  21744. /** @hidden */
  21745. _linesIndexCount: number;
  21746. private _mesh;
  21747. private _renderingMesh;
  21748. private _boundingInfo;
  21749. private _linesIndexBuffer;
  21750. /** @hidden */
  21751. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21752. /** @hidden */
  21753. _trianglePlanes: Plane[];
  21754. /** @hidden */
  21755. _lastColliderTransformMatrix: Nullable<Matrix>;
  21756. /** @hidden */
  21757. _renderId: number;
  21758. /** @hidden */
  21759. _alphaIndex: number;
  21760. /** @hidden */
  21761. _distanceToCamera: number;
  21762. /** @hidden */
  21763. _id: number;
  21764. private _currentMaterial;
  21765. /**
  21766. * Add a new submesh to a mesh
  21767. * @param materialIndex defines the material index to use
  21768. * @param verticesStart defines vertex index start
  21769. * @param verticesCount defines vertices count
  21770. * @param indexStart defines index start
  21771. * @param indexCount defines indices count
  21772. * @param mesh defines the parent mesh
  21773. * @param renderingMesh defines an optional rendering mesh
  21774. * @param createBoundingBox defines if bounding box should be created for this submesh
  21775. * @returns the new submesh
  21776. */
  21777. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21778. /**
  21779. * Creates a new submesh
  21780. * @param materialIndex defines the material index to use
  21781. * @param verticesStart defines vertex index start
  21782. * @param verticesCount defines vertices count
  21783. * @param indexStart defines index start
  21784. * @param indexCount defines indices count
  21785. * @param mesh defines the parent mesh
  21786. * @param renderingMesh defines an optional rendering mesh
  21787. * @param createBoundingBox defines if bounding box should be created for this submesh
  21788. */
  21789. constructor(
  21790. /** the material index to use */
  21791. materialIndex: number,
  21792. /** vertex index start */
  21793. verticesStart: number,
  21794. /** vertices count */
  21795. verticesCount: number,
  21796. /** index start */
  21797. indexStart: number,
  21798. /** indices count */
  21799. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21800. /**
  21801. * Returns true if this submesh covers the entire parent mesh
  21802. * @ignorenaming
  21803. */
  21804. readonly IsGlobal: boolean;
  21805. /**
  21806. * Returns the submesh BoudingInfo object
  21807. * @returns current bounding info (or mesh's one if the submesh is global)
  21808. */
  21809. getBoundingInfo(): BoundingInfo;
  21810. /**
  21811. * Sets the submesh BoundingInfo
  21812. * @param boundingInfo defines the new bounding info to use
  21813. * @returns the SubMesh
  21814. */
  21815. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21816. /**
  21817. * Returns the mesh of the current submesh
  21818. * @return the parent mesh
  21819. */
  21820. getMesh(): AbstractMesh;
  21821. /**
  21822. * Returns the rendering mesh of the submesh
  21823. * @returns the rendering mesh (could be different from parent mesh)
  21824. */
  21825. getRenderingMesh(): Mesh;
  21826. /**
  21827. * Returns the submesh material
  21828. * @returns null or the current material
  21829. */
  21830. getMaterial(): Nullable<Material>;
  21831. /**
  21832. * Sets a new updated BoundingInfo object to the submesh
  21833. * @param data defines an optional position array to use to determine the bounding info
  21834. * @returns the SubMesh
  21835. */
  21836. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21837. /** @hidden */
  21838. _checkCollision(collider: Collider): boolean;
  21839. /**
  21840. * Updates the submesh BoundingInfo
  21841. * @param world defines the world matrix to use to update the bounding info
  21842. * @returns the submesh
  21843. */
  21844. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21845. /**
  21846. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21847. * @param frustumPlanes defines the frustum planes
  21848. * @returns true if the submesh is intersecting with the frustum
  21849. */
  21850. isInFrustum(frustumPlanes: Plane[]): boolean;
  21851. /**
  21852. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21853. * @param frustumPlanes defines the frustum planes
  21854. * @returns true if the submesh is inside the frustum
  21855. */
  21856. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21857. /**
  21858. * Renders the submesh
  21859. * @param enableAlphaMode defines if alpha needs to be used
  21860. * @returns the submesh
  21861. */
  21862. render(enableAlphaMode: boolean): SubMesh;
  21863. /**
  21864. * @hidden
  21865. */
  21866. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21867. /**
  21868. * Checks if the submesh intersects with a ray
  21869. * @param ray defines the ray to test
  21870. * @returns true is the passed ray intersects the submesh bounding box
  21871. */
  21872. canIntersects(ray: Ray): boolean;
  21873. /**
  21874. * Intersects current submesh with a ray
  21875. * @param ray defines the ray to test
  21876. * @param positions defines mesh's positions array
  21877. * @param indices defines mesh's indices array
  21878. * @param fastCheck defines if only bounding info should be used
  21879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21880. * @returns intersection info or null if no intersection
  21881. */
  21882. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21883. /** @hidden */
  21884. private _intersectLines;
  21885. /** @hidden */
  21886. private _intersectUnIndexedLines;
  21887. /** @hidden */
  21888. private _intersectTriangles;
  21889. /** @hidden */
  21890. private _intersectUnIndexedTriangles;
  21891. /** @hidden */
  21892. _rebuild(): void;
  21893. /**
  21894. * Creates a new submesh from the passed mesh
  21895. * @param newMesh defines the new hosting mesh
  21896. * @param newRenderingMesh defines an optional rendering mesh
  21897. * @returns the new submesh
  21898. */
  21899. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21900. /**
  21901. * Release associated resources
  21902. */
  21903. dispose(): void;
  21904. /**
  21905. * Gets the class name
  21906. * @returns the string "SubMesh".
  21907. */
  21908. getClassName(): string;
  21909. /**
  21910. * Creates a new submesh from indices data
  21911. * @param materialIndex the index of the main mesh material
  21912. * @param startIndex the index where to start the copy in the mesh indices array
  21913. * @param indexCount the number of indices to copy then from the startIndex
  21914. * @param mesh the main mesh to create the submesh from
  21915. * @param renderingMesh the optional rendering mesh
  21916. * @returns a new submesh
  21917. */
  21918. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21919. }
  21920. }
  21921. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21922. /**
  21923. * Class used to represent data loading progression
  21924. */
  21925. export class SceneLoaderFlags {
  21926. private static _ForceFullSceneLoadingForIncremental;
  21927. private static _ShowLoadingScreen;
  21928. private static _CleanBoneMatrixWeights;
  21929. private static _loggingLevel;
  21930. /**
  21931. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21932. */
  21933. static ForceFullSceneLoadingForIncremental: boolean;
  21934. /**
  21935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21936. */
  21937. static ShowLoadingScreen: boolean;
  21938. /**
  21939. * Defines the current logging level (while loading the scene)
  21940. * @ignorenaming
  21941. */
  21942. static loggingLevel: number;
  21943. /**
  21944. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21945. */
  21946. static CleanBoneMatrixWeights: boolean;
  21947. }
  21948. }
  21949. declare module "babylonjs/Meshes/geometry" {
  21950. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21951. import { Scene } from "babylonjs/scene";
  21952. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21953. import { Engine } from "babylonjs/Engines/engine";
  21954. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21955. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21956. import { Effect } from "babylonjs/Materials/effect";
  21957. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21958. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21959. import { Mesh } from "babylonjs/Meshes/mesh";
  21960. /**
  21961. * Class used to store geometry data (vertex buffers + index buffer)
  21962. */
  21963. export class Geometry implements IGetSetVerticesData {
  21964. /**
  21965. * Gets or sets the ID of the geometry
  21966. */
  21967. id: string;
  21968. /**
  21969. * Gets or sets the unique ID of the geometry
  21970. */
  21971. uniqueId: number;
  21972. /**
  21973. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21974. */
  21975. delayLoadState: number;
  21976. /**
  21977. * Gets the file containing the data to load when running in delay load state
  21978. */
  21979. delayLoadingFile: Nullable<string>;
  21980. /**
  21981. * Callback called when the geometry is updated
  21982. */
  21983. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21984. private _scene;
  21985. private _engine;
  21986. private _meshes;
  21987. private _totalVertices;
  21988. /** @hidden */
  21989. _indices: IndicesArray;
  21990. /** @hidden */
  21991. _vertexBuffers: {
  21992. [key: string]: VertexBuffer;
  21993. };
  21994. private _isDisposed;
  21995. private _extend;
  21996. private _boundingBias;
  21997. /** @hidden */
  21998. _delayInfo: Array<string>;
  21999. private _indexBuffer;
  22000. private _indexBufferIsUpdatable;
  22001. /** @hidden */
  22002. _boundingInfo: Nullable<BoundingInfo>;
  22003. /** @hidden */
  22004. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22005. /** @hidden */
  22006. _softwareSkinningFrameId: number;
  22007. private _vertexArrayObjects;
  22008. private _updatable;
  22009. /** @hidden */
  22010. _positions: Nullable<Vector3[]>;
  22011. /**
  22012. * 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
  22013. */
  22014. /**
  22015. * 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
  22016. */
  22017. boundingBias: Vector2;
  22018. /**
  22019. * Static function used to attach a new empty geometry to a mesh
  22020. * @param mesh defines the mesh to attach the geometry to
  22021. * @returns the new Geometry
  22022. */
  22023. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22024. /**
  22025. * Creates a new geometry
  22026. * @param id defines the unique ID
  22027. * @param scene defines the hosting scene
  22028. * @param vertexData defines the VertexData used to get geometry data
  22029. * @param updatable defines if geometry must be updatable (false by default)
  22030. * @param mesh defines the mesh that will be associated with the geometry
  22031. */
  22032. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22033. /**
  22034. * Gets the current extend of the geometry
  22035. */
  22036. readonly extend: {
  22037. minimum: Vector3;
  22038. maximum: Vector3;
  22039. };
  22040. /**
  22041. * Gets the hosting scene
  22042. * @returns the hosting Scene
  22043. */
  22044. getScene(): Scene;
  22045. /**
  22046. * Gets the hosting engine
  22047. * @returns the hosting Engine
  22048. */
  22049. getEngine(): Engine;
  22050. /**
  22051. * Defines if the geometry is ready to use
  22052. * @returns true if the geometry is ready to be used
  22053. */
  22054. isReady(): boolean;
  22055. /**
  22056. * Gets a value indicating that the geometry should not be serialized
  22057. */
  22058. readonly doNotSerialize: boolean;
  22059. /** @hidden */
  22060. _rebuild(): void;
  22061. /**
  22062. * Affects all geometry data in one call
  22063. * @param vertexData defines the geometry data
  22064. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22065. */
  22066. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22067. /**
  22068. * Set specific vertex data
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param data defines the vertex data to use
  22071. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22072. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22073. */
  22074. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22075. /**
  22076. * Removes a specific vertex data
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. */
  22079. removeVerticesData(kind: string): void;
  22080. /**
  22081. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22082. * @param buffer defines the vertex buffer to use
  22083. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22084. */
  22085. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22086. /**
  22087. * Update a specific vertex buffer
  22088. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22089. * It will do nothing if the buffer is not updatable
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param data defines the data to use
  22092. * @param offset defines the offset in the target buffer where to store the data
  22093. * @param useBytes set to true if the offset is in bytes
  22094. */
  22095. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22096. /**
  22097. * Update a specific vertex buffer
  22098. * This function will create a new buffer if the current one is not updatable
  22099. * @param kind defines the data kind (Position, normal, etc...)
  22100. * @param data defines the data to use
  22101. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22102. */
  22103. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22104. private _updateBoundingInfo;
  22105. /** @hidden */
  22106. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22107. /**
  22108. * Gets total number of vertices
  22109. * @returns the total number of vertices
  22110. */
  22111. getTotalVertices(): number;
  22112. /**
  22113. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22114. * @param kind defines the data kind (Position, normal, etc...)
  22115. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22116. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22117. * @returns a float array containing vertex data
  22118. */
  22119. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22120. /**
  22121. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22122. * @param kind defines the data kind (Position, normal, etc...)
  22123. * @returns true if the vertex buffer with the specified kind is updatable
  22124. */
  22125. isVertexBufferUpdatable(kind: string): boolean;
  22126. /**
  22127. * Gets a specific vertex buffer
  22128. * @param kind defines the data kind (Position, normal, etc...)
  22129. * @returns a VertexBuffer
  22130. */
  22131. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22132. /**
  22133. * Returns all vertex buffers
  22134. * @return an object holding all vertex buffers indexed by kind
  22135. */
  22136. getVertexBuffers(): Nullable<{
  22137. [key: string]: VertexBuffer;
  22138. }>;
  22139. /**
  22140. * Gets a boolean indicating if specific vertex buffer is present
  22141. * @param kind defines the data kind (Position, normal, etc...)
  22142. * @returns true if data is present
  22143. */
  22144. isVerticesDataPresent(kind: string): boolean;
  22145. /**
  22146. * Gets a list of all attached data kinds (Position, normal, etc...)
  22147. * @returns a list of string containing all kinds
  22148. */
  22149. getVerticesDataKinds(): string[];
  22150. /**
  22151. * Update index buffer
  22152. * @param indices defines the indices to store in the index buffer
  22153. * @param offset defines the offset in the target buffer where to store the data
  22154. * @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)
  22155. */
  22156. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22157. /**
  22158. * Creates a new index buffer
  22159. * @param indices defines the indices to store in the index buffer
  22160. * @param totalVertices defines the total number of vertices (could be null)
  22161. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22162. */
  22163. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22164. /**
  22165. * Return the total number of indices
  22166. * @returns the total number of indices
  22167. */
  22168. getTotalIndices(): number;
  22169. /**
  22170. * Gets the index buffer array
  22171. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22172. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22173. * @returns the index buffer array
  22174. */
  22175. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22176. /**
  22177. * Gets the index buffer
  22178. * @return the index buffer
  22179. */
  22180. getIndexBuffer(): Nullable<DataBuffer>;
  22181. /** @hidden */
  22182. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22183. /**
  22184. * Release the associated resources for a specific mesh
  22185. * @param mesh defines the source mesh
  22186. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22187. */
  22188. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22189. /**
  22190. * Apply current geometry to a given mesh
  22191. * @param mesh defines the mesh to apply geometry to
  22192. */
  22193. applyToMesh(mesh: Mesh): void;
  22194. private _updateExtend;
  22195. private _applyToMesh;
  22196. private notifyUpdate;
  22197. /**
  22198. * Load the geometry if it was flagged as delay loaded
  22199. * @param scene defines the hosting scene
  22200. * @param onLoaded defines a callback called when the geometry is loaded
  22201. */
  22202. load(scene: Scene, onLoaded?: () => void): void;
  22203. private _queueLoad;
  22204. /**
  22205. * Invert the geometry to move from a right handed system to a left handed one.
  22206. */
  22207. toLeftHanded(): void;
  22208. /** @hidden */
  22209. _resetPointsArrayCache(): void;
  22210. /** @hidden */
  22211. _generatePointsArray(): boolean;
  22212. /**
  22213. * Gets a value indicating if the geometry is disposed
  22214. * @returns true if the geometry was disposed
  22215. */
  22216. isDisposed(): boolean;
  22217. private _disposeVertexArrayObjects;
  22218. /**
  22219. * Free all associated resources
  22220. */
  22221. dispose(): void;
  22222. /**
  22223. * Clone the current geometry into a new geometry
  22224. * @param id defines the unique ID of the new geometry
  22225. * @returns a new geometry object
  22226. */
  22227. copy(id: string): Geometry;
  22228. /**
  22229. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22230. * @return a JSON representation of the current geometry data (without the vertices data)
  22231. */
  22232. serialize(): any;
  22233. private toNumberArray;
  22234. /**
  22235. * Serialize all vertices data into a JSON oject
  22236. * @returns a JSON representation of the current geometry data
  22237. */
  22238. serializeVerticeData(): any;
  22239. /**
  22240. * Extracts a clone of a mesh geometry
  22241. * @param mesh defines the source mesh
  22242. * @param id defines the unique ID of the new geometry object
  22243. * @returns the new geometry object
  22244. */
  22245. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22246. /**
  22247. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22248. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22249. * Be aware Math.random() could cause collisions, but:
  22250. * "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"
  22251. * @returns a string containing a new GUID
  22252. */
  22253. static RandomId(): string;
  22254. /** @hidden */
  22255. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22256. private static _CleanMatricesWeights;
  22257. /**
  22258. * Create a new geometry from persisted data (Using .babylon file format)
  22259. * @param parsedVertexData defines the persisted data
  22260. * @param scene defines the hosting scene
  22261. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22262. * @returns the new geometry object
  22263. */
  22264. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22265. }
  22266. }
  22267. declare module "babylonjs/Meshes/mesh.vertexData" {
  22268. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22269. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22270. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22271. import { Geometry } from "babylonjs/Meshes/geometry";
  22272. import { Mesh } from "babylonjs/Meshes/mesh";
  22273. /**
  22274. * Define an interface for all classes that will get and set the data on vertices
  22275. */
  22276. export interface IGetSetVerticesData {
  22277. /**
  22278. * Gets a boolean indicating if specific vertex data is present
  22279. * @param kind defines the vertex data kind to use
  22280. * @returns true is data kind is present
  22281. */
  22282. isVerticesDataPresent(kind: string): boolean;
  22283. /**
  22284. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22285. * @param kind defines the data kind (Position, normal, etc...)
  22286. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22287. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22288. * @returns a float array containing vertex data
  22289. */
  22290. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22291. /**
  22292. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22293. * @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.
  22294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22295. * @returns the indices array or an empty array if the mesh has no geometry
  22296. */
  22297. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22298. /**
  22299. * Set specific vertex data
  22300. * @param kind defines the data kind (Position, normal, etc...)
  22301. * @param data defines the vertex data to use
  22302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22304. */
  22305. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22306. /**
  22307. * Update a specific associated vertex buffer
  22308. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22309. * - VertexBuffer.PositionKind
  22310. * - VertexBuffer.UVKind
  22311. * - VertexBuffer.UV2Kind
  22312. * - VertexBuffer.UV3Kind
  22313. * - VertexBuffer.UV4Kind
  22314. * - VertexBuffer.UV5Kind
  22315. * - VertexBuffer.UV6Kind
  22316. * - VertexBuffer.ColorKind
  22317. * - VertexBuffer.MatricesIndicesKind
  22318. * - VertexBuffer.MatricesIndicesExtraKind
  22319. * - VertexBuffer.MatricesWeightsKind
  22320. * - VertexBuffer.MatricesWeightsExtraKind
  22321. * @param data defines the data source
  22322. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22323. * @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)
  22324. */
  22325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22326. /**
  22327. * Creates a new index buffer
  22328. * @param indices defines the indices to store in the index buffer
  22329. * @param totalVertices defines the total number of vertices (could be null)
  22330. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22331. */
  22332. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22333. }
  22334. /**
  22335. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22336. */
  22337. export class VertexData {
  22338. /**
  22339. * Mesh side orientation : usually the external or front surface
  22340. */
  22341. static readonly FRONTSIDE: number;
  22342. /**
  22343. * Mesh side orientation : usually the internal or back surface
  22344. */
  22345. static readonly BACKSIDE: number;
  22346. /**
  22347. * Mesh side orientation : both internal and external or front and back surfaces
  22348. */
  22349. static readonly DOUBLESIDE: number;
  22350. /**
  22351. * Mesh side orientation : by default, `FRONTSIDE`
  22352. */
  22353. static readonly DEFAULTSIDE: number;
  22354. /**
  22355. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22356. */
  22357. positions: Nullable<FloatArray>;
  22358. /**
  22359. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22360. */
  22361. normals: Nullable<FloatArray>;
  22362. /**
  22363. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22364. */
  22365. tangents: Nullable<FloatArray>;
  22366. /**
  22367. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22368. */
  22369. uvs: Nullable<FloatArray>;
  22370. /**
  22371. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22372. */
  22373. uvs2: Nullable<FloatArray>;
  22374. /**
  22375. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22376. */
  22377. uvs3: Nullable<FloatArray>;
  22378. /**
  22379. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22380. */
  22381. uvs4: Nullable<FloatArray>;
  22382. /**
  22383. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22384. */
  22385. uvs5: Nullable<FloatArray>;
  22386. /**
  22387. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22388. */
  22389. uvs6: Nullable<FloatArray>;
  22390. /**
  22391. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22392. */
  22393. colors: Nullable<FloatArray>;
  22394. /**
  22395. * 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).
  22396. */
  22397. matricesIndices: Nullable<FloatArray>;
  22398. /**
  22399. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22400. */
  22401. matricesWeights: Nullable<FloatArray>;
  22402. /**
  22403. * An array extending the number of possible indices
  22404. */
  22405. matricesIndicesExtra: Nullable<FloatArray>;
  22406. /**
  22407. * An array extending the number of possible weights when the number of indices is extended
  22408. */
  22409. matricesWeightsExtra: Nullable<FloatArray>;
  22410. /**
  22411. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22412. */
  22413. indices: Nullable<IndicesArray>;
  22414. /**
  22415. * Uses the passed data array to set the set the values for the specified kind of data
  22416. * @param data a linear array of floating numbers
  22417. * @param kind the type of data that is being set, eg positions, colors etc
  22418. */
  22419. set(data: FloatArray, kind: string): void;
  22420. /**
  22421. * Associates the vertexData to the passed Mesh.
  22422. * Sets it as updatable or not (default `false`)
  22423. * @param mesh the mesh the vertexData is applied to
  22424. * @param updatable when used and having the value true allows new data to update the vertexData
  22425. * @returns the VertexData
  22426. */
  22427. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22428. /**
  22429. * Associates the vertexData to the passed Geometry.
  22430. * Sets it as updatable or not (default `false`)
  22431. * @param geometry the geometry the vertexData is applied to
  22432. * @param updatable when used and having the value true allows new data to update the vertexData
  22433. * @returns VertexData
  22434. */
  22435. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22436. /**
  22437. * Updates the associated mesh
  22438. * @param mesh the mesh to be updated
  22439. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22440. * @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
  22441. * @returns VertexData
  22442. */
  22443. updateMesh(mesh: Mesh): VertexData;
  22444. /**
  22445. * Updates the associated geometry
  22446. * @param geometry the geometry to be updated
  22447. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22448. * @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
  22449. * @returns VertexData.
  22450. */
  22451. updateGeometry(geometry: Geometry): VertexData;
  22452. private _applyTo;
  22453. private _update;
  22454. /**
  22455. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22456. * @param matrix the transforming matrix
  22457. * @returns the VertexData
  22458. */
  22459. transform(matrix: Matrix): VertexData;
  22460. /**
  22461. * Merges the passed VertexData into the current one
  22462. * @param other the VertexData to be merged into the current one
  22463. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22464. * @returns the modified VertexData
  22465. */
  22466. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22467. private _mergeElement;
  22468. private _validate;
  22469. /**
  22470. * Serializes the VertexData
  22471. * @returns a serialized object
  22472. */
  22473. serialize(): any;
  22474. /**
  22475. * Extracts the vertexData from a mesh
  22476. * @param mesh the mesh from which to extract the VertexData
  22477. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22478. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22479. * @returns the object VertexData associated to the passed mesh
  22480. */
  22481. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22482. /**
  22483. * Extracts the vertexData from the geometry
  22484. * @param geometry the geometry from which to extract the VertexData
  22485. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22486. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22487. * @returns the object VertexData associated to the passed mesh
  22488. */
  22489. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22490. private static _ExtractFrom;
  22491. /**
  22492. * Creates the VertexData for a Ribbon
  22493. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22494. * * pathArray array of paths, each of which an array of successive Vector3
  22495. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22496. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22497. * * 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
  22498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * 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)
  22500. * * 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)
  22501. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22502. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22503. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22504. * @returns the VertexData of the ribbon
  22505. */
  22506. static CreateRibbon(options: {
  22507. pathArray: Vector3[][];
  22508. closeArray?: boolean;
  22509. closePath?: boolean;
  22510. offset?: number;
  22511. sideOrientation?: number;
  22512. frontUVs?: Vector4;
  22513. backUVs?: Vector4;
  22514. invertUV?: boolean;
  22515. uvs?: Vector2[];
  22516. colors?: Color4[];
  22517. }): VertexData;
  22518. /**
  22519. * Creates the VertexData for a box
  22520. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22521. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22522. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22523. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22524. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22525. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22526. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22527. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22528. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22529. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22530. * @returns the VertexData of the box
  22531. */
  22532. static CreateBox(options: {
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. depth?: number;
  22537. faceUV?: Vector4[];
  22538. faceColors?: Color4[];
  22539. sideOrientation?: number;
  22540. frontUVs?: Vector4;
  22541. backUVs?: Vector4;
  22542. }): VertexData;
  22543. /**
  22544. * Creates the VertexData for a tiled box
  22545. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22546. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22547. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22548. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * @returns the VertexData of the box
  22551. */
  22552. static CreateTiledBox(options: {
  22553. pattern?: number;
  22554. width?: number;
  22555. height?: number;
  22556. depth?: number;
  22557. tileSize?: number;
  22558. tileWidth?: number;
  22559. tileHeight?: number;
  22560. alignHorizontal?: number;
  22561. alignVertical?: number;
  22562. faceUV?: Vector4[];
  22563. faceColors?: Color4[];
  22564. sideOrientation?: number;
  22565. }): VertexData;
  22566. /**
  22567. * Creates the VertexData for a tiled plane
  22568. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22569. * * pattern a limited pattern arrangement depending on the number
  22570. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22571. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22572. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22573. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22574. * * 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)
  22575. * * 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)
  22576. * @returns the VertexData of the tiled plane
  22577. */
  22578. static CreateTiledPlane(options: {
  22579. pattern?: number;
  22580. tileSize?: number;
  22581. tileWidth?: number;
  22582. tileHeight?: number;
  22583. size?: number;
  22584. width?: number;
  22585. height?: number;
  22586. alignHorizontal?: number;
  22587. alignVertical?: number;
  22588. sideOrientation?: number;
  22589. frontUVs?: Vector4;
  22590. backUVs?: Vector4;
  22591. }): VertexData;
  22592. /**
  22593. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22594. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22595. * * segments sets the number of horizontal strips optional, default 32
  22596. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22597. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22598. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22599. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22600. * * 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
  22601. * * 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
  22602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22603. * * 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)
  22604. * * 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)
  22605. * @returns the VertexData of the ellipsoid
  22606. */
  22607. static CreateSphere(options: {
  22608. segments?: number;
  22609. diameter?: number;
  22610. diameterX?: number;
  22611. diameterY?: number;
  22612. diameterZ?: number;
  22613. arc?: number;
  22614. slice?: number;
  22615. sideOrientation?: number;
  22616. frontUVs?: Vector4;
  22617. backUVs?: Vector4;
  22618. }): VertexData;
  22619. /**
  22620. * Creates the VertexData for a cylinder, cone or prism
  22621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22622. * * height sets the height (y direction) of the cylinder, optional, default 2
  22623. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22624. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22625. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22626. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22627. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22628. * * 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
  22629. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22630. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22631. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22632. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22634. * * 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)
  22635. * * 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)
  22636. * @returns the VertexData of the cylinder, cone or prism
  22637. */
  22638. static CreateCylinder(options: {
  22639. height?: number;
  22640. diameterTop?: number;
  22641. diameterBottom?: number;
  22642. diameter?: number;
  22643. tessellation?: number;
  22644. subdivisions?: number;
  22645. arc?: number;
  22646. faceColors?: Color4[];
  22647. faceUV?: Vector4[];
  22648. hasRings?: boolean;
  22649. enclose?: boolean;
  22650. sideOrientation?: number;
  22651. frontUVs?: Vector4;
  22652. backUVs?: Vector4;
  22653. }): VertexData;
  22654. /**
  22655. * Creates the VertexData for a torus
  22656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22657. * * diameter the diameter of the torus, optional default 1
  22658. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22659. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22660. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22661. * * 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)
  22662. * * 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)
  22663. * @returns the VertexData of the torus
  22664. */
  22665. static CreateTorus(options: {
  22666. diameter?: number;
  22667. thickness?: number;
  22668. tessellation?: number;
  22669. sideOrientation?: number;
  22670. frontUVs?: Vector4;
  22671. backUVs?: Vector4;
  22672. }): VertexData;
  22673. /**
  22674. * Creates the VertexData of the LineSystem
  22675. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22676. * - lines an array of lines, each line being an array of successive Vector3
  22677. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22678. * @returns the VertexData of the LineSystem
  22679. */
  22680. static CreateLineSystem(options: {
  22681. lines: Vector3[][];
  22682. colors?: Nullable<Color4[][]>;
  22683. }): VertexData;
  22684. /**
  22685. * Create the VertexData for a DashedLines
  22686. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22687. * - points an array successive Vector3
  22688. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22689. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22690. * - dashNb the intended total number of dashes, optional, default 200
  22691. * @returns the VertexData for the DashedLines
  22692. */
  22693. static CreateDashedLines(options: {
  22694. points: Vector3[];
  22695. dashSize?: number;
  22696. gapSize?: number;
  22697. dashNb?: number;
  22698. }): VertexData;
  22699. /**
  22700. * Creates the VertexData for a Ground
  22701. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22702. * - width the width (x direction) of the ground, optional, default 1
  22703. * - height the height (z direction) of the ground, optional, default 1
  22704. * - subdivisions the number of subdivisions per side, optional, default 1
  22705. * @returns the VertexData of the Ground
  22706. */
  22707. static CreateGround(options: {
  22708. width?: number;
  22709. height?: number;
  22710. subdivisions?: number;
  22711. subdivisionsX?: number;
  22712. subdivisionsY?: number;
  22713. }): VertexData;
  22714. /**
  22715. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22716. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22717. * * xmin the ground minimum X coordinate, optional, default -1
  22718. * * zmin the ground minimum Z coordinate, optional, default -1
  22719. * * xmax the ground maximum X coordinate, optional, default 1
  22720. * * zmax the ground maximum Z coordinate, optional, default 1
  22721. * * 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}
  22722. * * 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}
  22723. * @returns the VertexData of the TiledGround
  22724. */
  22725. static CreateTiledGround(options: {
  22726. xmin: number;
  22727. zmin: number;
  22728. xmax: number;
  22729. zmax: number;
  22730. subdivisions?: {
  22731. w: number;
  22732. h: number;
  22733. };
  22734. precision?: {
  22735. w: number;
  22736. h: number;
  22737. };
  22738. }): VertexData;
  22739. /**
  22740. * Creates the VertexData of the Ground designed from a heightmap
  22741. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22742. * * width the width (x direction) of the ground
  22743. * * height the height (z direction) of the ground
  22744. * * subdivisions the number of subdivisions per side
  22745. * * minHeight the minimum altitude on the ground, optional, default 0
  22746. * * maxHeight the maximum altitude on the ground, optional default 1
  22747. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22748. * * buffer the array holding the image color data
  22749. * * bufferWidth the width of image
  22750. * * bufferHeight the height of image
  22751. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22752. * @returns the VertexData of the Ground designed from a heightmap
  22753. */
  22754. static CreateGroundFromHeightMap(options: {
  22755. width: number;
  22756. height: number;
  22757. subdivisions: number;
  22758. minHeight: number;
  22759. maxHeight: number;
  22760. colorFilter: Color3;
  22761. buffer: Uint8Array;
  22762. bufferWidth: number;
  22763. bufferHeight: number;
  22764. alphaFilter: number;
  22765. }): VertexData;
  22766. /**
  22767. * Creates the VertexData for a Plane
  22768. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22769. * * size sets the width and height of the plane to the value of size, optional default 1
  22770. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22771. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22773. * * 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)
  22774. * * 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)
  22775. * @returns the VertexData of the box
  22776. */
  22777. static CreatePlane(options: {
  22778. size?: number;
  22779. width?: number;
  22780. height?: number;
  22781. sideOrientation?: number;
  22782. frontUVs?: Vector4;
  22783. backUVs?: Vector4;
  22784. }): VertexData;
  22785. /**
  22786. * Creates the VertexData of the Disc or regular Polygon
  22787. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22788. * * radius the radius of the disc, optional default 0.5
  22789. * * tessellation the number of polygon sides, optional, default 64
  22790. * * 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
  22791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22792. * * 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)
  22793. * * 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)
  22794. * @returns the VertexData of the box
  22795. */
  22796. static CreateDisc(options: {
  22797. radius?: number;
  22798. tessellation?: number;
  22799. arc?: number;
  22800. sideOrientation?: number;
  22801. frontUVs?: Vector4;
  22802. backUVs?: Vector4;
  22803. }): VertexData;
  22804. /**
  22805. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22806. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22807. * @param polygon a mesh built from polygonTriangulation.build()
  22808. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22809. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22810. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22811. * @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)
  22812. * @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)
  22813. * @returns the VertexData of the Polygon
  22814. */
  22815. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22816. /**
  22817. * Creates the VertexData of the IcoSphere
  22818. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22819. * * radius the radius of the IcoSphere, optional default 1
  22820. * * radiusX allows stretching in the x direction, optional, default radius
  22821. * * radiusY allows stretching in the y direction, optional, default radius
  22822. * * radiusZ allows stretching in the z direction, optional, default radius
  22823. * * flat when true creates a flat shaded mesh, optional, default true
  22824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22826. * * 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)
  22827. * * 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)
  22828. * @returns the VertexData of the IcoSphere
  22829. */
  22830. static CreateIcoSphere(options: {
  22831. radius?: number;
  22832. radiusX?: number;
  22833. radiusY?: number;
  22834. radiusZ?: number;
  22835. flat?: boolean;
  22836. subdivisions?: number;
  22837. sideOrientation?: number;
  22838. frontUVs?: Vector4;
  22839. backUVs?: Vector4;
  22840. }): VertexData;
  22841. /**
  22842. * Creates the VertexData for a Polyhedron
  22843. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22844. * * type provided types are:
  22845. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22846. * * 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)
  22847. * * size the size of the IcoSphere, optional default 1
  22848. * * sizeX allows stretching in the x direction, optional, default size
  22849. * * sizeY allows stretching in the y direction, optional, default size
  22850. * * sizeZ allows stretching in the z direction, optional, default size
  22851. * * 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
  22852. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22853. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22854. * * flat when true creates a flat shaded mesh, optional, default true
  22855. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22856. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22857. * * 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)
  22858. * * 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)
  22859. * @returns the VertexData of the Polyhedron
  22860. */
  22861. static CreatePolyhedron(options: {
  22862. type?: number;
  22863. size?: number;
  22864. sizeX?: number;
  22865. sizeY?: number;
  22866. sizeZ?: number;
  22867. custom?: any;
  22868. faceUV?: Vector4[];
  22869. faceColors?: Color4[];
  22870. flat?: boolean;
  22871. sideOrientation?: number;
  22872. frontUVs?: Vector4;
  22873. backUVs?: Vector4;
  22874. }): VertexData;
  22875. /**
  22876. * Creates the VertexData for a TorusKnot
  22877. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22878. * * radius the radius of the torus knot, optional, default 2
  22879. * * tube the thickness of the tube, optional, default 0.5
  22880. * * radialSegments the number of sides on each tube segments, optional, default 32
  22881. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22882. * * p the number of windings around the z axis, optional, default 2
  22883. * * q the number of windings around the x axis, optional, default 3
  22884. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22885. * * 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)
  22886. * * 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)
  22887. * @returns the VertexData of the Torus Knot
  22888. */
  22889. static CreateTorusKnot(options: {
  22890. radius?: number;
  22891. tube?: number;
  22892. radialSegments?: number;
  22893. tubularSegments?: number;
  22894. p?: number;
  22895. q?: number;
  22896. sideOrientation?: number;
  22897. frontUVs?: Vector4;
  22898. backUVs?: Vector4;
  22899. }): VertexData;
  22900. /**
  22901. * Compute normals for given positions and indices
  22902. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22903. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22904. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22905. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22906. * * facetNormals : optional array of facet normals (vector3)
  22907. * * facetPositions : optional array of facet positions (vector3)
  22908. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22909. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22910. * * bInfo : optional bounding info, required for facetPartitioning computation
  22911. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22912. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22913. * * useRightHandedSystem: optional boolean to for right handed system computation
  22914. * * depthSort : optional boolean to enable the facet depth sort computation
  22915. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22916. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22917. */
  22918. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22919. facetNormals?: any;
  22920. facetPositions?: any;
  22921. facetPartitioning?: any;
  22922. ratio?: number;
  22923. bInfo?: any;
  22924. bbSize?: Vector3;
  22925. subDiv?: any;
  22926. useRightHandedSystem?: boolean;
  22927. depthSort?: boolean;
  22928. distanceTo?: Vector3;
  22929. depthSortedFacets?: any;
  22930. }): void;
  22931. /** @hidden */
  22932. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22933. /**
  22934. * Applies VertexData created from the imported parameters to the geometry
  22935. * @param parsedVertexData the parsed data from an imported file
  22936. * @param geometry the geometry to apply the VertexData to
  22937. */
  22938. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22939. }
  22940. }
  22941. declare module "babylonjs/Morph/morphTarget" {
  22942. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22943. import { Observable } from "babylonjs/Misc/observable";
  22944. import { Nullable, FloatArray } from "babylonjs/types";
  22945. import { Scene } from "babylonjs/scene";
  22946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22947. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22948. /**
  22949. * Defines a target to use with MorphTargetManager
  22950. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22951. */
  22952. export class MorphTarget implements IAnimatable {
  22953. /** defines the name of the target */
  22954. name: string;
  22955. /**
  22956. * Gets or sets the list of animations
  22957. */
  22958. animations: import("babylonjs/Animations/animation").Animation[];
  22959. private _scene;
  22960. private _positions;
  22961. private _normals;
  22962. private _tangents;
  22963. private _uvs;
  22964. private _influence;
  22965. private _uniqueId;
  22966. /**
  22967. * Observable raised when the influence changes
  22968. */
  22969. onInfluenceChanged: Observable<boolean>;
  22970. /** @hidden */
  22971. _onDataLayoutChanged: Observable<void>;
  22972. /**
  22973. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22974. */
  22975. influence: number;
  22976. /**
  22977. * Gets or sets the id of the morph Target
  22978. */
  22979. id: string;
  22980. private _animationPropertiesOverride;
  22981. /**
  22982. * Gets or sets the animation properties override
  22983. */
  22984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22985. /**
  22986. * Creates a new MorphTarget
  22987. * @param name defines the name of the target
  22988. * @param influence defines the influence to use
  22989. * @param scene defines the scene the morphtarget belongs to
  22990. */
  22991. constructor(
  22992. /** defines the name of the target */
  22993. name: string, influence?: number, scene?: Nullable<Scene>);
  22994. /**
  22995. * Gets the unique ID of this manager
  22996. */
  22997. readonly uniqueId: number;
  22998. /**
  22999. * Gets a boolean defining if the target contains position data
  23000. */
  23001. readonly hasPositions: boolean;
  23002. /**
  23003. * Gets a boolean defining if the target contains normal data
  23004. */
  23005. readonly hasNormals: boolean;
  23006. /**
  23007. * Gets a boolean defining if the target contains tangent data
  23008. */
  23009. readonly hasTangents: boolean;
  23010. /**
  23011. * Gets a boolean defining if the target contains texture coordinates data
  23012. */
  23013. readonly hasUVs: boolean;
  23014. /**
  23015. * Affects position data to this target
  23016. * @param data defines the position data to use
  23017. */
  23018. setPositions(data: Nullable<FloatArray>): void;
  23019. /**
  23020. * Gets the position data stored in this target
  23021. * @returns a FloatArray containing the position data (or null if not present)
  23022. */
  23023. getPositions(): Nullable<FloatArray>;
  23024. /**
  23025. * Affects normal data to this target
  23026. * @param data defines the normal data to use
  23027. */
  23028. setNormals(data: Nullable<FloatArray>): void;
  23029. /**
  23030. * Gets the normal data stored in this target
  23031. * @returns a FloatArray containing the normal data (or null if not present)
  23032. */
  23033. getNormals(): Nullable<FloatArray>;
  23034. /**
  23035. * Affects tangent data to this target
  23036. * @param data defines the tangent data to use
  23037. */
  23038. setTangents(data: Nullable<FloatArray>): void;
  23039. /**
  23040. * Gets the tangent data stored in this target
  23041. * @returns a FloatArray containing the tangent data (or null if not present)
  23042. */
  23043. getTangents(): Nullable<FloatArray>;
  23044. /**
  23045. * Affects texture coordinates data to this target
  23046. * @param data defines the texture coordinates data to use
  23047. */
  23048. setUVs(data: Nullable<FloatArray>): void;
  23049. /**
  23050. * Gets the texture coordinates data stored in this target
  23051. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23052. */
  23053. getUVs(): Nullable<FloatArray>;
  23054. /**
  23055. * Clone the current target
  23056. * @returns a new MorphTarget
  23057. */
  23058. clone(): MorphTarget;
  23059. /**
  23060. * Serializes the current target into a Serialization object
  23061. * @returns the serialized object
  23062. */
  23063. serialize(): any;
  23064. /**
  23065. * Returns the string "MorphTarget"
  23066. * @returns "MorphTarget"
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Creates a new target from serialized data
  23071. * @param serializationObject defines the serialized data to use
  23072. * @returns a new MorphTarget
  23073. */
  23074. static Parse(serializationObject: any): MorphTarget;
  23075. /**
  23076. * Creates a MorphTarget from mesh data
  23077. * @param mesh defines the source mesh
  23078. * @param name defines the name to use for the new target
  23079. * @param influence defines the influence to attach to the target
  23080. * @returns a new MorphTarget
  23081. */
  23082. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23083. }
  23084. }
  23085. declare module "babylonjs/Morph/morphTargetManager" {
  23086. import { Nullable } from "babylonjs/types";
  23087. import { Scene } from "babylonjs/scene";
  23088. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23089. /**
  23090. * This class is used to deform meshes using morphing between different targets
  23091. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23092. */
  23093. export class MorphTargetManager {
  23094. private _targets;
  23095. private _targetInfluenceChangedObservers;
  23096. private _targetDataLayoutChangedObservers;
  23097. private _activeTargets;
  23098. private _scene;
  23099. private _influences;
  23100. private _supportsNormals;
  23101. private _supportsTangents;
  23102. private _supportsUVs;
  23103. private _vertexCount;
  23104. private _uniqueId;
  23105. private _tempInfluences;
  23106. /**
  23107. * Gets or sets a boolean indicating if normals must be morphed
  23108. */
  23109. enableNormalMorphing: boolean;
  23110. /**
  23111. * Gets or sets a boolean indicating if tangents must be morphed
  23112. */
  23113. enableTangentMorphing: boolean;
  23114. /**
  23115. * Gets or sets a boolean indicating if UV must be morphed
  23116. */
  23117. enableUVMorphing: boolean;
  23118. /**
  23119. * Creates a new MorphTargetManager
  23120. * @param scene defines the current scene
  23121. */
  23122. constructor(scene?: Nullable<Scene>);
  23123. /**
  23124. * Gets the unique ID of this manager
  23125. */
  23126. readonly uniqueId: number;
  23127. /**
  23128. * Gets the number of vertices handled by this manager
  23129. */
  23130. readonly vertexCount: number;
  23131. /**
  23132. * Gets a boolean indicating if this manager supports morphing of normals
  23133. */
  23134. readonly supportsNormals: boolean;
  23135. /**
  23136. * Gets a boolean indicating if this manager supports morphing of tangents
  23137. */
  23138. readonly supportsTangents: boolean;
  23139. /**
  23140. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23141. */
  23142. readonly supportsUVs: boolean;
  23143. /**
  23144. * Gets the number of targets stored in this manager
  23145. */
  23146. readonly numTargets: number;
  23147. /**
  23148. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23149. */
  23150. readonly numInfluencers: number;
  23151. /**
  23152. * Gets the list of influences (one per target)
  23153. */
  23154. readonly influences: Float32Array;
  23155. /**
  23156. * Gets the active target at specified index. An active target is a target with an influence > 0
  23157. * @param index defines the index to check
  23158. * @returns the requested target
  23159. */
  23160. getActiveTarget(index: number): MorphTarget;
  23161. /**
  23162. * Gets the target at specified index
  23163. * @param index defines the index to check
  23164. * @returns the requested target
  23165. */
  23166. getTarget(index: number): MorphTarget;
  23167. /**
  23168. * Add a new target to this manager
  23169. * @param target defines the target to add
  23170. */
  23171. addTarget(target: MorphTarget): void;
  23172. /**
  23173. * Removes a target from the manager
  23174. * @param target defines the target to remove
  23175. */
  23176. removeTarget(target: MorphTarget): void;
  23177. /**
  23178. * Clone the current manager
  23179. * @returns a new MorphTargetManager
  23180. */
  23181. clone(): MorphTargetManager;
  23182. /**
  23183. * Serializes the current manager into a Serialization object
  23184. * @returns the serialized object
  23185. */
  23186. serialize(): any;
  23187. private _syncActiveTargets;
  23188. /**
  23189. * Syncrhonize the targets with all the meshes using this morph target manager
  23190. */
  23191. synchronize(): void;
  23192. /**
  23193. * Creates a new MorphTargetManager from serialized data
  23194. * @param serializationObject defines the serialized data
  23195. * @param scene defines the hosting scene
  23196. * @returns the new MorphTargetManager
  23197. */
  23198. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/meshLODLevel" {
  23202. import { Mesh } from "babylonjs/Meshes/mesh";
  23203. import { Nullable } from "babylonjs/types";
  23204. /**
  23205. * Class used to represent a specific level of detail of a mesh
  23206. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23207. */
  23208. export class MeshLODLevel {
  23209. /** Defines the distance where this level should start being displayed */
  23210. distance: number;
  23211. /** Defines the mesh to use to render this level */
  23212. mesh: Nullable<Mesh>;
  23213. /**
  23214. * Creates a new LOD level
  23215. * @param distance defines the distance where this level should star being displayed
  23216. * @param mesh defines the mesh to use to render this level
  23217. */
  23218. constructor(
  23219. /** Defines the distance where this level should start being displayed */
  23220. distance: number,
  23221. /** Defines the mesh to use to render this level */
  23222. mesh: Nullable<Mesh>);
  23223. }
  23224. }
  23225. declare module "babylonjs/Meshes/groundMesh" {
  23226. import { Scene } from "babylonjs/scene";
  23227. import { Vector3 } from "babylonjs/Maths/math.vector";
  23228. import { Mesh } from "babylonjs/Meshes/mesh";
  23229. /**
  23230. * Mesh representing the gorund
  23231. */
  23232. export class GroundMesh extends Mesh {
  23233. /** If octree should be generated */
  23234. generateOctree: boolean;
  23235. private _heightQuads;
  23236. /** @hidden */
  23237. _subdivisionsX: number;
  23238. /** @hidden */
  23239. _subdivisionsY: number;
  23240. /** @hidden */
  23241. _width: number;
  23242. /** @hidden */
  23243. _height: number;
  23244. /** @hidden */
  23245. _minX: number;
  23246. /** @hidden */
  23247. _maxX: number;
  23248. /** @hidden */
  23249. _minZ: number;
  23250. /** @hidden */
  23251. _maxZ: number;
  23252. constructor(name: string, scene: Scene);
  23253. /**
  23254. * "GroundMesh"
  23255. * @returns "GroundMesh"
  23256. */
  23257. getClassName(): string;
  23258. /**
  23259. * The minimum of x and y subdivisions
  23260. */
  23261. readonly subdivisions: number;
  23262. /**
  23263. * X subdivisions
  23264. */
  23265. readonly subdivisionsX: number;
  23266. /**
  23267. * Y subdivisions
  23268. */
  23269. readonly subdivisionsY: number;
  23270. /**
  23271. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23272. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23273. * @param chunksCount the number of subdivisions for x and y
  23274. * @param octreeBlocksSize (Default: 32)
  23275. */
  23276. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23277. /**
  23278. * Returns a height (y) value in the Worl system :
  23279. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23280. * @param x x coordinate
  23281. * @param z z coordinate
  23282. * @returns the ground y position if (x, z) are outside the ground surface.
  23283. */
  23284. getHeightAtCoordinates(x: number, z: number): number;
  23285. /**
  23286. * Returns a normalized vector (Vector3) orthogonal to the ground
  23287. * at the ground coordinates (x, z) expressed in the World system.
  23288. * @param x x coordinate
  23289. * @param z z coordinate
  23290. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23291. */
  23292. getNormalAtCoordinates(x: number, z: number): Vector3;
  23293. /**
  23294. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23295. * at the ground coordinates (x, z) expressed in the World system.
  23296. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23297. * @param x x coordinate
  23298. * @param z z coordinate
  23299. * @param ref vector to store the result
  23300. * @returns the GroundMesh.
  23301. */
  23302. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23303. /**
  23304. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23305. * if the ground has been updated.
  23306. * This can be used in the render loop.
  23307. * @returns the GroundMesh.
  23308. */
  23309. updateCoordinateHeights(): GroundMesh;
  23310. private _getFacetAt;
  23311. private _initHeightQuads;
  23312. private _computeHeightQuads;
  23313. /**
  23314. * Serializes this ground mesh
  23315. * @param serializationObject object to write serialization to
  23316. */
  23317. serialize(serializationObject: any): void;
  23318. /**
  23319. * Parses a serialized ground mesh
  23320. * @param parsedMesh the serialized mesh
  23321. * @param scene the scene to create the ground mesh in
  23322. * @returns the created ground mesh
  23323. */
  23324. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23325. }
  23326. }
  23327. declare module "babylonjs/Physics/physicsJoint" {
  23328. import { Vector3 } from "babylonjs/Maths/math.vector";
  23329. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23330. /**
  23331. * Interface for Physics-Joint data
  23332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23333. */
  23334. export interface PhysicsJointData {
  23335. /**
  23336. * The main pivot of the joint
  23337. */
  23338. mainPivot?: Vector3;
  23339. /**
  23340. * The connected pivot of the joint
  23341. */
  23342. connectedPivot?: Vector3;
  23343. /**
  23344. * The main axis of the joint
  23345. */
  23346. mainAxis?: Vector3;
  23347. /**
  23348. * The connected axis of the joint
  23349. */
  23350. connectedAxis?: Vector3;
  23351. /**
  23352. * The collision of the joint
  23353. */
  23354. collision?: boolean;
  23355. /**
  23356. * Native Oimo/Cannon/Energy data
  23357. */
  23358. nativeParams?: any;
  23359. }
  23360. /**
  23361. * This is a holder class for the physics joint created by the physics plugin
  23362. * It holds a set of functions to control the underlying joint
  23363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23364. */
  23365. export class PhysicsJoint {
  23366. /**
  23367. * The type of the physics joint
  23368. */
  23369. type: number;
  23370. /**
  23371. * The data for the physics joint
  23372. */
  23373. jointData: PhysicsJointData;
  23374. private _physicsJoint;
  23375. protected _physicsPlugin: IPhysicsEnginePlugin;
  23376. /**
  23377. * Initializes the physics joint
  23378. * @param type The type of the physics joint
  23379. * @param jointData The data for the physics joint
  23380. */
  23381. constructor(
  23382. /**
  23383. * The type of the physics joint
  23384. */
  23385. type: number,
  23386. /**
  23387. * The data for the physics joint
  23388. */
  23389. jointData: PhysicsJointData);
  23390. /**
  23391. * Gets the physics joint
  23392. */
  23393. /**
  23394. * Sets the physics joint
  23395. */
  23396. physicsJoint: any;
  23397. /**
  23398. * Sets the physics plugin
  23399. */
  23400. physicsPlugin: IPhysicsEnginePlugin;
  23401. /**
  23402. * Execute a function that is physics-plugin specific.
  23403. * @param {Function} func the function that will be executed.
  23404. * It accepts two parameters: the physics world and the physics joint
  23405. */
  23406. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23407. /**
  23408. * Distance-Joint type
  23409. */
  23410. static DistanceJoint: number;
  23411. /**
  23412. * Hinge-Joint type
  23413. */
  23414. static HingeJoint: number;
  23415. /**
  23416. * Ball-and-Socket joint type
  23417. */
  23418. static BallAndSocketJoint: number;
  23419. /**
  23420. * Wheel-Joint type
  23421. */
  23422. static WheelJoint: number;
  23423. /**
  23424. * Slider-Joint type
  23425. */
  23426. static SliderJoint: number;
  23427. /**
  23428. * Prismatic-Joint type
  23429. */
  23430. static PrismaticJoint: number;
  23431. /**
  23432. * Universal-Joint type
  23433. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23434. */
  23435. static UniversalJoint: number;
  23436. /**
  23437. * Hinge-Joint 2 type
  23438. */
  23439. static Hinge2Joint: number;
  23440. /**
  23441. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23442. */
  23443. static PointToPointJoint: number;
  23444. /**
  23445. * Spring-Joint type
  23446. */
  23447. static SpringJoint: number;
  23448. /**
  23449. * Lock-Joint type
  23450. */
  23451. static LockJoint: number;
  23452. }
  23453. /**
  23454. * A class representing a physics distance joint
  23455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23456. */
  23457. export class DistanceJoint extends PhysicsJoint {
  23458. /**
  23459. *
  23460. * @param jointData The data for the Distance-Joint
  23461. */
  23462. constructor(jointData: DistanceJointData);
  23463. /**
  23464. * Update the predefined distance.
  23465. * @param maxDistance The maximum preferred distance
  23466. * @param minDistance The minimum preferred distance
  23467. */
  23468. updateDistance(maxDistance: number, minDistance?: number): void;
  23469. }
  23470. /**
  23471. * Represents a Motor-Enabled Joint
  23472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23473. */
  23474. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23475. /**
  23476. * Initializes the Motor-Enabled Joint
  23477. * @param type The type of the joint
  23478. * @param jointData The physica joint data for the joint
  23479. */
  23480. constructor(type: number, jointData: PhysicsJointData);
  23481. /**
  23482. * Set the motor values.
  23483. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23484. * @param force the force to apply
  23485. * @param maxForce max force for this motor.
  23486. */
  23487. setMotor(force?: number, maxForce?: number): void;
  23488. /**
  23489. * Set the motor's limits.
  23490. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23491. * @param upperLimit The upper limit of the motor
  23492. * @param lowerLimit The lower limit of the motor
  23493. */
  23494. setLimit(upperLimit: number, lowerLimit?: number): void;
  23495. }
  23496. /**
  23497. * This class represents a single physics Hinge-Joint
  23498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23499. */
  23500. export class HingeJoint extends MotorEnabledJoint {
  23501. /**
  23502. * Initializes the Hinge-Joint
  23503. * @param jointData The joint data for the Hinge-Joint
  23504. */
  23505. constructor(jointData: PhysicsJointData);
  23506. /**
  23507. * Set the motor values.
  23508. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23509. * @param {number} force the force to apply
  23510. * @param {number} maxForce max force for this motor.
  23511. */
  23512. setMotor(force?: number, maxForce?: number): void;
  23513. /**
  23514. * Set the motor's limits.
  23515. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23516. * @param upperLimit The upper limit of the motor
  23517. * @param lowerLimit The lower limit of the motor
  23518. */
  23519. setLimit(upperLimit: number, lowerLimit?: number): void;
  23520. }
  23521. /**
  23522. * This class represents a dual hinge physics joint (same as wheel joint)
  23523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23524. */
  23525. export class Hinge2Joint extends MotorEnabledJoint {
  23526. /**
  23527. * Initializes the Hinge2-Joint
  23528. * @param jointData The joint data for the Hinge2-Joint
  23529. */
  23530. constructor(jointData: PhysicsJointData);
  23531. /**
  23532. * Set the motor values.
  23533. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23534. * @param {number} targetSpeed the speed the motor is to reach
  23535. * @param {number} maxForce max force for this motor.
  23536. * @param {motorIndex} the motor's index, 0 or 1.
  23537. */
  23538. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23539. /**
  23540. * Set the motor limits.
  23541. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23542. * @param {number} upperLimit the upper limit
  23543. * @param {number} lowerLimit lower limit
  23544. * @param {motorIndex} the motor's index, 0 or 1.
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Interface for a motor enabled joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IMotorEnabledJoint {
  23553. /**
  23554. * Physics joint
  23555. */
  23556. physicsJoint: any;
  23557. /**
  23558. * Sets the motor of the motor-enabled joint
  23559. * @param force The force of the motor
  23560. * @param maxForce The maximum force of the motor
  23561. * @param motorIndex The index of the motor
  23562. */
  23563. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23564. /**
  23565. * Sets the limit of the motor
  23566. * @param upperLimit The upper limit of the motor
  23567. * @param lowerLimit The lower limit of the motor
  23568. * @param motorIndex The index of the motor
  23569. */
  23570. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23571. }
  23572. /**
  23573. * Joint data for a Distance-Joint
  23574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23575. */
  23576. export interface DistanceJointData extends PhysicsJointData {
  23577. /**
  23578. * Max distance the 2 joint objects can be apart
  23579. */
  23580. maxDistance: number;
  23581. }
  23582. /**
  23583. * Joint data from a spring joint
  23584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23585. */
  23586. export interface SpringJointData extends PhysicsJointData {
  23587. /**
  23588. * Length of the spring
  23589. */
  23590. length: number;
  23591. /**
  23592. * Stiffness of the spring
  23593. */
  23594. stiffness: number;
  23595. /**
  23596. * Damping of the spring
  23597. */
  23598. damping: number;
  23599. /** this callback will be called when applying the force to the impostors. */
  23600. forceApplicationCallback: () => void;
  23601. }
  23602. }
  23603. declare module "babylonjs/Physics/physicsRaycastResult" {
  23604. import { Vector3 } from "babylonjs/Maths/math.vector";
  23605. /**
  23606. * Holds the data for the raycast result
  23607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23608. */
  23609. export class PhysicsRaycastResult {
  23610. private _hasHit;
  23611. private _hitDistance;
  23612. private _hitNormalWorld;
  23613. private _hitPointWorld;
  23614. private _rayFromWorld;
  23615. private _rayToWorld;
  23616. /**
  23617. * Gets if there was a hit
  23618. */
  23619. readonly hasHit: boolean;
  23620. /**
  23621. * Gets the distance from the hit
  23622. */
  23623. readonly hitDistance: number;
  23624. /**
  23625. * Gets the hit normal/direction in the world
  23626. */
  23627. readonly hitNormalWorld: Vector3;
  23628. /**
  23629. * Gets the hit point in the world
  23630. */
  23631. readonly hitPointWorld: Vector3;
  23632. /**
  23633. * Gets the ray "start point" of the ray in the world
  23634. */
  23635. readonly rayFromWorld: Vector3;
  23636. /**
  23637. * Gets the ray "end point" of the ray in the world
  23638. */
  23639. readonly rayToWorld: Vector3;
  23640. /**
  23641. * Sets the hit data (normal & point in world space)
  23642. * @param hitNormalWorld defines the normal in world space
  23643. * @param hitPointWorld defines the point in world space
  23644. */
  23645. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23646. /**
  23647. * Sets the distance from the start point to the hit point
  23648. * @param distance
  23649. */
  23650. setHitDistance(distance: number): void;
  23651. /**
  23652. * Calculates the distance manually
  23653. */
  23654. calculateHitDistance(): void;
  23655. /**
  23656. * Resets all the values to default
  23657. * @param from The from point on world space
  23658. * @param to The to point on world space
  23659. */
  23660. reset(from?: Vector3, to?: Vector3): void;
  23661. }
  23662. /**
  23663. * Interface for the size containing width and height
  23664. */
  23665. interface IXYZ {
  23666. /**
  23667. * X
  23668. */
  23669. x: number;
  23670. /**
  23671. * Y
  23672. */
  23673. y: number;
  23674. /**
  23675. * Z
  23676. */
  23677. z: number;
  23678. }
  23679. }
  23680. declare module "babylonjs/Physics/IPhysicsEngine" {
  23681. import { Nullable } from "babylonjs/types";
  23682. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23684. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23685. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23686. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23687. /**
  23688. * Interface used to describe a physics joint
  23689. */
  23690. export interface PhysicsImpostorJoint {
  23691. /** Defines the main impostor to which the joint is linked */
  23692. mainImpostor: PhysicsImpostor;
  23693. /** Defines the impostor that is connected to the main impostor using this joint */
  23694. connectedImpostor: PhysicsImpostor;
  23695. /** Defines the joint itself */
  23696. joint: PhysicsJoint;
  23697. }
  23698. /** @hidden */
  23699. export interface IPhysicsEnginePlugin {
  23700. world: any;
  23701. name: string;
  23702. setGravity(gravity: Vector3): void;
  23703. setTimeStep(timeStep: number): void;
  23704. getTimeStep(): number;
  23705. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23706. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23707. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23709. removePhysicsBody(impostor: PhysicsImpostor): void;
  23710. generateJoint(joint: PhysicsImpostorJoint): void;
  23711. removeJoint(joint: PhysicsImpostorJoint): void;
  23712. isSupported(): boolean;
  23713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23714. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23715. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23716. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23717. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23718. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23719. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23720. getBodyMass(impostor: PhysicsImpostor): number;
  23721. getBodyFriction(impostor: PhysicsImpostor): number;
  23722. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23723. getBodyRestitution(impostor: PhysicsImpostor): number;
  23724. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23725. getBodyPressure?(impostor: PhysicsImpostor): number;
  23726. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23727. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23728. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23729. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23730. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23731. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23732. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23733. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23734. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23735. sleepBody(impostor: PhysicsImpostor): void;
  23736. wakeUpBody(impostor: PhysicsImpostor): void;
  23737. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23738. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23739. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23740. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23741. getRadius(impostor: PhysicsImpostor): number;
  23742. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23743. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23744. dispose(): void;
  23745. }
  23746. /**
  23747. * Interface used to define a physics engine
  23748. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23749. */
  23750. export interface IPhysicsEngine {
  23751. /**
  23752. * Gets the gravity vector used by the simulation
  23753. */
  23754. gravity: Vector3;
  23755. /**
  23756. * Sets the gravity vector used by the simulation
  23757. * @param gravity defines the gravity vector to use
  23758. */
  23759. setGravity(gravity: Vector3): void;
  23760. /**
  23761. * Set the time step of the physics engine.
  23762. * Default is 1/60.
  23763. * To slow it down, enter 1/600 for example.
  23764. * To speed it up, 1/30
  23765. * @param newTimeStep the new timestep to apply to this world.
  23766. */
  23767. setTimeStep(newTimeStep: number): void;
  23768. /**
  23769. * Get the time step of the physics engine.
  23770. * @returns the current time step
  23771. */
  23772. getTimeStep(): number;
  23773. /**
  23774. * Set the sub time step of the physics engine.
  23775. * Default is 0 meaning there is no sub steps
  23776. * To increase physics resolution precision, set a small value (like 1 ms)
  23777. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23778. */
  23779. setSubTimeStep(subTimeStep: number): void;
  23780. /**
  23781. * Get the sub time step of the physics engine.
  23782. * @returns the current sub time step
  23783. */
  23784. getSubTimeStep(): number;
  23785. /**
  23786. * Release all resources
  23787. */
  23788. dispose(): void;
  23789. /**
  23790. * Gets the name of the current physics plugin
  23791. * @returns the name of the plugin
  23792. */
  23793. getPhysicsPluginName(): string;
  23794. /**
  23795. * Adding a new impostor for the impostor tracking.
  23796. * This will be done by the impostor itself.
  23797. * @param impostor the impostor to add
  23798. */
  23799. addImpostor(impostor: PhysicsImpostor): void;
  23800. /**
  23801. * Remove an impostor from the engine.
  23802. * This impostor and its mesh will not longer be updated by the physics engine.
  23803. * @param impostor the impostor to remove
  23804. */
  23805. removeImpostor(impostor: PhysicsImpostor): void;
  23806. /**
  23807. * Add a joint to the physics engine
  23808. * @param mainImpostor defines the main impostor to which the joint is added.
  23809. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23810. * @param joint defines the joint that will connect both impostors.
  23811. */
  23812. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23813. /**
  23814. * Removes a joint from the simulation
  23815. * @param mainImpostor defines the impostor used with the joint
  23816. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23817. * @param joint defines the joint to remove
  23818. */
  23819. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23820. /**
  23821. * Gets the current plugin used to run the simulation
  23822. * @returns current plugin
  23823. */
  23824. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23825. /**
  23826. * Gets the list of physic impostors
  23827. * @returns an array of PhysicsImpostor
  23828. */
  23829. getImpostors(): Array<PhysicsImpostor>;
  23830. /**
  23831. * Gets the impostor for a physics enabled object
  23832. * @param object defines the object impersonated by the impostor
  23833. * @returns the PhysicsImpostor or null if not found
  23834. */
  23835. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23836. /**
  23837. * Gets the impostor for a physics body object
  23838. * @param body defines physics body used by the impostor
  23839. * @returns the PhysicsImpostor or null if not found
  23840. */
  23841. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23842. /**
  23843. * Does a raycast in the physics world
  23844. * @param from when should the ray start?
  23845. * @param to when should the ray end?
  23846. * @returns PhysicsRaycastResult
  23847. */
  23848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23849. /**
  23850. * Called by the scene. No need to call it.
  23851. * @param delta defines the timespam between frames
  23852. */
  23853. _step(delta: number): void;
  23854. }
  23855. }
  23856. declare module "babylonjs/Physics/physicsImpostor" {
  23857. import { Nullable, IndicesArray } from "babylonjs/types";
  23858. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23861. import { Scene } from "babylonjs/scene";
  23862. import { Bone } from "babylonjs/Bones/bone";
  23863. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23864. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23865. import { Space } from "babylonjs/Maths/math.axis";
  23866. /**
  23867. * The interface for the physics imposter parameters
  23868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23869. */
  23870. export interface PhysicsImpostorParameters {
  23871. /**
  23872. * The mass of the physics imposter
  23873. */
  23874. mass: number;
  23875. /**
  23876. * The friction of the physics imposter
  23877. */
  23878. friction?: number;
  23879. /**
  23880. * The coefficient of restitution of the physics imposter
  23881. */
  23882. restitution?: number;
  23883. /**
  23884. * The native options of the physics imposter
  23885. */
  23886. nativeOptions?: any;
  23887. /**
  23888. * Specifies if the parent should be ignored
  23889. */
  23890. ignoreParent?: boolean;
  23891. /**
  23892. * Specifies if bi-directional transformations should be disabled
  23893. */
  23894. disableBidirectionalTransformation?: boolean;
  23895. /**
  23896. * The pressure inside the physics imposter, soft object only
  23897. */
  23898. pressure?: number;
  23899. /**
  23900. * The stiffness the physics imposter, soft object only
  23901. */
  23902. stiffness?: number;
  23903. /**
  23904. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23905. */
  23906. velocityIterations?: number;
  23907. /**
  23908. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23909. */
  23910. positionIterations?: number;
  23911. /**
  23912. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23913. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23914. * Add to fix multiple points
  23915. */
  23916. fixedPoints?: number;
  23917. /**
  23918. * The collision margin around a soft object
  23919. */
  23920. margin?: number;
  23921. /**
  23922. * The collision margin around a soft object
  23923. */
  23924. damping?: number;
  23925. /**
  23926. * The path for a rope based on an extrusion
  23927. */
  23928. path?: any;
  23929. /**
  23930. * The shape of an extrusion used for a rope based on an extrusion
  23931. */
  23932. shape?: any;
  23933. }
  23934. /**
  23935. * Interface for a physics-enabled object
  23936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23937. */
  23938. export interface IPhysicsEnabledObject {
  23939. /**
  23940. * The position of the physics-enabled object
  23941. */
  23942. position: Vector3;
  23943. /**
  23944. * The rotation of the physics-enabled object
  23945. */
  23946. rotationQuaternion: Nullable<Quaternion>;
  23947. /**
  23948. * The scale of the physics-enabled object
  23949. */
  23950. scaling: Vector3;
  23951. /**
  23952. * The rotation of the physics-enabled object
  23953. */
  23954. rotation?: Vector3;
  23955. /**
  23956. * The parent of the physics-enabled object
  23957. */
  23958. parent?: any;
  23959. /**
  23960. * The bounding info of the physics-enabled object
  23961. * @returns The bounding info of the physics-enabled object
  23962. */
  23963. getBoundingInfo(): BoundingInfo;
  23964. /**
  23965. * Computes the world matrix
  23966. * @param force Specifies if the world matrix should be computed by force
  23967. * @returns A world matrix
  23968. */
  23969. computeWorldMatrix(force: boolean): Matrix;
  23970. /**
  23971. * Gets the world matrix
  23972. * @returns A world matrix
  23973. */
  23974. getWorldMatrix?(): Matrix;
  23975. /**
  23976. * Gets the child meshes
  23977. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23978. * @returns An array of abstract meshes
  23979. */
  23980. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23981. /**
  23982. * Gets the vertex data
  23983. * @param kind The type of vertex data
  23984. * @returns A nullable array of numbers, or a float32 array
  23985. */
  23986. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23987. /**
  23988. * Gets the indices from the mesh
  23989. * @returns A nullable array of index arrays
  23990. */
  23991. getIndices?(): Nullable<IndicesArray>;
  23992. /**
  23993. * Gets the scene from the mesh
  23994. * @returns the indices array or null
  23995. */
  23996. getScene?(): Scene;
  23997. /**
  23998. * Gets the absolute position from the mesh
  23999. * @returns the absolute position
  24000. */
  24001. getAbsolutePosition(): Vector3;
  24002. /**
  24003. * Gets the absolute pivot point from the mesh
  24004. * @returns the absolute pivot point
  24005. */
  24006. getAbsolutePivotPoint(): Vector3;
  24007. /**
  24008. * Rotates the mesh
  24009. * @param axis The axis of rotation
  24010. * @param amount The amount of rotation
  24011. * @param space The space of the rotation
  24012. * @returns The rotation transform node
  24013. */
  24014. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24015. /**
  24016. * Translates the mesh
  24017. * @param axis The axis of translation
  24018. * @param distance The distance of translation
  24019. * @param space The space of the translation
  24020. * @returns The transform node
  24021. */
  24022. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24023. /**
  24024. * Sets the absolute position of the mesh
  24025. * @param absolutePosition The absolute position of the mesh
  24026. * @returns The transform node
  24027. */
  24028. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24029. /**
  24030. * Gets the class name of the mesh
  24031. * @returns The class name
  24032. */
  24033. getClassName(): string;
  24034. }
  24035. /**
  24036. * Represents a physics imposter
  24037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24038. */
  24039. export class PhysicsImpostor {
  24040. /**
  24041. * The physics-enabled object used as the physics imposter
  24042. */
  24043. object: IPhysicsEnabledObject;
  24044. /**
  24045. * The type of the physics imposter
  24046. */
  24047. type: number;
  24048. private _options;
  24049. private _scene?;
  24050. /**
  24051. * The default object size of the imposter
  24052. */
  24053. static DEFAULT_OBJECT_SIZE: Vector3;
  24054. /**
  24055. * The identity quaternion of the imposter
  24056. */
  24057. static IDENTITY_QUATERNION: Quaternion;
  24058. /** @hidden */
  24059. _pluginData: any;
  24060. private _physicsEngine;
  24061. private _physicsBody;
  24062. private _bodyUpdateRequired;
  24063. private _onBeforePhysicsStepCallbacks;
  24064. private _onAfterPhysicsStepCallbacks;
  24065. /** @hidden */
  24066. _onPhysicsCollideCallbacks: Array<{
  24067. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24068. otherImpostors: Array<PhysicsImpostor>;
  24069. }>;
  24070. private _deltaPosition;
  24071. private _deltaRotation;
  24072. private _deltaRotationConjugated;
  24073. /** @hidden */
  24074. _isFromLine: boolean;
  24075. private _parent;
  24076. private _isDisposed;
  24077. private static _tmpVecs;
  24078. private static _tmpQuat;
  24079. /**
  24080. * Specifies if the physics imposter is disposed
  24081. */
  24082. readonly isDisposed: boolean;
  24083. /**
  24084. * Gets the mass of the physics imposter
  24085. */
  24086. mass: number;
  24087. /**
  24088. * Gets the coefficient of friction
  24089. */
  24090. /**
  24091. * Sets the coefficient of friction
  24092. */
  24093. friction: number;
  24094. /**
  24095. * Gets the coefficient of restitution
  24096. */
  24097. /**
  24098. * Sets the coefficient of restitution
  24099. */
  24100. restitution: number;
  24101. /**
  24102. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24103. */
  24104. /**
  24105. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24106. */
  24107. pressure: number;
  24108. /**
  24109. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24110. */
  24111. /**
  24112. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24113. */
  24114. stiffness: number;
  24115. /**
  24116. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24117. */
  24118. /**
  24119. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24120. */
  24121. velocityIterations: number;
  24122. /**
  24123. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24124. */
  24125. /**
  24126. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24127. */
  24128. positionIterations: number;
  24129. /**
  24130. * The unique id of the physics imposter
  24131. * set by the physics engine when adding this impostor to the array
  24132. */
  24133. uniqueId: number;
  24134. /**
  24135. * @hidden
  24136. */
  24137. soft: boolean;
  24138. /**
  24139. * @hidden
  24140. */
  24141. segments: number;
  24142. private _joints;
  24143. /**
  24144. * Initializes the physics imposter
  24145. * @param object The physics-enabled object used as the physics imposter
  24146. * @param type The type of the physics imposter
  24147. * @param _options The options for the physics imposter
  24148. * @param _scene The Babylon scene
  24149. */
  24150. constructor(
  24151. /**
  24152. * The physics-enabled object used as the physics imposter
  24153. */
  24154. object: IPhysicsEnabledObject,
  24155. /**
  24156. * The type of the physics imposter
  24157. */
  24158. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24159. /**
  24160. * This function will completly initialize this impostor.
  24161. * It will create a new body - but only if this mesh has no parent.
  24162. * If it has, this impostor will not be used other than to define the impostor
  24163. * of the child mesh.
  24164. * @hidden
  24165. */
  24166. _init(): void;
  24167. private _getPhysicsParent;
  24168. /**
  24169. * Should a new body be generated.
  24170. * @returns boolean specifying if body initialization is required
  24171. */
  24172. isBodyInitRequired(): boolean;
  24173. /**
  24174. * Sets the updated scaling
  24175. * @param updated Specifies if the scaling is updated
  24176. */
  24177. setScalingUpdated(): void;
  24178. /**
  24179. * Force a regeneration of this or the parent's impostor's body.
  24180. * Use under cautious - This will remove all joints already implemented.
  24181. */
  24182. forceUpdate(): void;
  24183. /**
  24184. * Gets the body that holds this impostor. Either its own, or its parent.
  24185. */
  24186. /**
  24187. * Set the physics body. Used mainly by the physics engine/plugin
  24188. */
  24189. physicsBody: any;
  24190. /**
  24191. * Get the parent of the physics imposter
  24192. * @returns Physics imposter or null
  24193. */
  24194. /**
  24195. * Sets the parent of the physics imposter
  24196. */
  24197. parent: Nullable<PhysicsImpostor>;
  24198. /**
  24199. * Resets the update flags
  24200. */
  24201. resetUpdateFlags(): void;
  24202. /**
  24203. * Gets the object extend size
  24204. * @returns the object extend size
  24205. */
  24206. getObjectExtendSize(): Vector3;
  24207. /**
  24208. * Gets the object center
  24209. * @returns The object center
  24210. */
  24211. getObjectCenter(): Vector3;
  24212. /**
  24213. * Get a specific parametes from the options parameter
  24214. * @param paramName The object parameter name
  24215. * @returns The object parameter
  24216. */
  24217. getParam(paramName: string): any;
  24218. /**
  24219. * Sets a specific parameter in the options given to the physics plugin
  24220. * @param paramName The parameter name
  24221. * @param value The value of the parameter
  24222. */
  24223. setParam(paramName: string, value: number): void;
  24224. /**
  24225. * Specifically change the body's mass option. Won't recreate the physics body object
  24226. * @param mass The mass of the physics imposter
  24227. */
  24228. setMass(mass: number): void;
  24229. /**
  24230. * Gets the linear velocity
  24231. * @returns linear velocity or null
  24232. */
  24233. getLinearVelocity(): Nullable<Vector3>;
  24234. /**
  24235. * Sets the linear velocity
  24236. * @param velocity linear velocity or null
  24237. */
  24238. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24239. /**
  24240. * Gets the angular velocity
  24241. * @returns angular velocity or null
  24242. */
  24243. getAngularVelocity(): Nullable<Vector3>;
  24244. /**
  24245. * Sets the angular velocity
  24246. * @param velocity The velocity or null
  24247. */
  24248. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24249. /**
  24250. * Execute a function with the physics plugin native code
  24251. * Provide a function the will have two variables - the world object and the physics body object
  24252. * @param func The function to execute with the physics plugin native code
  24253. */
  24254. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24255. /**
  24256. * Register a function that will be executed before the physics world is stepping forward
  24257. * @param func The function to execute before the physics world is stepped forward
  24258. */
  24259. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24260. /**
  24261. * Unregister a function that will be executed before the physics world is stepping forward
  24262. * @param func The function to execute before the physics world is stepped forward
  24263. */
  24264. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24265. /**
  24266. * Register a function that will be executed after the physics step
  24267. * @param func The function to execute after physics step
  24268. */
  24269. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24270. /**
  24271. * Unregisters a function that will be executed after the physics step
  24272. * @param func The function to execute after physics step
  24273. */
  24274. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24275. /**
  24276. * register a function that will be executed when this impostor collides against a different body
  24277. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24278. * @param func Callback that is executed on collision
  24279. */
  24280. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24281. /**
  24282. * Unregisters the physics imposter on contact
  24283. * @param collideAgainst The physics object to collide against
  24284. * @param func Callback to execute on collision
  24285. */
  24286. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24287. private _tmpQuat;
  24288. private _tmpQuat2;
  24289. /**
  24290. * Get the parent rotation
  24291. * @returns The parent rotation
  24292. */
  24293. getParentsRotation(): Quaternion;
  24294. /**
  24295. * this function is executed by the physics engine.
  24296. */
  24297. beforeStep: () => void;
  24298. /**
  24299. * this function is executed by the physics engine
  24300. */
  24301. afterStep: () => void;
  24302. /**
  24303. * Legacy collision detection event support
  24304. */
  24305. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24306. /**
  24307. * event and body object due to cannon's event-based architecture.
  24308. */
  24309. onCollide: (e: {
  24310. body: any;
  24311. }) => void;
  24312. /**
  24313. * Apply a force
  24314. * @param force The force to apply
  24315. * @param contactPoint The contact point for the force
  24316. * @returns The physics imposter
  24317. */
  24318. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24319. /**
  24320. * Apply an impulse
  24321. * @param force The impulse force
  24322. * @param contactPoint The contact point for the impulse force
  24323. * @returns The physics imposter
  24324. */
  24325. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24326. /**
  24327. * A help function to create a joint
  24328. * @param otherImpostor A physics imposter used to create a joint
  24329. * @param jointType The type of joint
  24330. * @param jointData The data for the joint
  24331. * @returns The physics imposter
  24332. */
  24333. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24334. /**
  24335. * Add a joint to this impostor with a different impostor
  24336. * @param otherImpostor A physics imposter used to add a joint
  24337. * @param joint The joint to add
  24338. * @returns The physics imposter
  24339. */
  24340. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24341. /**
  24342. * Add an anchor to a cloth impostor
  24343. * @param otherImpostor rigid impostor to anchor to
  24344. * @param width ratio across width from 0 to 1
  24345. * @param height ratio up height from 0 to 1
  24346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24347. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24348. * @returns impostor the soft imposter
  24349. */
  24350. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24351. /**
  24352. * Add a hook to a rope impostor
  24353. * @param otherImpostor rigid impostor to anchor to
  24354. * @param length ratio across rope from 0 to 1
  24355. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24357. * @returns impostor the rope imposter
  24358. */
  24359. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24360. /**
  24361. * Will keep this body still, in a sleep mode.
  24362. * @returns the physics imposter
  24363. */
  24364. sleep(): PhysicsImpostor;
  24365. /**
  24366. * Wake the body up.
  24367. * @returns The physics imposter
  24368. */
  24369. wakeUp(): PhysicsImpostor;
  24370. /**
  24371. * Clones the physics imposter
  24372. * @param newObject The physics imposter clones to this physics-enabled object
  24373. * @returns A nullable physics imposter
  24374. */
  24375. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24376. /**
  24377. * Disposes the physics imposter
  24378. */
  24379. dispose(): void;
  24380. /**
  24381. * Sets the delta position
  24382. * @param position The delta position amount
  24383. */
  24384. setDeltaPosition(position: Vector3): void;
  24385. /**
  24386. * Sets the delta rotation
  24387. * @param rotation The delta rotation amount
  24388. */
  24389. setDeltaRotation(rotation: Quaternion): void;
  24390. /**
  24391. * Gets the box size of the physics imposter and stores the result in the input parameter
  24392. * @param result Stores the box size
  24393. * @returns The physics imposter
  24394. */
  24395. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24396. /**
  24397. * Gets the radius of the physics imposter
  24398. * @returns Radius of the physics imposter
  24399. */
  24400. getRadius(): number;
  24401. /**
  24402. * Sync a bone with this impostor
  24403. * @param bone The bone to sync to the impostor.
  24404. * @param boneMesh The mesh that the bone is influencing.
  24405. * @param jointPivot The pivot of the joint / bone in local space.
  24406. * @param distToJoint Optional distance from the impostor to the joint.
  24407. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24408. */
  24409. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24410. /**
  24411. * Sync impostor to a bone
  24412. * @param bone The bone that the impostor will be synced to.
  24413. * @param boneMesh The mesh that the bone is influencing.
  24414. * @param jointPivot The pivot of the joint / bone in local space.
  24415. * @param distToJoint Optional distance from the impostor to the joint.
  24416. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24417. * @param boneAxis Optional vector3 axis the bone is aligned with
  24418. */
  24419. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24420. /**
  24421. * No-Imposter type
  24422. */
  24423. static NoImpostor: number;
  24424. /**
  24425. * Sphere-Imposter type
  24426. */
  24427. static SphereImpostor: number;
  24428. /**
  24429. * Box-Imposter type
  24430. */
  24431. static BoxImpostor: number;
  24432. /**
  24433. * Plane-Imposter type
  24434. */
  24435. static PlaneImpostor: number;
  24436. /**
  24437. * Mesh-imposter type
  24438. */
  24439. static MeshImpostor: number;
  24440. /**
  24441. * Capsule-Impostor type (Ammo.js plugin only)
  24442. */
  24443. static CapsuleImpostor: number;
  24444. /**
  24445. * Cylinder-Imposter type
  24446. */
  24447. static CylinderImpostor: number;
  24448. /**
  24449. * Particle-Imposter type
  24450. */
  24451. static ParticleImpostor: number;
  24452. /**
  24453. * Heightmap-Imposter type
  24454. */
  24455. static HeightmapImpostor: number;
  24456. /**
  24457. * ConvexHull-Impostor type (Ammo.js plugin only)
  24458. */
  24459. static ConvexHullImpostor: number;
  24460. /**
  24461. * Custom-Imposter type (Ammo.js plugin only)
  24462. */
  24463. static CustomImpostor: number;
  24464. /**
  24465. * Rope-Imposter type
  24466. */
  24467. static RopeImpostor: number;
  24468. /**
  24469. * Cloth-Imposter type
  24470. */
  24471. static ClothImpostor: number;
  24472. /**
  24473. * Softbody-Imposter type
  24474. */
  24475. static SoftbodyImpostor: number;
  24476. }
  24477. }
  24478. declare module "babylonjs/Meshes/mesh" {
  24479. import { Observable } from "babylonjs/Misc/observable";
  24480. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24481. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24482. import { Camera } from "babylonjs/Cameras/camera";
  24483. import { Scene } from "babylonjs/scene";
  24484. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24485. import { Color4 } from "babylonjs/Maths/math.color";
  24486. import { Engine } from "babylonjs/Engines/engine";
  24487. import { Node } from "babylonjs/node";
  24488. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24489. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24490. import { Buffer } from "babylonjs/Meshes/buffer";
  24491. import { Geometry } from "babylonjs/Meshes/geometry";
  24492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24493. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24494. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24495. import { Effect } from "babylonjs/Materials/effect";
  24496. import { Material } from "babylonjs/Materials/material";
  24497. import { Skeleton } from "babylonjs/Bones/skeleton";
  24498. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24499. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24500. import { Path3D } from "babylonjs/Maths/math.path";
  24501. import { Plane } from "babylonjs/Maths/math.plane";
  24502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24503. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24504. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24505. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24506. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24507. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24508. /**
  24509. * @hidden
  24510. **/
  24511. export class _CreationDataStorage {
  24512. closePath?: boolean;
  24513. closeArray?: boolean;
  24514. idx: number[];
  24515. dashSize: number;
  24516. gapSize: number;
  24517. path3D: Path3D;
  24518. pathArray: Vector3[][];
  24519. arc: number;
  24520. radius: number;
  24521. cap: number;
  24522. tessellation: number;
  24523. }
  24524. /**
  24525. * @hidden
  24526. **/
  24527. class _InstanceDataStorage {
  24528. visibleInstances: any;
  24529. batchCache: _InstancesBatch;
  24530. instancesBufferSize: number;
  24531. instancesBuffer: Nullable<Buffer>;
  24532. instancesData: Float32Array;
  24533. overridenInstanceCount: number;
  24534. isFrozen: boolean;
  24535. previousBatch: Nullable<_InstancesBatch>;
  24536. hardwareInstancedRendering: boolean;
  24537. sideOrientation: number;
  24538. manualUpdate: boolean;
  24539. }
  24540. /**
  24541. * @hidden
  24542. **/
  24543. export class _InstancesBatch {
  24544. mustReturn: boolean;
  24545. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24546. renderSelf: boolean[];
  24547. hardwareInstancedRendering: boolean[];
  24548. }
  24549. /**
  24550. * Class used to represent renderable models
  24551. */
  24552. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24553. /**
  24554. * Mesh side orientation : usually the external or front surface
  24555. */
  24556. static readonly FRONTSIDE: number;
  24557. /**
  24558. * Mesh side orientation : usually the internal or back surface
  24559. */
  24560. static readonly BACKSIDE: number;
  24561. /**
  24562. * Mesh side orientation : both internal and external or front and back surfaces
  24563. */
  24564. static readonly DOUBLESIDE: number;
  24565. /**
  24566. * Mesh side orientation : by default, `FRONTSIDE`
  24567. */
  24568. static readonly DEFAULTSIDE: number;
  24569. /**
  24570. * Mesh cap setting : no cap
  24571. */
  24572. static readonly NO_CAP: number;
  24573. /**
  24574. * Mesh cap setting : one cap at the beginning of the mesh
  24575. */
  24576. static readonly CAP_START: number;
  24577. /**
  24578. * Mesh cap setting : one cap at the end of the mesh
  24579. */
  24580. static readonly CAP_END: number;
  24581. /**
  24582. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24583. */
  24584. static readonly CAP_ALL: number;
  24585. /**
  24586. * Mesh pattern setting : no flip or rotate
  24587. */
  24588. static readonly NO_FLIP: number;
  24589. /**
  24590. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24591. */
  24592. static readonly FLIP_TILE: number;
  24593. /**
  24594. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24595. */
  24596. static readonly ROTATE_TILE: number;
  24597. /**
  24598. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24599. */
  24600. static readonly FLIP_ROW: number;
  24601. /**
  24602. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24603. */
  24604. static readonly ROTATE_ROW: number;
  24605. /**
  24606. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24607. */
  24608. static readonly FLIP_N_ROTATE_TILE: number;
  24609. /**
  24610. * Mesh pattern setting : rotate pattern and rotate
  24611. */
  24612. static readonly FLIP_N_ROTATE_ROW: number;
  24613. /**
  24614. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24615. */
  24616. static readonly CENTER: number;
  24617. /**
  24618. * Mesh tile positioning : part tiles on left
  24619. */
  24620. static readonly LEFT: number;
  24621. /**
  24622. * Mesh tile positioning : part tiles on right
  24623. */
  24624. static readonly RIGHT: number;
  24625. /**
  24626. * Mesh tile positioning : part tiles on top
  24627. */
  24628. static readonly TOP: number;
  24629. /**
  24630. * Mesh tile positioning : part tiles on bottom
  24631. */
  24632. static readonly BOTTOM: number;
  24633. /**
  24634. * Gets the default side orientation.
  24635. * @param orientation the orientation to value to attempt to get
  24636. * @returns the default orientation
  24637. * @hidden
  24638. */
  24639. static _GetDefaultSideOrientation(orientation?: number): number;
  24640. private _internalMeshDataInfo;
  24641. /**
  24642. * An event triggered before rendering the mesh
  24643. */
  24644. readonly onBeforeRenderObservable: Observable<Mesh>;
  24645. /**
  24646. * An event triggered before binding the mesh
  24647. */
  24648. readonly onBeforeBindObservable: Observable<Mesh>;
  24649. /**
  24650. * An event triggered after rendering the mesh
  24651. */
  24652. readonly onAfterRenderObservable: Observable<Mesh>;
  24653. /**
  24654. * An event triggered before drawing the mesh
  24655. */
  24656. readonly onBeforeDrawObservable: Observable<Mesh>;
  24657. private _onBeforeDrawObserver;
  24658. /**
  24659. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24660. */
  24661. onBeforeDraw: () => void;
  24662. readonly hasInstances: boolean;
  24663. /**
  24664. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24665. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24666. */
  24667. delayLoadState: number;
  24668. /**
  24669. * Gets the list of instances created from this mesh
  24670. * it is not supposed to be modified manually.
  24671. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24672. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24673. */
  24674. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24675. /**
  24676. * Gets the file containing delay loading data for this mesh
  24677. */
  24678. delayLoadingFile: string;
  24679. /** @hidden */
  24680. _binaryInfo: any;
  24681. /**
  24682. * User defined function used to change how LOD level selection is done
  24683. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24684. */
  24685. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24686. /**
  24687. * Gets or sets the morph target manager
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24689. */
  24690. morphTargetManager: Nullable<MorphTargetManager>;
  24691. /** @hidden */
  24692. _creationDataStorage: Nullable<_CreationDataStorage>;
  24693. /** @hidden */
  24694. _geometry: Nullable<Geometry>;
  24695. /** @hidden */
  24696. _delayInfo: Array<string>;
  24697. /** @hidden */
  24698. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24699. /** @hidden */
  24700. _instanceDataStorage: _InstanceDataStorage;
  24701. private _effectiveMaterial;
  24702. /** @hidden */
  24703. _shouldGenerateFlatShading: boolean;
  24704. /** @hidden */
  24705. _originalBuilderSideOrientation: number;
  24706. /**
  24707. * Use this property to change the original side orientation defined at construction time
  24708. */
  24709. overrideMaterialSideOrientation: Nullable<number>;
  24710. /**
  24711. * Gets the source mesh (the one used to clone this one from)
  24712. */
  24713. readonly source: Nullable<Mesh>;
  24714. /**
  24715. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24716. */
  24717. isUnIndexed: boolean;
  24718. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24719. readonly worldMatrixInstancedBuffer: Float32Array;
  24720. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24721. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24722. /**
  24723. * @constructor
  24724. * @param name The value used by scene.getMeshByName() to do a lookup.
  24725. * @param scene The scene to add this mesh to.
  24726. * @param parent The parent of this mesh, if it has one
  24727. * @param source An optional Mesh from which geometry is shared, cloned.
  24728. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24729. * When false, achieved by calling a clone(), also passing False.
  24730. * This will make creation of children, recursive.
  24731. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24732. */
  24733. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24734. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24735. doNotInstantiate: boolean;
  24736. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24737. /**
  24738. * Gets the class name
  24739. * @returns the string "Mesh".
  24740. */
  24741. getClassName(): string;
  24742. /** @hidden */
  24743. readonly _isMesh: boolean;
  24744. /**
  24745. * Returns a description of this mesh
  24746. * @param fullDetails define if full details about this mesh must be used
  24747. * @returns a descriptive string representing this mesh
  24748. */
  24749. toString(fullDetails?: boolean): string;
  24750. /** @hidden */
  24751. _unBindEffect(): void;
  24752. /**
  24753. * Gets a boolean indicating if this mesh has LOD
  24754. */
  24755. readonly hasLODLevels: boolean;
  24756. /**
  24757. * Gets the list of MeshLODLevel associated with the current mesh
  24758. * @returns an array of MeshLODLevel
  24759. */
  24760. getLODLevels(): MeshLODLevel[];
  24761. private _sortLODLevels;
  24762. /**
  24763. * Add a mesh as LOD level triggered at the given distance.
  24764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24765. * @param distance The distance from the center of the object to show this level
  24766. * @param mesh The mesh to be added as LOD level (can be null)
  24767. * @return This mesh (for chaining)
  24768. */
  24769. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24770. /**
  24771. * Returns the LOD level mesh at the passed distance or null if not found.
  24772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24773. * @param distance The distance from the center of the object to show this level
  24774. * @returns a Mesh or `null`
  24775. */
  24776. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24777. /**
  24778. * Remove a mesh from the LOD array
  24779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24780. * @param mesh defines the mesh to be removed
  24781. * @return This mesh (for chaining)
  24782. */
  24783. removeLODLevel(mesh: Mesh): Mesh;
  24784. /**
  24785. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24786. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24787. * @param camera defines the camera to use to compute distance
  24788. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24789. * @return This mesh (for chaining)
  24790. */
  24791. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24792. /**
  24793. * Gets the mesh internal Geometry object
  24794. */
  24795. readonly geometry: Nullable<Geometry>;
  24796. /**
  24797. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24798. * @returns the total number of vertices
  24799. */
  24800. getTotalVertices(): number;
  24801. /**
  24802. * Returns the content of an associated vertex buffer
  24803. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24804. * - VertexBuffer.PositionKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @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
  24817. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24818. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24819. */
  24820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24821. /**
  24822. * Returns the mesh VertexBuffer object from the requested `kind`
  24823. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24824. * - VertexBuffer.PositionKind
  24825. * - VertexBuffer.NormalKind
  24826. * - VertexBuffer.UVKind
  24827. * - VertexBuffer.UV2Kind
  24828. * - VertexBuffer.UV3Kind
  24829. * - VertexBuffer.UV4Kind
  24830. * - VertexBuffer.UV5Kind
  24831. * - VertexBuffer.UV6Kind
  24832. * - VertexBuffer.ColorKind
  24833. * - VertexBuffer.MatricesIndicesKind
  24834. * - VertexBuffer.MatricesIndicesExtraKind
  24835. * - VertexBuffer.MatricesWeightsKind
  24836. * - VertexBuffer.MatricesWeightsExtraKind
  24837. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24838. */
  24839. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24840. /**
  24841. * Tests if a specific vertex buffer is associated with this mesh
  24842. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24843. * - VertexBuffer.PositionKind
  24844. * - VertexBuffer.NormalKind
  24845. * - VertexBuffer.UVKind
  24846. * - VertexBuffer.UV2Kind
  24847. * - VertexBuffer.UV3Kind
  24848. * - VertexBuffer.UV4Kind
  24849. * - VertexBuffer.UV5Kind
  24850. * - VertexBuffer.UV6Kind
  24851. * - VertexBuffer.ColorKind
  24852. * - VertexBuffer.MatricesIndicesKind
  24853. * - VertexBuffer.MatricesIndicesExtraKind
  24854. * - VertexBuffer.MatricesWeightsKind
  24855. * - VertexBuffer.MatricesWeightsExtraKind
  24856. * @returns a boolean
  24857. */
  24858. isVerticesDataPresent(kind: string): boolean;
  24859. /**
  24860. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24861. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24862. * - VertexBuffer.PositionKind
  24863. * - VertexBuffer.UVKind
  24864. * - VertexBuffer.UV2Kind
  24865. * - VertexBuffer.UV3Kind
  24866. * - VertexBuffer.UV4Kind
  24867. * - VertexBuffer.UV5Kind
  24868. * - VertexBuffer.UV6Kind
  24869. * - VertexBuffer.ColorKind
  24870. * - VertexBuffer.MatricesIndicesKind
  24871. * - VertexBuffer.MatricesIndicesExtraKind
  24872. * - VertexBuffer.MatricesWeightsKind
  24873. * - VertexBuffer.MatricesWeightsExtraKind
  24874. * @returns a boolean
  24875. */
  24876. isVertexBufferUpdatable(kind: string): boolean;
  24877. /**
  24878. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24879. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24880. * - VertexBuffer.PositionKind
  24881. * - VertexBuffer.NormalKind
  24882. * - VertexBuffer.UVKind
  24883. * - VertexBuffer.UV2Kind
  24884. * - VertexBuffer.UV3Kind
  24885. * - VertexBuffer.UV4Kind
  24886. * - VertexBuffer.UV5Kind
  24887. * - VertexBuffer.UV6Kind
  24888. * - VertexBuffer.ColorKind
  24889. * - VertexBuffer.MatricesIndicesKind
  24890. * - VertexBuffer.MatricesIndicesExtraKind
  24891. * - VertexBuffer.MatricesWeightsKind
  24892. * - VertexBuffer.MatricesWeightsExtraKind
  24893. * @returns an array of strings
  24894. */
  24895. getVerticesDataKinds(): string[];
  24896. /**
  24897. * Returns a positive integer : the total number of indices in this mesh geometry.
  24898. * @returns the numner of indices or zero if the mesh has no geometry.
  24899. */
  24900. getTotalIndices(): number;
  24901. /**
  24902. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24903. * @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.
  24904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24905. * @returns the indices array or an empty array if the mesh has no geometry
  24906. */
  24907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24908. readonly isBlocked: boolean;
  24909. /**
  24910. * Determine if the current mesh is ready to be rendered
  24911. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24912. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24913. * @returns true if all associated assets are ready (material, textures, shaders)
  24914. */
  24915. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24916. /**
  24917. * 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.
  24918. */
  24919. readonly areNormalsFrozen: boolean;
  24920. /**
  24921. * 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.
  24922. * @returns the current mesh
  24923. */
  24924. freezeNormals(): Mesh;
  24925. /**
  24926. * 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
  24927. * @returns the current mesh
  24928. */
  24929. unfreezeNormals(): Mesh;
  24930. /**
  24931. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24932. */
  24933. overridenInstanceCount: number;
  24934. /** @hidden */
  24935. _preActivate(): Mesh;
  24936. /** @hidden */
  24937. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24938. /** @hidden */
  24939. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24940. /**
  24941. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24942. * This means the mesh underlying bounding box and sphere are recomputed.
  24943. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24944. * @returns the current mesh
  24945. */
  24946. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24947. /** @hidden */
  24948. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24949. /**
  24950. * This function will subdivide the mesh into multiple submeshes
  24951. * @param count defines the expected number of submeshes
  24952. */
  24953. subdivide(count: number): void;
  24954. /**
  24955. * Copy a FloatArray into a specific associated vertex buffer
  24956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24957. * - VertexBuffer.PositionKind
  24958. * - VertexBuffer.UVKind
  24959. * - VertexBuffer.UV2Kind
  24960. * - VertexBuffer.UV3Kind
  24961. * - VertexBuffer.UV4Kind
  24962. * - VertexBuffer.UV5Kind
  24963. * - VertexBuffer.UV6Kind
  24964. * - VertexBuffer.ColorKind
  24965. * - VertexBuffer.MatricesIndicesKind
  24966. * - VertexBuffer.MatricesIndicesExtraKind
  24967. * - VertexBuffer.MatricesWeightsKind
  24968. * - VertexBuffer.MatricesWeightsExtraKind
  24969. * @param data defines the data source
  24970. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24971. * @param stride defines the data stride size (can be null)
  24972. * @returns the current mesh
  24973. */
  24974. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24975. /**
  24976. * Delete a vertex buffer associated with this mesh
  24977. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24978. * - VertexBuffer.PositionKind
  24979. * - VertexBuffer.UVKind
  24980. * - VertexBuffer.UV2Kind
  24981. * - VertexBuffer.UV3Kind
  24982. * - VertexBuffer.UV4Kind
  24983. * - VertexBuffer.UV5Kind
  24984. * - VertexBuffer.UV6Kind
  24985. * - VertexBuffer.ColorKind
  24986. * - VertexBuffer.MatricesIndicesKind
  24987. * - VertexBuffer.MatricesIndicesExtraKind
  24988. * - VertexBuffer.MatricesWeightsKind
  24989. * - VertexBuffer.MatricesWeightsExtraKind
  24990. */
  24991. removeVerticesData(kind: string): void;
  24992. /**
  24993. * Flags an associated vertex buffer as updatable
  24994. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24995. * - VertexBuffer.PositionKind
  24996. * - VertexBuffer.UVKind
  24997. * - VertexBuffer.UV2Kind
  24998. * - VertexBuffer.UV3Kind
  24999. * - VertexBuffer.UV4Kind
  25000. * - VertexBuffer.UV5Kind
  25001. * - VertexBuffer.UV6Kind
  25002. * - VertexBuffer.ColorKind
  25003. * - VertexBuffer.MatricesIndicesKind
  25004. * - VertexBuffer.MatricesIndicesExtraKind
  25005. * - VertexBuffer.MatricesWeightsKind
  25006. * - VertexBuffer.MatricesWeightsExtraKind
  25007. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25008. */
  25009. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25010. /**
  25011. * Sets the mesh global Vertex Buffer
  25012. * @param buffer defines the buffer to use
  25013. * @returns the current mesh
  25014. */
  25015. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25016. /**
  25017. * Update a specific associated vertex buffer
  25018. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25019. * - VertexBuffer.PositionKind
  25020. * - VertexBuffer.UVKind
  25021. * - VertexBuffer.UV2Kind
  25022. * - VertexBuffer.UV3Kind
  25023. * - VertexBuffer.UV4Kind
  25024. * - VertexBuffer.UV5Kind
  25025. * - VertexBuffer.UV6Kind
  25026. * - VertexBuffer.ColorKind
  25027. * - VertexBuffer.MatricesIndicesKind
  25028. * - VertexBuffer.MatricesIndicesExtraKind
  25029. * - VertexBuffer.MatricesWeightsKind
  25030. * - VertexBuffer.MatricesWeightsExtraKind
  25031. * @param data defines the data source
  25032. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25033. * @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)
  25034. * @returns the current mesh
  25035. */
  25036. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25037. /**
  25038. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25039. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25040. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25041. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25042. * @returns the current mesh
  25043. */
  25044. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25045. /**
  25046. * Creates a un-shared specific occurence of the geometry for the mesh.
  25047. * @returns the current mesh
  25048. */
  25049. makeGeometryUnique(): Mesh;
  25050. /**
  25051. * Set the index buffer of this mesh
  25052. * @param indices defines the source data
  25053. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25054. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25055. * @returns the current mesh
  25056. */
  25057. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25058. /**
  25059. * Update the current index buffer
  25060. * @param indices defines the source data
  25061. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25062. * @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)
  25063. * @returns the current mesh
  25064. */
  25065. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25066. /**
  25067. * Invert the geometry to move from a right handed system to a left handed one.
  25068. * @returns the current mesh
  25069. */
  25070. toLeftHanded(): Mesh;
  25071. /** @hidden */
  25072. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25073. /** @hidden */
  25074. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25075. /**
  25076. * Registers for this mesh a javascript function called just before the rendering process
  25077. * @param func defines the function to call before rendering this mesh
  25078. * @returns the current mesh
  25079. */
  25080. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25081. /**
  25082. * Disposes a previously registered javascript function called before the rendering
  25083. * @param func defines the function to remove
  25084. * @returns the current mesh
  25085. */
  25086. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25087. /**
  25088. * Registers for this mesh a javascript function called just after the rendering is complete
  25089. * @param func defines the function to call after rendering this mesh
  25090. * @returns the current mesh
  25091. */
  25092. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25093. /**
  25094. * Disposes a previously registered javascript function called after the rendering.
  25095. * @param func defines the function to remove
  25096. * @returns the current mesh
  25097. */
  25098. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25099. /** @hidden */
  25100. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25101. /** @hidden */
  25102. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25103. /** @hidden */
  25104. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25105. /** @hidden */
  25106. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25107. /** @hidden */
  25108. _rebuild(): void;
  25109. /** @hidden */
  25110. _freeze(): void;
  25111. /** @hidden */
  25112. _unFreeze(): void;
  25113. /**
  25114. * 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
  25115. * @param subMesh defines the subMesh to render
  25116. * @param enableAlphaMode defines if alpha mode can be changed
  25117. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25118. * @returns the current mesh
  25119. */
  25120. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25121. private _onBeforeDraw;
  25122. /**
  25123. * Renormalize the mesh and patch it up if there are no weights
  25124. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25125. * However in the case of zero weights then we set just a single influence to 1.
  25126. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25127. */
  25128. cleanMatrixWeights(): void;
  25129. private normalizeSkinFourWeights;
  25130. private normalizeSkinWeightsAndExtra;
  25131. /**
  25132. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25133. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25134. * the user know there was an issue with importing the mesh
  25135. * @returns a validation object with skinned, valid and report string
  25136. */
  25137. validateSkinning(): {
  25138. skinned: boolean;
  25139. valid: boolean;
  25140. report: string;
  25141. };
  25142. /** @hidden */
  25143. _checkDelayState(): Mesh;
  25144. private _queueLoad;
  25145. /**
  25146. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25147. * A mesh is in the frustum if its bounding box intersects the frustum
  25148. * @param frustumPlanes defines the frustum to test
  25149. * @returns true if the mesh is in the frustum planes
  25150. */
  25151. isInFrustum(frustumPlanes: Plane[]): boolean;
  25152. /**
  25153. * Sets the mesh material by the material or multiMaterial `id` property
  25154. * @param id is a string identifying the material or the multiMaterial
  25155. * @returns the current mesh
  25156. */
  25157. setMaterialByID(id: string): Mesh;
  25158. /**
  25159. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25160. * @returns an array of IAnimatable
  25161. */
  25162. getAnimatables(): IAnimatable[];
  25163. /**
  25164. * Modifies the mesh geometry according to the passed transformation matrix.
  25165. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25166. * The mesh normals are modified using the same transformation.
  25167. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25168. * @param transform defines the transform matrix to use
  25169. * @see http://doc.babylonjs.com/resources/baking_transformations
  25170. * @returns the current mesh
  25171. */
  25172. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25173. /**
  25174. * Modifies the mesh geometry according to its own current World Matrix.
  25175. * The mesh World Matrix is then reset.
  25176. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25177. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25178. * @see http://doc.babylonjs.com/resources/baking_transformations
  25179. * @returns the current mesh
  25180. */
  25181. bakeCurrentTransformIntoVertices(): Mesh;
  25182. /** @hidden */
  25183. readonly _positions: Nullable<Vector3[]>;
  25184. /** @hidden */
  25185. _resetPointsArrayCache(): Mesh;
  25186. /** @hidden */
  25187. _generatePointsArray(): boolean;
  25188. /**
  25189. * Returns a new Mesh object generated from the current mesh properties.
  25190. * This method must not get confused with createInstance()
  25191. * @param name is a string, the name given to the new mesh
  25192. * @param newParent can be any Node object (default `null`)
  25193. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25194. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25195. * @returns a new mesh
  25196. */
  25197. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25198. /**
  25199. * Releases resources associated with this mesh.
  25200. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25201. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25202. */
  25203. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25204. /** @hidden */
  25205. _disposeInstanceSpecificData(): void;
  25206. /**
  25207. * Modifies the mesh geometry according to a displacement map.
  25208. * 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.
  25209. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25210. * @param url is a string, the URL from the image file is to be downloaded.
  25211. * @param minHeight is the lower limit of the displacement.
  25212. * @param maxHeight is the upper limit of the displacement.
  25213. * @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.
  25214. * @param uvOffset is an optional vector2 used to offset UV.
  25215. * @param uvScale is an optional vector2 used to scale UV.
  25216. * @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.
  25217. * @returns the Mesh.
  25218. */
  25219. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25220. /**
  25221. * Modifies the mesh geometry according to a displacementMap buffer.
  25222. * 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.
  25223. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25224. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25225. * @param heightMapWidth is the width of the buffer image.
  25226. * @param heightMapHeight is the height of the buffer image.
  25227. * @param minHeight is the lower limit of the displacement.
  25228. * @param maxHeight is the upper limit of the displacement.
  25229. * @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.
  25230. * @param uvOffset is an optional vector2 used to offset UV.
  25231. * @param uvScale is an optional vector2 used to scale UV.
  25232. * @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.
  25233. * @returns the Mesh.
  25234. */
  25235. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25236. /**
  25237. * Modify the mesh to get a flat shading rendering.
  25238. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25239. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25240. * @returns current mesh
  25241. */
  25242. convertToFlatShadedMesh(): Mesh;
  25243. /**
  25244. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25245. * In other words, more vertices, no more indices and a single bigger VBO.
  25246. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25247. * @returns current mesh
  25248. */
  25249. convertToUnIndexedMesh(): Mesh;
  25250. /**
  25251. * Inverses facet orientations.
  25252. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25253. * @param flipNormals will also inverts the normals
  25254. * @returns current mesh
  25255. */
  25256. flipFaces(flipNormals?: boolean): Mesh;
  25257. /**
  25258. * Increase the number of facets and hence vertices in a mesh
  25259. * Vertex normals are interpolated from existing vertex normals
  25260. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25261. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25262. */
  25263. increaseVertices(numberPerEdge: number): void;
  25264. /**
  25265. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25266. * This will undo any application of covertToFlatShadedMesh
  25267. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25268. */
  25269. forceSharedVertices(): void;
  25270. /** @hidden */
  25271. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25272. /** @hidden */
  25273. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25274. /**
  25275. * Creates a new InstancedMesh object from the mesh model.
  25276. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25277. * @param name defines the name of the new instance
  25278. * @returns a new InstancedMesh
  25279. */
  25280. createInstance(name: string): InstancedMesh;
  25281. /**
  25282. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25283. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25284. * @returns the current mesh
  25285. */
  25286. synchronizeInstances(): Mesh;
  25287. /**
  25288. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25289. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25290. * This should be used together with the simplification to avoid disappearing triangles.
  25291. * @param successCallback an optional success callback to be called after the optimization finished.
  25292. * @returns the current mesh
  25293. */
  25294. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25295. /**
  25296. * Serialize current mesh
  25297. * @param serializationObject defines the object which will receive the serialization data
  25298. */
  25299. serialize(serializationObject: any): void;
  25300. /** @hidden */
  25301. _syncGeometryWithMorphTargetManager(): void;
  25302. /** @hidden */
  25303. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25304. /**
  25305. * Returns a new Mesh object parsed from the source provided.
  25306. * @param parsedMesh is the source
  25307. * @param scene defines the hosting scene
  25308. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25309. * @returns a new Mesh
  25310. */
  25311. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25312. /**
  25313. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25314. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25315. * @param name defines the name of the mesh to create
  25316. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25317. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25318. * @param closePath creates a seam between the first and the last points of each path of the path array
  25319. * @param offset is taken in account only if the `pathArray` is containing a single path
  25320. * @param scene defines the hosting scene
  25321. * @param updatable defines if the mesh must be flagged as updatable
  25322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25323. * @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)
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25327. /**
  25328. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25329. * @param name defines the name of the mesh to create
  25330. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25331. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25338. /**
  25339. * Creates a box 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 size sets the size (float) of each box side (default 1)
  25342. * @param scene defines the hosting scene
  25343. * @param updatable defines if the mesh must be flagged as updatable
  25344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25345. * @returns a new Mesh
  25346. */
  25347. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25348. /**
  25349. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25352. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25353. * @param scene defines the hosting scene
  25354. * @param updatable defines if the mesh must be flagged as updatable
  25355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25356. * @returns a new Mesh
  25357. */
  25358. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25359. /**
  25360. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25361. * @param name defines the name of the mesh to create
  25362. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25363. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25364. * @param scene defines the hosting scene
  25365. * @returns a new Mesh
  25366. */
  25367. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25368. /**
  25369. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25370. * @param name defines the name of the mesh to create
  25371. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25372. * @param diameterTop set the top cap diameter (floats, default 1)
  25373. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25374. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25375. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25376. * @param scene defines the hosting scene
  25377. * @param updatable defines if the mesh must be flagged as updatable
  25378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25379. * @returns a new Mesh
  25380. */
  25381. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25382. /**
  25383. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25384. * @param name defines the name of the mesh to create
  25385. * @param diameter sets the diameter size (float) of the torus (default 1)
  25386. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25387. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25388. * @param scene defines the hosting scene
  25389. * @param updatable defines if the mesh must be flagged as updatable
  25390. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25391. * @returns a new Mesh
  25392. */
  25393. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25394. /**
  25395. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25396. * @param name defines the name of the mesh to create
  25397. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25398. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25399. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25400. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25401. * @param p the number of windings on X axis (positive integers, default 2)
  25402. * @param q the number of windings on Y axis (positive integers, default 3)
  25403. * @param scene defines the hosting scene
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @returns a new Mesh
  25407. */
  25408. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25409. /**
  25410. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25411. * @param name defines the name of the mesh to create
  25412. * @param points is an array successive Vector3
  25413. * @param scene defines the hosting scene
  25414. * @param updatable defines if the mesh must be flagged as updatable
  25415. * @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).
  25416. * @returns a new Mesh
  25417. */
  25418. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25419. /**
  25420. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25421. * @param name defines the name of the mesh to create
  25422. * @param points is an array successive Vector3
  25423. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25424. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25425. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25426. * @param scene defines the hosting scene
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @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)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25432. /**
  25433. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25434. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25435. * 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.
  25436. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25437. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25438. * Remember you can only change the shape positions, not their number when updating a polygon.
  25439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25440. * @param name defines the name of the mesh to create
  25441. * @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
  25442. * @param scene defines the hosting scene
  25443. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25444. * @param updatable defines if the mesh must be flagged as updatable
  25445. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25446. * @param earcutInjection can be used to inject your own earcut reference
  25447. * @returns a new Mesh
  25448. */
  25449. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25450. /**
  25451. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25453. * @param name defines the name of the mesh to create
  25454. * @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
  25455. * @param depth defines the height of extrusion
  25456. * @param scene defines the hosting scene
  25457. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25458. * @param updatable defines if the mesh must be flagged as updatable
  25459. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25460. * @param earcutInjection can be used to inject your own earcut reference
  25461. * @returns a new Mesh
  25462. */
  25463. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25464. /**
  25465. * Creates an extruded shape mesh.
  25466. * 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
  25467. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25468. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25469. * @param name defines the name of the mesh to create
  25470. * @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
  25471. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25472. * @param scale is the value to scale the shape
  25473. * @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
  25474. * @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
  25475. * @param scene defines the hosting scene
  25476. * @param updatable defines if the mesh must be flagged as updatable
  25477. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25478. * @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)
  25479. * @returns a new Mesh
  25480. */
  25481. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25482. /**
  25483. * Creates an custom extruded shape mesh.
  25484. * The custom extrusion is a parametric shape.
  25485. * It has no predefined shape. Its final shape will depend on the input parameters.
  25486. * Please consider using the same method from the MeshBuilder class instead
  25487. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25488. * @param name defines the name of the mesh to create
  25489. * @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
  25490. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25491. * @param scaleFunction is a custom Javascript function called on each path point
  25492. * @param rotationFunction is a custom Javascript function called on each path point
  25493. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25494. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25495. * @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
  25496. * @param scene defines the hosting scene
  25497. * @param updatable defines if the mesh must be flagged as updatable
  25498. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25499. * @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)
  25500. * @returns a new Mesh
  25501. */
  25502. 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;
  25503. /**
  25504. * Creates lathe mesh.
  25505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25506. * Please consider using the same method from the MeshBuilder class instead
  25507. * @param name defines the name of the mesh to create
  25508. * @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
  25509. * @param radius is the radius value of the lathe
  25510. * @param tessellation is the side number of the lathe.
  25511. * @param scene defines the hosting scene
  25512. * @param updatable defines if the mesh must be flagged as updatable
  25513. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25514. * @returns a new Mesh
  25515. */
  25516. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25517. /**
  25518. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25519. * @param name defines the name of the mesh to create
  25520. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25521. * @param scene defines the hosting scene
  25522. * @param updatable defines if the mesh must be flagged as updatable
  25523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25524. * @returns a new Mesh
  25525. */
  25526. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25527. /**
  25528. * Creates a ground mesh.
  25529. * Please consider using the same method from the MeshBuilder class instead
  25530. * @param name defines the name of the mesh to create
  25531. * @param width set the width of the ground
  25532. * @param height set the height of the ground
  25533. * @param subdivisions sets the number of subdivisions per side
  25534. * @param scene defines the hosting scene
  25535. * @param updatable defines if the mesh must be flagged as updatable
  25536. * @returns a new Mesh
  25537. */
  25538. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25539. /**
  25540. * Creates a tiled ground mesh.
  25541. * Please consider using the same method from the MeshBuilder class instead
  25542. * @param name defines the name of the mesh to create
  25543. * @param xmin set the ground minimum X coordinate
  25544. * @param zmin set the ground minimum Y coordinate
  25545. * @param xmax set the ground maximum X coordinate
  25546. * @param zmax set the ground maximum Z coordinate
  25547. * @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
  25548. * @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
  25549. * @param scene defines the hosting scene
  25550. * @param updatable defines if the mesh must be flagged as updatable
  25551. * @returns a new Mesh
  25552. */
  25553. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25554. w: number;
  25555. h: number;
  25556. }, precision: {
  25557. w: number;
  25558. h: number;
  25559. }, scene: Scene, updatable?: boolean): Mesh;
  25560. /**
  25561. * Creates a ground mesh from a height map.
  25562. * Please consider using the same method from the MeshBuilder class instead
  25563. * @see http://doc.babylonjs.com/babylon101/height_map
  25564. * @param name defines the name of the mesh to create
  25565. * @param url sets the URL of the height map image resource
  25566. * @param width set the ground width size
  25567. * @param height set the ground height size
  25568. * @param subdivisions sets the number of subdivision per side
  25569. * @param minHeight is the minimum altitude on the ground
  25570. * @param maxHeight is the maximum altitude on the ground
  25571. * @param scene defines the hosting scene
  25572. * @param updatable defines if the mesh must be flagged as updatable
  25573. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25574. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25575. * @returns a new Mesh
  25576. */
  25577. 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;
  25578. /**
  25579. * Creates a tube mesh.
  25580. * The tube is a parametric shape.
  25581. * It has no predefined shape. Its final shape will depend on the input parameters.
  25582. * Please consider using the same method from the MeshBuilder class instead
  25583. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25584. * @param name defines the name of the mesh to create
  25585. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25586. * @param radius sets the tube radius size
  25587. * @param tessellation is the number of sides on the tubular surface
  25588. * @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
  25589. * @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
  25590. * @param scene defines the hosting scene
  25591. * @param updatable defines if the mesh must be flagged as updatable
  25592. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25593. * @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)
  25594. * @returns a new Mesh
  25595. */
  25596. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25597. (i: number, distance: number): number;
  25598. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25599. /**
  25600. * Creates a polyhedron mesh.
  25601. * Please consider using the same method from the MeshBuilder class instead.
  25602. * * 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
  25603. * * The parameter `size` (positive float, default 1) sets the polygon size
  25604. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25605. * * 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`
  25606. * * 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
  25607. * * 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)`)
  25608. * * 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
  25609. * * 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
  25610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25611. * * If you create a double-sided mesh, you can choose what parts of 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
  25612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25613. * @param name defines the name of the mesh to create
  25614. * @param options defines the options used to create the mesh
  25615. * @param scene defines the hosting scene
  25616. * @returns a new Mesh
  25617. */
  25618. static CreatePolyhedron(name: string, options: {
  25619. type?: number;
  25620. size?: number;
  25621. sizeX?: number;
  25622. sizeY?: number;
  25623. sizeZ?: number;
  25624. custom?: any;
  25625. faceUV?: Vector4[];
  25626. faceColors?: Color4[];
  25627. updatable?: boolean;
  25628. sideOrientation?: number;
  25629. }, scene: Scene): Mesh;
  25630. /**
  25631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25633. * * 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`)
  25634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25635. * * 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
  25636. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25637. * * If you create a double-sided mesh, you can choose what parts of 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
  25638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25639. * @param name defines the name of the mesh
  25640. * @param options defines the options used to create the mesh
  25641. * @param scene defines the hosting scene
  25642. * @returns a new Mesh
  25643. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25644. */
  25645. static CreateIcoSphere(name: string, options: {
  25646. radius?: number;
  25647. flat?: boolean;
  25648. subdivisions?: number;
  25649. sideOrientation?: number;
  25650. updatable?: boolean;
  25651. }, scene: Scene): Mesh;
  25652. /**
  25653. * Creates a decal mesh.
  25654. * Please consider using the same method from the MeshBuilder class instead.
  25655. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25656. * @param name defines the name of the mesh
  25657. * @param sourceMesh defines the mesh receiving the decal
  25658. * @param position sets the position of the decal in world coordinates
  25659. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25660. * @param size sets the decal scaling
  25661. * @param angle sets the angle to rotate the decal
  25662. * @returns a new Mesh
  25663. */
  25664. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25665. /**
  25666. * Prepare internal position array for software CPU skinning
  25667. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25668. */
  25669. setPositionsForCPUSkinning(): Float32Array;
  25670. /**
  25671. * Prepare internal normal array for software CPU skinning
  25672. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25673. */
  25674. setNormalsForCPUSkinning(): Float32Array;
  25675. /**
  25676. * Updates the vertex buffer by applying transformation from the bones
  25677. * @param skeleton defines the skeleton to apply to current mesh
  25678. * @returns the current mesh
  25679. */
  25680. applySkeleton(skeleton: Skeleton): Mesh;
  25681. /**
  25682. * 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
  25683. * @param meshes defines the list of meshes to scan
  25684. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25685. */
  25686. static MinMax(meshes: AbstractMesh[]): {
  25687. min: Vector3;
  25688. max: Vector3;
  25689. };
  25690. /**
  25691. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25692. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25693. * @returns a vector3
  25694. */
  25695. static Center(meshesOrMinMaxVector: {
  25696. min: Vector3;
  25697. max: Vector3;
  25698. } | AbstractMesh[]): Vector3;
  25699. /**
  25700. * Merge the array of meshes into a single mesh for performance reasons.
  25701. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25702. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25703. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25704. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25705. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25706. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25707. * @returns a new mesh
  25708. */
  25709. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25710. /** @hidden */
  25711. addInstance(instance: InstancedMesh): void;
  25712. /** @hidden */
  25713. removeInstance(instance: InstancedMesh): void;
  25714. }
  25715. }
  25716. declare module "babylonjs/Cameras/camera" {
  25717. import { SmartArray } from "babylonjs/Misc/smartArray";
  25718. import { Observable } from "babylonjs/Misc/observable";
  25719. import { Nullable } from "babylonjs/types";
  25720. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25721. import { Scene } from "babylonjs/scene";
  25722. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25723. import { Node } from "babylonjs/node";
  25724. import { Mesh } from "babylonjs/Meshes/mesh";
  25725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25726. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25727. import { Viewport } from "babylonjs/Maths/math.viewport";
  25728. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25729. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25730. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25731. import { Ray } from "babylonjs/Culling/ray";
  25732. /**
  25733. * This is the base class of all the camera used in the application.
  25734. * @see http://doc.babylonjs.com/features/cameras
  25735. */
  25736. export class Camera extends Node {
  25737. /** @hidden */
  25738. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25739. /**
  25740. * This is the default projection mode used by the cameras.
  25741. * It helps recreating a feeling of perspective and better appreciate depth.
  25742. * This is the best way to simulate real life cameras.
  25743. */
  25744. static readonly PERSPECTIVE_CAMERA: number;
  25745. /**
  25746. * This helps creating camera with an orthographic mode.
  25747. * 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.
  25748. */
  25749. static readonly ORTHOGRAPHIC_CAMERA: number;
  25750. /**
  25751. * This is the default FOV mode for perspective cameras.
  25752. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25753. */
  25754. static readonly FOVMODE_VERTICAL_FIXED: number;
  25755. /**
  25756. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25757. */
  25758. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25759. /**
  25760. * This specifies ther is no need for a camera rig.
  25761. * Basically only one eye is rendered corresponding to the camera.
  25762. */
  25763. static readonly RIG_MODE_NONE: number;
  25764. /**
  25765. * Simulates a camera Rig with one blue eye and one red eye.
  25766. * This can be use with 3d blue and red glasses.
  25767. */
  25768. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25769. /**
  25770. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25771. */
  25772. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25773. /**
  25774. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25775. */
  25776. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25777. /**
  25778. * Defines that both eyes of the camera will be rendered over under each other.
  25779. */
  25780. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25781. /**
  25782. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25783. */
  25784. static readonly RIG_MODE_VR: number;
  25785. /**
  25786. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25787. */
  25788. static readonly RIG_MODE_WEBVR: number;
  25789. /**
  25790. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25791. */
  25792. static readonly RIG_MODE_CUSTOM: number;
  25793. /**
  25794. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25795. */
  25796. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25797. /**
  25798. * Define the input manager associated with the camera.
  25799. */
  25800. inputs: CameraInputsManager<Camera>;
  25801. /** @hidden */
  25802. _position: Vector3;
  25803. /**
  25804. * Define the current local position of the camera in the scene
  25805. */
  25806. position: Vector3;
  25807. /**
  25808. * The vector the camera should consider as up.
  25809. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25810. */
  25811. upVector: Vector3;
  25812. /**
  25813. * Define the current limit on the left side for an orthographic camera
  25814. * In scene unit
  25815. */
  25816. orthoLeft: Nullable<number>;
  25817. /**
  25818. * Define the current limit on the right side for an orthographic camera
  25819. * In scene unit
  25820. */
  25821. orthoRight: Nullable<number>;
  25822. /**
  25823. * Define the current limit on the bottom side for an orthographic camera
  25824. * In scene unit
  25825. */
  25826. orthoBottom: Nullable<number>;
  25827. /**
  25828. * Define the current limit on the top side for an orthographic camera
  25829. * In scene unit
  25830. */
  25831. orthoTop: Nullable<number>;
  25832. /**
  25833. * Field Of View is set in Radians. (default is 0.8)
  25834. */
  25835. fov: number;
  25836. /**
  25837. * Define the minimum distance the camera can see from.
  25838. * This is important to note that the depth buffer are not infinite and the closer it starts
  25839. * the more your scene might encounter depth fighting issue.
  25840. */
  25841. minZ: number;
  25842. /**
  25843. * Define the maximum distance the camera can see to.
  25844. * This is important to note that the depth buffer are not infinite and the further it end
  25845. * the more your scene might encounter depth fighting issue.
  25846. */
  25847. maxZ: number;
  25848. /**
  25849. * Define the default inertia of the camera.
  25850. * This helps giving a smooth feeling to the camera movement.
  25851. */
  25852. inertia: number;
  25853. /**
  25854. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25855. */
  25856. mode: number;
  25857. /**
  25858. * Define wether the camera is intermediate.
  25859. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25860. */
  25861. isIntermediate: boolean;
  25862. /**
  25863. * Define the viewport of the camera.
  25864. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25865. */
  25866. viewport: Viewport;
  25867. /**
  25868. * Restricts the camera to viewing objects with the same layerMask.
  25869. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25870. */
  25871. layerMask: number;
  25872. /**
  25873. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25874. */
  25875. fovMode: number;
  25876. /**
  25877. * Rig mode of the camera.
  25878. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25879. * This is normally controlled byt the camera themselves as internal use.
  25880. */
  25881. cameraRigMode: number;
  25882. /**
  25883. * Defines the distance between both "eyes" in case of a RIG
  25884. */
  25885. interaxialDistance: number;
  25886. /**
  25887. * Defines if stereoscopic rendering is done side by side or over under.
  25888. */
  25889. isStereoscopicSideBySide: boolean;
  25890. /**
  25891. * 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
  25892. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25893. * else in the scene. (Eg. security camera)
  25894. *
  25895. * 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)
  25896. */
  25897. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25898. /**
  25899. * When set, the camera will render to this render target instead of the default canvas
  25900. *
  25901. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25902. */
  25903. outputRenderTarget: Nullable<RenderTargetTexture>;
  25904. /**
  25905. * Observable triggered when the camera view matrix has changed.
  25906. */
  25907. onViewMatrixChangedObservable: Observable<Camera>;
  25908. /**
  25909. * Observable triggered when the camera Projection matrix has changed.
  25910. */
  25911. onProjectionMatrixChangedObservable: Observable<Camera>;
  25912. /**
  25913. * Observable triggered when the inputs have been processed.
  25914. */
  25915. onAfterCheckInputsObservable: Observable<Camera>;
  25916. /**
  25917. * Observable triggered when reset has been called and applied to the camera.
  25918. */
  25919. onRestoreStateObservable: Observable<Camera>;
  25920. /** @hidden */
  25921. _cameraRigParams: any;
  25922. /** @hidden */
  25923. _rigCameras: Camera[];
  25924. /** @hidden */
  25925. _rigPostProcess: Nullable<PostProcess>;
  25926. protected _webvrViewMatrix: Matrix;
  25927. /** @hidden */
  25928. _skipRendering: boolean;
  25929. /** @hidden */
  25930. _projectionMatrix: Matrix;
  25931. /** @hidden */
  25932. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25933. /** @hidden */
  25934. _activeMeshes: SmartArray<AbstractMesh>;
  25935. protected _globalPosition: Vector3;
  25936. /** @hidden */
  25937. _computedViewMatrix: Matrix;
  25938. private _doNotComputeProjectionMatrix;
  25939. private _transformMatrix;
  25940. private _frustumPlanes;
  25941. private _refreshFrustumPlanes;
  25942. private _storedFov;
  25943. private _stateStored;
  25944. /**
  25945. * Instantiates a new camera object.
  25946. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25947. * @see http://doc.babylonjs.com/features/cameras
  25948. * @param name Defines the name of the camera in the scene
  25949. * @param position Defines the position of the camera
  25950. * @param scene Defines the scene the camera belongs too
  25951. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25952. */
  25953. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25954. /**
  25955. * Store current camera state (fov, position, etc..)
  25956. * @returns the camera
  25957. */
  25958. storeState(): Camera;
  25959. /**
  25960. * Restores the camera state values if it has been stored. You must call storeState() first
  25961. */
  25962. protected _restoreStateValues(): boolean;
  25963. /**
  25964. * Restored camera state. You must call storeState() first.
  25965. * @returns true if restored and false otherwise
  25966. */
  25967. restoreState(): boolean;
  25968. /**
  25969. * Gets the class name of the camera.
  25970. * @returns the class name
  25971. */
  25972. getClassName(): string;
  25973. /** @hidden */
  25974. readonly _isCamera: boolean;
  25975. /**
  25976. * Gets a string representation of the camera useful for debug purpose.
  25977. * @param fullDetails Defines that a more verboe level of logging is required
  25978. * @returns the string representation
  25979. */
  25980. toString(fullDetails?: boolean): string;
  25981. /**
  25982. * Gets the current world space position of the camera.
  25983. */
  25984. readonly globalPosition: Vector3;
  25985. /**
  25986. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25987. * @returns the active meshe list
  25988. */
  25989. getActiveMeshes(): SmartArray<AbstractMesh>;
  25990. /**
  25991. * Check wether a mesh is part of the current active mesh list of the camera
  25992. * @param mesh Defines the mesh to check
  25993. * @returns true if active, false otherwise
  25994. */
  25995. isActiveMesh(mesh: Mesh): boolean;
  25996. /**
  25997. * Is this camera ready to be used/rendered
  25998. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25999. * @return true if the camera is ready
  26000. */
  26001. isReady(completeCheck?: boolean): boolean;
  26002. /** @hidden */
  26003. _initCache(): void;
  26004. /** @hidden */
  26005. _updateCache(ignoreParentClass?: boolean): void;
  26006. /** @hidden */
  26007. _isSynchronized(): boolean;
  26008. /** @hidden */
  26009. _isSynchronizedViewMatrix(): boolean;
  26010. /** @hidden */
  26011. _isSynchronizedProjectionMatrix(): boolean;
  26012. /**
  26013. * Attach the input controls to a specific dom element to get the input from.
  26014. * @param element Defines the element the controls should be listened from
  26015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26016. */
  26017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26018. /**
  26019. * Detach the current controls from the specified dom element.
  26020. * @param element Defines the element to stop listening the inputs from
  26021. */
  26022. detachControl(element: HTMLElement): void;
  26023. /**
  26024. * Update the camera state according to the different inputs gathered during the frame.
  26025. */
  26026. update(): void;
  26027. /** @hidden */
  26028. _checkInputs(): void;
  26029. /** @hidden */
  26030. readonly rigCameras: Camera[];
  26031. /**
  26032. * Gets the post process used by the rig cameras
  26033. */
  26034. readonly rigPostProcess: Nullable<PostProcess>;
  26035. /**
  26036. * Internal, gets the first post proces.
  26037. * @returns the first post process to be run on this camera.
  26038. */
  26039. _getFirstPostProcess(): Nullable<PostProcess>;
  26040. private _cascadePostProcessesToRigCams;
  26041. /**
  26042. * Attach a post process to the camera.
  26043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26044. * @param postProcess The post process to attach to the camera
  26045. * @param insertAt The position of the post process in case several of them are in use in the scene
  26046. * @returns the position the post process has been inserted at
  26047. */
  26048. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26049. /**
  26050. * Detach a post process to the camera.
  26051. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26052. * @param postProcess The post process to detach from the camera
  26053. */
  26054. detachPostProcess(postProcess: PostProcess): void;
  26055. /**
  26056. * Gets the current world matrix of the camera
  26057. */
  26058. getWorldMatrix(): Matrix;
  26059. /** @hidden */
  26060. _getViewMatrix(): Matrix;
  26061. /**
  26062. * Gets the current view matrix of the camera.
  26063. * @param force forces the camera to recompute the matrix without looking at the cached state
  26064. * @returns the view matrix
  26065. */
  26066. getViewMatrix(force?: boolean): Matrix;
  26067. /**
  26068. * Freeze the projection matrix.
  26069. * It will prevent the cache check of the camera projection compute and can speed up perf
  26070. * if no parameter of the camera are meant to change
  26071. * @param projection Defines manually a projection if necessary
  26072. */
  26073. freezeProjectionMatrix(projection?: Matrix): void;
  26074. /**
  26075. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26076. */
  26077. unfreezeProjectionMatrix(): void;
  26078. /**
  26079. * Gets the current projection matrix of the camera.
  26080. * @param force forces the camera to recompute the matrix without looking at the cached state
  26081. * @returns the projection matrix
  26082. */
  26083. getProjectionMatrix(force?: boolean): Matrix;
  26084. /**
  26085. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26086. * @returns a Matrix
  26087. */
  26088. getTransformationMatrix(): Matrix;
  26089. private _updateFrustumPlanes;
  26090. /**
  26091. * Checks if a cullable object (mesh...) is in the camera frustum
  26092. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26093. * @param target The object to check
  26094. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26095. * @returns true if the object is in frustum otherwise false
  26096. */
  26097. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26098. /**
  26099. * Checks if a cullable object (mesh...) is in the camera frustum
  26100. * Unlike isInFrustum this cheks the full bounding box
  26101. * @param target The object to check
  26102. * @returns true if the object is in frustum otherwise false
  26103. */
  26104. isCompletelyInFrustum(target: ICullable): boolean;
  26105. /**
  26106. * Gets a ray in the forward direction from the camera.
  26107. * @param length Defines the length of the ray to create
  26108. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26109. * @param origin Defines the start point of the ray which defaults to the camera position
  26110. * @returns the forward ray
  26111. */
  26112. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26113. /**
  26114. * Releases resources associated with this node.
  26115. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26116. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26117. */
  26118. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26119. /** @hidden */
  26120. _isLeftCamera: boolean;
  26121. /**
  26122. * Gets the left camera of a rig setup in case of Rigged Camera
  26123. */
  26124. readonly isLeftCamera: boolean;
  26125. /** @hidden */
  26126. _isRightCamera: boolean;
  26127. /**
  26128. * Gets the right camera of a rig setup in case of Rigged Camera
  26129. */
  26130. readonly isRightCamera: boolean;
  26131. /**
  26132. * Gets the left camera of a rig setup in case of Rigged Camera
  26133. */
  26134. readonly leftCamera: Nullable<FreeCamera>;
  26135. /**
  26136. * Gets the right camera of a rig setup in case of Rigged Camera
  26137. */
  26138. readonly rightCamera: Nullable<FreeCamera>;
  26139. /**
  26140. * Gets the left camera target of a rig setup in case of Rigged Camera
  26141. * @returns the target position
  26142. */
  26143. getLeftTarget(): Nullable<Vector3>;
  26144. /**
  26145. * Gets the right camera target of a rig setup in case of Rigged Camera
  26146. * @returns the target position
  26147. */
  26148. getRightTarget(): Nullable<Vector3>;
  26149. /**
  26150. * @hidden
  26151. */
  26152. setCameraRigMode(mode: number, rigParams: any): void;
  26153. /** @hidden */
  26154. static _setStereoscopicRigMode(camera: Camera): void;
  26155. /** @hidden */
  26156. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26157. /** @hidden */
  26158. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26159. /** @hidden */
  26160. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26161. /** @hidden */
  26162. _getVRProjectionMatrix(): Matrix;
  26163. protected _updateCameraRotationMatrix(): void;
  26164. protected _updateWebVRCameraRotationMatrix(): void;
  26165. /**
  26166. * This function MUST be overwritten by the different WebVR cameras available.
  26167. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26168. * @hidden
  26169. */
  26170. _getWebVRProjectionMatrix(): Matrix;
  26171. /**
  26172. * This function MUST be overwritten by the different WebVR cameras available.
  26173. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26174. * @hidden
  26175. */
  26176. _getWebVRViewMatrix(): Matrix;
  26177. /** @hidden */
  26178. setCameraRigParameter(name: string, value: any): void;
  26179. /**
  26180. * needs to be overridden by children so sub has required properties to be copied
  26181. * @hidden
  26182. */
  26183. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26184. /**
  26185. * May need to be overridden by children
  26186. * @hidden
  26187. */
  26188. _updateRigCameras(): void;
  26189. /** @hidden */
  26190. _setupInputs(): void;
  26191. /**
  26192. * Serialiaze the camera setup to a json represention
  26193. * @returns the JSON representation
  26194. */
  26195. serialize(): any;
  26196. /**
  26197. * Clones the current camera.
  26198. * @param name The cloned camera name
  26199. * @returns the cloned camera
  26200. */
  26201. clone(name: string): Camera;
  26202. /**
  26203. * Gets the direction of the camera relative to a given local axis.
  26204. * @param localAxis Defines the reference axis to provide a relative direction.
  26205. * @return the direction
  26206. */
  26207. getDirection(localAxis: Vector3): Vector3;
  26208. /**
  26209. * Returns the current camera absolute rotation
  26210. */
  26211. readonly absoluteRotation: Quaternion;
  26212. /**
  26213. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26214. * @param localAxis Defines the reference axis to provide a relative direction.
  26215. * @param result Defines the vector to store the result in
  26216. */
  26217. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26218. /**
  26219. * Gets a camera constructor for a given camera type
  26220. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26221. * @param name The name of the camera the result will be able to instantiate
  26222. * @param scene The scene the result will construct the camera in
  26223. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26224. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26225. * @returns a factory method to construc the camera
  26226. */
  26227. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26228. /**
  26229. * Compute the world matrix of the camera.
  26230. * @returns the camera world matrix
  26231. */
  26232. computeWorldMatrix(): Matrix;
  26233. /**
  26234. * Parse a JSON and creates the camera from the parsed information
  26235. * @param parsedCamera The JSON to parse
  26236. * @param scene The scene to instantiate the camera in
  26237. * @returns the newly constructed camera
  26238. */
  26239. static Parse(parsedCamera: any, scene: Scene): Camera;
  26240. }
  26241. }
  26242. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26243. import { Nullable } from "babylonjs/types";
  26244. import { Scene } from "babylonjs/scene";
  26245. import { Vector4 } from "babylonjs/Maths/math.vector";
  26246. import { Mesh } from "babylonjs/Meshes/mesh";
  26247. /**
  26248. * Class containing static functions to help procedurally build meshes
  26249. */
  26250. export class DiscBuilder {
  26251. /**
  26252. * Creates a plane polygonal mesh. By default, this is a disc
  26253. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26254. * * 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
  26255. * * 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
  26256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26259. * @param name defines the name of the mesh
  26260. * @param options defines the options used to create the mesh
  26261. * @param scene defines the hosting scene
  26262. * @returns the plane polygonal mesh
  26263. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26264. */
  26265. static CreateDisc(name: string, options: {
  26266. radius?: number;
  26267. tessellation?: number;
  26268. arc?: number;
  26269. updatable?: boolean;
  26270. sideOrientation?: number;
  26271. frontUVs?: Vector4;
  26272. backUVs?: Vector4;
  26273. }, scene?: Nullable<Scene>): Mesh;
  26274. }
  26275. }
  26276. declare module "babylonjs/Materials/fresnelParameters" {
  26277. import { Color3 } from "babylonjs/Maths/math.color";
  26278. /**
  26279. * This represents all the required information to add a fresnel effect on a material:
  26280. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26281. */
  26282. export class FresnelParameters {
  26283. private _isEnabled;
  26284. /**
  26285. * Define if the fresnel effect is enable or not.
  26286. */
  26287. isEnabled: boolean;
  26288. /**
  26289. * Define the color used on edges (grazing angle)
  26290. */
  26291. leftColor: Color3;
  26292. /**
  26293. * Define the color used on center
  26294. */
  26295. rightColor: Color3;
  26296. /**
  26297. * Define bias applied to computed fresnel term
  26298. */
  26299. bias: number;
  26300. /**
  26301. * Defined the power exponent applied to fresnel term
  26302. */
  26303. power: number;
  26304. /**
  26305. * Clones the current fresnel and its valuues
  26306. * @returns a clone fresnel configuration
  26307. */
  26308. clone(): FresnelParameters;
  26309. /**
  26310. * Serializes the current fresnel parameters to a JSON representation.
  26311. * @return the JSON serialization
  26312. */
  26313. serialize(): any;
  26314. /**
  26315. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26316. * @param parsedFresnelParameters Define the JSON representation
  26317. * @returns the parsed parameters
  26318. */
  26319. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26320. }
  26321. }
  26322. declare module "babylonjs/Materials/pushMaterial" {
  26323. import { Nullable } from "babylonjs/types";
  26324. import { Scene } from "babylonjs/scene";
  26325. import { Matrix } from "babylonjs/Maths/math.vector";
  26326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26327. import { Mesh } from "babylonjs/Meshes/mesh";
  26328. import { Material } from "babylonjs/Materials/material";
  26329. import { Effect } from "babylonjs/Materials/effect";
  26330. /**
  26331. * Base class of materials working in push mode in babylon JS
  26332. * @hidden
  26333. */
  26334. export class PushMaterial extends Material {
  26335. protected _activeEffect: Effect;
  26336. protected _normalMatrix: Matrix;
  26337. /**
  26338. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26339. * This means that the material can keep using a previous shader while a new one is being compiled.
  26340. * This is mostly used when shader parallel compilation is supported (true by default)
  26341. */
  26342. allowShaderHotSwapping: boolean;
  26343. constructor(name: string, scene: Scene);
  26344. getEffect(): Effect;
  26345. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26346. /**
  26347. * Binds the given world matrix to the active effect
  26348. *
  26349. * @param world the matrix to bind
  26350. */
  26351. bindOnlyWorldMatrix(world: Matrix): void;
  26352. /**
  26353. * Binds the given normal matrix to the active effect
  26354. *
  26355. * @param normalMatrix the matrix to bind
  26356. */
  26357. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26358. bind(world: Matrix, mesh?: Mesh): void;
  26359. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26360. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26361. }
  26362. }
  26363. declare module "babylonjs/Materials/materialFlags" {
  26364. /**
  26365. * This groups all the flags used to control the materials channel.
  26366. */
  26367. export class MaterialFlags {
  26368. private static _DiffuseTextureEnabled;
  26369. /**
  26370. * Are diffuse textures enabled in the application.
  26371. */
  26372. static DiffuseTextureEnabled: boolean;
  26373. private static _AmbientTextureEnabled;
  26374. /**
  26375. * Are ambient textures enabled in the application.
  26376. */
  26377. static AmbientTextureEnabled: boolean;
  26378. private static _OpacityTextureEnabled;
  26379. /**
  26380. * Are opacity textures enabled in the application.
  26381. */
  26382. static OpacityTextureEnabled: boolean;
  26383. private static _ReflectionTextureEnabled;
  26384. /**
  26385. * Are reflection textures enabled in the application.
  26386. */
  26387. static ReflectionTextureEnabled: boolean;
  26388. private static _EmissiveTextureEnabled;
  26389. /**
  26390. * Are emissive textures enabled in the application.
  26391. */
  26392. static EmissiveTextureEnabled: boolean;
  26393. private static _SpecularTextureEnabled;
  26394. /**
  26395. * Are specular textures enabled in the application.
  26396. */
  26397. static SpecularTextureEnabled: boolean;
  26398. private static _BumpTextureEnabled;
  26399. /**
  26400. * Are bump textures enabled in the application.
  26401. */
  26402. static BumpTextureEnabled: boolean;
  26403. private static _LightmapTextureEnabled;
  26404. /**
  26405. * Are lightmap textures enabled in the application.
  26406. */
  26407. static LightmapTextureEnabled: boolean;
  26408. private static _RefractionTextureEnabled;
  26409. /**
  26410. * Are refraction textures enabled in the application.
  26411. */
  26412. static RefractionTextureEnabled: boolean;
  26413. private static _ColorGradingTextureEnabled;
  26414. /**
  26415. * Are color grading textures enabled in the application.
  26416. */
  26417. static ColorGradingTextureEnabled: boolean;
  26418. private static _FresnelEnabled;
  26419. /**
  26420. * Are fresnels enabled in the application.
  26421. */
  26422. static FresnelEnabled: boolean;
  26423. private static _ClearCoatTextureEnabled;
  26424. /**
  26425. * Are clear coat textures enabled in the application.
  26426. */
  26427. static ClearCoatTextureEnabled: boolean;
  26428. private static _ClearCoatBumpTextureEnabled;
  26429. /**
  26430. * Are clear coat bump textures enabled in the application.
  26431. */
  26432. static ClearCoatBumpTextureEnabled: boolean;
  26433. private static _ClearCoatTintTextureEnabled;
  26434. /**
  26435. * Are clear coat tint textures enabled in the application.
  26436. */
  26437. static ClearCoatTintTextureEnabled: boolean;
  26438. private static _SheenTextureEnabled;
  26439. /**
  26440. * Are sheen textures enabled in the application.
  26441. */
  26442. static SheenTextureEnabled: boolean;
  26443. private static _AnisotropicTextureEnabled;
  26444. /**
  26445. * Are anisotropic textures enabled in the application.
  26446. */
  26447. static AnisotropicTextureEnabled: boolean;
  26448. private static _ThicknessTextureEnabled;
  26449. /**
  26450. * Are thickness textures enabled in the application.
  26451. */
  26452. static ThicknessTextureEnabled: boolean;
  26453. }
  26454. }
  26455. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26456. /** @hidden */
  26457. export var defaultFragmentDeclaration: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26463. /** @hidden */
  26464. export var defaultUboDeclaration: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26470. /** @hidden */
  26471. export var lightFragmentDeclaration: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26477. /** @hidden */
  26478. export var lightUboDeclaration: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26484. /** @hidden */
  26485. export var lightsFragmentFunctions: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26491. /** @hidden */
  26492. export var shadowsFragmentFunctions: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26498. /** @hidden */
  26499. export var fresnelFunction: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26505. /** @hidden */
  26506. export var reflectionFunction: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26512. /** @hidden */
  26513. export var bumpFragmentFunctions: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26519. /** @hidden */
  26520. export var logDepthDeclaration: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26526. /** @hidden */
  26527. export var bumpFragment: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26533. /** @hidden */
  26534. export var depthPrePass: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26540. /** @hidden */
  26541. export var lightFragment: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26547. /** @hidden */
  26548. export var logDepthFragment: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module "babylonjs/Shaders/default.fragment" {
  26554. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26555. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26557. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26558. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26559. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26560. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26561. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26562. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26563. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26565. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26567. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26568. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26570. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26571. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26572. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26573. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26574. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26575. /** @hidden */
  26576. export var defaultPixelShader: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26582. /** @hidden */
  26583. export var defaultVertexDeclaration: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26589. /** @hidden */
  26590. export var bumpVertexDeclaration: {
  26591. name: string;
  26592. shader: string;
  26593. };
  26594. }
  26595. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26596. /** @hidden */
  26597. export var bumpVertex: {
  26598. name: string;
  26599. shader: string;
  26600. };
  26601. }
  26602. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26603. /** @hidden */
  26604. export var fogVertex: {
  26605. name: string;
  26606. shader: string;
  26607. };
  26608. }
  26609. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26610. /** @hidden */
  26611. export var shadowsVertex: {
  26612. name: string;
  26613. shader: string;
  26614. };
  26615. }
  26616. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26617. /** @hidden */
  26618. export var pointCloudVertex: {
  26619. name: string;
  26620. shader: string;
  26621. };
  26622. }
  26623. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26624. /** @hidden */
  26625. export var logDepthVertex: {
  26626. name: string;
  26627. shader: string;
  26628. };
  26629. }
  26630. declare module "babylonjs/Shaders/default.vertex" {
  26631. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26632. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26634. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26635. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26636. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26638. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26639. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26640. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26643. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26645. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26646. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26647. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26649. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26650. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26651. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26652. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26653. /** @hidden */
  26654. export var defaultVertexShader: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Materials/standardMaterial" {
  26660. import { SmartArray } from "babylonjs/Misc/smartArray";
  26661. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26662. import { Nullable } from "babylonjs/types";
  26663. import { Scene } from "babylonjs/scene";
  26664. import { Matrix } from "babylonjs/Maths/math.vector";
  26665. import { Color3 } from "babylonjs/Maths/math.color";
  26666. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26668. import { Mesh } from "babylonjs/Meshes/mesh";
  26669. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26670. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26671. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26672. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26673. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26675. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26676. import "babylonjs/Shaders/default.fragment";
  26677. import "babylonjs/Shaders/default.vertex";
  26678. /** @hidden */
  26679. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26680. MAINUV1: boolean;
  26681. MAINUV2: boolean;
  26682. DIFFUSE: boolean;
  26683. DIFFUSEDIRECTUV: number;
  26684. AMBIENT: boolean;
  26685. AMBIENTDIRECTUV: number;
  26686. OPACITY: boolean;
  26687. OPACITYDIRECTUV: number;
  26688. OPACITYRGB: boolean;
  26689. REFLECTION: boolean;
  26690. EMISSIVE: boolean;
  26691. EMISSIVEDIRECTUV: number;
  26692. SPECULAR: boolean;
  26693. SPECULARDIRECTUV: number;
  26694. BUMP: boolean;
  26695. BUMPDIRECTUV: number;
  26696. PARALLAX: boolean;
  26697. PARALLAXOCCLUSION: boolean;
  26698. SPECULAROVERALPHA: boolean;
  26699. CLIPPLANE: boolean;
  26700. CLIPPLANE2: boolean;
  26701. CLIPPLANE3: boolean;
  26702. CLIPPLANE4: boolean;
  26703. ALPHATEST: boolean;
  26704. DEPTHPREPASS: boolean;
  26705. ALPHAFROMDIFFUSE: boolean;
  26706. POINTSIZE: boolean;
  26707. FOG: boolean;
  26708. SPECULARTERM: boolean;
  26709. DIFFUSEFRESNEL: boolean;
  26710. OPACITYFRESNEL: boolean;
  26711. REFLECTIONFRESNEL: boolean;
  26712. REFRACTIONFRESNEL: boolean;
  26713. EMISSIVEFRESNEL: boolean;
  26714. FRESNEL: boolean;
  26715. NORMAL: boolean;
  26716. UV1: boolean;
  26717. UV2: boolean;
  26718. VERTEXCOLOR: boolean;
  26719. VERTEXALPHA: boolean;
  26720. NUM_BONE_INFLUENCERS: number;
  26721. BonesPerMesh: number;
  26722. BONETEXTURE: boolean;
  26723. INSTANCES: boolean;
  26724. GLOSSINESS: boolean;
  26725. ROUGHNESS: boolean;
  26726. EMISSIVEASILLUMINATION: boolean;
  26727. LINKEMISSIVEWITHDIFFUSE: boolean;
  26728. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26729. LIGHTMAP: boolean;
  26730. LIGHTMAPDIRECTUV: number;
  26731. OBJECTSPACE_NORMALMAP: boolean;
  26732. USELIGHTMAPASSHADOWMAP: boolean;
  26733. REFLECTIONMAP_3D: boolean;
  26734. REFLECTIONMAP_SPHERICAL: boolean;
  26735. REFLECTIONMAP_PLANAR: boolean;
  26736. REFLECTIONMAP_CUBIC: boolean;
  26737. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26738. REFLECTIONMAP_PROJECTION: boolean;
  26739. REFLECTIONMAP_SKYBOX: boolean;
  26740. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26741. REFLECTIONMAP_EXPLICIT: boolean;
  26742. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26743. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26744. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26745. INVERTCUBICMAP: boolean;
  26746. LOGARITHMICDEPTH: boolean;
  26747. REFRACTION: boolean;
  26748. REFRACTIONMAP_3D: boolean;
  26749. REFLECTIONOVERALPHA: boolean;
  26750. TWOSIDEDLIGHTING: boolean;
  26751. SHADOWFLOAT: boolean;
  26752. MORPHTARGETS: boolean;
  26753. MORPHTARGETS_NORMAL: boolean;
  26754. MORPHTARGETS_TANGENT: boolean;
  26755. MORPHTARGETS_UV: boolean;
  26756. NUM_MORPH_INFLUENCERS: number;
  26757. NONUNIFORMSCALING: boolean;
  26758. PREMULTIPLYALPHA: boolean;
  26759. IMAGEPROCESSING: boolean;
  26760. VIGNETTE: boolean;
  26761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26762. VIGNETTEBLENDMODEOPAQUE: boolean;
  26763. TONEMAPPING: boolean;
  26764. TONEMAPPING_ACES: boolean;
  26765. CONTRAST: boolean;
  26766. COLORCURVES: boolean;
  26767. COLORGRADING: boolean;
  26768. COLORGRADING3D: boolean;
  26769. SAMPLER3DGREENDEPTH: boolean;
  26770. SAMPLER3DBGRMAP: boolean;
  26771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26772. MULTIVIEW: boolean;
  26773. /**
  26774. * If the reflection texture on this material is in linear color space
  26775. * @hidden
  26776. */
  26777. IS_REFLECTION_LINEAR: boolean;
  26778. /**
  26779. * If the refraction texture on this material is in linear color space
  26780. * @hidden
  26781. */
  26782. IS_REFRACTION_LINEAR: boolean;
  26783. EXPOSURE: boolean;
  26784. constructor();
  26785. setReflectionMode(modeToEnable: string): void;
  26786. }
  26787. /**
  26788. * This is the default material used in Babylon. It is the best trade off between quality
  26789. * and performances.
  26790. * @see http://doc.babylonjs.com/babylon101/materials
  26791. */
  26792. export class StandardMaterial extends PushMaterial {
  26793. private _diffuseTexture;
  26794. /**
  26795. * The basic texture of the material as viewed under a light.
  26796. */
  26797. diffuseTexture: Nullable<BaseTexture>;
  26798. private _ambientTexture;
  26799. /**
  26800. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26801. */
  26802. ambientTexture: Nullable<BaseTexture>;
  26803. private _opacityTexture;
  26804. /**
  26805. * Define the transparency of the material from a texture.
  26806. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26807. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26808. */
  26809. opacityTexture: Nullable<BaseTexture>;
  26810. private _reflectionTexture;
  26811. /**
  26812. * Define the texture used to display the reflection.
  26813. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26814. */
  26815. reflectionTexture: Nullable<BaseTexture>;
  26816. private _emissiveTexture;
  26817. /**
  26818. * Define texture of the material as if self lit.
  26819. * This will be mixed in the final result even in the absence of light.
  26820. */
  26821. emissiveTexture: Nullable<BaseTexture>;
  26822. private _specularTexture;
  26823. /**
  26824. * Define how the color and intensity of the highlight given by the light in the material.
  26825. */
  26826. specularTexture: Nullable<BaseTexture>;
  26827. private _bumpTexture;
  26828. /**
  26829. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26830. * 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.
  26831. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26832. */
  26833. bumpTexture: Nullable<BaseTexture>;
  26834. private _lightmapTexture;
  26835. /**
  26836. * Complex lighting can be computationally expensive to compute at runtime.
  26837. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26838. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26839. */
  26840. lightmapTexture: Nullable<BaseTexture>;
  26841. private _refractionTexture;
  26842. /**
  26843. * Define the texture used to display the refraction.
  26844. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26845. */
  26846. refractionTexture: Nullable<BaseTexture>;
  26847. /**
  26848. * The color of the material lit by the environmental background lighting.
  26849. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26850. */
  26851. ambientColor: Color3;
  26852. /**
  26853. * The basic color of the material as viewed under a light.
  26854. */
  26855. diffuseColor: Color3;
  26856. /**
  26857. * Define how the color and intensity of the highlight given by the light in the material.
  26858. */
  26859. specularColor: Color3;
  26860. /**
  26861. * Define the color of the material as if self lit.
  26862. * This will be mixed in the final result even in the absence of light.
  26863. */
  26864. emissiveColor: Color3;
  26865. /**
  26866. * Defines how sharp are the highlights in the material.
  26867. * The bigger the value the sharper giving a more glossy feeling to the result.
  26868. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26869. */
  26870. specularPower: number;
  26871. private _useAlphaFromDiffuseTexture;
  26872. /**
  26873. * Does the transparency come from the diffuse texture alpha channel.
  26874. */
  26875. useAlphaFromDiffuseTexture: boolean;
  26876. private _useEmissiveAsIllumination;
  26877. /**
  26878. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26879. */
  26880. useEmissiveAsIllumination: boolean;
  26881. private _linkEmissiveWithDiffuse;
  26882. /**
  26883. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26884. * the emissive level when the final color is close to one.
  26885. */
  26886. linkEmissiveWithDiffuse: boolean;
  26887. private _useSpecularOverAlpha;
  26888. /**
  26889. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26891. */
  26892. useSpecularOverAlpha: boolean;
  26893. private _useReflectionOverAlpha;
  26894. /**
  26895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26897. */
  26898. useReflectionOverAlpha: boolean;
  26899. private _disableLighting;
  26900. /**
  26901. * Does lights from the scene impacts this material.
  26902. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26903. */
  26904. disableLighting: boolean;
  26905. private _useObjectSpaceNormalMap;
  26906. /**
  26907. * Allows using an object space normal map (instead of tangent space).
  26908. */
  26909. useObjectSpaceNormalMap: boolean;
  26910. private _useParallax;
  26911. /**
  26912. * Is parallax enabled or not.
  26913. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26914. */
  26915. useParallax: boolean;
  26916. private _useParallaxOcclusion;
  26917. /**
  26918. * Is parallax occlusion enabled or not.
  26919. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26920. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26921. */
  26922. useParallaxOcclusion: boolean;
  26923. /**
  26924. * 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.
  26925. */
  26926. parallaxScaleBias: number;
  26927. private _roughness;
  26928. /**
  26929. * Helps to define how blurry the reflections should appears in the material.
  26930. */
  26931. roughness: number;
  26932. /**
  26933. * In case of refraction, define the value of the index of refraction.
  26934. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26935. */
  26936. indexOfRefraction: number;
  26937. /**
  26938. * Invert the refraction texture alongside the y axis.
  26939. * It can be useful with procedural textures or probe for instance.
  26940. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26941. */
  26942. invertRefractionY: boolean;
  26943. /**
  26944. * Defines the alpha limits in alpha test mode.
  26945. */
  26946. alphaCutOff: number;
  26947. private _useLightmapAsShadowmap;
  26948. /**
  26949. * In case of light mapping, define whether the map contains light or shadow informations.
  26950. */
  26951. useLightmapAsShadowmap: boolean;
  26952. private _diffuseFresnelParameters;
  26953. /**
  26954. * Define the diffuse fresnel parameters of the material.
  26955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26956. */
  26957. diffuseFresnelParameters: FresnelParameters;
  26958. private _opacityFresnelParameters;
  26959. /**
  26960. * Define the opacity fresnel parameters of the material.
  26961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26962. */
  26963. opacityFresnelParameters: FresnelParameters;
  26964. private _reflectionFresnelParameters;
  26965. /**
  26966. * Define the reflection fresnel parameters of the material.
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26968. */
  26969. reflectionFresnelParameters: FresnelParameters;
  26970. private _refractionFresnelParameters;
  26971. /**
  26972. * Define the refraction fresnel parameters of the material.
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26974. */
  26975. refractionFresnelParameters: FresnelParameters;
  26976. private _emissiveFresnelParameters;
  26977. /**
  26978. * Define the emissive fresnel parameters of the material.
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26980. */
  26981. emissiveFresnelParameters: FresnelParameters;
  26982. private _useReflectionFresnelFromSpecular;
  26983. /**
  26984. * If true automatically deducts the fresnels values from the material specularity.
  26985. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26986. */
  26987. useReflectionFresnelFromSpecular: boolean;
  26988. private _useGlossinessFromSpecularMapAlpha;
  26989. /**
  26990. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26991. */
  26992. useGlossinessFromSpecularMapAlpha: boolean;
  26993. private _maxSimultaneousLights;
  26994. /**
  26995. * Defines the maximum number of lights that can be used in the material
  26996. */
  26997. maxSimultaneousLights: number;
  26998. private _invertNormalMapX;
  26999. /**
  27000. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27001. */
  27002. invertNormalMapX: boolean;
  27003. private _invertNormalMapY;
  27004. /**
  27005. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27006. */
  27007. invertNormalMapY: boolean;
  27008. private _twoSidedLighting;
  27009. /**
  27010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27011. */
  27012. twoSidedLighting: boolean;
  27013. /**
  27014. * Default configuration related to image processing available in the standard Material.
  27015. */
  27016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27017. /**
  27018. * Gets the image processing configuration used either in this material.
  27019. */
  27020. /**
  27021. * Sets the Default image processing configuration used either in the this material.
  27022. *
  27023. * If sets to null, the scene one is in use.
  27024. */
  27025. imageProcessingConfiguration: ImageProcessingConfiguration;
  27026. /**
  27027. * Keep track of the image processing observer to allow dispose and replace.
  27028. */
  27029. private _imageProcessingObserver;
  27030. /**
  27031. * Attaches a new image processing configuration to the Standard Material.
  27032. * @param configuration
  27033. */
  27034. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27035. /**
  27036. * Gets wether the color curves effect is enabled.
  27037. */
  27038. /**
  27039. * Sets wether the color curves effect is enabled.
  27040. */
  27041. cameraColorCurvesEnabled: boolean;
  27042. /**
  27043. * Gets wether the color grading effect is enabled.
  27044. */
  27045. /**
  27046. * Gets wether the color grading effect is enabled.
  27047. */
  27048. cameraColorGradingEnabled: boolean;
  27049. /**
  27050. * Gets wether tonemapping is enabled or not.
  27051. */
  27052. /**
  27053. * Sets wether tonemapping is enabled or not
  27054. */
  27055. cameraToneMappingEnabled: boolean;
  27056. /**
  27057. * The camera exposure used on this material.
  27058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27059. * This corresponds to a photographic exposure.
  27060. */
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. cameraExposure: number;
  27067. /**
  27068. * Gets The camera contrast used on this material.
  27069. */
  27070. /**
  27071. * Sets The camera contrast used on this material.
  27072. */
  27073. cameraContrast: number;
  27074. /**
  27075. * Gets the Color Grading 2D Lookup Texture.
  27076. */
  27077. /**
  27078. * Sets the Color Grading 2D Lookup Texture.
  27079. */
  27080. cameraColorGradingTexture: Nullable<BaseTexture>;
  27081. /**
  27082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27084. * 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;
  27085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27086. */
  27087. /**
  27088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27090. * 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;
  27091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27092. */
  27093. cameraColorCurves: Nullable<ColorCurves>;
  27094. /**
  27095. * Custom callback helping to override the default shader used in the material.
  27096. */
  27097. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27098. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27099. protected _worldViewProjectionMatrix: Matrix;
  27100. protected _globalAmbientColor: Color3;
  27101. protected _useLogarithmicDepth: boolean;
  27102. protected _rebuildInParallel: boolean;
  27103. /**
  27104. * Instantiates a new standard material.
  27105. * This is the default material used in Babylon. It is the best trade off between quality
  27106. * and performances.
  27107. * @see http://doc.babylonjs.com/babylon101/materials
  27108. * @param name Define the name of the material in the scene
  27109. * @param scene Define the scene the material belong to
  27110. */
  27111. constructor(name: string, scene: Scene);
  27112. /**
  27113. * Gets a boolean indicating that current material needs to register RTT
  27114. */
  27115. readonly hasRenderTargetTextures: boolean;
  27116. /**
  27117. * Gets the current class name of the material e.g. "StandardMaterial"
  27118. * Mainly use in serialization.
  27119. * @returns the class name
  27120. */
  27121. getClassName(): string;
  27122. /**
  27123. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27124. * You can try switching to logarithmic depth.
  27125. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27126. */
  27127. useLogarithmicDepth: boolean;
  27128. /**
  27129. * Specifies if the material will require alpha blending
  27130. * @returns a boolean specifying if alpha blending is needed
  27131. */
  27132. needAlphaBlending(): boolean;
  27133. /**
  27134. * Specifies if this material should be rendered in alpha test mode
  27135. * @returns a boolean specifying if an alpha test is needed.
  27136. */
  27137. needAlphaTesting(): boolean;
  27138. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27139. /**
  27140. * Get the texture used for alpha test purpose.
  27141. * @returns the diffuse texture in case of the standard material.
  27142. */
  27143. getAlphaTestTexture(): Nullable<BaseTexture>;
  27144. /**
  27145. * Get if the submesh is ready to be used and all its information available.
  27146. * Child classes can use it to update shaders
  27147. * @param mesh defines the mesh to check
  27148. * @param subMesh defines which submesh to check
  27149. * @param useInstances specifies that instances should be used
  27150. * @returns a boolean indicating that the submesh is ready or not
  27151. */
  27152. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27153. /**
  27154. * Builds the material UBO layouts.
  27155. * Used internally during the effect preparation.
  27156. */
  27157. buildUniformLayout(): void;
  27158. /**
  27159. * Unbinds the material from the mesh
  27160. */
  27161. unbind(): void;
  27162. /**
  27163. * Binds the submesh to this material by preparing the effect and shader to draw
  27164. * @param world defines the world transformation matrix
  27165. * @param mesh defines the mesh containing the submesh
  27166. * @param subMesh defines the submesh to bind the material to
  27167. */
  27168. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27169. /**
  27170. * Get the list of animatables in the material.
  27171. * @returns the list of animatables object used in the material
  27172. */
  27173. getAnimatables(): IAnimatable[];
  27174. /**
  27175. * Gets the active textures from the material
  27176. * @returns an array of textures
  27177. */
  27178. getActiveTextures(): BaseTexture[];
  27179. /**
  27180. * Specifies if the material uses a texture
  27181. * @param texture defines the texture to check against the material
  27182. * @returns a boolean specifying if the material uses the texture
  27183. */
  27184. hasTexture(texture: BaseTexture): boolean;
  27185. /**
  27186. * Disposes the material
  27187. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27188. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27189. */
  27190. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27191. /**
  27192. * Makes a duplicate of the material, and gives it a new name
  27193. * @param name defines the new name for the duplicated material
  27194. * @returns the cloned material
  27195. */
  27196. clone(name: string): StandardMaterial;
  27197. /**
  27198. * Serializes this material in a JSON representation
  27199. * @returns the serialized material object
  27200. */
  27201. serialize(): any;
  27202. /**
  27203. * Creates a standard material from parsed material data
  27204. * @param source defines the JSON representation of the material
  27205. * @param scene defines the hosting scene
  27206. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27207. * @returns a new standard material
  27208. */
  27209. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27210. /**
  27211. * Are diffuse textures enabled in the application.
  27212. */
  27213. static DiffuseTextureEnabled: boolean;
  27214. /**
  27215. * Are ambient textures enabled in the application.
  27216. */
  27217. static AmbientTextureEnabled: boolean;
  27218. /**
  27219. * Are opacity textures enabled in the application.
  27220. */
  27221. static OpacityTextureEnabled: boolean;
  27222. /**
  27223. * Are reflection textures enabled in the application.
  27224. */
  27225. static ReflectionTextureEnabled: boolean;
  27226. /**
  27227. * Are emissive textures enabled in the application.
  27228. */
  27229. static EmissiveTextureEnabled: boolean;
  27230. /**
  27231. * Are specular textures enabled in the application.
  27232. */
  27233. static SpecularTextureEnabled: boolean;
  27234. /**
  27235. * Are bump textures enabled in the application.
  27236. */
  27237. static BumpTextureEnabled: boolean;
  27238. /**
  27239. * Are lightmap textures enabled in the application.
  27240. */
  27241. static LightmapTextureEnabled: boolean;
  27242. /**
  27243. * Are refraction textures enabled in the application.
  27244. */
  27245. static RefractionTextureEnabled: boolean;
  27246. /**
  27247. * Are color grading textures enabled in the application.
  27248. */
  27249. static ColorGradingTextureEnabled: boolean;
  27250. /**
  27251. * Are fresnels enabled in the application.
  27252. */
  27253. static FresnelEnabled: boolean;
  27254. }
  27255. }
  27256. declare module "babylonjs/Particles/solidParticleSystem" {
  27257. import { Nullable } from "babylonjs/types";
  27258. import { Vector3 } from "babylonjs/Maths/math.vector";
  27259. import { Mesh } from "babylonjs/Meshes/mesh";
  27260. import { Scene, IDisposable } from "babylonjs/scene";
  27261. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27262. import { Material } from "babylonjs/Materials/material";
  27263. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27264. /**
  27265. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27266. *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.
  27267. * The SPS is also a particle system. It provides some methods to manage the particles.
  27268. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27269. *
  27270. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27271. */
  27272. export class SolidParticleSystem implements IDisposable {
  27273. /**
  27274. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27275. * Example : var p = SPS.particles[i];
  27276. */
  27277. particles: SolidParticle[];
  27278. /**
  27279. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27280. */
  27281. nbParticles: number;
  27282. /**
  27283. * If the particles must ever face the camera (default false). Useful for planar particles.
  27284. */
  27285. billboard: boolean;
  27286. /**
  27287. * Recompute normals when adding a shape
  27288. */
  27289. recomputeNormals: boolean;
  27290. /**
  27291. * This a counter ofr your own usage. It's not set by any SPS functions.
  27292. */
  27293. counter: number;
  27294. /**
  27295. * The SPS name. This name is also given to the underlying mesh.
  27296. */
  27297. name: string;
  27298. /**
  27299. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27300. */
  27301. mesh: Mesh;
  27302. /**
  27303. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27304. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27305. */
  27306. vars: any;
  27307. /**
  27308. * This array is populated when the SPS is set as 'pickable'.
  27309. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27310. * Each element of this array is an object `{idx: int, faceId: int}`.
  27311. * `idx` is the picked particle index in the `SPS.particles` array
  27312. * `faceId` is the picked face index counted within this particle.
  27313. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27314. */
  27315. pickedParticles: {
  27316. idx: number;
  27317. faceId: number;
  27318. }[];
  27319. /**
  27320. * This array is populated when `enableDepthSort` is set to true.
  27321. * Each element of this array is an instance of the class DepthSortedParticle.
  27322. */
  27323. depthSortedParticles: DepthSortedParticle[];
  27324. /**
  27325. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27326. * @hidden
  27327. */
  27328. _bSphereOnly: boolean;
  27329. /**
  27330. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27331. * @hidden
  27332. */
  27333. _bSphereRadiusFactor: number;
  27334. private _scene;
  27335. private _positions;
  27336. private _indices;
  27337. private _normals;
  27338. private _colors;
  27339. private _uvs;
  27340. private _indices32;
  27341. private _positions32;
  27342. private _normals32;
  27343. private _fixedNormal32;
  27344. private _colors32;
  27345. private _uvs32;
  27346. private _index;
  27347. private _updatable;
  27348. private _pickable;
  27349. private _isVisibilityBoxLocked;
  27350. private _alwaysVisible;
  27351. private _depthSort;
  27352. private _expandable;
  27353. private _shapeCounter;
  27354. private _copy;
  27355. private _color;
  27356. private _computeParticleColor;
  27357. private _computeParticleTexture;
  27358. private _computeParticleRotation;
  27359. private _computeParticleVertex;
  27360. private _computeBoundingBox;
  27361. private _depthSortParticles;
  27362. private _camera;
  27363. private _mustUnrotateFixedNormals;
  27364. private _particlesIntersect;
  27365. private _needs32Bits;
  27366. private _isNotBuilt;
  27367. private _lastParticleId;
  27368. private _idxOfId;
  27369. private _multimaterialEnabled;
  27370. private _useModelMaterial;
  27371. private _indicesByMaterial;
  27372. private _materialIndexes;
  27373. private _depthSortFunction;
  27374. private _materialSortFunction;
  27375. private _materials;
  27376. private _multimaterial;
  27377. private _materialIndexesById;
  27378. private _defaultMaterial;
  27379. private _autoUpdateSubMeshes;
  27380. /**
  27381. * Creates a SPS (Solid Particle System) object.
  27382. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27383. * @param scene (Scene) is the scene in which the SPS is added.
  27384. * @param options defines the options of the sps e.g.
  27385. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27386. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27387. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27388. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27389. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27390. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27391. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27392. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27393. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27394. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27395. */
  27396. constructor(name: string, scene: Scene, options?: {
  27397. updatable?: boolean;
  27398. isPickable?: boolean;
  27399. enableDepthSort?: boolean;
  27400. particleIntersection?: boolean;
  27401. boundingSphereOnly?: boolean;
  27402. bSphereRadiusFactor?: number;
  27403. expandable?: boolean;
  27404. useModelMaterial?: boolean;
  27405. enableMultiMaterial?: boolean;
  27406. });
  27407. /**
  27408. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27409. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27410. * @returns the created mesh
  27411. */
  27412. buildMesh(): Mesh;
  27413. /**
  27414. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27415. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27416. * Thus the particles generated from `digest()` have their property `position` set yet.
  27417. * @param mesh ( Mesh ) is the mesh to be digested
  27418. * @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
  27419. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27420. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27421. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27422. * @returns the current SPS
  27423. */
  27424. digest(mesh: Mesh, options?: {
  27425. facetNb?: number;
  27426. number?: number;
  27427. delta?: number;
  27428. storage?: [];
  27429. }): SolidParticleSystem;
  27430. /**
  27431. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27432. * @hidden
  27433. */
  27434. private _unrotateFixedNormals;
  27435. /**
  27436. * Resets the temporary working copy particle
  27437. * @hidden
  27438. */
  27439. private _resetCopy;
  27440. /**
  27441. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27442. * @param p the current index in the positions array to be updated
  27443. * @param ind the current index in the indices array
  27444. * @param shape a Vector3 array, the shape geometry
  27445. * @param positions the positions array to be updated
  27446. * @param meshInd the shape indices array
  27447. * @param indices the indices array to be updated
  27448. * @param meshUV the shape uv array
  27449. * @param uvs the uv array to be updated
  27450. * @param meshCol the shape color array
  27451. * @param colors the color array to be updated
  27452. * @param meshNor the shape normals array
  27453. * @param normals the normals array to be updated
  27454. * @param idx the particle index
  27455. * @param idxInShape the particle index in its shape
  27456. * @param options the addShape() method passed options
  27457. * @model the particle model
  27458. * @hidden
  27459. */
  27460. private _meshBuilder;
  27461. /**
  27462. * Returns a shape Vector3 array from positions float array
  27463. * @param positions float array
  27464. * @returns a vector3 array
  27465. * @hidden
  27466. */
  27467. private _posToShape;
  27468. /**
  27469. * Returns a shapeUV array from a float uvs (array deep copy)
  27470. * @param uvs as a float array
  27471. * @returns a shapeUV array
  27472. * @hidden
  27473. */
  27474. private _uvsToShapeUV;
  27475. /**
  27476. * Adds a new particle object in the particles array
  27477. * @param idx particle index in particles array
  27478. * @param id particle id
  27479. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27480. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27481. * @param model particle ModelShape object
  27482. * @param shapeId model shape identifier
  27483. * @param idxInShape index of the particle in the current model
  27484. * @param bInfo model bounding info object
  27485. * @param storage target storage array, if any
  27486. * @hidden
  27487. */
  27488. private _addParticle;
  27489. /**
  27490. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27491. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27492. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27493. * @param nb (positive integer) the number of particles to be created from this model
  27494. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27495. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27496. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27497. * @returns the number of shapes in the system
  27498. */
  27499. addShape(mesh: Mesh, nb: number, options?: {
  27500. positionFunction?: any;
  27501. vertexFunction?: any;
  27502. storage?: [];
  27503. }): number;
  27504. /**
  27505. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27506. * @hidden
  27507. */
  27508. private _rebuildParticle;
  27509. /**
  27510. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27511. * @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.
  27512. * @returns the SPS.
  27513. */
  27514. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27515. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27516. * Returns an array with the removed particles.
  27517. * 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.
  27518. * The SPS can't be empty so at least one particle needs to remain in place.
  27519. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27520. * @param start index of the first particle to remove
  27521. * @param end index of the last particle to remove (included)
  27522. * @returns an array populated with the removed particles
  27523. */
  27524. removeParticles(start: number, end: number): SolidParticle[];
  27525. /**
  27526. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27527. * @param solidParticleArray an array populated with Solid Particles objects
  27528. * @returns the SPS
  27529. */
  27530. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27531. /**
  27532. * Creates a new particle and modifies the SPS mesh geometry :
  27533. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27534. * - calls _addParticle() to populate the particle array
  27535. * factorized code from addShape() and insertParticlesFromArray()
  27536. * @param idx particle index in the particles array
  27537. * @param i particle index in its shape
  27538. * @param modelShape particle ModelShape object
  27539. * @param shape shape vertex array
  27540. * @param meshInd shape indices array
  27541. * @param meshUV shape uv array
  27542. * @param meshCol shape color array
  27543. * @param meshNor shape normals array
  27544. * @param bbInfo shape bounding info
  27545. * @param storage target particle storage
  27546. * @options addShape() passed options
  27547. * @hidden
  27548. */
  27549. private _insertNewParticle;
  27550. /**
  27551. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27552. * This method calls `updateParticle()` for each particle of the SPS.
  27553. * For an animated SPS, it is usually called within the render loop.
  27554. * 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.
  27555. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27556. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27557. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27558. * @returns the SPS.
  27559. */
  27560. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27561. /**
  27562. * Disposes the SPS.
  27563. */
  27564. dispose(): void;
  27565. /**
  27566. * Returns a SolidParticle object from its identifier : particle.id
  27567. * @param id (integer) the particle Id
  27568. * @returns the searched particle or null if not found in the SPS.
  27569. */
  27570. getParticleById(id: number): Nullable<SolidParticle>;
  27571. /**
  27572. * Returns a new array populated with the particles having the passed shapeId.
  27573. * @param shapeId (integer) the shape identifier
  27574. * @returns a new solid particle array
  27575. */
  27576. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27577. /**
  27578. * Populates the passed array "ref" with the particles having the passed shapeId.
  27579. * @param shapeId the shape identifier
  27580. * @returns the SPS
  27581. * @param ref
  27582. */
  27583. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27584. /**
  27585. * Computes the required SubMeshes according the materials assigned to the particles.
  27586. * @returns the solid particle system.
  27587. * Does nothing if called before the SPS mesh is built.
  27588. */
  27589. computeSubMeshes(): SolidParticleSystem;
  27590. /**
  27591. * Sorts the solid particles by material when MultiMaterial is enabled.
  27592. * Updates the indices32 array.
  27593. * Updates the indicesByMaterial array.
  27594. * Updates the mesh indices array.
  27595. * @returns the SPS
  27596. * @hidden
  27597. */
  27598. private _sortParticlesByMaterial;
  27599. /**
  27600. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27601. * @hidden
  27602. */
  27603. private _setMaterialIndexesById;
  27604. /**
  27605. * Returns an array with unique values of Materials from the passed array
  27606. * @param array the material array to be checked and filtered
  27607. * @hidden
  27608. */
  27609. private _filterUniqueMaterialId;
  27610. /**
  27611. * Sets a new Standard Material as _defaultMaterial if not already set.
  27612. * @hidden
  27613. */
  27614. private _setDefaultMaterial;
  27615. /**
  27616. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27617. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27618. * @returns the SPS.
  27619. */
  27620. refreshVisibleSize(): SolidParticleSystem;
  27621. /**
  27622. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27623. * @param size the size (float) of the visibility box
  27624. * note : this doesn't lock the SPS mesh bounding box.
  27625. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27626. */
  27627. setVisibilityBox(size: number): void;
  27628. /**
  27629. * Gets whether the SPS as always visible or not
  27630. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27631. */
  27632. /**
  27633. * Sets the SPS as always visible or not
  27634. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27635. */
  27636. isAlwaysVisible: boolean;
  27637. /**
  27638. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. /**
  27642. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27644. */
  27645. isVisibilityBoxLocked: boolean;
  27646. /**
  27647. * Tells to `setParticles()` to compute the particle rotations or not.
  27648. * Default value : true. The SPS is faster when it's set to false.
  27649. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27650. */
  27651. /**
  27652. * Gets if `setParticles()` computes the particle rotations or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27655. */
  27656. computeParticleRotation: boolean;
  27657. /**
  27658. * Tells to `setParticles()` to compute the particle colors or not.
  27659. * Default value : true. The SPS is faster when it's set to false.
  27660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27661. */
  27662. /**
  27663. * Gets if `setParticles()` computes the particle colors or not.
  27664. * Default value : true. The SPS is faster when it's set to false.
  27665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27666. */
  27667. computeParticleColor: boolean;
  27668. /**
  27669. * Gets if `setParticles()` computes the particle textures or not.
  27670. * Default value : true. The SPS is faster when it's set to false.
  27671. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27672. */
  27673. computeParticleTexture: boolean;
  27674. /**
  27675. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27676. * Default value : false. The SPS is faster when it's set to false.
  27677. * Note : the particle custom vertex positions aren't stored values.
  27678. */
  27679. /**
  27680. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27681. * Default value : false. The SPS is faster when it's set to false.
  27682. * Note : the particle custom vertex positions aren't stored values.
  27683. */
  27684. computeParticleVertex: boolean;
  27685. /**
  27686. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27687. */
  27688. /**
  27689. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27690. */
  27691. computeBoundingBox: boolean;
  27692. /**
  27693. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27694. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27695. * Default : `true`
  27696. */
  27697. /**
  27698. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27699. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27700. * Default : `true`
  27701. */
  27702. depthSortParticles: boolean;
  27703. /**
  27704. * Gets if the SPS is created as expandable at construction time.
  27705. * Default : `false`
  27706. */
  27707. readonly expandable: boolean;
  27708. /**
  27709. * Gets if the SPS supports the Multi Materials
  27710. */
  27711. readonly multimaterialEnabled: boolean;
  27712. /**
  27713. * Gets if the SPS uses the model materials for its own multimaterial.
  27714. */
  27715. readonly useModelMaterial: boolean;
  27716. /**
  27717. * The SPS used material array.
  27718. */
  27719. readonly materials: Material[];
  27720. /**
  27721. * Sets the SPS MultiMaterial from the passed materials.
  27722. * Note : the passed array is internally copied and not used then by reference.
  27723. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27724. */
  27725. setMultiMaterial(materials: Material[]): void;
  27726. /**
  27727. * The SPS computed multimaterial object
  27728. */
  27729. multimaterial: MultiMaterial;
  27730. /**
  27731. * If the subMeshes must be updated on the next call to setParticles()
  27732. */
  27733. autoUpdateSubMeshes: boolean;
  27734. /**
  27735. * This function does nothing. It may be overwritten to set all the particle first values.
  27736. * The SPS doesn't call this function, you may have to call it by your own.
  27737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27738. */
  27739. initParticles(): void;
  27740. /**
  27741. * This function does nothing. It may be overwritten to recycle a particle.
  27742. * The SPS doesn't call this function, you may have to call it by your own.
  27743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27744. * @param particle The particle to recycle
  27745. * @returns the recycled particle
  27746. */
  27747. recycleParticle(particle: SolidParticle): SolidParticle;
  27748. /**
  27749. * Updates a particle : this function should be overwritten by the user.
  27750. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27752. * @example : just set a particle position or velocity and recycle conditions
  27753. * @param particle The particle to update
  27754. * @returns the updated particle
  27755. */
  27756. updateParticle(particle: SolidParticle): SolidParticle;
  27757. /**
  27758. * Updates a vertex of a particle : it can be overwritten by the user.
  27759. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27760. * @param particle the current particle
  27761. * @param vertex the current index of the current particle
  27762. * @param pt the index of the current vertex in the particle shape
  27763. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27764. * @example : just set a vertex particle position
  27765. * @returns the updated vertex
  27766. */
  27767. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27768. /**
  27769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27770. * This does nothing and may be overwritten by the user.
  27771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27773. * @param update the boolean update value actually passed to setParticles()
  27774. */
  27775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27776. /**
  27777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27778. * This will be passed three parameters.
  27779. * This does nothing and may be overwritten by the user.
  27780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27782. * @param update the boolean update value actually passed to setParticles()
  27783. */
  27784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27785. }
  27786. }
  27787. declare module "babylonjs/Particles/solidParticle" {
  27788. import { Nullable } from "babylonjs/types";
  27789. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27790. import { Color4 } from "babylonjs/Maths/math.color";
  27791. import { Mesh } from "babylonjs/Meshes/mesh";
  27792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27793. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27794. import { Plane } from "babylonjs/Maths/math.plane";
  27795. import { Material } from "babylonjs/Materials/material";
  27796. /**
  27797. * Represents one particle of a solid particle system.
  27798. */
  27799. export class SolidParticle {
  27800. /**
  27801. * particle global index
  27802. */
  27803. idx: number;
  27804. /**
  27805. * particle identifier
  27806. */
  27807. id: number;
  27808. /**
  27809. * The color of the particle
  27810. */
  27811. color: Nullable<Color4>;
  27812. /**
  27813. * The world space position of the particle.
  27814. */
  27815. position: Vector3;
  27816. /**
  27817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27818. */
  27819. rotation: Vector3;
  27820. /**
  27821. * The world space rotation quaternion of the particle.
  27822. */
  27823. rotationQuaternion: Nullable<Quaternion>;
  27824. /**
  27825. * The scaling of the particle.
  27826. */
  27827. scaling: Vector3;
  27828. /**
  27829. * The uvs of the particle.
  27830. */
  27831. uvs: Vector4;
  27832. /**
  27833. * The current speed of the particle.
  27834. */
  27835. velocity: Vector3;
  27836. /**
  27837. * The pivot point in the particle local space.
  27838. */
  27839. pivot: Vector3;
  27840. /**
  27841. * Must the particle be translated from its pivot point in its local space ?
  27842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27843. * Default : false
  27844. */
  27845. translateFromPivot: boolean;
  27846. /**
  27847. * Is the particle active or not ?
  27848. */
  27849. alive: boolean;
  27850. /**
  27851. * Is the particle visible or not ?
  27852. */
  27853. isVisible: boolean;
  27854. /**
  27855. * Index of this particle in the global "positions" array (Internal use)
  27856. * @hidden
  27857. */
  27858. _pos: number;
  27859. /**
  27860. * @hidden Index of this particle in the global "indices" array (Internal use)
  27861. */
  27862. _ind: number;
  27863. /**
  27864. * @hidden ModelShape of this particle (Internal use)
  27865. */
  27866. _model: ModelShape;
  27867. /**
  27868. * ModelShape id of this particle
  27869. */
  27870. shapeId: number;
  27871. /**
  27872. * Index of the particle in its shape id
  27873. */
  27874. idxInShape: number;
  27875. /**
  27876. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27877. */
  27878. _modelBoundingInfo: BoundingInfo;
  27879. /**
  27880. * @hidden Particle BoundingInfo object (Internal use)
  27881. */
  27882. _boundingInfo: BoundingInfo;
  27883. /**
  27884. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27885. */
  27886. _sps: SolidParticleSystem;
  27887. /**
  27888. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27889. */
  27890. _stillInvisible: boolean;
  27891. /**
  27892. * @hidden Last computed particle rotation matrix
  27893. */
  27894. _rotationMatrix: number[];
  27895. /**
  27896. * Parent particle Id, if any.
  27897. * Default null.
  27898. */
  27899. parentId: Nullable<number>;
  27900. /**
  27901. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27902. */
  27903. materialIndex: Nullable<number>;
  27904. /**
  27905. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27906. * The possible values are :
  27907. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27908. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27911. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27912. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27913. * */
  27914. cullingStrategy: number;
  27915. /**
  27916. * @hidden Internal global position in the SPS.
  27917. */
  27918. _globalPosition: Vector3;
  27919. /**
  27920. * Creates a Solid Particle object.
  27921. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27922. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27923. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27924. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27925. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27926. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27927. * @param shapeId (integer) is the model shape identifier in the SPS.
  27928. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27929. * @param sps defines the sps it is associated to
  27930. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27931. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27932. */
  27933. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27934. /**
  27935. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27936. * @param target the particle target
  27937. * @returns the current particle
  27938. */
  27939. copyToRef(target: SolidParticle): SolidParticle;
  27940. /**
  27941. * Legacy support, changed scale to scaling
  27942. */
  27943. /**
  27944. * Legacy support, changed scale to scaling
  27945. */
  27946. scale: Vector3;
  27947. /**
  27948. * Legacy support, changed quaternion to rotationQuaternion
  27949. */
  27950. /**
  27951. * Legacy support, changed quaternion to rotationQuaternion
  27952. */
  27953. quaternion: Nullable<Quaternion>;
  27954. /**
  27955. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27956. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27957. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27958. * @returns true if it intersects
  27959. */
  27960. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27961. /**
  27962. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27963. * A particle is in the frustum if its bounding box intersects the frustum
  27964. * @param frustumPlanes defines the frustum to test
  27965. * @returns true if the particle is in the frustum planes
  27966. */
  27967. isInFrustum(frustumPlanes: Plane[]): boolean;
  27968. /**
  27969. * get the rotation matrix of the particle
  27970. * @hidden
  27971. */
  27972. getRotationMatrix(m: Matrix): void;
  27973. }
  27974. /**
  27975. * Represents the shape of the model used by one particle of a solid particle system.
  27976. * SPS internal tool, don't use it manually.
  27977. */
  27978. export class ModelShape {
  27979. /**
  27980. * The shape id
  27981. * @hidden
  27982. */
  27983. shapeID: number;
  27984. /**
  27985. * flat array of model positions (internal use)
  27986. * @hidden
  27987. */
  27988. _shape: Vector3[];
  27989. /**
  27990. * flat array of model UVs (internal use)
  27991. * @hidden
  27992. */
  27993. _shapeUV: number[];
  27994. /**
  27995. * color array of the model
  27996. * @hidden
  27997. */
  27998. _shapeColors: number[];
  27999. /**
  28000. * indices array of the model
  28001. * @hidden
  28002. */
  28003. _indices: number[];
  28004. /**
  28005. * normals array of the model
  28006. * @hidden
  28007. */
  28008. _normals: number[];
  28009. /**
  28010. * length of the shape in the model indices array (internal use)
  28011. * @hidden
  28012. */
  28013. _indicesLength: number;
  28014. /**
  28015. * Custom position function (internal use)
  28016. * @hidden
  28017. */
  28018. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28019. /**
  28020. * Custom vertex function (internal use)
  28021. * @hidden
  28022. */
  28023. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28024. /**
  28025. * Model material (internal use)
  28026. * @hidden
  28027. */
  28028. _material: Nullable<Material>;
  28029. /**
  28030. * 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.
  28031. * SPS internal tool, don't use it manually.
  28032. * @hidden
  28033. */
  28034. 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>, material: Nullable<Material>);
  28035. }
  28036. /**
  28037. * Represents a Depth Sorted Particle in the solid particle system.
  28038. * @hidden
  28039. */
  28040. export class DepthSortedParticle {
  28041. /**
  28042. * Index of the particle in the "indices" array
  28043. */
  28044. ind: number;
  28045. /**
  28046. * Length of the particle shape in the "indices" array
  28047. */
  28048. indicesLength: number;
  28049. /**
  28050. * Squared distance from the particle to the camera
  28051. */
  28052. sqDistance: number;
  28053. /**
  28054. * Material index when used with MultiMaterials
  28055. */
  28056. materialIndex: number;
  28057. /**
  28058. * Creates a new sorted particle
  28059. * @param materialIndex
  28060. */
  28061. constructor(ind: number, indLength: number, materialIndex: number);
  28062. }
  28063. }
  28064. declare module "babylonjs/Collisions/meshCollisionData" {
  28065. import { Collider } from "babylonjs/Collisions/collider";
  28066. import { Vector3 } from "babylonjs/Maths/math.vector";
  28067. import { Nullable } from "babylonjs/types";
  28068. import { Observer } from "babylonjs/Misc/observable";
  28069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28070. /**
  28071. * @hidden
  28072. */
  28073. export class _MeshCollisionData {
  28074. _checkCollisions: boolean;
  28075. _collisionMask: number;
  28076. _collisionGroup: number;
  28077. _collider: Nullable<Collider>;
  28078. _oldPositionForCollisions: Vector3;
  28079. _diffPositionForCollisions: Vector3;
  28080. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28081. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28082. }
  28083. }
  28084. declare module "babylonjs/Meshes/abstractMesh" {
  28085. import { Observable } from "babylonjs/Misc/observable";
  28086. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28087. import { Camera } from "babylonjs/Cameras/camera";
  28088. import { Scene, IDisposable } from "babylonjs/scene";
  28089. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28090. import { Node } from "babylonjs/node";
  28091. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28092. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28094. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28095. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28096. import { Material } from "babylonjs/Materials/material";
  28097. import { Light } from "babylonjs/Lights/light";
  28098. import { Skeleton } from "babylonjs/Bones/skeleton";
  28099. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28100. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28101. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28102. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28103. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28104. import { Plane } from "babylonjs/Maths/math.plane";
  28105. import { Ray } from "babylonjs/Culling/ray";
  28106. import { Collider } from "babylonjs/Collisions/collider";
  28107. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28108. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28109. /** @hidden */
  28110. class _FacetDataStorage {
  28111. facetPositions: Vector3[];
  28112. facetNormals: Vector3[];
  28113. facetPartitioning: number[][];
  28114. facetNb: number;
  28115. partitioningSubdivisions: number;
  28116. partitioningBBoxRatio: number;
  28117. facetDataEnabled: boolean;
  28118. facetParameters: any;
  28119. bbSize: Vector3;
  28120. subDiv: {
  28121. max: number;
  28122. X: number;
  28123. Y: number;
  28124. Z: number;
  28125. };
  28126. facetDepthSort: boolean;
  28127. facetDepthSortEnabled: boolean;
  28128. depthSortedIndices: IndicesArray;
  28129. depthSortedFacets: {
  28130. ind: number;
  28131. sqDistance: number;
  28132. }[];
  28133. facetDepthSortFunction: (f1: {
  28134. ind: number;
  28135. sqDistance: number;
  28136. }, f2: {
  28137. ind: number;
  28138. sqDistance: number;
  28139. }) => number;
  28140. facetDepthSortFrom: Vector3;
  28141. facetDepthSortOrigin: Vector3;
  28142. invertedMatrix: Matrix;
  28143. }
  28144. /**
  28145. * @hidden
  28146. **/
  28147. class _InternalAbstractMeshDataInfo {
  28148. _hasVertexAlpha: boolean;
  28149. _useVertexColors: boolean;
  28150. _numBoneInfluencers: number;
  28151. _applyFog: boolean;
  28152. _receiveShadows: boolean;
  28153. _facetData: _FacetDataStorage;
  28154. _visibility: number;
  28155. _skeleton: Nullable<Skeleton>;
  28156. _layerMask: number;
  28157. _computeBonesUsingShaders: boolean;
  28158. _isActive: boolean;
  28159. _onlyForInstances: boolean;
  28160. _isActiveIntermediate: boolean;
  28161. _onlyForInstancesIntermediate: boolean;
  28162. _actAsRegularMesh: boolean;
  28163. }
  28164. /**
  28165. * Class used to store all common mesh properties
  28166. */
  28167. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28168. /** No occlusion */
  28169. static OCCLUSION_TYPE_NONE: number;
  28170. /** Occlusion set to optimisitic */
  28171. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28172. /** Occlusion set to strict */
  28173. static OCCLUSION_TYPE_STRICT: number;
  28174. /** Use an accurante occlusion algorithm */
  28175. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28176. /** Use a conservative occlusion algorithm */
  28177. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28178. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28179. * Test order :
  28180. * Is the bounding sphere outside the frustum ?
  28181. * If not, are the bounding box vertices outside the frustum ?
  28182. * It not, then the cullable object is in the frustum.
  28183. */
  28184. static readonly CULLINGSTRATEGY_STANDARD: number;
  28185. /** Culling strategy : Bounding Sphere Only.
  28186. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28187. * It's also less accurate than the standard because some not visible objects can still be selected.
  28188. * Test : is the bounding sphere outside the frustum ?
  28189. * If not, then the cullable object is in the frustum.
  28190. */
  28191. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28192. /** Culling strategy : Optimistic Inclusion.
  28193. * This in an inclusion test first, then the standard exclusion test.
  28194. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28195. * 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.
  28196. * Anyway, it's as accurate as the standard strategy.
  28197. * Test :
  28198. * Is the cullable object bounding sphere center in the frustum ?
  28199. * If not, apply the default culling strategy.
  28200. */
  28201. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28202. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28203. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28204. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28205. * 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.
  28206. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28207. * Test :
  28208. * Is the cullable object bounding sphere center in the frustum ?
  28209. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28210. */
  28211. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28212. /**
  28213. * No billboard
  28214. */
  28215. static readonly BILLBOARDMODE_NONE: number;
  28216. /** Billboard on X axis */
  28217. static readonly BILLBOARDMODE_X: number;
  28218. /** Billboard on Y axis */
  28219. static readonly BILLBOARDMODE_Y: number;
  28220. /** Billboard on Z axis */
  28221. static readonly BILLBOARDMODE_Z: number;
  28222. /** Billboard on all axes */
  28223. static readonly BILLBOARDMODE_ALL: number;
  28224. /** Billboard on using position instead of orientation */
  28225. static readonly BILLBOARDMODE_USE_POSITION: number;
  28226. /** @hidden */
  28227. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28228. /**
  28229. * The culling strategy to use to check whether the mesh must be rendered or not.
  28230. * This value can be changed at any time and will be used on the next render mesh selection.
  28231. * The possible values are :
  28232. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28233. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28234. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28236. * Please read each static variable documentation to get details about the culling process.
  28237. * */
  28238. cullingStrategy: number;
  28239. /**
  28240. * Gets the number of facets in the mesh
  28241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28242. */
  28243. readonly facetNb: number;
  28244. /**
  28245. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28247. */
  28248. partitioningSubdivisions: number;
  28249. /**
  28250. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28251. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28253. */
  28254. partitioningBBoxRatio: number;
  28255. /**
  28256. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28257. * Works only for updatable meshes.
  28258. * Doesn't work with multi-materials
  28259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28260. */
  28261. mustDepthSortFacets: boolean;
  28262. /**
  28263. * The location (Vector3) where the facet depth sort must be computed from.
  28264. * By default, the active camera position.
  28265. * Used only when facet depth sort is enabled
  28266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28267. */
  28268. facetDepthSortFrom: Vector3;
  28269. /**
  28270. * gets a boolean indicating if facetData is enabled
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28272. */
  28273. readonly isFacetDataEnabled: boolean;
  28274. /** @hidden */
  28275. _updateNonUniformScalingState(value: boolean): boolean;
  28276. /**
  28277. * An event triggered when this mesh collides with another one
  28278. */
  28279. onCollideObservable: Observable<AbstractMesh>;
  28280. /** Set a function to call when this mesh collides with another one */
  28281. onCollide: () => void;
  28282. /**
  28283. * An event triggered when the collision's position changes
  28284. */
  28285. onCollisionPositionChangeObservable: Observable<Vector3>;
  28286. /** Set a function to call when the collision's position changes */
  28287. onCollisionPositionChange: () => void;
  28288. /**
  28289. * An event triggered when material is changed
  28290. */
  28291. onMaterialChangedObservable: Observable<AbstractMesh>;
  28292. /**
  28293. * Gets or sets the orientation for POV movement & rotation
  28294. */
  28295. definedFacingForward: boolean;
  28296. /** @hidden */
  28297. _occlusionQuery: Nullable<WebGLQuery>;
  28298. /** @hidden */
  28299. _renderingGroup: Nullable<RenderingGroup>;
  28300. /**
  28301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28302. */
  28303. /**
  28304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28305. */
  28306. visibility: number;
  28307. /** Gets or sets the alpha index used to sort transparent meshes
  28308. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28309. */
  28310. alphaIndex: number;
  28311. /**
  28312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28317. */
  28318. isPickable: boolean;
  28319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28320. showSubMeshesBoundingBox: boolean;
  28321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28322. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28323. */
  28324. isBlocker: boolean;
  28325. /**
  28326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28327. */
  28328. enablePointerMoveEvents: boolean;
  28329. /**
  28330. * Specifies the rendering group id for this mesh (0 by default)
  28331. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28332. */
  28333. renderingGroupId: number;
  28334. private _material;
  28335. /** Gets or sets current material */
  28336. material: Nullable<Material>;
  28337. /**
  28338. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28339. * @see http://doc.babylonjs.com/babylon101/shadows
  28340. */
  28341. receiveShadows: boolean;
  28342. /** Defines color to use when rendering outline */
  28343. outlineColor: Color3;
  28344. /** Define width to use when rendering outline */
  28345. outlineWidth: number;
  28346. /** Defines color to use when rendering overlay */
  28347. overlayColor: Color3;
  28348. /** Defines alpha to use when rendering overlay */
  28349. overlayAlpha: number;
  28350. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28351. hasVertexAlpha: boolean;
  28352. /** 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) */
  28353. useVertexColors: boolean;
  28354. /**
  28355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28356. */
  28357. computeBonesUsingShaders: boolean;
  28358. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28359. numBoneInfluencers: number;
  28360. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28361. applyFog: boolean;
  28362. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28363. useOctreeForRenderingSelection: boolean;
  28364. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28365. useOctreeForPicking: boolean;
  28366. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28367. useOctreeForCollisions: boolean;
  28368. /**
  28369. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28370. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28371. */
  28372. layerMask: number;
  28373. /**
  28374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28375. */
  28376. alwaysSelectAsActiveMesh: boolean;
  28377. /**
  28378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28379. */
  28380. doNotSyncBoundingInfo: boolean;
  28381. /**
  28382. * Gets or sets the current action manager
  28383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28384. */
  28385. actionManager: Nullable<AbstractActionManager>;
  28386. private _meshCollisionData;
  28387. /**
  28388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28390. */
  28391. ellipsoid: Vector3;
  28392. /**
  28393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28395. */
  28396. ellipsoidOffset: Vector3;
  28397. /**
  28398. * Gets or sets a collision mask used to mask collisions (default is -1).
  28399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28400. */
  28401. collisionMask: number;
  28402. /**
  28403. * Gets or sets the current collision group mask (-1 by default).
  28404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28405. */
  28406. collisionGroup: number;
  28407. /**
  28408. * Defines edge width used when edgesRenderer is enabled
  28409. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28410. */
  28411. edgesWidth: number;
  28412. /**
  28413. * Defines edge color used when edgesRenderer is enabled
  28414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28415. */
  28416. edgesColor: Color4;
  28417. /** @hidden */
  28418. _edgesRenderer: Nullable<IEdgesRenderer>;
  28419. /** @hidden */
  28420. _masterMesh: Nullable<AbstractMesh>;
  28421. /** @hidden */
  28422. _boundingInfo: Nullable<BoundingInfo>;
  28423. /** @hidden */
  28424. _renderId: number;
  28425. /**
  28426. * Gets or sets the list of subMeshes
  28427. * @see http://doc.babylonjs.com/how_to/multi_materials
  28428. */
  28429. subMeshes: SubMesh[];
  28430. /** @hidden */
  28431. _intersectionsInProgress: AbstractMesh[];
  28432. /** @hidden */
  28433. _unIndexed: boolean;
  28434. /** @hidden */
  28435. _lightSources: Light[];
  28436. /** Gets the list of lights affecting that mesh */
  28437. readonly lightSources: Light[];
  28438. /** @hidden */
  28439. readonly _positions: Nullable<Vector3[]>;
  28440. /** @hidden */
  28441. _waitingData: {
  28442. lods: Nullable<any>;
  28443. actions: Nullable<any>;
  28444. freezeWorldMatrix: Nullable<boolean>;
  28445. };
  28446. /** @hidden */
  28447. _bonesTransformMatrices: Nullable<Float32Array>;
  28448. /** @hidden */
  28449. _transformMatrixTexture: Nullable<RawTexture>;
  28450. /**
  28451. * Gets or sets a skeleton to apply skining transformations
  28452. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28453. */
  28454. skeleton: Nullable<Skeleton>;
  28455. /**
  28456. * An event triggered when the mesh is rebuilt.
  28457. */
  28458. onRebuildObservable: Observable<AbstractMesh>;
  28459. /**
  28460. * Creates a new AbstractMesh
  28461. * @param name defines the name of the mesh
  28462. * @param scene defines the hosting scene
  28463. */
  28464. constructor(name: string, scene?: Nullable<Scene>);
  28465. /**
  28466. * Returns the string "AbstractMesh"
  28467. * @returns "AbstractMesh"
  28468. */
  28469. getClassName(): string;
  28470. /**
  28471. * Gets a string representation of the current mesh
  28472. * @param fullDetails defines a boolean indicating if full details must be included
  28473. * @returns a string representation of the current mesh
  28474. */
  28475. toString(fullDetails?: boolean): string;
  28476. /**
  28477. * @hidden
  28478. */
  28479. protected _getEffectiveParent(): Nullable<Node>;
  28480. /** @hidden */
  28481. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28482. /** @hidden */
  28483. _rebuild(): void;
  28484. /** @hidden */
  28485. _resyncLightSources(): void;
  28486. /** @hidden */
  28487. _resyncLightSource(light: Light): void;
  28488. /** @hidden */
  28489. _unBindEffect(): void;
  28490. /** @hidden */
  28491. _removeLightSource(light: Light, dispose: boolean): void;
  28492. private _markSubMeshesAsDirty;
  28493. /** @hidden */
  28494. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28495. /** @hidden */
  28496. _markSubMeshesAsAttributesDirty(): void;
  28497. /** @hidden */
  28498. _markSubMeshesAsMiscDirty(): void;
  28499. /**
  28500. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28501. */
  28502. scaling: Vector3;
  28503. /**
  28504. * Returns true if the mesh is blocked. Implemented by child classes
  28505. */
  28506. readonly isBlocked: boolean;
  28507. /**
  28508. * Returns the mesh itself by default. Implemented by child classes
  28509. * @param camera defines the camera to use to pick the right LOD level
  28510. * @returns the currentAbstractMesh
  28511. */
  28512. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28513. /**
  28514. * Returns 0 by default. Implemented by child classes
  28515. * @returns an integer
  28516. */
  28517. getTotalVertices(): number;
  28518. /**
  28519. * Returns a positive integer : the total number of indices in this mesh geometry.
  28520. * @returns the numner of indices or zero if the mesh has no geometry.
  28521. */
  28522. getTotalIndices(): number;
  28523. /**
  28524. * Returns null by default. Implemented by child classes
  28525. * @returns null
  28526. */
  28527. getIndices(): Nullable<IndicesArray>;
  28528. /**
  28529. * Returns the array of the requested vertex data kind. Implemented by child classes
  28530. * @param kind defines the vertex data kind to use
  28531. * @returns null
  28532. */
  28533. getVerticesData(kind: string): Nullable<FloatArray>;
  28534. /**
  28535. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28536. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28537. * Note that a new underlying VertexBuffer object is created each call.
  28538. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28539. * @param kind defines vertex data kind:
  28540. * * VertexBuffer.PositionKind
  28541. * * VertexBuffer.UVKind
  28542. * * VertexBuffer.UV2Kind
  28543. * * VertexBuffer.UV3Kind
  28544. * * VertexBuffer.UV4Kind
  28545. * * VertexBuffer.UV5Kind
  28546. * * VertexBuffer.UV6Kind
  28547. * * VertexBuffer.ColorKind
  28548. * * VertexBuffer.MatricesIndicesKind
  28549. * * VertexBuffer.MatricesIndicesExtraKind
  28550. * * VertexBuffer.MatricesWeightsKind
  28551. * * VertexBuffer.MatricesWeightsExtraKind
  28552. * @param data defines the data source
  28553. * @param updatable defines if the data must be flagged as updatable (or static)
  28554. * @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
  28555. * @returns the current mesh
  28556. */
  28557. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28558. /**
  28559. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28560. * If the mesh has no geometry, it is simply returned as it is.
  28561. * @param kind defines vertex data kind:
  28562. * * VertexBuffer.PositionKind
  28563. * * VertexBuffer.UVKind
  28564. * * VertexBuffer.UV2Kind
  28565. * * VertexBuffer.UV3Kind
  28566. * * VertexBuffer.UV4Kind
  28567. * * VertexBuffer.UV5Kind
  28568. * * VertexBuffer.UV6Kind
  28569. * * VertexBuffer.ColorKind
  28570. * * VertexBuffer.MatricesIndicesKind
  28571. * * VertexBuffer.MatricesIndicesExtraKind
  28572. * * VertexBuffer.MatricesWeightsKind
  28573. * * VertexBuffer.MatricesWeightsExtraKind
  28574. * @param data defines the data source
  28575. * @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
  28576. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28577. * @returns the current mesh
  28578. */
  28579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28580. /**
  28581. * Sets the mesh indices,
  28582. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28583. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28584. * @param totalVertices Defines the total number of vertices
  28585. * @returns the current mesh
  28586. */
  28587. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28588. /**
  28589. * Gets a boolean indicating if specific vertex data is present
  28590. * @param kind defines the vertex data kind to use
  28591. * @returns true is data kind is present
  28592. */
  28593. isVerticesDataPresent(kind: string): boolean;
  28594. /**
  28595. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28596. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28597. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28598. * @returns a BoundingInfo
  28599. */
  28600. getBoundingInfo(): BoundingInfo;
  28601. /**
  28602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28606. * @returns the current mesh
  28607. */
  28608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28609. /**
  28610. * Overwrite the current bounding info
  28611. * @param boundingInfo defines the new bounding info
  28612. * @returns the current mesh
  28613. */
  28614. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28615. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28616. readonly useBones: boolean;
  28617. /** @hidden */
  28618. _preActivate(): void;
  28619. /** @hidden */
  28620. _preActivateForIntermediateRendering(renderId: number): void;
  28621. /** @hidden */
  28622. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28623. /** @hidden */
  28624. _postActivate(): void;
  28625. /** @hidden */
  28626. _freeze(): void;
  28627. /** @hidden */
  28628. _unFreeze(): void;
  28629. /**
  28630. * Gets the current world matrix
  28631. * @returns a Matrix
  28632. */
  28633. getWorldMatrix(): Matrix;
  28634. /** @hidden */
  28635. _getWorldMatrixDeterminant(): number;
  28636. /**
  28637. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28638. */
  28639. readonly isAnInstance: boolean;
  28640. /**
  28641. * Gets a boolean indicating if this mesh has instances
  28642. */
  28643. readonly hasInstances: boolean;
  28644. /**
  28645. * Perform relative position change from the point of view of behind the front of the mesh.
  28646. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28647. * Supports definition of mesh facing forward or backward
  28648. * @param amountRight defines the distance on the right axis
  28649. * @param amountUp defines the distance on the up axis
  28650. * @param amountForward defines the distance on the forward axis
  28651. * @returns the current mesh
  28652. */
  28653. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28654. /**
  28655. * Calculate relative position change from the point of view of behind the front of the mesh.
  28656. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28657. * Supports definition of mesh facing forward or backward
  28658. * @param amountRight defines the distance on the right axis
  28659. * @param amountUp defines the distance on the up axis
  28660. * @param amountForward defines the distance on the forward axis
  28661. * @returns the new displacement vector
  28662. */
  28663. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28664. /**
  28665. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28666. * Supports definition of mesh facing forward or backward
  28667. * @param flipBack defines the flip
  28668. * @param twirlClockwise defines the twirl
  28669. * @param tiltRight defines the tilt
  28670. * @returns the current mesh
  28671. */
  28672. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28673. /**
  28674. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28675. * Supports definition of mesh facing forward or backward.
  28676. * @param flipBack defines the flip
  28677. * @param twirlClockwise defines the twirl
  28678. * @param tiltRight defines the tilt
  28679. * @returns the new rotation vector
  28680. */
  28681. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28682. /**
  28683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28684. * This means the mesh underlying bounding box and sphere are recomputed.
  28685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28686. * @returns the current mesh
  28687. */
  28688. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28689. /** @hidden */
  28690. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28691. /** @hidden */
  28692. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28693. /** @hidden */
  28694. _updateBoundingInfo(): AbstractMesh;
  28695. /** @hidden */
  28696. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28697. /** @hidden */
  28698. protected _afterComputeWorldMatrix(): void;
  28699. /** @hidden */
  28700. readonly _effectiveMesh: AbstractMesh;
  28701. /**
  28702. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28703. * A mesh is in the frustum if its bounding box intersects the frustum
  28704. * @param frustumPlanes defines the frustum to test
  28705. * @returns true if the mesh is in the frustum planes
  28706. */
  28707. isInFrustum(frustumPlanes: Plane[]): boolean;
  28708. /**
  28709. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28710. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28711. * @param frustumPlanes defines the frustum to test
  28712. * @returns true if the mesh is completely in the frustum planes
  28713. */
  28714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28715. /**
  28716. * True if the mesh intersects another mesh or a SolidParticle object
  28717. * @param mesh defines a target mesh or SolidParticle to test
  28718. * @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)
  28719. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28720. * @returns true if there is an intersection
  28721. */
  28722. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28723. /**
  28724. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28725. * @param point defines the point to test
  28726. * @returns true if there is an intersection
  28727. */
  28728. intersectsPoint(point: Vector3): boolean;
  28729. /**
  28730. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28731. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28732. */
  28733. checkCollisions: boolean;
  28734. /**
  28735. * Gets Collider object used to compute collisions (not physics)
  28736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28737. */
  28738. readonly collider: Nullable<Collider>;
  28739. /**
  28740. * Move the mesh using collision engine
  28741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28742. * @param displacement defines the requested displacement vector
  28743. * @returns the current mesh
  28744. */
  28745. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28746. private _onCollisionPositionChange;
  28747. /** @hidden */
  28748. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28749. /** @hidden */
  28750. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28751. /** @hidden */
  28752. _checkCollision(collider: Collider): AbstractMesh;
  28753. /** @hidden */
  28754. _generatePointsArray(): boolean;
  28755. /**
  28756. * Checks if the passed Ray intersects with the mesh
  28757. * @param ray defines the ray to use
  28758. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28760. * @returns the picking info
  28761. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28762. */
  28763. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28764. /**
  28765. * Clones the current mesh
  28766. * @param name defines the mesh name
  28767. * @param newParent defines the new mesh parent
  28768. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28769. * @returns the new mesh
  28770. */
  28771. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28772. /**
  28773. * Disposes all the submeshes of the current meshnp
  28774. * @returns the current mesh
  28775. */
  28776. releaseSubMeshes(): AbstractMesh;
  28777. /**
  28778. * Releases resources associated with this abstract mesh.
  28779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28781. */
  28782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28783. /**
  28784. * Adds the passed mesh as a child to the current mesh
  28785. * @param mesh defines the child mesh
  28786. * @returns the current mesh
  28787. */
  28788. addChild(mesh: AbstractMesh): AbstractMesh;
  28789. /**
  28790. * Removes the passed mesh from the current mesh children list
  28791. * @param mesh defines the child mesh
  28792. * @returns the current mesh
  28793. */
  28794. removeChild(mesh: AbstractMesh): AbstractMesh;
  28795. /** @hidden */
  28796. private _initFacetData;
  28797. /**
  28798. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28799. * This method can be called within the render loop.
  28800. * 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
  28801. * @returns the current mesh
  28802. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28803. */
  28804. updateFacetData(): AbstractMesh;
  28805. /**
  28806. * Returns the facetLocalNormals array.
  28807. * The normals are expressed in the mesh local spac
  28808. * @returns an array of Vector3
  28809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28810. */
  28811. getFacetLocalNormals(): Vector3[];
  28812. /**
  28813. * Returns the facetLocalPositions array.
  28814. * The facet positions are expressed in the mesh local space
  28815. * @returns an array of Vector3
  28816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28817. */
  28818. getFacetLocalPositions(): Vector3[];
  28819. /**
  28820. * Returns the facetLocalPartioning array
  28821. * @returns an array of array of numbers
  28822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28823. */
  28824. getFacetLocalPartitioning(): number[][];
  28825. /**
  28826. * Returns the i-th facet position in the world system.
  28827. * This method allocates a new Vector3 per call
  28828. * @param i defines the facet index
  28829. * @returns a new Vector3
  28830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28831. */
  28832. getFacetPosition(i: number): Vector3;
  28833. /**
  28834. * Sets the reference Vector3 with the i-th facet position in the world system
  28835. * @param i defines the facet index
  28836. * @param ref defines the target vector
  28837. * @returns the current mesh
  28838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28839. */
  28840. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28841. /**
  28842. * Returns the i-th facet normal in the world system.
  28843. * This method allocates a new Vector3 per call
  28844. * @param i defines the facet index
  28845. * @returns a new Vector3
  28846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28847. */
  28848. getFacetNormal(i: number): Vector3;
  28849. /**
  28850. * Sets the reference Vector3 with the i-th facet normal in the world system
  28851. * @param i defines the facet index
  28852. * @param ref defines the target vector
  28853. * @returns the current mesh
  28854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28855. */
  28856. getFacetNormalToRef(i: number, ref: Vector3): this;
  28857. /**
  28858. * 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)
  28859. * @param x defines x coordinate
  28860. * @param y defines y coordinate
  28861. * @param z defines z coordinate
  28862. * @returns the array of facet indexes
  28863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28864. */
  28865. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28866. /**
  28867. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28868. * @param projected sets as the (x,y,z) world projection on the facet
  28869. * @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
  28870. * @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
  28871. * @param x defines x coordinate
  28872. * @param y defines y coordinate
  28873. * @param z defines z coordinate
  28874. * @returns the face index if found (or null instead)
  28875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28876. */
  28877. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28878. /**
  28879. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28880. * @param projected sets as the (x,y,z) local projection on the facet
  28881. * @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
  28882. * @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
  28883. * @param x defines x coordinate
  28884. * @param y defines y coordinate
  28885. * @param z defines z coordinate
  28886. * @returns the face index if found (or null instead)
  28887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28888. */
  28889. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28890. /**
  28891. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28892. * @returns the parameters
  28893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28894. */
  28895. getFacetDataParameters(): any;
  28896. /**
  28897. * Disables the feature FacetData and frees the related memory
  28898. * @returns the current mesh
  28899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28900. */
  28901. disableFacetData(): AbstractMesh;
  28902. /**
  28903. * Updates the AbstractMesh indices array
  28904. * @param indices defines the data source
  28905. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28906. * @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)
  28907. * @returns the current mesh
  28908. */
  28909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28910. /**
  28911. * Creates new normals data for the mesh
  28912. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28913. * @returns the current mesh
  28914. */
  28915. createNormals(updatable: boolean): AbstractMesh;
  28916. /**
  28917. * Align the mesh with a normal
  28918. * @param normal defines the normal to use
  28919. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28920. * @returns the current mesh
  28921. */
  28922. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28923. /** @hidden */
  28924. _checkOcclusionQuery(): boolean;
  28925. /**
  28926. * Disables the mesh edge rendering mode
  28927. * @returns the currentAbstractMesh
  28928. */
  28929. disableEdgesRendering(): AbstractMesh;
  28930. /**
  28931. * Enables the edge rendering mode on the mesh.
  28932. * This mode makes the mesh edges visible
  28933. * @param epsilon defines the maximal distance between two angles to detect a face
  28934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28935. * @returns the currentAbstractMesh
  28936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28937. */
  28938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28939. }
  28940. }
  28941. declare module "babylonjs/Actions/actionEvent" {
  28942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28943. import { Nullable } from "babylonjs/types";
  28944. import { Sprite } from "babylonjs/Sprites/sprite";
  28945. import { Scene } from "babylonjs/scene";
  28946. import { Vector2 } from "babylonjs/Maths/math.vector";
  28947. /**
  28948. * Interface used to define ActionEvent
  28949. */
  28950. export interface IActionEvent {
  28951. /** The mesh or sprite that triggered the action */
  28952. source: any;
  28953. /** The X mouse cursor position at the time of the event */
  28954. pointerX: number;
  28955. /** The Y mouse cursor position at the time of the event */
  28956. pointerY: number;
  28957. /** The mesh that is currently pointed at (can be null) */
  28958. meshUnderPointer: Nullable<AbstractMesh>;
  28959. /** the original (browser) event that triggered the ActionEvent */
  28960. sourceEvent?: any;
  28961. /** additional data for the event */
  28962. additionalData?: any;
  28963. }
  28964. /**
  28965. * ActionEvent is the event being sent when an action is triggered.
  28966. */
  28967. export class ActionEvent implements IActionEvent {
  28968. /** The mesh or sprite that triggered the action */
  28969. source: any;
  28970. /** The X mouse cursor position at the time of the event */
  28971. pointerX: number;
  28972. /** The Y mouse cursor position at the time of the event */
  28973. pointerY: number;
  28974. /** The mesh that is currently pointed at (can be null) */
  28975. meshUnderPointer: Nullable<AbstractMesh>;
  28976. /** the original (browser) event that triggered the ActionEvent */
  28977. sourceEvent?: any;
  28978. /** additional data for the event */
  28979. additionalData?: any;
  28980. /**
  28981. * Creates a new ActionEvent
  28982. * @param source The mesh or sprite that triggered the action
  28983. * @param pointerX The X mouse cursor position at the time of the event
  28984. * @param pointerY The Y mouse cursor position at the time of the event
  28985. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28986. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28987. * @param additionalData additional data for the event
  28988. */
  28989. constructor(
  28990. /** The mesh or sprite that triggered the action */
  28991. source: any,
  28992. /** The X mouse cursor position at the time of the event */
  28993. pointerX: number,
  28994. /** The Y mouse cursor position at the time of the event */
  28995. pointerY: number,
  28996. /** The mesh that is currently pointed at (can be null) */
  28997. meshUnderPointer: Nullable<AbstractMesh>,
  28998. /** the original (browser) event that triggered the ActionEvent */
  28999. sourceEvent?: any,
  29000. /** additional data for the event */
  29001. additionalData?: any);
  29002. /**
  29003. * Helper function to auto-create an ActionEvent from a source mesh.
  29004. * @param source The source mesh that triggered the event
  29005. * @param evt The original (browser) event
  29006. * @param additionalData additional data for the event
  29007. * @returns the new ActionEvent
  29008. */
  29009. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29010. /**
  29011. * Helper function to auto-create an ActionEvent from a source sprite
  29012. * @param source The source sprite that triggered the event
  29013. * @param scene Scene associated with the sprite
  29014. * @param evt The original (browser) event
  29015. * @param additionalData additional data for the event
  29016. * @returns the new ActionEvent
  29017. */
  29018. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29019. /**
  29020. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29021. * @param scene the scene where the event occurred
  29022. * @param evt The original (browser) event
  29023. * @returns the new ActionEvent
  29024. */
  29025. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29026. /**
  29027. * Helper function to auto-create an ActionEvent from a primitive
  29028. * @param prim defines the target primitive
  29029. * @param pointerPos defines the pointer position
  29030. * @param evt The original (browser) event
  29031. * @param additionalData additional data for the event
  29032. * @returns the new ActionEvent
  29033. */
  29034. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29035. }
  29036. }
  29037. declare module "babylonjs/Actions/abstractActionManager" {
  29038. import { IDisposable } from "babylonjs/scene";
  29039. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29040. import { IAction } from "babylonjs/Actions/action";
  29041. import { Nullable } from "babylonjs/types";
  29042. /**
  29043. * Abstract class used to decouple action Manager from scene and meshes.
  29044. * Do not instantiate.
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29046. */
  29047. export abstract class AbstractActionManager implements IDisposable {
  29048. /** Gets the list of active triggers */
  29049. static Triggers: {
  29050. [key: string]: number;
  29051. };
  29052. /** Gets the cursor to use when hovering items */
  29053. hoverCursor: string;
  29054. /** Gets the list of actions */
  29055. actions: IAction[];
  29056. /**
  29057. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29058. */
  29059. isRecursive: boolean;
  29060. /**
  29061. * Releases all associated resources
  29062. */
  29063. abstract dispose(): void;
  29064. /**
  29065. * Does this action manager has pointer triggers
  29066. */
  29067. abstract readonly hasPointerTriggers: boolean;
  29068. /**
  29069. * Does this action manager has pick triggers
  29070. */
  29071. abstract readonly hasPickTriggers: boolean;
  29072. /**
  29073. * Process a specific trigger
  29074. * @param trigger defines the trigger to process
  29075. * @param evt defines the event details to be processed
  29076. */
  29077. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29078. /**
  29079. * Does this action manager handles actions of any of the given triggers
  29080. * @param triggers defines the triggers to be tested
  29081. * @return a boolean indicating whether one (or more) of the triggers is handled
  29082. */
  29083. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29084. /**
  29085. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29086. * speed.
  29087. * @param triggerA defines the trigger to be tested
  29088. * @param triggerB defines the trigger to be tested
  29089. * @return a boolean indicating whether one (or more) of the triggers is handled
  29090. */
  29091. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29092. /**
  29093. * Does this action manager handles actions of a given trigger
  29094. * @param trigger defines the trigger to be tested
  29095. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29096. * @return whether the trigger is handled
  29097. */
  29098. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29099. /**
  29100. * Serialize this manager to a JSON object
  29101. * @param name defines the property name to store this manager
  29102. * @returns a JSON representation of this manager
  29103. */
  29104. abstract serialize(name: string): any;
  29105. /**
  29106. * Registers an action to this action manager
  29107. * @param action defines the action to be registered
  29108. * @return the action amended (prepared) after registration
  29109. */
  29110. abstract registerAction(action: IAction): Nullable<IAction>;
  29111. /**
  29112. * Unregisters an action to this action manager
  29113. * @param action defines the action to be unregistered
  29114. * @return a boolean indicating whether the action has been unregistered
  29115. */
  29116. abstract unregisterAction(action: IAction): Boolean;
  29117. /**
  29118. * Does exist one action manager with at least one trigger
  29119. **/
  29120. static readonly HasTriggers: boolean;
  29121. /**
  29122. * Does exist one action manager with at least one pick trigger
  29123. **/
  29124. static readonly HasPickTriggers: boolean;
  29125. /**
  29126. * Does exist one action manager that handles actions of a given trigger
  29127. * @param trigger defines the trigger to be tested
  29128. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29129. **/
  29130. static HasSpecificTrigger(trigger: number): boolean;
  29131. }
  29132. }
  29133. declare module "babylonjs/node" {
  29134. import { Scene } from "babylonjs/scene";
  29135. import { Nullable } from "babylonjs/types";
  29136. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29137. import { Engine } from "babylonjs/Engines/engine";
  29138. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29139. import { Observable } from "babylonjs/Misc/observable";
  29140. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29141. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29142. import { Animatable } from "babylonjs/Animations/animatable";
  29143. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29144. import { Animation } from "babylonjs/Animations/animation";
  29145. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29147. /**
  29148. * Defines how a node can be built from a string name.
  29149. */
  29150. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29151. /**
  29152. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29153. */
  29154. export class Node implements IBehaviorAware<Node> {
  29155. /** @hidden */
  29156. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29157. private static _NodeConstructors;
  29158. /**
  29159. * Add a new node constructor
  29160. * @param type defines the type name of the node to construct
  29161. * @param constructorFunc defines the constructor function
  29162. */
  29163. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29164. /**
  29165. * Returns a node constructor based on type name
  29166. * @param type defines the type name
  29167. * @param name defines the new node name
  29168. * @param scene defines the hosting scene
  29169. * @param options defines optional options to transmit to constructors
  29170. * @returns the new constructor or null
  29171. */
  29172. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29173. /**
  29174. * Gets or sets the name of the node
  29175. */
  29176. name: string;
  29177. /**
  29178. * Gets or sets the id of the node
  29179. */
  29180. id: string;
  29181. /**
  29182. * Gets or sets the unique id of the node
  29183. */
  29184. uniqueId: number;
  29185. /**
  29186. * Gets or sets a string used to store user defined state for the node
  29187. */
  29188. state: string;
  29189. /**
  29190. * Gets or sets an object used to store user defined information for the node
  29191. */
  29192. metadata: any;
  29193. /**
  29194. * For internal use only. Please do not use.
  29195. */
  29196. reservedDataStore: any;
  29197. /**
  29198. * List of inspectable custom properties (used by the Inspector)
  29199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29200. */
  29201. inspectableCustomProperties: IInspectable[];
  29202. private _doNotSerialize;
  29203. /**
  29204. * Gets or sets a boolean used to define if the node must be serialized
  29205. */
  29206. doNotSerialize: boolean;
  29207. /** @hidden */
  29208. _isDisposed: boolean;
  29209. /**
  29210. * Gets a list of Animations associated with the node
  29211. */
  29212. animations: import("babylonjs/Animations/animation").Animation[];
  29213. protected _ranges: {
  29214. [name: string]: Nullable<AnimationRange>;
  29215. };
  29216. /**
  29217. * Callback raised when the node is ready to be used
  29218. */
  29219. onReady: Nullable<(node: Node) => void>;
  29220. private _isEnabled;
  29221. private _isParentEnabled;
  29222. private _isReady;
  29223. /** @hidden */
  29224. _currentRenderId: number;
  29225. private _parentUpdateId;
  29226. /** @hidden */
  29227. _childUpdateId: number;
  29228. /** @hidden */
  29229. _waitingParentId: Nullable<string>;
  29230. /** @hidden */
  29231. _scene: Scene;
  29232. /** @hidden */
  29233. _cache: any;
  29234. private _parentNode;
  29235. private _children;
  29236. /** @hidden */
  29237. _worldMatrix: Matrix;
  29238. /** @hidden */
  29239. _worldMatrixDeterminant: number;
  29240. /** @hidden */
  29241. _worldMatrixDeterminantIsDirty: boolean;
  29242. /** @hidden */
  29243. private _sceneRootNodesIndex;
  29244. /**
  29245. * Gets a boolean indicating if the node has been disposed
  29246. * @returns true if the node was disposed
  29247. */
  29248. isDisposed(): boolean;
  29249. /**
  29250. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29251. * @see https://doc.babylonjs.com/how_to/parenting
  29252. */
  29253. parent: Nullable<Node>;
  29254. /** @hidden */
  29255. _addToSceneRootNodes(): void;
  29256. /** @hidden */
  29257. _removeFromSceneRootNodes(): void;
  29258. private _animationPropertiesOverride;
  29259. /**
  29260. * Gets or sets the animation properties override
  29261. */
  29262. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29263. /**
  29264. * Gets a string idenfifying the name of the class
  29265. * @returns "Node" string
  29266. */
  29267. getClassName(): string;
  29268. /** @hidden */
  29269. readonly _isNode: boolean;
  29270. /**
  29271. * An event triggered when the mesh is disposed
  29272. */
  29273. onDisposeObservable: Observable<Node>;
  29274. private _onDisposeObserver;
  29275. /**
  29276. * Sets a callback that will be raised when the node will be disposed
  29277. */
  29278. onDispose: () => void;
  29279. /**
  29280. * Creates a new Node
  29281. * @param name the name and id to be given to this node
  29282. * @param scene the scene this node will be added to
  29283. */
  29284. constructor(name: string, scene?: Nullable<Scene>);
  29285. /**
  29286. * Gets the scene of the node
  29287. * @returns a scene
  29288. */
  29289. getScene(): Scene;
  29290. /**
  29291. * Gets the engine of the node
  29292. * @returns a Engine
  29293. */
  29294. getEngine(): Engine;
  29295. private _behaviors;
  29296. /**
  29297. * Attach a behavior to the node
  29298. * @see http://doc.babylonjs.com/features/behaviour
  29299. * @param behavior defines the behavior to attach
  29300. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29301. * @returns the current Node
  29302. */
  29303. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29304. /**
  29305. * Remove an attached behavior
  29306. * @see http://doc.babylonjs.com/features/behaviour
  29307. * @param behavior defines the behavior to attach
  29308. * @returns the current Node
  29309. */
  29310. removeBehavior(behavior: Behavior<Node>): Node;
  29311. /**
  29312. * Gets the list of attached behaviors
  29313. * @see http://doc.babylonjs.com/features/behaviour
  29314. */
  29315. readonly behaviors: Behavior<Node>[];
  29316. /**
  29317. * Gets an attached behavior by name
  29318. * @param name defines the name of the behavior to look for
  29319. * @see http://doc.babylonjs.com/features/behaviour
  29320. * @returns null if behavior was not found else the requested behavior
  29321. */
  29322. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29323. /**
  29324. * Returns the latest update of the World matrix
  29325. * @returns a Matrix
  29326. */
  29327. getWorldMatrix(): Matrix;
  29328. /** @hidden */
  29329. _getWorldMatrixDeterminant(): number;
  29330. /**
  29331. * Returns directly the latest state of the mesh World matrix.
  29332. * A Matrix is returned.
  29333. */
  29334. readonly worldMatrixFromCache: Matrix;
  29335. /** @hidden */
  29336. _initCache(): void;
  29337. /** @hidden */
  29338. updateCache(force?: boolean): void;
  29339. /** @hidden */
  29340. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29341. /** @hidden */
  29342. _updateCache(ignoreParentClass?: boolean): void;
  29343. /** @hidden */
  29344. _isSynchronized(): boolean;
  29345. /** @hidden */
  29346. _markSyncedWithParent(): void;
  29347. /** @hidden */
  29348. isSynchronizedWithParent(): boolean;
  29349. /** @hidden */
  29350. isSynchronized(): boolean;
  29351. /**
  29352. * Is this node ready to be used/rendered
  29353. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29354. * @return true if the node is ready
  29355. */
  29356. isReady(completeCheck?: boolean): boolean;
  29357. /**
  29358. * Is this node enabled?
  29359. * 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
  29360. * @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
  29361. * @return whether this node (and its parent) is enabled
  29362. */
  29363. isEnabled(checkAncestors?: boolean): boolean;
  29364. /** @hidden */
  29365. protected _syncParentEnabledState(): void;
  29366. /**
  29367. * Set the enabled state of this node
  29368. * @param value defines the new enabled state
  29369. */
  29370. setEnabled(value: boolean): void;
  29371. /**
  29372. * Is this node a descendant of the given node?
  29373. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29374. * @param ancestor defines the parent node to inspect
  29375. * @returns a boolean indicating if this node is a descendant of the given node
  29376. */
  29377. isDescendantOf(ancestor: Node): boolean;
  29378. /** @hidden */
  29379. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29380. /**
  29381. * Will return all nodes that have this node as ascendant
  29382. * @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
  29383. * @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
  29384. * @return all children nodes of all types
  29385. */
  29386. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29387. /**
  29388. * Get all child-meshes of this node
  29389. * @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)
  29390. * @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
  29391. * @returns an array of AbstractMesh
  29392. */
  29393. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29394. /**
  29395. * Get all direct children of this node
  29396. * @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
  29397. * @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)
  29398. * @returns an array of Node
  29399. */
  29400. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29401. /** @hidden */
  29402. _setReady(state: boolean): void;
  29403. /**
  29404. * Get an animation by name
  29405. * @param name defines the name of the animation to look for
  29406. * @returns null if not found else the requested animation
  29407. */
  29408. getAnimationByName(name: string): Nullable<Animation>;
  29409. /**
  29410. * Creates an animation range for this node
  29411. * @param name defines the name of the range
  29412. * @param from defines the starting key
  29413. * @param to defines the end key
  29414. */
  29415. createAnimationRange(name: string, from: number, to: number): void;
  29416. /**
  29417. * Delete a specific animation range
  29418. * @param name defines the name of the range to delete
  29419. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29420. */
  29421. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29422. /**
  29423. * Get an animation range by name
  29424. * @param name defines the name of the animation range to look for
  29425. * @returns null if not found else the requested animation range
  29426. */
  29427. getAnimationRange(name: string): Nullable<AnimationRange>;
  29428. /**
  29429. * Gets the list of all animation ranges defined on this node
  29430. * @returns an array
  29431. */
  29432. getAnimationRanges(): Nullable<AnimationRange>[];
  29433. /**
  29434. * Will start the animation sequence
  29435. * @param name defines the range frames for animation sequence
  29436. * @param loop defines if the animation should loop (false by default)
  29437. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29438. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29439. * @returns the object created for this animation. If range does not exist, it will return null
  29440. */
  29441. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29442. /**
  29443. * Serialize animation ranges into a JSON compatible object
  29444. * @returns serialization object
  29445. */
  29446. serializeAnimationRanges(): any;
  29447. /**
  29448. * Computes the world matrix of the node
  29449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29450. * @returns the world matrix
  29451. */
  29452. computeWorldMatrix(force?: boolean): Matrix;
  29453. /**
  29454. * Releases resources associated with this node.
  29455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29457. */
  29458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29459. /**
  29460. * Parse animation range data from a serialization object and store them into a given node
  29461. * @param node defines where to store the animation ranges
  29462. * @param parsedNode defines the serialization object to read data from
  29463. * @param scene defines the hosting scene
  29464. */
  29465. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29466. /**
  29467. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29468. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29469. * @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
  29470. * @returns the new bounding vectors
  29471. */
  29472. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29473. min: Vector3;
  29474. max: Vector3;
  29475. };
  29476. }
  29477. }
  29478. declare module "babylonjs/Animations/animation" {
  29479. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29480. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29481. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29482. import { Nullable } from "babylonjs/types";
  29483. import { Scene } from "babylonjs/scene";
  29484. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29485. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29486. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29487. import { Node } from "babylonjs/node";
  29488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29489. import { Size } from "babylonjs/Maths/math.size";
  29490. import { Animatable } from "babylonjs/Animations/animatable";
  29491. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29492. /**
  29493. * @hidden
  29494. */
  29495. export class _IAnimationState {
  29496. key: number;
  29497. repeatCount: number;
  29498. workValue?: any;
  29499. loopMode?: number;
  29500. offsetValue?: any;
  29501. highLimitValue?: any;
  29502. }
  29503. /**
  29504. * Class used to store any kind of animation
  29505. */
  29506. export class Animation {
  29507. /**Name of the animation */
  29508. name: string;
  29509. /**Property to animate */
  29510. targetProperty: string;
  29511. /**The frames per second of the animation */
  29512. framePerSecond: number;
  29513. /**The data type of the animation */
  29514. dataType: number;
  29515. /**The loop mode of the animation */
  29516. loopMode?: number | undefined;
  29517. /**Specifies if blending should be enabled */
  29518. enableBlending?: boolean | undefined;
  29519. /**
  29520. * Use matrix interpolation instead of using direct key value when animating matrices
  29521. */
  29522. static AllowMatricesInterpolation: boolean;
  29523. /**
  29524. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29525. */
  29526. static AllowMatrixDecomposeForInterpolation: boolean;
  29527. /**
  29528. * Stores the key frames of the animation
  29529. */
  29530. private _keys;
  29531. /**
  29532. * Stores the easing function of the animation
  29533. */
  29534. private _easingFunction;
  29535. /**
  29536. * @hidden Internal use only
  29537. */
  29538. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29539. /**
  29540. * The set of event that will be linked to this animation
  29541. */
  29542. private _events;
  29543. /**
  29544. * Stores an array of target property paths
  29545. */
  29546. targetPropertyPath: string[];
  29547. /**
  29548. * Stores the blending speed of the animation
  29549. */
  29550. blendingSpeed: number;
  29551. /**
  29552. * Stores the animation ranges for the animation
  29553. */
  29554. private _ranges;
  29555. /**
  29556. * @hidden Internal use
  29557. */
  29558. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29559. /**
  29560. * Sets up an animation
  29561. * @param property The property to animate
  29562. * @param animationType The animation type to apply
  29563. * @param framePerSecond The frames per second of the animation
  29564. * @param easingFunction The easing function used in the animation
  29565. * @returns The created animation
  29566. */
  29567. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29568. /**
  29569. * Create and start an animation on a node
  29570. * @param name defines the name of the global animation that will be run on all nodes
  29571. * @param node defines the root node where the animation will take place
  29572. * @param targetProperty defines property to animate
  29573. * @param framePerSecond defines the number of frame per second yo use
  29574. * @param totalFrame defines the number of frames in total
  29575. * @param from defines the initial value
  29576. * @param to defines the final value
  29577. * @param loopMode defines which loop mode you want to use (off by default)
  29578. * @param easingFunction defines the easing function to use (linear by default)
  29579. * @param onAnimationEnd defines the callback to call when animation end
  29580. * @returns the animatable created for this animation
  29581. */
  29582. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29583. /**
  29584. * Create and start an animation on a node and its descendants
  29585. * @param name defines the name of the global animation that will be run on all nodes
  29586. * @param node defines the root node where the animation will take place
  29587. * @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
  29588. * @param targetProperty defines property to animate
  29589. * @param framePerSecond defines the number of frame per second to use
  29590. * @param totalFrame defines the number of frames in total
  29591. * @param from defines the initial value
  29592. * @param to defines the final value
  29593. * @param loopMode defines which loop mode you want to use (off by default)
  29594. * @param easingFunction defines the easing function to use (linear by default)
  29595. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29596. * @returns the list of animatables created for all nodes
  29597. * @example https://www.babylonjs-playground.com/#MH0VLI
  29598. */
  29599. 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[]>;
  29600. /**
  29601. * Creates a new animation, merges it with the existing animations and starts it
  29602. * @param name Name of the animation
  29603. * @param node Node which contains the scene that begins the animations
  29604. * @param targetProperty Specifies which property to animate
  29605. * @param framePerSecond The frames per second of the animation
  29606. * @param totalFrame The total number of frames
  29607. * @param from The frame at the beginning of the animation
  29608. * @param to The frame at the end of the animation
  29609. * @param loopMode Specifies the loop mode of the animation
  29610. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29611. * @param onAnimationEnd Callback to run once the animation is complete
  29612. * @returns Nullable animation
  29613. */
  29614. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29615. /**
  29616. * Transition property of an host to the target Value
  29617. * @param property The property to transition
  29618. * @param targetValue The target Value of the property
  29619. * @param host The object where the property to animate belongs
  29620. * @param scene Scene used to run the animation
  29621. * @param frameRate Framerate (in frame/s) to use
  29622. * @param transition The transition type we want to use
  29623. * @param duration The duration of the animation, in milliseconds
  29624. * @param onAnimationEnd Callback trigger at the end of the animation
  29625. * @returns Nullable animation
  29626. */
  29627. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29628. /**
  29629. * Return the array of runtime animations currently using this animation
  29630. */
  29631. readonly runtimeAnimations: RuntimeAnimation[];
  29632. /**
  29633. * Specifies if any of the runtime animations are currently running
  29634. */
  29635. readonly hasRunningRuntimeAnimations: boolean;
  29636. /**
  29637. * Initializes the animation
  29638. * @param name Name of the animation
  29639. * @param targetProperty Property to animate
  29640. * @param framePerSecond The frames per second of the animation
  29641. * @param dataType The data type of the animation
  29642. * @param loopMode The loop mode of the animation
  29643. * @param enableBlending Specifies if blending should be enabled
  29644. */
  29645. constructor(
  29646. /**Name of the animation */
  29647. name: string,
  29648. /**Property to animate */
  29649. targetProperty: string,
  29650. /**The frames per second of the animation */
  29651. framePerSecond: number,
  29652. /**The data type of the animation */
  29653. dataType: number,
  29654. /**The loop mode of the animation */
  29655. loopMode?: number | undefined,
  29656. /**Specifies if blending should be enabled */
  29657. enableBlending?: boolean | undefined);
  29658. /**
  29659. * Converts the animation to a string
  29660. * @param fullDetails support for multiple levels of logging within scene loading
  29661. * @returns String form of the animation
  29662. */
  29663. toString(fullDetails?: boolean): string;
  29664. /**
  29665. * Add an event to this animation
  29666. * @param event Event to add
  29667. */
  29668. addEvent(event: AnimationEvent): void;
  29669. /**
  29670. * Remove all events found at the given frame
  29671. * @param frame The frame to remove events from
  29672. */
  29673. removeEvents(frame: number): void;
  29674. /**
  29675. * Retrieves all the events from the animation
  29676. * @returns Events from the animation
  29677. */
  29678. getEvents(): AnimationEvent[];
  29679. /**
  29680. * Creates an animation range
  29681. * @param name Name of the animation range
  29682. * @param from Starting frame of the animation range
  29683. * @param to Ending frame of the animation
  29684. */
  29685. createRange(name: string, from: number, to: number): void;
  29686. /**
  29687. * Deletes an animation range by name
  29688. * @param name Name of the animation range to delete
  29689. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29690. */
  29691. deleteRange(name: string, deleteFrames?: boolean): void;
  29692. /**
  29693. * Gets the animation range by name, or null if not defined
  29694. * @param name Name of the animation range
  29695. * @returns Nullable animation range
  29696. */
  29697. getRange(name: string): Nullable<AnimationRange>;
  29698. /**
  29699. * Gets the key frames from the animation
  29700. * @returns The key frames of the animation
  29701. */
  29702. getKeys(): Array<IAnimationKey>;
  29703. /**
  29704. * Gets the highest frame rate of the animation
  29705. * @returns Highest frame rate of the animation
  29706. */
  29707. getHighestFrame(): number;
  29708. /**
  29709. * Gets the easing function of the animation
  29710. * @returns Easing function of the animation
  29711. */
  29712. getEasingFunction(): IEasingFunction;
  29713. /**
  29714. * Sets the easing function of the animation
  29715. * @param easingFunction A custom mathematical formula for animation
  29716. */
  29717. setEasingFunction(easingFunction: EasingFunction): void;
  29718. /**
  29719. * Interpolates a scalar linearly
  29720. * @param startValue Start value of the animation curve
  29721. * @param endValue End value of the animation curve
  29722. * @param gradient Scalar amount to interpolate
  29723. * @returns Interpolated scalar value
  29724. */
  29725. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29726. /**
  29727. * Interpolates a scalar cubically
  29728. * @param startValue Start value of the animation curve
  29729. * @param outTangent End tangent of the animation
  29730. * @param endValue End value of the animation curve
  29731. * @param inTangent Start tangent of the animation curve
  29732. * @param gradient Scalar amount to interpolate
  29733. * @returns Interpolated scalar value
  29734. */
  29735. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29736. /**
  29737. * Interpolates a quaternion using a spherical linear interpolation
  29738. * @param startValue Start value of the animation curve
  29739. * @param endValue End value of the animation curve
  29740. * @param gradient Scalar amount to interpolate
  29741. * @returns Interpolated quaternion value
  29742. */
  29743. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29744. /**
  29745. * Interpolates a quaternion cubically
  29746. * @param startValue Start value of the animation curve
  29747. * @param outTangent End tangent of the animation curve
  29748. * @param endValue End value of the animation curve
  29749. * @param inTangent Start tangent of the animation curve
  29750. * @param gradient Scalar amount to interpolate
  29751. * @returns Interpolated quaternion value
  29752. */
  29753. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29754. /**
  29755. * Interpolates a Vector3 linearl
  29756. * @param startValue Start value of the animation curve
  29757. * @param endValue End value of the animation curve
  29758. * @param gradient Scalar amount to interpolate
  29759. * @returns Interpolated scalar value
  29760. */
  29761. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29762. /**
  29763. * Interpolates a Vector3 cubically
  29764. * @param startValue Start value of the animation curve
  29765. * @param outTangent End tangent of the animation
  29766. * @param endValue End value of the animation curve
  29767. * @param inTangent Start tangent of the animation curve
  29768. * @param gradient Scalar amount to interpolate
  29769. * @returns InterpolatedVector3 value
  29770. */
  29771. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29772. /**
  29773. * Interpolates a Vector2 linearly
  29774. * @param startValue Start value of the animation curve
  29775. * @param endValue End value of the animation curve
  29776. * @param gradient Scalar amount to interpolate
  29777. * @returns Interpolated Vector2 value
  29778. */
  29779. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29780. /**
  29781. * Interpolates a Vector2 cubically
  29782. * @param startValue Start value of the animation curve
  29783. * @param outTangent End tangent of the animation
  29784. * @param endValue End value of the animation curve
  29785. * @param inTangent Start tangent of the animation curve
  29786. * @param gradient Scalar amount to interpolate
  29787. * @returns Interpolated Vector2 value
  29788. */
  29789. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29790. /**
  29791. * Interpolates a size linearly
  29792. * @param startValue Start value of the animation curve
  29793. * @param endValue End value of the animation curve
  29794. * @param gradient Scalar amount to interpolate
  29795. * @returns Interpolated Size value
  29796. */
  29797. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29798. /**
  29799. * Interpolates a Color3 linearly
  29800. * @param startValue Start value of the animation curve
  29801. * @param endValue End value of the animation curve
  29802. * @param gradient Scalar amount to interpolate
  29803. * @returns Interpolated Color3 value
  29804. */
  29805. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29806. /**
  29807. * Interpolates a Color4 linearly
  29808. * @param startValue Start value of the animation curve
  29809. * @param endValue End value of the animation curve
  29810. * @param gradient Scalar amount to interpolate
  29811. * @returns Interpolated Color3 value
  29812. */
  29813. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29814. /**
  29815. * @hidden Internal use only
  29816. */
  29817. _getKeyValue(value: any): any;
  29818. /**
  29819. * @hidden Internal use only
  29820. */
  29821. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29822. /**
  29823. * Defines the function to use to interpolate matrices
  29824. * @param startValue defines the start matrix
  29825. * @param endValue defines the end matrix
  29826. * @param gradient defines the gradient between both matrices
  29827. * @param result defines an optional target matrix where to store the interpolation
  29828. * @returns the interpolated matrix
  29829. */
  29830. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29831. /**
  29832. * Makes a copy of the animation
  29833. * @returns Cloned animation
  29834. */
  29835. clone(): Animation;
  29836. /**
  29837. * Sets the key frames of the animation
  29838. * @param values The animation key frames to set
  29839. */
  29840. setKeys(values: Array<IAnimationKey>): void;
  29841. /**
  29842. * Serializes the animation to an object
  29843. * @returns Serialized object
  29844. */
  29845. serialize(): any;
  29846. /**
  29847. * Float animation type
  29848. */
  29849. static readonly ANIMATIONTYPE_FLOAT: number;
  29850. /**
  29851. * Vector3 animation type
  29852. */
  29853. static readonly ANIMATIONTYPE_VECTOR3: number;
  29854. /**
  29855. * Quaternion animation type
  29856. */
  29857. static readonly ANIMATIONTYPE_QUATERNION: number;
  29858. /**
  29859. * Matrix animation type
  29860. */
  29861. static readonly ANIMATIONTYPE_MATRIX: number;
  29862. /**
  29863. * Color3 animation type
  29864. */
  29865. static readonly ANIMATIONTYPE_COLOR3: number;
  29866. /**
  29867. * Color3 animation type
  29868. */
  29869. static readonly ANIMATIONTYPE_COLOR4: number;
  29870. /**
  29871. * Vector2 animation type
  29872. */
  29873. static readonly ANIMATIONTYPE_VECTOR2: number;
  29874. /**
  29875. * Size animation type
  29876. */
  29877. static readonly ANIMATIONTYPE_SIZE: number;
  29878. /**
  29879. * Relative Loop Mode
  29880. */
  29881. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29882. /**
  29883. * Cycle Loop Mode
  29884. */
  29885. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29886. /**
  29887. * Constant Loop Mode
  29888. */
  29889. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29890. /** @hidden */
  29891. static _UniversalLerp(left: any, right: any, amount: number): any;
  29892. /**
  29893. * Parses an animation object and creates an animation
  29894. * @param parsedAnimation Parsed animation object
  29895. * @returns Animation object
  29896. */
  29897. static Parse(parsedAnimation: any): Animation;
  29898. /**
  29899. * Appends the serialized animations from the source animations
  29900. * @param source Source containing the animations
  29901. * @param destination Target to store the animations
  29902. */
  29903. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29904. }
  29905. }
  29906. declare module "babylonjs/Animations/animatable.interface" {
  29907. import { Nullable } from "babylonjs/types";
  29908. import { Animation } from "babylonjs/Animations/animation";
  29909. /**
  29910. * Interface containing an array of animations
  29911. */
  29912. export interface IAnimatable {
  29913. /**
  29914. * Array of animations
  29915. */
  29916. animations: Nullable<Array<Animation>>;
  29917. }
  29918. }
  29919. declare module "babylonjs/Misc/decorators" {
  29920. import { Nullable } from "babylonjs/types";
  29921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29922. import { Scene } from "babylonjs/scene";
  29923. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29924. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29925. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29926. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29927. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29928. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29929. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. /**
  29937. * Decorator used to define property that can be serialized as reference to a camera
  29938. * @param sourceName defines the name of the property to decorate
  29939. */
  29940. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. /**
  29942. * Class used to help serialization objects
  29943. */
  29944. export class SerializationHelper {
  29945. /** @hidden */
  29946. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29947. /** @hidden */
  29948. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29949. /** @hidden */
  29950. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29951. /** @hidden */
  29952. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29953. /**
  29954. * Appends the serialized animations from the source animations
  29955. * @param source Source containing the animations
  29956. * @param destination Target to store the animations
  29957. */
  29958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29959. /**
  29960. * Static function used to serialized a specific entity
  29961. * @param entity defines the entity to serialize
  29962. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29963. * @returns a JSON compatible object representing the serialization of the entity
  29964. */
  29965. static Serialize<T>(entity: T, serializationObject?: any): any;
  29966. /**
  29967. * Creates a new entity from a serialization data object
  29968. * @param creationFunction defines a function used to instanciated the new entity
  29969. * @param source defines the source serialization data
  29970. * @param scene defines the hosting scene
  29971. * @param rootUrl defines the root url for resources
  29972. * @returns a new entity
  29973. */
  29974. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29975. /**
  29976. * Clones an object
  29977. * @param creationFunction defines the function used to instanciate the new object
  29978. * @param source defines the source object
  29979. * @returns the cloned object
  29980. */
  29981. static Clone<T>(creationFunction: () => T, source: T): T;
  29982. /**
  29983. * Instanciates a new object based on a source one (some data will be shared between both object)
  29984. * @param creationFunction defines the function used to instanciate the new object
  29985. * @param source defines the source object
  29986. * @returns the new object
  29987. */
  29988. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29989. }
  29990. }
  29991. declare module "babylonjs/Misc/guid" {
  29992. /**
  29993. * Class used to manipulate GUIDs
  29994. */
  29995. export class GUID {
  29996. /**
  29997. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29998. * Be aware Math.random() could cause collisions, but:
  29999. * "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"
  30000. * @returns a pseudo random id
  30001. */
  30002. static RandomId(): string;
  30003. }
  30004. }
  30005. declare module "babylonjs/Materials/Textures/baseTexture" {
  30006. import { Observable } from "babylonjs/Misc/observable";
  30007. import { Nullable } from "babylonjs/types";
  30008. import { Scene } from "babylonjs/scene";
  30009. import { Matrix } from "babylonjs/Maths/math.vector";
  30010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30012. import { ISize } from "babylonjs/Maths/math.size";
  30013. /**
  30014. * Base class of all the textures in babylon.
  30015. * It groups all the common properties the materials, post process, lights... might need
  30016. * in order to make a correct use of the texture.
  30017. */
  30018. export class BaseTexture implements IAnimatable {
  30019. /**
  30020. * Default anisotropic filtering level for the application.
  30021. * It is set to 4 as a good tradeoff between perf and quality.
  30022. */
  30023. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30024. /**
  30025. * Gets or sets the unique id of the texture
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Define the name of the texture.
  30030. */
  30031. name: string;
  30032. /**
  30033. * Gets or sets an object used to store user defined information.
  30034. */
  30035. metadata: any;
  30036. /**
  30037. * For internal use only. Please do not use.
  30038. */
  30039. reservedDataStore: any;
  30040. private _hasAlpha;
  30041. /**
  30042. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30043. */
  30044. hasAlpha: boolean;
  30045. /**
  30046. * Defines if the alpha value should be determined via the rgb values.
  30047. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30048. */
  30049. getAlphaFromRGB: boolean;
  30050. /**
  30051. * Intensity or strength of the texture.
  30052. * It is commonly used by materials to fine tune the intensity of the texture
  30053. */
  30054. level: number;
  30055. /**
  30056. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30057. * This is part of the texture as textures usually maps to one uv set.
  30058. */
  30059. coordinatesIndex: number;
  30060. private _coordinatesMode;
  30061. /**
  30062. * How a texture is mapped.
  30063. *
  30064. * | Value | Type | Description |
  30065. * | ----- | ----------------------------------- | ----------- |
  30066. * | 0 | EXPLICIT_MODE | |
  30067. * | 1 | SPHERICAL_MODE | |
  30068. * | 2 | PLANAR_MODE | |
  30069. * | 3 | CUBIC_MODE | |
  30070. * | 4 | PROJECTION_MODE | |
  30071. * | 5 | SKYBOX_MODE | |
  30072. * | 6 | INVCUBIC_MODE | |
  30073. * | 7 | EQUIRECTANGULAR_MODE | |
  30074. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30075. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30076. */
  30077. coordinatesMode: number;
  30078. /**
  30079. * | Value | Type | Description |
  30080. * | ----- | ------------------ | ----------- |
  30081. * | 0 | CLAMP_ADDRESSMODE | |
  30082. * | 1 | WRAP_ADDRESSMODE | |
  30083. * | 2 | MIRROR_ADDRESSMODE | |
  30084. */
  30085. wrapU: number;
  30086. /**
  30087. * | Value | Type | Description |
  30088. * | ----- | ------------------ | ----------- |
  30089. * | 0 | CLAMP_ADDRESSMODE | |
  30090. * | 1 | WRAP_ADDRESSMODE | |
  30091. * | 2 | MIRROR_ADDRESSMODE | |
  30092. */
  30093. wrapV: number;
  30094. /**
  30095. * | Value | Type | Description |
  30096. * | ----- | ------------------ | ----------- |
  30097. * | 0 | CLAMP_ADDRESSMODE | |
  30098. * | 1 | WRAP_ADDRESSMODE | |
  30099. * | 2 | MIRROR_ADDRESSMODE | |
  30100. */
  30101. wrapR: number;
  30102. /**
  30103. * With compliant hardware and browser (supporting anisotropic filtering)
  30104. * this defines the level of anisotropic filtering in the texture.
  30105. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30106. */
  30107. anisotropicFilteringLevel: number;
  30108. /**
  30109. * Define if the texture is a cube texture or if false a 2d texture.
  30110. */
  30111. isCube: boolean;
  30112. /**
  30113. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30114. */
  30115. is3D: boolean;
  30116. /**
  30117. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30118. */
  30119. is2DArray: boolean;
  30120. /**
  30121. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30122. * HDR texture are usually stored in linear space.
  30123. * This only impacts the PBR and Background materials
  30124. */
  30125. gammaSpace: boolean;
  30126. /**
  30127. * Gets or sets whether or not the texture contains RGBD data.
  30128. */
  30129. isRGBD: boolean;
  30130. /**
  30131. * Is Z inverted in the texture (useful in a cube texture).
  30132. */
  30133. invertZ: boolean;
  30134. /**
  30135. * Are mip maps generated for this texture or not.
  30136. */
  30137. readonly noMipmap: boolean;
  30138. /**
  30139. * @hidden
  30140. */
  30141. lodLevelInAlpha: boolean;
  30142. /**
  30143. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30144. */
  30145. lodGenerationOffset: number;
  30146. /**
  30147. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30148. */
  30149. lodGenerationScale: number;
  30150. /**
  30151. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30152. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30153. * average roughness values.
  30154. */
  30155. linearSpecularLOD: boolean;
  30156. /**
  30157. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30158. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30159. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30160. */
  30161. irradianceTexture: Nullable<BaseTexture>;
  30162. /**
  30163. * Define if the texture is a render target.
  30164. */
  30165. isRenderTarget: boolean;
  30166. /**
  30167. * Define the unique id of the texture in the scene.
  30168. */
  30169. readonly uid: string;
  30170. /**
  30171. * Return a string representation of the texture.
  30172. * @returns the texture as a string
  30173. */
  30174. toString(): string;
  30175. /**
  30176. * Get the class name of the texture.
  30177. * @returns "BaseTexture"
  30178. */
  30179. getClassName(): string;
  30180. /**
  30181. * Define the list of animation attached to the texture.
  30182. */
  30183. animations: import("babylonjs/Animations/animation").Animation[];
  30184. /**
  30185. * An event triggered when the texture is disposed.
  30186. */
  30187. onDisposeObservable: Observable<BaseTexture>;
  30188. private _onDisposeObserver;
  30189. /**
  30190. * Callback triggered when the texture has been disposed.
  30191. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30192. */
  30193. onDispose: () => void;
  30194. /**
  30195. * Define the current state of the loading sequence when in delayed load mode.
  30196. */
  30197. delayLoadState: number;
  30198. private _scene;
  30199. /** @hidden */
  30200. _texture: Nullable<InternalTexture>;
  30201. private _uid;
  30202. /**
  30203. * Define if the texture is preventinga material to render or not.
  30204. * If not and the texture is not ready, the engine will use a default black texture instead.
  30205. */
  30206. readonly isBlocking: boolean;
  30207. /**
  30208. * Instantiates a new BaseTexture.
  30209. * Base class of all the textures in babylon.
  30210. * It groups all the common properties the materials, post process, lights... might need
  30211. * in order to make a correct use of the texture.
  30212. * @param scene Define the scene the texture blongs to
  30213. */
  30214. constructor(scene: Nullable<Scene>);
  30215. /**
  30216. * Get the scene the texture belongs to.
  30217. * @returns the scene or null if undefined
  30218. */
  30219. getScene(): Nullable<Scene>;
  30220. /**
  30221. * Get the texture transform matrix used to offset tile the texture for istance.
  30222. * @returns the transformation matrix
  30223. */
  30224. getTextureMatrix(): Matrix;
  30225. /**
  30226. * Get the texture reflection matrix used to rotate/transform the reflection.
  30227. * @returns the reflection matrix
  30228. */
  30229. getReflectionTextureMatrix(): Matrix;
  30230. /**
  30231. * Get the underlying lower level texture from Babylon.
  30232. * @returns the insternal texture
  30233. */
  30234. getInternalTexture(): Nullable<InternalTexture>;
  30235. /**
  30236. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30237. * @returns true if ready or not blocking
  30238. */
  30239. isReadyOrNotBlocking(): boolean;
  30240. /**
  30241. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30242. * @returns true if fully ready
  30243. */
  30244. isReady(): boolean;
  30245. private _cachedSize;
  30246. /**
  30247. * Get the size of the texture.
  30248. * @returns the texture size.
  30249. */
  30250. getSize(): ISize;
  30251. /**
  30252. * Get the base size of the texture.
  30253. * It can be different from the size if the texture has been resized for POT for instance
  30254. * @returns the base size
  30255. */
  30256. getBaseSize(): ISize;
  30257. /**
  30258. * Update the sampling mode of the texture.
  30259. * Default is Trilinear mode.
  30260. *
  30261. * | Value | Type | Description |
  30262. * | ----- | ------------------ | ----------- |
  30263. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30264. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30265. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30266. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30267. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30268. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30269. * | 7 | NEAREST_LINEAR | |
  30270. * | 8 | NEAREST_NEAREST | |
  30271. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30272. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30273. * | 11 | LINEAR_LINEAR | |
  30274. * | 12 | LINEAR_NEAREST | |
  30275. *
  30276. * > _mag_: magnification filter (close to the viewer)
  30277. * > _min_: minification filter (far from the viewer)
  30278. * > _mip_: filter used between mip map levels
  30279. *@param samplingMode Define the new sampling mode of the texture
  30280. */
  30281. updateSamplingMode(samplingMode: number): void;
  30282. /**
  30283. * Scales the texture if is `canRescale()`
  30284. * @param ratio the resize factor we want to use to rescale
  30285. */
  30286. scale(ratio: number): void;
  30287. /**
  30288. * Get if the texture can rescale.
  30289. */
  30290. readonly canRescale: boolean;
  30291. /** @hidden */
  30292. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30293. /** @hidden */
  30294. _rebuild(): void;
  30295. /**
  30296. * Triggers the load sequence in delayed load mode.
  30297. */
  30298. delayLoad(): void;
  30299. /**
  30300. * Clones the texture.
  30301. * @returns the cloned texture
  30302. */
  30303. clone(): Nullable<BaseTexture>;
  30304. /**
  30305. * Get the texture underlying type (INT, FLOAT...)
  30306. */
  30307. readonly textureType: number;
  30308. /**
  30309. * Get the texture underlying format (RGB, RGBA...)
  30310. */
  30311. readonly textureFormat: number;
  30312. /**
  30313. * Indicates that textures need to be re-calculated for all materials
  30314. */
  30315. protected _markAllSubMeshesAsTexturesDirty(): void;
  30316. /**
  30317. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30318. * This will returns an RGBA array buffer containing either in values (0-255) or
  30319. * float values (0-1) depending of the underlying buffer type.
  30320. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30321. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30322. * @param buffer defines a user defined buffer to fill with data (can be null)
  30323. * @returns The Array buffer containing the pixels data.
  30324. */
  30325. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30326. /**
  30327. * Release and destroy the underlying lower level texture aka internalTexture.
  30328. */
  30329. releaseInternalTexture(): void;
  30330. /** @hidden */
  30331. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30332. /** @hidden */
  30333. readonly _lodTextureMid: Nullable<BaseTexture>;
  30334. /** @hidden */
  30335. readonly _lodTextureLow: Nullable<BaseTexture>;
  30336. /**
  30337. * Dispose the texture and release its associated resources.
  30338. */
  30339. dispose(): void;
  30340. /**
  30341. * Serialize the texture into a JSON representation that can be parsed later on.
  30342. * @returns the JSON representation of the texture
  30343. */
  30344. serialize(): any;
  30345. /**
  30346. * Helper function to be called back once a list of texture contains only ready textures.
  30347. * @param textures Define the list of textures to wait for
  30348. * @param callback Define the callback triggered once the entire list will be ready
  30349. */
  30350. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30351. }
  30352. }
  30353. declare module "babylonjs/Materials/effect" {
  30354. import { Observable } from "babylonjs/Misc/observable";
  30355. import { Nullable } from "babylonjs/types";
  30356. import { IDisposable } from "babylonjs/scene";
  30357. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30358. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30359. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30360. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30361. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30362. import { Engine } from "babylonjs/Engines/engine";
  30363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30367. /**
  30368. * Options to be used when creating an effect.
  30369. */
  30370. export interface IEffectCreationOptions {
  30371. /**
  30372. * Atrributes that will be used in the shader.
  30373. */
  30374. attributes: string[];
  30375. /**
  30376. * Uniform varible names that will be set in the shader.
  30377. */
  30378. uniformsNames: string[];
  30379. /**
  30380. * Uniform buffer variable names that will be set in the shader.
  30381. */
  30382. uniformBuffersNames: string[];
  30383. /**
  30384. * Sampler texture variable names that will be set in the shader.
  30385. */
  30386. samplers: string[];
  30387. /**
  30388. * Define statements that will be set in the shader.
  30389. */
  30390. defines: any;
  30391. /**
  30392. * Possible fallbacks for this effect to improve performance when needed.
  30393. */
  30394. fallbacks: Nullable<IEffectFallbacks>;
  30395. /**
  30396. * Callback that will be called when the shader is compiled.
  30397. */
  30398. onCompiled: Nullable<(effect: Effect) => void>;
  30399. /**
  30400. * Callback that will be called if an error occurs during shader compilation.
  30401. */
  30402. onError: Nullable<(effect: Effect, errors: string) => void>;
  30403. /**
  30404. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30405. */
  30406. indexParameters?: any;
  30407. /**
  30408. * Max number of lights that can be used in the shader.
  30409. */
  30410. maxSimultaneousLights?: number;
  30411. /**
  30412. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30413. */
  30414. transformFeedbackVaryings?: Nullable<string[]>;
  30415. }
  30416. /**
  30417. * Effect containing vertex and fragment shader that can be executed on an object.
  30418. */
  30419. export class Effect implements IDisposable {
  30420. /**
  30421. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30422. */
  30423. static ShadersRepository: string;
  30424. /**
  30425. * Name of the effect.
  30426. */
  30427. name: any;
  30428. /**
  30429. * String container all the define statements that should be set on the shader.
  30430. */
  30431. defines: string;
  30432. /**
  30433. * Callback that will be called when the shader is compiled.
  30434. */
  30435. onCompiled: Nullable<(effect: Effect) => void>;
  30436. /**
  30437. * Callback that will be called if an error occurs during shader compilation.
  30438. */
  30439. onError: Nullable<(effect: Effect, errors: string) => void>;
  30440. /**
  30441. * Callback that will be called when effect is bound.
  30442. */
  30443. onBind: Nullable<(effect: Effect) => void>;
  30444. /**
  30445. * Unique ID of the effect.
  30446. */
  30447. uniqueId: number;
  30448. /**
  30449. * Observable that will be called when the shader is compiled.
  30450. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30451. */
  30452. onCompileObservable: Observable<Effect>;
  30453. /**
  30454. * Observable that will be called if an error occurs during shader compilation.
  30455. */
  30456. onErrorObservable: Observable<Effect>;
  30457. /** @hidden */
  30458. _onBindObservable: Nullable<Observable<Effect>>;
  30459. /**
  30460. * Observable that will be called when effect is bound.
  30461. */
  30462. readonly onBindObservable: Observable<Effect>;
  30463. /** @hidden */
  30464. _bonesComputationForcedToCPU: boolean;
  30465. private static _uniqueIdSeed;
  30466. private _engine;
  30467. private _uniformBuffersNames;
  30468. private _uniformsNames;
  30469. private _samplerList;
  30470. private _samplers;
  30471. private _isReady;
  30472. private _compilationError;
  30473. private _allFallbacksProcessed;
  30474. private _attributesNames;
  30475. private _attributes;
  30476. private _uniforms;
  30477. /**
  30478. * Key for the effect.
  30479. * @hidden
  30480. */
  30481. _key: string;
  30482. private _indexParameters;
  30483. private _fallbacks;
  30484. private _vertexSourceCode;
  30485. private _fragmentSourceCode;
  30486. private _vertexSourceCodeOverride;
  30487. private _fragmentSourceCodeOverride;
  30488. private _transformFeedbackVaryings;
  30489. /**
  30490. * Compiled shader to webGL program.
  30491. * @hidden
  30492. */
  30493. _pipelineContext: Nullable<IPipelineContext>;
  30494. private _valueCache;
  30495. private static _baseCache;
  30496. /**
  30497. * Instantiates an effect.
  30498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30499. * @param baseName Name of the effect.
  30500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30502. * @param samplers List of sampler variables that will be passed to the shader.
  30503. * @param engine Engine to be used to render the effect
  30504. * @param defines Define statements to be added to the shader.
  30505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30506. * @param onCompiled Callback that will be called when the shader is compiled.
  30507. * @param onError Callback that will be called if an error occurs during shader compilation.
  30508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30509. */
  30510. 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);
  30511. private _useFinalCode;
  30512. /**
  30513. * Unique key for this effect
  30514. */
  30515. readonly key: string;
  30516. /**
  30517. * If the effect has been compiled and prepared.
  30518. * @returns if the effect is compiled and prepared.
  30519. */
  30520. isReady(): boolean;
  30521. private _isReadyInternal;
  30522. /**
  30523. * The engine the effect was initialized with.
  30524. * @returns the engine.
  30525. */
  30526. getEngine(): Engine;
  30527. /**
  30528. * The pipeline context for this effect
  30529. * @returns the associated pipeline context
  30530. */
  30531. getPipelineContext(): Nullable<IPipelineContext>;
  30532. /**
  30533. * The set of names of attribute variables for the shader.
  30534. * @returns An array of attribute names.
  30535. */
  30536. getAttributesNames(): string[];
  30537. /**
  30538. * Returns the attribute at the given index.
  30539. * @param index The index of the attribute.
  30540. * @returns The location of the attribute.
  30541. */
  30542. getAttributeLocation(index: number): number;
  30543. /**
  30544. * Returns the attribute based on the name of the variable.
  30545. * @param name of the attribute to look up.
  30546. * @returns the attribute location.
  30547. */
  30548. getAttributeLocationByName(name: string): number;
  30549. /**
  30550. * The number of attributes.
  30551. * @returns the numnber of attributes.
  30552. */
  30553. getAttributesCount(): number;
  30554. /**
  30555. * Gets the index of a uniform variable.
  30556. * @param uniformName of the uniform to look up.
  30557. * @returns the index.
  30558. */
  30559. getUniformIndex(uniformName: string): number;
  30560. /**
  30561. * Returns the attribute based on the name of the variable.
  30562. * @param uniformName of the uniform to look up.
  30563. * @returns the location of the uniform.
  30564. */
  30565. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30566. /**
  30567. * Returns an array of sampler variable names
  30568. * @returns The array of sampler variable neames.
  30569. */
  30570. getSamplers(): string[];
  30571. /**
  30572. * The error from the last compilation.
  30573. * @returns the error string.
  30574. */
  30575. getCompilationError(): string;
  30576. /**
  30577. * Gets a boolean indicating that all fallbacks were used during compilation
  30578. * @returns true if all fallbacks were used
  30579. */
  30580. allFallbacksProcessed(): boolean;
  30581. /**
  30582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30583. * @param func The callback to be used.
  30584. */
  30585. executeWhenCompiled(func: (effect: Effect) => void): void;
  30586. private _checkIsReady;
  30587. private _loadShader;
  30588. /**
  30589. * Recompiles the webGL program
  30590. * @param vertexSourceCode The source code for the vertex shader.
  30591. * @param fragmentSourceCode The source code for the fragment shader.
  30592. * @param onCompiled Callback called when completed.
  30593. * @param onError Callback called on error.
  30594. * @hidden
  30595. */
  30596. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30597. /**
  30598. * Prepares the effect
  30599. * @hidden
  30600. */
  30601. _prepareEffect(): void;
  30602. private _processCompilationErrors;
  30603. /**
  30604. * Checks if the effect is supported. (Must be called after compilation)
  30605. */
  30606. readonly isSupported: boolean;
  30607. /**
  30608. * Binds a texture to the engine to be used as output of the shader.
  30609. * @param channel Name of the output variable.
  30610. * @param texture Texture to bind.
  30611. * @hidden
  30612. */
  30613. _bindTexture(channel: string, texture: InternalTexture): void;
  30614. /**
  30615. * Sets a texture on the engine to be used in the shader.
  30616. * @param channel Name of the sampler variable.
  30617. * @param texture Texture to set.
  30618. */
  30619. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30620. /**
  30621. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30622. * @param channel Name of the sampler variable.
  30623. * @param texture Texture to set.
  30624. */
  30625. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30626. /**
  30627. * Sets an array of textures on the engine to be used in the shader.
  30628. * @param channel Name of the variable.
  30629. * @param textures Textures to set.
  30630. */
  30631. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30632. /**
  30633. * 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)
  30634. * @param channel Name of the sampler variable.
  30635. * @param postProcess Post process to get the input texture from.
  30636. */
  30637. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30638. /**
  30639. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30640. * 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)
  30641. * @param channel Name of the sampler variable.
  30642. * @param postProcess Post process to get the output texture from.
  30643. */
  30644. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30645. /** @hidden */
  30646. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30647. /** @hidden */
  30648. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30649. /** @hidden */
  30650. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30651. /** @hidden */
  30652. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30653. /**
  30654. * Binds a buffer to a uniform.
  30655. * @param buffer Buffer to bind.
  30656. * @param name Name of the uniform variable to bind to.
  30657. */
  30658. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30659. /**
  30660. * Binds block to a uniform.
  30661. * @param blockName Name of the block to bind.
  30662. * @param index Index to bind.
  30663. */
  30664. bindUniformBlock(blockName: string, index: number): void;
  30665. /**
  30666. * Sets an interger value on a uniform variable.
  30667. * @param uniformName Name of the variable.
  30668. * @param value Value to be set.
  30669. * @returns this effect.
  30670. */
  30671. setInt(uniformName: string, value: number): Effect;
  30672. /**
  30673. * Sets an int array on a uniform variable.
  30674. * @param uniformName Name of the variable.
  30675. * @param array array to be set.
  30676. * @returns this effect.
  30677. */
  30678. setIntArray(uniformName: string, array: Int32Array): Effect;
  30679. /**
  30680. * 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)
  30681. * @param uniformName Name of the variable.
  30682. * @param array array to be set.
  30683. * @returns this effect.
  30684. */
  30685. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30686. /**
  30687. * 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)
  30688. * @param uniformName Name of the variable.
  30689. * @param array array to be set.
  30690. * @returns this effect.
  30691. */
  30692. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30693. /**
  30694. * 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)
  30695. * @param uniformName Name of the variable.
  30696. * @param array array to be set.
  30697. * @returns this effect.
  30698. */
  30699. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30700. /**
  30701. * Sets an float array on a uniform variable.
  30702. * @param uniformName Name of the variable.
  30703. * @param array array to be set.
  30704. * @returns this effect.
  30705. */
  30706. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30707. /**
  30708. * 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)
  30709. * @param uniformName Name of the variable.
  30710. * @param array array to be set.
  30711. * @returns this effect.
  30712. */
  30713. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30714. /**
  30715. * 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)
  30716. * @param uniformName Name of the variable.
  30717. * @param array array to be set.
  30718. * @returns this effect.
  30719. */
  30720. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30721. /**
  30722. * 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)
  30723. * @param uniformName Name of the variable.
  30724. * @param array array to be set.
  30725. * @returns this effect.
  30726. */
  30727. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30728. /**
  30729. * Sets an array on a uniform variable.
  30730. * @param uniformName Name of the variable.
  30731. * @param array array to be set.
  30732. * @returns this effect.
  30733. */
  30734. setArray(uniformName: string, array: number[]): Effect;
  30735. /**
  30736. * 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)
  30737. * @param uniformName Name of the variable.
  30738. * @param array array to be set.
  30739. * @returns this effect.
  30740. */
  30741. setArray2(uniformName: string, array: number[]): Effect;
  30742. /**
  30743. * 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)
  30744. * @param uniformName Name of the variable.
  30745. * @param array array to be set.
  30746. * @returns this effect.
  30747. */
  30748. setArray3(uniformName: string, array: number[]): Effect;
  30749. /**
  30750. * 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)
  30751. * @param uniformName Name of the variable.
  30752. * @param array array to be set.
  30753. * @returns this effect.
  30754. */
  30755. setArray4(uniformName: string, array: number[]): Effect;
  30756. /**
  30757. * Sets matrices on a uniform variable.
  30758. * @param uniformName Name of the variable.
  30759. * @param matrices matrices to be set.
  30760. * @returns this effect.
  30761. */
  30762. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30763. /**
  30764. * Sets matrix on a uniform variable.
  30765. * @param uniformName Name of the variable.
  30766. * @param matrix matrix to be set.
  30767. * @returns this effect.
  30768. */
  30769. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30770. /**
  30771. * 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)
  30772. * @param uniformName Name of the variable.
  30773. * @param matrix matrix to be set.
  30774. * @returns this effect.
  30775. */
  30776. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30777. /**
  30778. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30779. * @param uniformName Name of the variable.
  30780. * @param matrix matrix to be set.
  30781. * @returns this effect.
  30782. */
  30783. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30784. /**
  30785. * Sets a float on a uniform variable.
  30786. * @param uniformName Name of the variable.
  30787. * @param value value to be set.
  30788. * @returns this effect.
  30789. */
  30790. setFloat(uniformName: string, value: number): Effect;
  30791. /**
  30792. * Sets a boolean on a uniform variable.
  30793. * @param uniformName Name of the variable.
  30794. * @param bool value to be set.
  30795. * @returns this effect.
  30796. */
  30797. setBool(uniformName: string, bool: boolean): Effect;
  30798. /**
  30799. * Sets a Vector2 on a uniform variable.
  30800. * @param uniformName Name of the variable.
  30801. * @param vector2 vector2 to be set.
  30802. * @returns this effect.
  30803. */
  30804. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30805. /**
  30806. * Sets a float2 on a uniform variable.
  30807. * @param uniformName Name of the variable.
  30808. * @param x First float in float2.
  30809. * @param y Second float in float2.
  30810. * @returns this effect.
  30811. */
  30812. setFloat2(uniformName: string, x: number, y: number): Effect;
  30813. /**
  30814. * Sets a Vector3 on a uniform variable.
  30815. * @param uniformName Name of the variable.
  30816. * @param vector3 Value to be set.
  30817. * @returns this effect.
  30818. */
  30819. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30820. /**
  30821. * Sets a float3 on a uniform variable.
  30822. * @param uniformName Name of the variable.
  30823. * @param x First float in float3.
  30824. * @param y Second float in float3.
  30825. * @param z Third float in float3.
  30826. * @returns this effect.
  30827. */
  30828. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30829. /**
  30830. * Sets a Vector4 on a uniform variable.
  30831. * @param uniformName Name of the variable.
  30832. * @param vector4 Value to be set.
  30833. * @returns this effect.
  30834. */
  30835. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30836. /**
  30837. * Sets a float4 on a uniform variable.
  30838. * @param uniformName Name of the variable.
  30839. * @param x First float in float4.
  30840. * @param y Second float in float4.
  30841. * @param z Third float in float4.
  30842. * @param w Fourth float in float4.
  30843. * @returns this effect.
  30844. */
  30845. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30846. /**
  30847. * Sets a Color3 on a uniform variable.
  30848. * @param uniformName Name of the variable.
  30849. * @param color3 Value to be set.
  30850. * @returns this effect.
  30851. */
  30852. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30853. /**
  30854. * Sets a Color4 on a uniform variable.
  30855. * @param uniformName Name of the variable.
  30856. * @param color3 Value to be set.
  30857. * @param alpha Alpha value to be set.
  30858. * @returns this effect.
  30859. */
  30860. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30861. /**
  30862. * Sets a Color4 on a uniform variable
  30863. * @param uniformName defines the name of the variable
  30864. * @param color4 defines the value to be set
  30865. * @returns this effect.
  30866. */
  30867. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30868. /** Release all associated resources */
  30869. dispose(): void;
  30870. /**
  30871. * This function will add a new shader to the shader store
  30872. * @param name the name of the shader
  30873. * @param pixelShader optional pixel shader content
  30874. * @param vertexShader optional vertex shader content
  30875. */
  30876. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30877. /**
  30878. * Store of each shader (The can be looked up using effect.key)
  30879. */
  30880. static ShadersStore: {
  30881. [key: string]: string;
  30882. };
  30883. /**
  30884. * Store of each included file for a shader (The can be looked up using effect.key)
  30885. */
  30886. static IncludesShadersStore: {
  30887. [key: string]: string;
  30888. };
  30889. /**
  30890. * Resets the cache of effects.
  30891. */
  30892. static ResetCache(): void;
  30893. }
  30894. }
  30895. declare module "babylonjs/Engines/engineCapabilities" {
  30896. /**
  30897. * Interface used to describe the capabilities of the engine relatively to the current browser
  30898. */
  30899. export interface EngineCapabilities {
  30900. /** Maximum textures units per fragment shader */
  30901. maxTexturesImageUnits: number;
  30902. /** Maximum texture units per vertex shader */
  30903. maxVertexTextureImageUnits: number;
  30904. /** Maximum textures units in the entire pipeline */
  30905. maxCombinedTexturesImageUnits: number;
  30906. /** Maximum texture size */
  30907. maxTextureSize: number;
  30908. /** Maximum texture samples */
  30909. maxSamples?: number;
  30910. /** Maximum cube texture size */
  30911. maxCubemapTextureSize: number;
  30912. /** Maximum render texture size */
  30913. maxRenderTextureSize: number;
  30914. /** Maximum number of vertex attributes */
  30915. maxVertexAttribs: number;
  30916. /** Maximum number of varyings */
  30917. maxVaryingVectors: number;
  30918. /** Maximum number of uniforms per vertex shader */
  30919. maxVertexUniformVectors: number;
  30920. /** Maximum number of uniforms per fragment shader */
  30921. maxFragmentUniformVectors: number;
  30922. /** Defines if standard derivates (dx/dy) are supported */
  30923. standardDerivatives: boolean;
  30924. /** Defines if s3tc texture compression is supported */
  30925. s3tc?: WEBGL_compressed_texture_s3tc;
  30926. /** Defines if pvrtc texture compression is supported */
  30927. pvrtc: any;
  30928. /** Defines if etc1 texture compression is supported */
  30929. etc1: any;
  30930. /** Defines if etc2 texture compression is supported */
  30931. etc2: any;
  30932. /** Defines if astc texture compression is supported */
  30933. astc: any;
  30934. /** Defines if float textures are supported */
  30935. textureFloat: boolean;
  30936. /** Defines if vertex array objects are supported */
  30937. vertexArrayObject: boolean;
  30938. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30939. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30940. /** Gets the maximum level of anisotropy supported */
  30941. maxAnisotropy: number;
  30942. /** Defines if instancing is supported */
  30943. instancedArrays: boolean;
  30944. /** Defines if 32 bits indices are supported */
  30945. uintIndices: boolean;
  30946. /** Defines if high precision shaders are supported */
  30947. highPrecisionShaderSupported: boolean;
  30948. /** Defines if depth reading in the fragment shader is supported */
  30949. fragmentDepthSupported: boolean;
  30950. /** Defines if float texture linear filtering is supported*/
  30951. textureFloatLinearFiltering: boolean;
  30952. /** Defines if rendering to float textures is supported */
  30953. textureFloatRender: boolean;
  30954. /** Defines if half float textures are supported*/
  30955. textureHalfFloat: boolean;
  30956. /** Defines if half float texture linear filtering is supported*/
  30957. textureHalfFloatLinearFiltering: boolean;
  30958. /** Defines if rendering to half float textures is supported */
  30959. textureHalfFloatRender: boolean;
  30960. /** Defines if textureLOD shader command is supported */
  30961. textureLOD: boolean;
  30962. /** Defines if draw buffers extension is supported */
  30963. drawBuffersExtension: boolean;
  30964. /** Defines if depth textures are supported */
  30965. depthTextureExtension: boolean;
  30966. /** Defines if float color buffer are supported */
  30967. colorBufferFloat: boolean;
  30968. /** Gets disjoint timer query extension (null if not supported) */
  30969. timerQuery?: EXT_disjoint_timer_query;
  30970. /** Defines if timestamp can be used with timer query */
  30971. canUseTimestampForTimerQuery: boolean;
  30972. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30973. multiview?: any;
  30974. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30975. oculusMultiview?: any;
  30976. /** Function used to let the system compiles shaders in background */
  30977. parallelShaderCompile?: {
  30978. COMPLETION_STATUS_KHR: number;
  30979. };
  30980. /** Max number of texture samples for MSAA */
  30981. maxMSAASamples: number;
  30982. /** Defines if the blend min max extension is supported */
  30983. blendMinMax: boolean;
  30984. }
  30985. }
  30986. declare module "babylonjs/States/depthCullingState" {
  30987. import { Nullable } from "babylonjs/types";
  30988. /**
  30989. * @hidden
  30990. **/
  30991. export class DepthCullingState {
  30992. private _isDepthTestDirty;
  30993. private _isDepthMaskDirty;
  30994. private _isDepthFuncDirty;
  30995. private _isCullFaceDirty;
  30996. private _isCullDirty;
  30997. private _isZOffsetDirty;
  30998. private _isFrontFaceDirty;
  30999. private _depthTest;
  31000. private _depthMask;
  31001. private _depthFunc;
  31002. private _cull;
  31003. private _cullFace;
  31004. private _zOffset;
  31005. private _frontFace;
  31006. /**
  31007. * Initializes the state.
  31008. */
  31009. constructor();
  31010. readonly isDirty: boolean;
  31011. zOffset: number;
  31012. cullFace: Nullable<number>;
  31013. cull: Nullable<boolean>;
  31014. depthFunc: Nullable<number>;
  31015. depthMask: boolean;
  31016. depthTest: boolean;
  31017. frontFace: Nullable<number>;
  31018. reset(): void;
  31019. apply(gl: WebGLRenderingContext): void;
  31020. }
  31021. }
  31022. declare module "babylonjs/States/stencilState" {
  31023. /**
  31024. * @hidden
  31025. **/
  31026. export class StencilState {
  31027. /** 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 */
  31028. static readonly ALWAYS: number;
  31029. /** Passed to stencilOperation to specify that stencil value must be kept */
  31030. static readonly KEEP: number;
  31031. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31032. static readonly REPLACE: number;
  31033. private _isStencilTestDirty;
  31034. private _isStencilMaskDirty;
  31035. private _isStencilFuncDirty;
  31036. private _isStencilOpDirty;
  31037. private _stencilTest;
  31038. private _stencilMask;
  31039. private _stencilFunc;
  31040. private _stencilFuncRef;
  31041. private _stencilFuncMask;
  31042. private _stencilOpStencilFail;
  31043. private _stencilOpDepthFail;
  31044. private _stencilOpStencilDepthPass;
  31045. readonly isDirty: boolean;
  31046. stencilFunc: number;
  31047. stencilFuncRef: number;
  31048. stencilFuncMask: number;
  31049. stencilOpStencilFail: number;
  31050. stencilOpDepthFail: number;
  31051. stencilOpStencilDepthPass: number;
  31052. stencilMask: number;
  31053. stencilTest: boolean;
  31054. constructor();
  31055. reset(): void;
  31056. apply(gl: WebGLRenderingContext): void;
  31057. }
  31058. }
  31059. declare module "babylonjs/States/alphaCullingState" {
  31060. /**
  31061. * @hidden
  31062. **/
  31063. export class AlphaState {
  31064. private _isAlphaBlendDirty;
  31065. private _isBlendFunctionParametersDirty;
  31066. private _isBlendEquationParametersDirty;
  31067. private _isBlendConstantsDirty;
  31068. private _alphaBlend;
  31069. private _blendFunctionParameters;
  31070. private _blendEquationParameters;
  31071. private _blendConstants;
  31072. /**
  31073. * Initializes the state.
  31074. */
  31075. constructor();
  31076. readonly isDirty: boolean;
  31077. alphaBlend: boolean;
  31078. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31079. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31080. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31081. reset(): void;
  31082. apply(gl: WebGLRenderingContext): void;
  31083. }
  31084. }
  31085. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31086. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31087. /** @hidden */
  31088. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31089. attributeProcessor(attribute: string): string;
  31090. varyingProcessor(varying: string, isFragment: boolean): string;
  31091. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31092. }
  31093. }
  31094. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31095. /**
  31096. * Interface for attribute information associated with buffer instanciation
  31097. */
  31098. export interface InstancingAttributeInfo {
  31099. /**
  31100. * Index/offset of the attribute in the vertex shader
  31101. */
  31102. index: number;
  31103. /**
  31104. * size of the attribute, 1, 2, 3 or 4
  31105. */
  31106. attributeSize: number;
  31107. /**
  31108. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31109. * default is FLOAT
  31110. */
  31111. attributeType: number;
  31112. /**
  31113. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31114. */
  31115. normalized: boolean;
  31116. /**
  31117. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31118. */
  31119. offset: number;
  31120. /**
  31121. * Name of the GLSL attribute, for debugging purpose only
  31122. */
  31123. attributeName: string;
  31124. }
  31125. }
  31126. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31127. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31128. import { Nullable } from "babylonjs/types";
  31129. module "babylonjs/Engines/thinEngine" {
  31130. interface ThinEngine {
  31131. /**
  31132. * Update a video texture
  31133. * @param texture defines the texture to update
  31134. * @param video defines the video element to use
  31135. * @param invertY defines if data must be stored with Y axis inverted
  31136. */
  31137. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31138. }
  31139. }
  31140. }
  31141. declare module "babylonjs/Materials/Textures/videoTexture" {
  31142. import { Observable } from "babylonjs/Misc/observable";
  31143. import { Nullable } from "babylonjs/types";
  31144. import { Scene } from "babylonjs/scene";
  31145. import { Texture } from "babylonjs/Materials/Textures/texture";
  31146. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31147. /**
  31148. * Settings for finer control over video usage
  31149. */
  31150. export interface VideoTextureSettings {
  31151. /**
  31152. * Applies `autoplay` to video, if specified
  31153. */
  31154. autoPlay?: boolean;
  31155. /**
  31156. * Applies `loop` to video, if specified
  31157. */
  31158. loop?: boolean;
  31159. /**
  31160. * Automatically updates internal texture from video at every frame in the render loop
  31161. */
  31162. autoUpdateTexture: boolean;
  31163. /**
  31164. * Image src displayed during the video loading or until the user interacts with the video.
  31165. */
  31166. poster?: string;
  31167. }
  31168. /**
  31169. * If you want to display a video in your scene, this is the special texture for that.
  31170. * This special texture works similar to other textures, with the exception of a few parameters.
  31171. * @see https://doc.babylonjs.com/how_to/video_texture
  31172. */
  31173. export class VideoTexture extends Texture {
  31174. /**
  31175. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31176. */
  31177. readonly autoUpdateTexture: boolean;
  31178. /**
  31179. * The video instance used by the texture internally
  31180. */
  31181. readonly video: HTMLVideoElement;
  31182. private _onUserActionRequestedObservable;
  31183. /**
  31184. * Event triggerd when a dom action is required by the user to play the video.
  31185. * This happens due to recent changes in browser policies preventing video to auto start.
  31186. */
  31187. readonly onUserActionRequestedObservable: Observable<Texture>;
  31188. private _generateMipMaps;
  31189. private _engine;
  31190. private _stillImageCaptured;
  31191. private _displayingPosterTexture;
  31192. private _settings;
  31193. private _createInternalTextureOnEvent;
  31194. private _frameId;
  31195. /**
  31196. * Creates a video texture.
  31197. * If you want to display a video in your scene, this is the special texture for that.
  31198. * This special texture works similar to other textures, with the exception of a few parameters.
  31199. * @see https://doc.babylonjs.com/how_to/video_texture
  31200. * @param name optional name, will detect from video source, if not defined
  31201. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31202. * @param scene is obviously the current scene.
  31203. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31204. * @param invertY is false by default but can be used to invert video on Y axis
  31205. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31206. * @param settings allows finer control over video usage
  31207. */
  31208. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31209. private _getName;
  31210. private _getVideo;
  31211. private _createInternalTexture;
  31212. private reset;
  31213. /**
  31214. * @hidden Internal method to initiate `update`.
  31215. */
  31216. _rebuild(): void;
  31217. /**
  31218. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31219. */
  31220. update(): void;
  31221. /**
  31222. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31223. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31224. */
  31225. updateTexture(isVisible: boolean): void;
  31226. protected _updateInternalTexture: () => void;
  31227. /**
  31228. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31229. * @param url New url.
  31230. */
  31231. updateURL(url: string): void;
  31232. /**
  31233. * Dispose the texture and release its associated resources.
  31234. */
  31235. dispose(): void;
  31236. /**
  31237. * Creates a video texture straight from a stream.
  31238. * @param scene Define the scene the texture should be created in
  31239. * @param stream Define the stream the texture should be created from
  31240. * @returns The created video texture as a promise
  31241. */
  31242. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31243. /**
  31244. * Creates a video texture straight from your WebCam video feed.
  31245. * @param scene Define the scene the texture should be created in
  31246. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31247. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31248. * @returns The created video texture as a promise
  31249. */
  31250. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31251. minWidth: number;
  31252. maxWidth: number;
  31253. minHeight: number;
  31254. maxHeight: number;
  31255. deviceId: string;
  31256. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31257. /**
  31258. * Creates a video texture straight from your WebCam video feed.
  31259. * @param scene Define the scene the texture should be created in
  31260. * @param onReady Define a callback to triggered once the texture will be ready
  31261. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31262. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31263. */
  31264. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31265. minWidth: number;
  31266. maxWidth: number;
  31267. minHeight: number;
  31268. maxHeight: number;
  31269. deviceId: string;
  31270. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31271. }
  31272. }
  31273. declare module "babylonjs/Engines/thinEngine" {
  31274. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31275. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31276. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31277. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31278. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31279. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31280. import { Observable } from "babylonjs/Misc/observable";
  31281. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31282. import { StencilState } from "babylonjs/States/stencilState";
  31283. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31284. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31285. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31287. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31288. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31289. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31290. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31291. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31292. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31293. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31294. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31295. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31296. /**
  31297. * Defines the interface used by objects working like Scene
  31298. * @hidden
  31299. */
  31300. interface ISceneLike {
  31301. _addPendingData(data: any): void;
  31302. _removePendingData(data: any): void;
  31303. offlineProvider: IOfflineProvider;
  31304. }
  31305. /** Interface defining initialization parameters for Engine class */
  31306. export interface EngineOptions extends WebGLContextAttributes {
  31307. /**
  31308. * Defines if the engine should no exceed a specified device ratio
  31309. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31310. */
  31311. limitDeviceRatio?: number;
  31312. /**
  31313. * Defines if webvr should be enabled automatically
  31314. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31315. */
  31316. autoEnableWebVR?: boolean;
  31317. /**
  31318. * Defines if webgl2 should be turned off even if supported
  31319. * @see http://doc.babylonjs.com/features/webgl2
  31320. */
  31321. disableWebGL2Support?: boolean;
  31322. /**
  31323. * Defines if webaudio should be initialized as well
  31324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31325. */
  31326. audioEngine?: boolean;
  31327. /**
  31328. * Defines if animations should run using a deterministic lock step
  31329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31330. */
  31331. deterministicLockstep?: boolean;
  31332. /** Defines the maximum steps to use with deterministic lock step mode */
  31333. lockstepMaxSteps?: number;
  31334. /** Defines the seconds between each deterministic lock step */
  31335. timeStep?: number;
  31336. /**
  31337. * Defines that engine should ignore context lost events
  31338. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31339. */
  31340. doNotHandleContextLost?: boolean;
  31341. /**
  31342. * Defines that engine should ignore modifying touch action attribute and style
  31343. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31344. */
  31345. doNotHandleTouchAction?: boolean;
  31346. /**
  31347. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31348. */
  31349. useHighPrecisionFloats?: boolean;
  31350. }
  31351. /**
  31352. * The base engine class (root of all engines)
  31353. */
  31354. export class ThinEngine {
  31355. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31356. static ExceptionList: ({
  31357. key: string;
  31358. capture: string;
  31359. captureConstraint: number;
  31360. targets: string[];
  31361. } | {
  31362. key: string;
  31363. capture: null;
  31364. captureConstraint: null;
  31365. targets: string[];
  31366. })[];
  31367. /** @hidden */
  31368. static _TextureLoaders: IInternalTextureLoader[];
  31369. /**
  31370. * Returns the current npm package of the sdk
  31371. */
  31372. static readonly NpmPackage: string;
  31373. /**
  31374. * Returns the current version of the framework
  31375. */
  31376. static readonly Version: string;
  31377. /**
  31378. * Returns a string describing the current engine
  31379. */
  31380. readonly description: string;
  31381. /**
  31382. * Gets or sets the epsilon value used by collision engine
  31383. */
  31384. static CollisionsEpsilon: number;
  31385. /**
  31386. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31387. */
  31388. static ShadersRepository: string;
  31389. /**
  31390. * Gets or sets the textures that the engine should not attempt to load as compressed
  31391. */
  31392. protected _excludedCompressedTextures: string[];
  31393. /**
  31394. * Filters the compressed texture formats to only include
  31395. * files that are not included in the skippable list
  31396. *
  31397. * @param url the current extension
  31398. * @param textureFormatInUse the current compressed texture format
  31399. * @returns "format" string
  31400. */
  31401. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31402. /** @hidden */
  31403. _shaderProcessor: IShaderProcessor;
  31404. /**
  31405. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31406. */
  31407. forcePOTTextures: boolean;
  31408. /**
  31409. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31410. */
  31411. isFullscreen: boolean;
  31412. /**
  31413. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31414. */
  31415. cullBackFaces: boolean;
  31416. /**
  31417. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31418. */
  31419. renderEvenInBackground: boolean;
  31420. /**
  31421. * Gets or sets a boolean indicating that cache can be kept between frames
  31422. */
  31423. preventCacheWipeBetweenFrames: boolean;
  31424. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31425. validateShaderPrograms: boolean;
  31426. /**
  31427. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31428. * This can provide greater z depth for distant objects.
  31429. */
  31430. useReverseDepthBuffer: boolean;
  31431. /**
  31432. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31433. */
  31434. disableUniformBuffers: boolean;
  31435. /** @hidden */
  31436. _uniformBuffers: UniformBuffer[];
  31437. /**
  31438. * Gets a boolean indicating that the engine supports uniform buffers
  31439. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31440. */
  31441. readonly supportsUniformBuffers: boolean;
  31442. /** @hidden */
  31443. _gl: WebGLRenderingContext;
  31444. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31445. protected _windowIsBackground: boolean;
  31446. protected _webGLVersion: number;
  31447. protected _creationOptions: EngineOptions;
  31448. protected _highPrecisionShadersAllowed: boolean;
  31449. /** @hidden */
  31450. readonly _shouldUseHighPrecisionShader: boolean;
  31451. /**
  31452. * Gets a boolean indicating that only power of 2 textures are supported
  31453. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31454. */
  31455. readonly needPOTTextures: boolean;
  31456. /** @hidden */
  31457. _badOS: boolean;
  31458. /** @hidden */
  31459. _badDesktopOS: boolean;
  31460. private _hardwareScalingLevel;
  31461. /** @hidden */
  31462. _caps: EngineCapabilities;
  31463. private _isStencilEnable;
  31464. protected _colorWrite: boolean;
  31465. private _glVersion;
  31466. private _glRenderer;
  31467. private _glVendor;
  31468. /** @hidden */
  31469. _videoTextureSupported: boolean;
  31470. protected _renderingQueueLaunched: boolean;
  31471. protected _activeRenderLoops: (() => void)[];
  31472. /**
  31473. * Observable signaled when a context lost event is raised
  31474. */
  31475. onContextLostObservable: Observable<ThinEngine>;
  31476. /**
  31477. * Observable signaled when a context restored event is raised
  31478. */
  31479. onContextRestoredObservable: Observable<ThinEngine>;
  31480. private _onContextLost;
  31481. private _onContextRestored;
  31482. protected _contextWasLost: boolean;
  31483. /** @hidden */
  31484. _doNotHandleContextLost: boolean;
  31485. /**
  31486. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31488. */
  31489. doNotHandleContextLost: boolean;
  31490. /**
  31491. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31492. */
  31493. disableVertexArrayObjects: boolean;
  31494. /** @hidden */
  31495. protected _depthCullingState: DepthCullingState;
  31496. /** @hidden */
  31497. protected _stencilState: StencilState;
  31498. /** @hidden */
  31499. protected _alphaState: AlphaState;
  31500. /** @hidden */
  31501. _internalTexturesCache: InternalTexture[];
  31502. /** @hidden */
  31503. protected _activeChannel: number;
  31504. private _currentTextureChannel;
  31505. /** @hidden */
  31506. protected _boundTexturesCache: {
  31507. [key: string]: Nullable<InternalTexture>;
  31508. };
  31509. /** @hidden */
  31510. protected _currentEffect: Nullable<Effect>;
  31511. /** @hidden */
  31512. protected _currentProgram: Nullable<WebGLProgram>;
  31513. private _compiledEffects;
  31514. private _vertexAttribArraysEnabled;
  31515. /** @hidden */
  31516. protected _cachedViewport: Nullable<IViewportLike>;
  31517. private _cachedVertexArrayObject;
  31518. /** @hidden */
  31519. protected _cachedVertexBuffers: any;
  31520. /** @hidden */
  31521. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31522. /** @hidden */
  31523. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31524. /** @hidden */
  31525. _currentRenderTarget: Nullable<InternalTexture>;
  31526. private _uintIndicesCurrentlySet;
  31527. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31528. /** @hidden */
  31529. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31530. private _currentBufferPointers;
  31531. private _currentInstanceLocations;
  31532. private _currentInstanceBuffers;
  31533. private _textureUnits;
  31534. /** @hidden */
  31535. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31536. /** @hidden */
  31537. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31538. /** @hidden */
  31539. _boundRenderFunction: any;
  31540. private _vaoRecordInProgress;
  31541. private _mustWipeVertexAttributes;
  31542. private _emptyTexture;
  31543. private _emptyCubeTexture;
  31544. private _emptyTexture3D;
  31545. private _emptyTexture2DArray;
  31546. /** @hidden */
  31547. _frameHandler: number;
  31548. private _nextFreeTextureSlots;
  31549. private _maxSimultaneousTextures;
  31550. private _activeRequests;
  31551. protected _texturesSupported: string[];
  31552. /** @hidden */
  31553. _textureFormatInUse: Nullable<string>;
  31554. protected readonly _supportsHardwareTextureRescaling: boolean;
  31555. /**
  31556. * Gets the list of texture formats supported
  31557. */
  31558. readonly texturesSupported: Array<string>;
  31559. /**
  31560. * Gets the list of texture formats in use
  31561. */
  31562. readonly textureFormatInUse: Nullable<string>;
  31563. /**
  31564. * Gets the current viewport
  31565. */
  31566. readonly currentViewport: Nullable<IViewportLike>;
  31567. /**
  31568. * Gets the default empty texture
  31569. */
  31570. readonly emptyTexture: InternalTexture;
  31571. /**
  31572. * Gets the default empty 3D texture
  31573. */
  31574. readonly emptyTexture3D: InternalTexture;
  31575. /**
  31576. * Gets the default empty 2D array texture
  31577. */
  31578. readonly emptyTexture2DArray: InternalTexture;
  31579. /**
  31580. * Gets the default empty cube texture
  31581. */
  31582. readonly emptyCubeTexture: InternalTexture;
  31583. /**
  31584. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31585. */
  31586. readonly premultipliedAlpha: boolean;
  31587. /**
  31588. * Observable event triggered before each texture is initialized
  31589. */
  31590. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31591. /**
  31592. * Creates a new engine
  31593. * @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
  31594. * @param antialias defines enable antialiasing (default: false)
  31595. * @param options defines further options to be sent to the getContext() function
  31596. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31597. */
  31598. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31599. private _rebuildInternalTextures;
  31600. private _rebuildEffects;
  31601. /**
  31602. * Gets a boolean indicating if all created effects are ready
  31603. * @returns true if all effects are ready
  31604. */
  31605. areAllEffectsReady(): boolean;
  31606. protected _rebuildBuffers(): void;
  31607. private _initGLContext;
  31608. /**
  31609. * Gets version of the current webGL context
  31610. */
  31611. readonly webGLVersion: number;
  31612. /**
  31613. * Gets a string idenfifying the name of the class
  31614. * @returns "Engine" string
  31615. */
  31616. getClassName(): string;
  31617. /**
  31618. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31619. */
  31620. readonly isStencilEnable: boolean;
  31621. /** @hidden */
  31622. _prepareWorkingCanvas(): void;
  31623. /**
  31624. * Reset the texture cache to empty state
  31625. */
  31626. resetTextureCache(): void;
  31627. /**
  31628. * Gets an object containing information about the current webGL context
  31629. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31630. */
  31631. getGlInfo(): {
  31632. vendor: string;
  31633. renderer: string;
  31634. version: string;
  31635. };
  31636. /**
  31637. * Defines the hardware scaling level.
  31638. * By default the hardware scaling level is computed from the window device ratio.
  31639. * 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.
  31640. * @param level defines the level to use
  31641. */
  31642. setHardwareScalingLevel(level: number): void;
  31643. /**
  31644. * Gets the current hardware scaling level.
  31645. * By default the hardware scaling level is computed from the window device ratio.
  31646. * 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.
  31647. * @returns a number indicating the current hardware scaling level
  31648. */
  31649. getHardwareScalingLevel(): number;
  31650. /**
  31651. * Gets the list of loaded textures
  31652. * @returns an array containing all loaded textures
  31653. */
  31654. getLoadedTexturesCache(): InternalTexture[];
  31655. /**
  31656. * Gets the object containing all engine capabilities
  31657. * @returns the EngineCapabilities object
  31658. */
  31659. getCaps(): EngineCapabilities;
  31660. /**
  31661. * stop executing a render loop function and remove it from the execution array
  31662. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31663. */
  31664. stopRenderLoop(renderFunction?: () => void): void;
  31665. /** @hidden */
  31666. _renderLoop(): void;
  31667. /**
  31668. * Gets the HTML canvas attached with the current webGL context
  31669. * @returns a HTML canvas
  31670. */
  31671. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31672. /**
  31673. * Gets host window
  31674. * @returns the host window object
  31675. */
  31676. getHostWindow(): Nullable<Window>;
  31677. /**
  31678. * Gets the current render width
  31679. * @param useScreen defines if screen size must be used (or the current render target if any)
  31680. * @returns a number defining the current render width
  31681. */
  31682. getRenderWidth(useScreen?: boolean): number;
  31683. /**
  31684. * Gets the current render height
  31685. * @param useScreen defines if screen size must be used (or the current render target if any)
  31686. * @returns a number defining the current render height
  31687. */
  31688. getRenderHeight(useScreen?: boolean): number;
  31689. /**
  31690. * Can be used to override the current requestAnimationFrame requester.
  31691. * @hidden
  31692. */
  31693. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31694. /**
  31695. * Register and execute a render loop. The engine can have more than one render function
  31696. * @param renderFunction defines the function to continuously execute
  31697. */
  31698. runRenderLoop(renderFunction: () => void): void;
  31699. /**
  31700. * Clear the current render buffer or the current render target (if any is set up)
  31701. * @param color defines the color to use
  31702. * @param backBuffer defines if the back buffer must be cleared
  31703. * @param depth defines if the depth buffer must be cleared
  31704. * @param stencil defines if the stencil buffer must be cleared
  31705. */
  31706. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31707. private _viewportCached;
  31708. /** @hidden */
  31709. _viewport(x: number, y: number, width: number, height: number): void;
  31710. /**
  31711. * Set the WebGL's viewport
  31712. * @param viewport defines the viewport element to be used
  31713. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31714. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31715. */
  31716. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31717. /**
  31718. * Begin a new frame
  31719. */
  31720. beginFrame(): void;
  31721. /**
  31722. * Enf the current frame
  31723. */
  31724. endFrame(): void;
  31725. /**
  31726. * Resize the view according to the canvas' size
  31727. */
  31728. resize(): void;
  31729. /**
  31730. * Force a specific size of the canvas
  31731. * @param width defines the new canvas' width
  31732. * @param height defines the new canvas' height
  31733. */
  31734. setSize(width: number, height: number): void;
  31735. /**
  31736. * Binds the frame buffer to the specified texture.
  31737. * @param texture The texture to render to or null for the default canvas
  31738. * @param faceIndex The face of the texture to render to in case of cube texture
  31739. * @param requiredWidth The width of the target to render to
  31740. * @param requiredHeight The height of the target to render to
  31741. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31742. * @param depthStencilTexture The depth stencil texture to use to render
  31743. * @param lodLevel defines le lod level to bind to the frame buffer
  31744. */
  31745. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31746. /** @hidden */
  31747. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31748. /**
  31749. * Unbind the current render target texture from the webGL context
  31750. * @param texture defines the render target texture to unbind
  31751. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31752. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31753. */
  31754. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31755. /**
  31756. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31757. */
  31758. flushFramebuffer(): void;
  31759. /**
  31760. * Unbind the current render target and bind the default framebuffer
  31761. */
  31762. restoreDefaultFramebuffer(): void;
  31763. /** @hidden */
  31764. protected _resetVertexBufferBinding(): void;
  31765. /**
  31766. * Creates a vertex buffer
  31767. * @param data the data for the vertex buffer
  31768. * @returns the new WebGL static buffer
  31769. */
  31770. createVertexBuffer(data: DataArray): DataBuffer;
  31771. private _createVertexBuffer;
  31772. /**
  31773. * Creates a dynamic vertex buffer
  31774. * @param data the data for the dynamic vertex buffer
  31775. * @returns the new WebGL dynamic buffer
  31776. */
  31777. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31778. protected _resetIndexBufferBinding(): void;
  31779. /**
  31780. * Creates a new index buffer
  31781. * @param indices defines the content of the index buffer
  31782. * @param updatable defines if the index buffer must be updatable
  31783. * @returns a new webGL buffer
  31784. */
  31785. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31786. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31787. /**
  31788. * Bind a webGL buffer to the webGL context
  31789. * @param buffer defines the buffer to bind
  31790. */
  31791. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31792. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31793. private bindBuffer;
  31794. /**
  31795. * update the bound buffer with the given data
  31796. * @param data defines the data to update
  31797. */
  31798. updateArrayBuffer(data: Float32Array): void;
  31799. private _vertexAttribPointer;
  31800. private _bindIndexBufferWithCache;
  31801. private _bindVertexBuffersAttributes;
  31802. /**
  31803. * Records a vertex array object
  31804. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31805. * @param vertexBuffers defines the list of vertex buffers to store
  31806. * @param indexBuffer defines the index buffer to store
  31807. * @param effect defines the effect to store
  31808. * @returns the new vertex array object
  31809. */
  31810. recordVertexArrayObject(vertexBuffers: {
  31811. [key: string]: VertexBuffer;
  31812. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31813. /**
  31814. * Bind a specific vertex array object
  31815. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31816. * @param vertexArrayObject defines the vertex array object to bind
  31817. * @param indexBuffer defines the index buffer to bind
  31818. */
  31819. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31820. /**
  31821. * Bind webGl buffers directly to the webGL context
  31822. * @param vertexBuffer defines the vertex buffer to bind
  31823. * @param indexBuffer defines the index buffer to bind
  31824. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31825. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31826. * @param effect defines the effect associated with the vertex buffer
  31827. */
  31828. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31829. private _unbindVertexArrayObject;
  31830. /**
  31831. * Bind a list of vertex buffers to the webGL context
  31832. * @param vertexBuffers defines the list of vertex buffers to bind
  31833. * @param indexBuffer defines the index buffer to bind
  31834. * @param effect defines the effect associated with the vertex buffers
  31835. */
  31836. bindBuffers(vertexBuffers: {
  31837. [key: string]: Nullable<VertexBuffer>;
  31838. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31839. /**
  31840. * Unbind all instance attributes
  31841. */
  31842. unbindInstanceAttributes(): void;
  31843. /**
  31844. * Release and free the memory of a vertex array object
  31845. * @param vao defines the vertex array object to delete
  31846. */
  31847. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31848. /** @hidden */
  31849. _releaseBuffer(buffer: DataBuffer): boolean;
  31850. protected _deleteBuffer(buffer: DataBuffer): void;
  31851. /**
  31852. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31853. * @param instancesBuffer defines the webGL buffer to update and bind
  31854. * @param data defines the data to store in the buffer
  31855. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31856. */
  31857. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31858. /**
  31859. * Apply all cached states (depth, culling, stencil and alpha)
  31860. */
  31861. applyStates(): void;
  31862. /**
  31863. * Send a draw order
  31864. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31865. * @param indexStart defines the starting index
  31866. * @param indexCount defines the number of index to draw
  31867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31868. */
  31869. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31870. /**
  31871. * Draw a list of points
  31872. * @param verticesStart defines the index of first vertex to draw
  31873. * @param verticesCount defines the count of vertices to draw
  31874. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31875. */
  31876. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31877. /**
  31878. * Draw a list of unindexed primitives
  31879. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31880. * @param verticesStart defines the index of first vertex to draw
  31881. * @param verticesCount defines the count of vertices to draw
  31882. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31883. */
  31884. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31885. /**
  31886. * Draw a list of indexed primitives
  31887. * @param fillMode defines the primitive to use
  31888. * @param indexStart defines the starting index
  31889. * @param indexCount defines the number of index to draw
  31890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31891. */
  31892. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31893. /**
  31894. * Draw a list of unindexed primitives
  31895. * @param fillMode defines the primitive to use
  31896. * @param verticesStart defines the index of first vertex to draw
  31897. * @param verticesCount defines the count of vertices to draw
  31898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31899. */
  31900. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31901. private _drawMode;
  31902. /** @hidden */
  31903. protected _reportDrawCall(): void;
  31904. /** @hidden */
  31905. _releaseEffect(effect: Effect): void;
  31906. /** @hidden */
  31907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31908. /**
  31909. * Create a new effect (used to store vertex/fragment shaders)
  31910. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31911. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31912. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31913. * @param samplers defines an array of string used to represent textures
  31914. * @param defines defines the string containing the defines to use to compile the shaders
  31915. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31916. * @param onCompiled defines a function to call when the effect creation is successful
  31917. * @param onError defines a function to call when the effect creation has failed
  31918. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31919. * @returns the new Effect
  31920. */
  31921. 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;
  31922. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31923. private _compileShader;
  31924. private _compileRawShader;
  31925. /**
  31926. * Directly creates a webGL program
  31927. * @param pipelineContext defines the pipeline context to attach to
  31928. * @param vertexCode defines the vertex shader code to use
  31929. * @param fragmentCode defines the fragment shader code to use
  31930. * @param context defines the webGL context to use (if not set, the current one will be used)
  31931. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31932. * @returns the new webGL program
  31933. */
  31934. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31935. /**
  31936. * Creates a webGL program
  31937. * @param pipelineContext defines the pipeline context to attach to
  31938. * @param vertexCode defines the vertex shader code to use
  31939. * @param fragmentCode defines the fragment shader code to use
  31940. * @param defines defines the string containing the defines to use to compile the shaders
  31941. * @param context defines the webGL context to use (if not set, the current one will be used)
  31942. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31943. * @returns the new webGL program
  31944. */
  31945. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31946. /**
  31947. * Creates a new pipeline context
  31948. * @returns the new pipeline
  31949. */
  31950. createPipelineContext(): IPipelineContext;
  31951. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31952. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31953. /** @hidden */
  31954. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31955. /** @hidden */
  31956. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31957. /** @hidden */
  31958. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31959. /**
  31960. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31961. * @param pipelineContext defines the pipeline context to use
  31962. * @param uniformsNames defines the list of uniform names
  31963. * @returns an array of webGL uniform locations
  31964. */
  31965. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31966. /**
  31967. * Gets the lsit of active attributes for a given webGL program
  31968. * @param pipelineContext defines the pipeline context to use
  31969. * @param attributesNames defines the list of attribute names to get
  31970. * @returns an array of indices indicating the offset of each attribute
  31971. */
  31972. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31973. /**
  31974. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31975. * @param effect defines the effect to activate
  31976. */
  31977. enableEffect(effect: Nullable<Effect>): void;
  31978. /**
  31979. * Set the value of an uniform to a number (int)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param value defines the int number to store
  31982. */
  31983. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31984. /**
  31985. * Set the value of an uniform to an array of int32
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param array defines the array of int32 to store
  31988. */
  31989. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31990. /**
  31991. * Set the value of an uniform to an array of int32 (stored as vec2)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param array defines the array of int32 to store
  31994. */
  31995. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31996. /**
  31997. * Set the value of an uniform to an array of int32 (stored as vec3)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param array defines the array of int32 to store
  32000. */
  32001. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32002. /**
  32003. * Set the value of an uniform to an array of int32 (stored as vec4)
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param array defines the array of int32 to store
  32006. */
  32007. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32008. /**
  32009. * Set the value of an uniform to an array of number
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param array defines the array of number to store
  32012. */
  32013. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32014. /**
  32015. * Set the value of an uniform to an array of number (stored as vec2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param array defines the array of number to store
  32018. */
  32019. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32020. /**
  32021. * Set the value of an uniform to an array of number (stored as vec3)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param array defines the array of number to store
  32024. */
  32025. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32026. /**
  32027. * Set the value of an uniform to an array of number (stored as vec4)
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of number to store
  32030. */
  32031. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of float32 (stored as matrices)
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param matrices defines the array of float32 to store
  32036. */
  32037. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32038. /**
  32039. * Set the value of an uniform to a matrix (3x3)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32042. */
  32043. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32044. /**
  32045. * Set the value of an uniform to a matrix (2x2)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32048. */
  32049. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32050. /**
  32051. * Set the value of an uniform to a number (float)
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param value defines the float number to store
  32054. */
  32055. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32056. /**
  32057. * Set the value of an uniform to a vec2
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param x defines the 1st component of the value
  32060. * @param y defines the 2nd component of the value
  32061. */
  32062. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32063. /**
  32064. * Set the value of an uniform to a vec3
  32065. * @param uniform defines the webGL uniform location where to store the value
  32066. * @param x defines the 1st component of the value
  32067. * @param y defines the 2nd component of the value
  32068. * @param z defines the 3rd component of the value
  32069. */
  32070. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32071. /**
  32072. * Set the value of an uniform to a vec4
  32073. * @param uniform defines the webGL uniform location where to store the value
  32074. * @param x defines the 1st component of the value
  32075. * @param y defines the 2nd component of the value
  32076. * @param z defines the 3rd component of the value
  32077. * @param w defines the 4th component of the value
  32078. */
  32079. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32080. /**
  32081. * Gets the depth culling state manager
  32082. */
  32083. readonly depthCullingState: DepthCullingState;
  32084. /**
  32085. * Gets the alpha state manager
  32086. */
  32087. readonly alphaState: AlphaState;
  32088. /**
  32089. * Gets the stencil state manager
  32090. */
  32091. readonly stencilState: StencilState;
  32092. /**
  32093. * Clears the list of texture accessible through engine.
  32094. * This can help preventing texture load conflict due to name collision.
  32095. */
  32096. clearInternalTexturesCache(): void;
  32097. /**
  32098. * Force the entire cache to be cleared
  32099. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32100. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32101. */
  32102. wipeCaches(bruteForce?: boolean): void;
  32103. /** @hidden */
  32104. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32105. min: number;
  32106. mag: number;
  32107. };
  32108. /** @hidden */
  32109. _createTexture(): WebGLTexture;
  32110. /**
  32111. * Usually called from Texture.ts.
  32112. * Passed information to create a WebGLTexture
  32113. * @param urlArg defines a value which contains one of the following:
  32114. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32115. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32116. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32117. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32118. * @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)
  32119. * @param scene needed for loading to the correct scene
  32120. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32121. * @param onLoad optional callback to be called upon successful completion
  32122. * @param onError optional callback to be called upon failure
  32123. * @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
  32124. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32125. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32126. * @param forcedExtension defines the extension to use to pick the right loader
  32127. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32128. * @param mimeType defines an optional mime type
  32129. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32130. */
  32131. 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;
  32132. /**
  32133. * @hidden
  32134. */
  32135. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32136. /**
  32137. * Creates a raw texture
  32138. * @param data defines the data to store in the texture
  32139. * @param width defines the width of the texture
  32140. * @param height defines the height of the texture
  32141. * @param format defines the format of the data
  32142. * @param generateMipMaps defines if the engine should generate the mip levels
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32145. * @param compression defines the compression used (null by default)
  32146. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32147. * @returns the raw texture inside an InternalTexture
  32148. */
  32149. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32150. /**
  32151. * Creates a new raw cube texture
  32152. * @param data defines the array of data to use to create each face
  32153. * @param size defines the size of the textures
  32154. * @param format defines the format of the data
  32155. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32156. * @param generateMipMaps defines if the engine should generate the mip levels
  32157. * @param invertY defines if data must be stored with Y axis inverted
  32158. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32159. * @param compression defines the compression used (null by default)
  32160. * @returns the cube texture as an InternalTexture
  32161. */
  32162. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32163. /**
  32164. * Creates a new raw 3D texture
  32165. * @param data defines the data used to create the texture
  32166. * @param width defines the width of the texture
  32167. * @param height defines the height of the texture
  32168. * @param depth defines the depth of the texture
  32169. * @param format defines the format of the texture
  32170. * @param generateMipMaps defines if the engine must generate mip levels
  32171. * @param invertY defines if data must be stored with Y axis inverted
  32172. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32173. * @param compression defines the compressed used (can be null)
  32174. * @param textureType defines the compressed used (can be null)
  32175. * @returns a new raw 3D texture (stored in an InternalTexture)
  32176. */
  32177. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32178. /**
  32179. * Creates a new raw 2D array texture
  32180. * @param data defines the data used to create the texture
  32181. * @param width defines the width of the texture
  32182. * @param height defines the height of the texture
  32183. * @param depth defines the number of layers of the texture
  32184. * @param format defines the format of the texture
  32185. * @param generateMipMaps defines if the engine must generate mip levels
  32186. * @param invertY defines if data must be stored with Y axis inverted
  32187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32188. * @param compression defines the compressed used (can be null)
  32189. * @param textureType defines the compressed used (can be null)
  32190. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32191. */
  32192. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32193. private _unpackFlipYCached;
  32194. /**
  32195. * In case you are sharing the context with other applications, it might
  32196. * be interested to not cache the unpack flip y state to ensure a consistent
  32197. * value would be set.
  32198. */
  32199. enableUnpackFlipYCached: boolean;
  32200. /** @hidden */
  32201. _unpackFlipY(value: boolean): void;
  32202. /** @hidden */
  32203. _getUnpackAlignement(): number;
  32204. /**
  32205. * Update the sampling mode of a given texture
  32206. * @param samplingMode defines the required sampling mode
  32207. * @param texture defines the texture to update
  32208. */
  32209. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32210. /** @hidden */
  32211. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32212. width: number;
  32213. height: number;
  32214. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32215. /** @hidden */
  32216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32217. /** @hidden */
  32218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32219. /** @hidden */
  32220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32221. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32222. private _prepareWebGLTexture;
  32223. /** @hidden */
  32224. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32225. /** @hidden */
  32226. _releaseFramebufferObjects(texture: InternalTexture): void;
  32227. /** @hidden */
  32228. _releaseTexture(texture: InternalTexture): void;
  32229. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32230. protected _setProgram(program: WebGLProgram): void;
  32231. protected _boundUniforms: {
  32232. [key: number]: WebGLUniformLocation;
  32233. };
  32234. /**
  32235. * Binds an effect to the webGL context
  32236. * @param effect defines the effect to bind
  32237. */
  32238. bindSamplers(effect: Effect): void;
  32239. private _activateCurrentTexture;
  32240. /** @hidden */
  32241. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32242. /** @hidden */
  32243. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32244. /**
  32245. * Unbind all textures from the webGL context
  32246. */
  32247. unbindAllTextures(): void;
  32248. /**
  32249. * Sets a texture to the according uniform.
  32250. * @param channel The texture channel
  32251. * @param uniform The uniform to set
  32252. * @param texture The texture to apply
  32253. */
  32254. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32255. private _bindSamplerUniformToChannel;
  32256. private _getTextureWrapMode;
  32257. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32258. /**
  32259. * Sets an array of texture to the webGL context
  32260. * @param channel defines the channel where the texture array must be set
  32261. * @param uniform defines the associated uniform location
  32262. * @param textures defines the array of textures to bind
  32263. */
  32264. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32265. /** @hidden */
  32266. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32267. private _setTextureParameterFloat;
  32268. private _setTextureParameterInteger;
  32269. /**
  32270. * Unbind all vertex attributes from the webGL context
  32271. */
  32272. unbindAllAttributes(): void;
  32273. /**
  32274. * 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
  32275. */
  32276. releaseEffects(): void;
  32277. /**
  32278. * Dispose and release all associated resources
  32279. */
  32280. dispose(): void;
  32281. /**
  32282. * Attach a new callback raised when context lost event is fired
  32283. * @param callback defines the callback to call
  32284. */
  32285. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32286. /**
  32287. * Attach a new callback raised when context restored event is fired
  32288. * @param callback defines the callback to call
  32289. */
  32290. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32291. /**
  32292. * Get the current error code of the webGL context
  32293. * @returns the error code
  32294. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32295. */
  32296. getError(): number;
  32297. private _canRenderToFloatFramebuffer;
  32298. private _canRenderToHalfFloatFramebuffer;
  32299. private _canRenderToFramebuffer;
  32300. /** @hidden */
  32301. _getWebGLTextureType(type: number): number;
  32302. /** @hidden */
  32303. _getInternalFormat(format: number): number;
  32304. /** @hidden */
  32305. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32306. /** @hidden */
  32307. _getRGBAMultiSampleBufferFormat(type: number): number;
  32308. /** @hidden */
  32309. _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;
  32310. /**
  32311. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32312. * @returns true if the engine can be created
  32313. * @ignorenaming
  32314. */
  32315. static isSupported(): boolean;
  32316. /**
  32317. * Find the next highest power of two.
  32318. * @param x Number to start search from.
  32319. * @return Next highest power of two.
  32320. */
  32321. static CeilingPOT(x: number): number;
  32322. /**
  32323. * Find the next lowest power of two.
  32324. * @param x Number to start search from.
  32325. * @return Next lowest power of two.
  32326. */
  32327. static FloorPOT(x: number): number;
  32328. /**
  32329. * Find the nearest power of two.
  32330. * @param x Number to start search from.
  32331. * @return Next nearest power of two.
  32332. */
  32333. static NearestPOT(x: number): number;
  32334. /**
  32335. * Get the closest exponent of two
  32336. * @param value defines the value to approximate
  32337. * @param max defines the maximum value to return
  32338. * @param mode defines how to define the closest value
  32339. * @returns closest exponent of two of the given value
  32340. */
  32341. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32342. /**
  32343. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32344. * @param func - the function to be called
  32345. * @param requester - the object that will request the next frame. Falls back to window.
  32346. * @returns frame number
  32347. */
  32348. static QueueNewFrame(func: () => void, requester?: any): number;
  32349. /**
  32350. * Gets host document
  32351. * @returns the host document object
  32352. */
  32353. getHostDocument(): Document;
  32354. }
  32355. }
  32356. declare module "babylonjs/Maths/sphericalPolynomial" {
  32357. import { Vector3 } from "babylonjs/Maths/math.vector";
  32358. import { Color3 } from "babylonjs/Maths/math.color";
  32359. /**
  32360. * Class representing spherical harmonics coefficients to the 3rd degree
  32361. */
  32362. export class SphericalHarmonics {
  32363. /**
  32364. * Defines whether or not the harmonics have been prescaled for rendering.
  32365. */
  32366. preScaled: boolean;
  32367. /**
  32368. * The l0,0 coefficients of the spherical harmonics
  32369. */
  32370. l00: Vector3;
  32371. /**
  32372. * The l1,-1 coefficients of the spherical harmonics
  32373. */
  32374. l1_1: Vector3;
  32375. /**
  32376. * The l1,0 coefficients of the spherical harmonics
  32377. */
  32378. l10: Vector3;
  32379. /**
  32380. * The l1,1 coefficients of the spherical harmonics
  32381. */
  32382. l11: Vector3;
  32383. /**
  32384. * The l2,-2 coefficients of the spherical harmonics
  32385. */
  32386. l2_2: Vector3;
  32387. /**
  32388. * The l2,-1 coefficients of the spherical harmonics
  32389. */
  32390. l2_1: Vector3;
  32391. /**
  32392. * The l2,0 coefficients of the spherical harmonics
  32393. */
  32394. l20: Vector3;
  32395. /**
  32396. * The l2,1 coefficients of the spherical harmonics
  32397. */
  32398. l21: Vector3;
  32399. /**
  32400. * The l2,2 coefficients of the spherical harmonics
  32401. */
  32402. l22: Vector3;
  32403. /**
  32404. * Adds a light to the spherical harmonics
  32405. * @param direction the direction of the light
  32406. * @param color the color of the light
  32407. * @param deltaSolidAngle the delta solid angle of the light
  32408. */
  32409. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32410. /**
  32411. * Scales the spherical harmonics by the given amount
  32412. * @param scale the amount to scale
  32413. */
  32414. scaleInPlace(scale: number): void;
  32415. /**
  32416. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32417. *
  32418. * ```
  32419. * E_lm = A_l * L_lm
  32420. * ```
  32421. *
  32422. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32423. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32424. * the scaling factors are given in equation 9.
  32425. */
  32426. convertIncidentRadianceToIrradiance(): void;
  32427. /**
  32428. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32429. *
  32430. * ```
  32431. * L = (1/pi) * E * rho
  32432. * ```
  32433. *
  32434. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32435. */
  32436. convertIrradianceToLambertianRadiance(): void;
  32437. /**
  32438. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32439. * required operations at run time.
  32440. *
  32441. * This is simply done by scaling back the SH with Ylm constants parameter.
  32442. * The trigonometric part being applied by the shader at run time.
  32443. */
  32444. preScaleForRendering(): void;
  32445. /**
  32446. * Constructs a spherical harmonics from an array.
  32447. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32448. * @returns the spherical harmonics
  32449. */
  32450. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32451. /**
  32452. * Gets the spherical harmonics from polynomial
  32453. * @param polynomial the spherical polynomial
  32454. * @returns the spherical harmonics
  32455. */
  32456. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32457. }
  32458. /**
  32459. * Class representing spherical polynomial coefficients to the 3rd degree
  32460. */
  32461. export class SphericalPolynomial {
  32462. private _harmonics;
  32463. /**
  32464. * The spherical harmonics used to create the polynomials.
  32465. */
  32466. readonly preScaledHarmonics: SphericalHarmonics;
  32467. /**
  32468. * The x coefficients of the spherical polynomial
  32469. */
  32470. x: Vector3;
  32471. /**
  32472. * The y coefficients of the spherical polynomial
  32473. */
  32474. y: Vector3;
  32475. /**
  32476. * The z coefficients of the spherical polynomial
  32477. */
  32478. z: Vector3;
  32479. /**
  32480. * The xx coefficients of the spherical polynomial
  32481. */
  32482. xx: Vector3;
  32483. /**
  32484. * The yy coefficients of the spherical polynomial
  32485. */
  32486. yy: Vector3;
  32487. /**
  32488. * The zz coefficients of the spherical polynomial
  32489. */
  32490. zz: Vector3;
  32491. /**
  32492. * The xy coefficients of the spherical polynomial
  32493. */
  32494. xy: Vector3;
  32495. /**
  32496. * The yz coefficients of the spherical polynomial
  32497. */
  32498. yz: Vector3;
  32499. /**
  32500. * The zx coefficients of the spherical polynomial
  32501. */
  32502. zx: Vector3;
  32503. /**
  32504. * Adds an ambient color to the spherical polynomial
  32505. * @param color the color to add
  32506. */
  32507. addAmbient(color: Color3): void;
  32508. /**
  32509. * Scales the spherical polynomial by the given amount
  32510. * @param scale the amount to scale
  32511. */
  32512. scaleInPlace(scale: number): void;
  32513. /**
  32514. * Gets the spherical polynomial from harmonics
  32515. * @param harmonics the spherical harmonics
  32516. * @returns the spherical polynomial
  32517. */
  32518. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32519. /**
  32520. * Constructs a spherical polynomial from an array.
  32521. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32522. * @returns the spherical polynomial
  32523. */
  32524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32525. }
  32526. }
  32527. declare module "babylonjs/Materials/Textures/internalTexture" {
  32528. import { Observable } from "babylonjs/Misc/observable";
  32529. import { Nullable, int } from "babylonjs/types";
  32530. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32532. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32533. /**
  32534. * Defines the source of the internal texture
  32535. */
  32536. export enum InternalTextureSource {
  32537. /**
  32538. * The source of the texture data is unknown
  32539. */
  32540. Unknown = 0,
  32541. /**
  32542. * Texture data comes from an URL
  32543. */
  32544. Url = 1,
  32545. /**
  32546. * Texture data is only used for temporary storage
  32547. */
  32548. Temp = 2,
  32549. /**
  32550. * Texture data comes from raw data (ArrayBuffer)
  32551. */
  32552. Raw = 3,
  32553. /**
  32554. * Texture content is dynamic (video or dynamic texture)
  32555. */
  32556. Dynamic = 4,
  32557. /**
  32558. * Texture content is generated by rendering to it
  32559. */
  32560. RenderTarget = 5,
  32561. /**
  32562. * Texture content is part of a multi render target process
  32563. */
  32564. MultiRenderTarget = 6,
  32565. /**
  32566. * Texture data comes from a cube data file
  32567. */
  32568. Cube = 7,
  32569. /**
  32570. * Texture data comes from a raw cube data
  32571. */
  32572. CubeRaw = 8,
  32573. /**
  32574. * Texture data come from a prefiltered cube data file
  32575. */
  32576. CubePrefiltered = 9,
  32577. /**
  32578. * Texture content is raw 3D data
  32579. */
  32580. Raw3D = 10,
  32581. /**
  32582. * Texture content is raw 2D array data
  32583. */
  32584. Raw2DArray = 11,
  32585. /**
  32586. * Texture content is a depth texture
  32587. */
  32588. Depth = 12,
  32589. /**
  32590. * Texture data comes from a raw cube data encoded with RGBD
  32591. */
  32592. CubeRawRGBD = 13
  32593. }
  32594. /**
  32595. * Class used to store data associated with WebGL texture data for the engine
  32596. * This class should not be used directly
  32597. */
  32598. export class InternalTexture {
  32599. /** @hidden */
  32600. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32601. /**
  32602. * Defines if the texture is ready
  32603. */
  32604. isReady: boolean;
  32605. /**
  32606. * Defines if the texture is a cube texture
  32607. */
  32608. isCube: boolean;
  32609. /**
  32610. * Defines if the texture contains 3D data
  32611. */
  32612. is3D: boolean;
  32613. /**
  32614. * Defines if the texture contains 2D array data
  32615. */
  32616. is2DArray: boolean;
  32617. /**
  32618. * Defines if the texture contains multiview data
  32619. */
  32620. isMultiview: boolean;
  32621. /**
  32622. * Gets the URL used to load this texture
  32623. */
  32624. url: string;
  32625. /**
  32626. * Gets the sampling mode of the texture
  32627. */
  32628. samplingMode: number;
  32629. /**
  32630. * Gets a boolean indicating if the texture needs mipmaps generation
  32631. */
  32632. generateMipMaps: boolean;
  32633. /**
  32634. * Gets the number of samples used by the texture (WebGL2+ only)
  32635. */
  32636. samples: number;
  32637. /**
  32638. * Gets the type of the texture (int, float...)
  32639. */
  32640. type: number;
  32641. /**
  32642. * Gets the format of the texture (RGB, RGBA...)
  32643. */
  32644. format: number;
  32645. /**
  32646. * Observable called when the texture is loaded
  32647. */
  32648. onLoadedObservable: Observable<InternalTexture>;
  32649. /**
  32650. * Gets the width of the texture
  32651. */
  32652. width: number;
  32653. /**
  32654. * Gets the height of the texture
  32655. */
  32656. height: number;
  32657. /**
  32658. * Gets the depth of the texture
  32659. */
  32660. depth: number;
  32661. /**
  32662. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32663. */
  32664. baseWidth: number;
  32665. /**
  32666. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32667. */
  32668. baseHeight: number;
  32669. /**
  32670. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32671. */
  32672. baseDepth: number;
  32673. /**
  32674. * Gets a boolean indicating if the texture is inverted on Y axis
  32675. */
  32676. invertY: boolean;
  32677. /** @hidden */
  32678. _invertVScale: boolean;
  32679. /** @hidden */
  32680. _associatedChannel: number;
  32681. /** @hidden */
  32682. _source: InternalTextureSource;
  32683. /** @hidden */
  32684. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32685. /** @hidden */
  32686. _bufferView: Nullable<ArrayBufferView>;
  32687. /** @hidden */
  32688. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32689. /** @hidden */
  32690. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32691. /** @hidden */
  32692. _size: number;
  32693. /** @hidden */
  32694. _extension: string;
  32695. /** @hidden */
  32696. _files: Nullable<string[]>;
  32697. /** @hidden */
  32698. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32699. /** @hidden */
  32700. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32701. /** @hidden */
  32702. _framebuffer: Nullable<WebGLFramebuffer>;
  32703. /** @hidden */
  32704. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32705. /** @hidden */
  32706. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32707. /** @hidden */
  32708. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32709. /** @hidden */
  32710. _attachments: Nullable<number[]>;
  32711. /** @hidden */
  32712. _cachedCoordinatesMode: Nullable<number>;
  32713. /** @hidden */
  32714. _cachedWrapU: Nullable<number>;
  32715. /** @hidden */
  32716. _cachedWrapV: Nullable<number>;
  32717. /** @hidden */
  32718. _cachedWrapR: Nullable<number>;
  32719. /** @hidden */
  32720. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32721. /** @hidden */
  32722. _isDisabled: boolean;
  32723. /** @hidden */
  32724. _compression: Nullable<string>;
  32725. /** @hidden */
  32726. _generateStencilBuffer: boolean;
  32727. /** @hidden */
  32728. _generateDepthBuffer: boolean;
  32729. /** @hidden */
  32730. _comparisonFunction: number;
  32731. /** @hidden */
  32732. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32733. /** @hidden */
  32734. _lodGenerationScale: number;
  32735. /** @hidden */
  32736. _lodGenerationOffset: number;
  32737. /** @hidden */
  32738. _colorTextureArray: Nullable<WebGLTexture>;
  32739. /** @hidden */
  32740. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32741. /** @hidden */
  32742. _lodTextureHigh: Nullable<BaseTexture>;
  32743. /** @hidden */
  32744. _lodTextureMid: Nullable<BaseTexture>;
  32745. /** @hidden */
  32746. _lodTextureLow: Nullable<BaseTexture>;
  32747. /** @hidden */
  32748. _isRGBD: boolean;
  32749. /** @hidden */
  32750. _linearSpecularLOD: boolean;
  32751. /** @hidden */
  32752. _irradianceTexture: Nullable<BaseTexture>;
  32753. /** @hidden */
  32754. _webGLTexture: Nullable<WebGLTexture>;
  32755. /** @hidden */
  32756. _references: number;
  32757. private _engine;
  32758. /**
  32759. * Gets the Engine the texture belongs to.
  32760. * @returns The babylon engine
  32761. */
  32762. getEngine(): ThinEngine;
  32763. /**
  32764. * Gets the data source type of the texture
  32765. */
  32766. readonly source: InternalTextureSource;
  32767. /**
  32768. * Creates a new InternalTexture
  32769. * @param engine defines the engine to use
  32770. * @param source defines the type of data that will be used
  32771. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32772. */
  32773. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32774. /**
  32775. * Increments the number of references (ie. the number of Texture that point to it)
  32776. */
  32777. incrementReferences(): void;
  32778. /**
  32779. * Change the size of the texture (not the size of the content)
  32780. * @param width defines the new width
  32781. * @param height defines the new height
  32782. * @param depth defines the new depth (1 by default)
  32783. */
  32784. updateSize(width: int, height: int, depth?: int): void;
  32785. /** @hidden */
  32786. _rebuild(): void;
  32787. /** @hidden */
  32788. _swapAndDie(target: InternalTexture): void;
  32789. /**
  32790. * Dispose the current allocated resources
  32791. */
  32792. dispose(): void;
  32793. }
  32794. }
  32795. declare module "babylonjs/Audio/analyser" {
  32796. import { Scene } from "babylonjs/scene";
  32797. /**
  32798. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32800. */
  32801. export class Analyser {
  32802. /**
  32803. * Gets or sets the smoothing
  32804. * @ignorenaming
  32805. */
  32806. SMOOTHING: number;
  32807. /**
  32808. * Gets or sets the FFT table size
  32809. * @ignorenaming
  32810. */
  32811. FFT_SIZE: number;
  32812. /**
  32813. * Gets or sets the bar graph amplitude
  32814. * @ignorenaming
  32815. */
  32816. BARGRAPHAMPLITUDE: number;
  32817. /**
  32818. * Gets or sets the position of the debug canvas
  32819. * @ignorenaming
  32820. */
  32821. DEBUGCANVASPOS: {
  32822. x: number;
  32823. y: number;
  32824. };
  32825. /**
  32826. * Gets or sets the debug canvas size
  32827. * @ignorenaming
  32828. */
  32829. DEBUGCANVASSIZE: {
  32830. width: number;
  32831. height: number;
  32832. };
  32833. private _byteFreqs;
  32834. private _byteTime;
  32835. private _floatFreqs;
  32836. private _webAudioAnalyser;
  32837. private _debugCanvas;
  32838. private _debugCanvasContext;
  32839. private _scene;
  32840. private _registerFunc;
  32841. private _audioEngine;
  32842. /**
  32843. * Creates a new analyser
  32844. * @param scene defines hosting scene
  32845. */
  32846. constructor(scene: Scene);
  32847. /**
  32848. * Get the number of data values you will have to play with for the visualization
  32849. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32850. * @returns a number
  32851. */
  32852. getFrequencyBinCount(): number;
  32853. /**
  32854. * Gets the current frequency data as a byte array
  32855. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32856. * @returns a Uint8Array
  32857. */
  32858. getByteFrequencyData(): Uint8Array;
  32859. /**
  32860. * Gets the current waveform as a byte array
  32861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32862. * @returns a Uint8Array
  32863. */
  32864. getByteTimeDomainData(): Uint8Array;
  32865. /**
  32866. * Gets the current frequency data as a float array
  32867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32868. * @returns a Float32Array
  32869. */
  32870. getFloatFrequencyData(): Float32Array;
  32871. /**
  32872. * Renders the debug canvas
  32873. */
  32874. drawDebugCanvas(): void;
  32875. /**
  32876. * Stops rendering the debug canvas and removes it
  32877. */
  32878. stopDebugCanvas(): void;
  32879. /**
  32880. * Connects two audio nodes
  32881. * @param inputAudioNode defines first node to connect
  32882. * @param outputAudioNode defines second node to connect
  32883. */
  32884. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32885. /**
  32886. * Releases all associated resources
  32887. */
  32888. dispose(): void;
  32889. }
  32890. }
  32891. declare module "babylonjs/Audio/audioEngine" {
  32892. import { IDisposable } from "babylonjs/scene";
  32893. import { Analyser } from "babylonjs/Audio/analyser";
  32894. import { Nullable } from "babylonjs/types";
  32895. import { Observable } from "babylonjs/Misc/observable";
  32896. /**
  32897. * This represents an audio engine and it is responsible
  32898. * to play, synchronize and analyse sounds throughout the application.
  32899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32900. */
  32901. export interface IAudioEngine extends IDisposable {
  32902. /**
  32903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32904. */
  32905. readonly canUseWebAudio: boolean;
  32906. /**
  32907. * Gets the current AudioContext if available.
  32908. */
  32909. readonly audioContext: Nullable<AudioContext>;
  32910. /**
  32911. * The master gain node defines the global audio volume of your audio engine.
  32912. */
  32913. readonly masterGain: GainNode;
  32914. /**
  32915. * Gets whether or not mp3 are supported by your browser.
  32916. */
  32917. readonly isMP3supported: boolean;
  32918. /**
  32919. * Gets whether or not ogg are supported by your browser.
  32920. */
  32921. readonly isOGGsupported: boolean;
  32922. /**
  32923. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32924. * @ignoreNaming
  32925. */
  32926. WarnedWebAudioUnsupported: boolean;
  32927. /**
  32928. * Defines if the audio engine relies on a custom unlocked button.
  32929. * In this case, the embedded button will not be displayed.
  32930. */
  32931. useCustomUnlockedButton: boolean;
  32932. /**
  32933. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32934. */
  32935. readonly unlocked: boolean;
  32936. /**
  32937. * Event raised when audio has been unlocked on the browser.
  32938. */
  32939. onAudioUnlockedObservable: Observable<AudioEngine>;
  32940. /**
  32941. * Event raised when audio has been locked on the browser.
  32942. */
  32943. onAudioLockedObservable: Observable<AudioEngine>;
  32944. /**
  32945. * Flags the audio engine in Locked state.
  32946. * This happens due to new browser policies preventing audio to autoplay.
  32947. */
  32948. lock(): void;
  32949. /**
  32950. * Unlocks the audio engine once a user action has been done on the dom.
  32951. * This is helpful to resume play once browser policies have been satisfied.
  32952. */
  32953. unlock(): void;
  32954. }
  32955. /**
  32956. * This represents the default audio engine used in babylon.
  32957. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32959. */
  32960. export class AudioEngine implements IAudioEngine {
  32961. private _audioContext;
  32962. private _audioContextInitialized;
  32963. private _muteButton;
  32964. private _hostElement;
  32965. /**
  32966. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32967. */
  32968. canUseWebAudio: boolean;
  32969. /**
  32970. * The master gain node defines the global audio volume of your audio engine.
  32971. */
  32972. masterGain: GainNode;
  32973. /**
  32974. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32975. * @ignoreNaming
  32976. */
  32977. WarnedWebAudioUnsupported: boolean;
  32978. /**
  32979. * Gets whether or not mp3 are supported by your browser.
  32980. */
  32981. isMP3supported: boolean;
  32982. /**
  32983. * Gets whether or not ogg are supported by your browser.
  32984. */
  32985. isOGGsupported: boolean;
  32986. /**
  32987. * Gets whether audio has been unlocked on the device.
  32988. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32989. * a user interaction has happened.
  32990. */
  32991. unlocked: boolean;
  32992. /**
  32993. * Defines if the audio engine relies on a custom unlocked button.
  32994. * In this case, the embedded button will not be displayed.
  32995. */
  32996. useCustomUnlockedButton: boolean;
  32997. /**
  32998. * Event raised when audio has been unlocked on the browser.
  32999. */
  33000. onAudioUnlockedObservable: Observable<AudioEngine>;
  33001. /**
  33002. * Event raised when audio has been locked on the browser.
  33003. */
  33004. onAudioLockedObservable: Observable<AudioEngine>;
  33005. /**
  33006. * Gets the current AudioContext if available.
  33007. */
  33008. readonly audioContext: Nullable<AudioContext>;
  33009. private _connectedAnalyser;
  33010. /**
  33011. * Instantiates a new audio engine.
  33012. *
  33013. * There should be only one per page as some browsers restrict the number
  33014. * of audio contexts you can create.
  33015. * @param hostElement defines the host element where to display the mute icon if necessary
  33016. */
  33017. constructor(hostElement?: Nullable<HTMLElement>);
  33018. /**
  33019. * Flags the audio engine in Locked state.
  33020. * This happens due to new browser policies preventing audio to autoplay.
  33021. */
  33022. lock(): void;
  33023. /**
  33024. * Unlocks the audio engine once a user action has been done on the dom.
  33025. * This is helpful to resume play once browser policies have been satisfied.
  33026. */
  33027. unlock(): void;
  33028. private _resumeAudioContext;
  33029. private _initializeAudioContext;
  33030. private _tryToRun;
  33031. private _triggerRunningState;
  33032. private _triggerSuspendedState;
  33033. private _displayMuteButton;
  33034. private _moveButtonToTopLeft;
  33035. private _onResize;
  33036. private _hideMuteButton;
  33037. /**
  33038. * Destroy and release the resources associated with the audio ccontext.
  33039. */
  33040. dispose(): void;
  33041. /**
  33042. * Gets the global volume sets on the master gain.
  33043. * @returns the global volume if set or -1 otherwise
  33044. */
  33045. getGlobalVolume(): number;
  33046. /**
  33047. * Sets the global volume of your experience (sets on the master gain).
  33048. * @param newVolume Defines the new global volume of the application
  33049. */
  33050. setGlobalVolume(newVolume: number): void;
  33051. /**
  33052. * Connect the audio engine to an audio analyser allowing some amazing
  33053. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33055. * @param analyser The analyser to connect to the engine
  33056. */
  33057. connectToAnalyser(analyser: Analyser): void;
  33058. }
  33059. }
  33060. declare module "babylonjs/Loading/loadingScreen" {
  33061. /**
  33062. * Interface used to present a loading screen while loading a scene
  33063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33064. */
  33065. export interface ILoadingScreen {
  33066. /**
  33067. * Function called to display the loading screen
  33068. */
  33069. displayLoadingUI: () => void;
  33070. /**
  33071. * Function called to hide the loading screen
  33072. */
  33073. hideLoadingUI: () => void;
  33074. /**
  33075. * Gets or sets the color to use for the background
  33076. */
  33077. loadingUIBackgroundColor: string;
  33078. /**
  33079. * Gets or sets the text to display while loading
  33080. */
  33081. loadingUIText: string;
  33082. }
  33083. /**
  33084. * Class used for the default loading screen
  33085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33086. */
  33087. export class DefaultLoadingScreen implements ILoadingScreen {
  33088. private _renderingCanvas;
  33089. private _loadingText;
  33090. private _loadingDivBackgroundColor;
  33091. private _loadingDiv;
  33092. private _loadingTextDiv;
  33093. /** Gets or sets the logo url to use for the default loading screen */
  33094. static DefaultLogoUrl: string;
  33095. /** Gets or sets the spinner url to use for the default loading screen */
  33096. static DefaultSpinnerUrl: string;
  33097. /**
  33098. * Creates a new default loading screen
  33099. * @param _renderingCanvas defines the canvas used to render the scene
  33100. * @param _loadingText defines the default text to display
  33101. * @param _loadingDivBackgroundColor defines the default background color
  33102. */
  33103. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33104. /**
  33105. * Function called to display the loading screen
  33106. */
  33107. displayLoadingUI(): void;
  33108. /**
  33109. * Function called to hide the loading screen
  33110. */
  33111. hideLoadingUI(): void;
  33112. /**
  33113. * Gets or sets the text to display while loading
  33114. */
  33115. loadingUIText: string;
  33116. /**
  33117. * Gets or sets the color to use for the background
  33118. */
  33119. loadingUIBackgroundColor: string;
  33120. private _resizeLoadingUI;
  33121. }
  33122. }
  33123. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33124. /**
  33125. * Interface for any object that can request an animation frame
  33126. */
  33127. export interface ICustomAnimationFrameRequester {
  33128. /**
  33129. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33130. */
  33131. renderFunction?: Function;
  33132. /**
  33133. * Called to request the next frame to render to
  33134. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33135. */
  33136. requestAnimationFrame: Function;
  33137. /**
  33138. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33139. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33140. */
  33141. requestID?: number;
  33142. }
  33143. }
  33144. declare module "babylonjs/Misc/performanceMonitor" {
  33145. /**
  33146. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33147. */
  33148. export class PerformanceMonitor {
  33149. private _enabled;
  33150. private _rollingFrameTime;
  33151. private _lastFrameTimeMs;
  33152. /**
  33153. * constructor
  33154. * @param frameSampleSize The number of samples required to saturate the sliding window
  33155. */
  33156. constructor(frameSampleSize?: number);
  33157. /**
  33158. * Samples current frame
  33159. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33160. */
  33161. sampleFrame(timeMs?: number): void;
  33162. /**
  33163. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33164. */
  33165. readonly averageFrameTime: number;
  33166. /**
  33167. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33168. */
  33169. readonly averageFrameTimeVariance: number;
  33170. /**
  33171. * Returns the frame time of the most recent frame
  33172. */
  33173. readonly instantaneousFrameTime: number;
  33174. /**
  33175. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33176. */
  33177. readonly averageFPS: number;
  33178. /**
  33179. * Returns the average framerate in frames per second using the most recent frame time
  33180. */
  33181. readonly instantaneousFPS: number;
  33182. /**
  33183. * Returns true if enough samples have been taken to completely fill the sliding window
  33184. */
  33185. readonly isSaturated: boolean;
  33186. /**
  33187. * Enables contributions to the sliding window sample set
  33188. */
  33189. enable(): void;
  33190. /**
  33191. * Disables contributions to the sliding window sample set
  33192. * Samples will not be interpolated over the disabled period
  33193. */
  33194. disable(): void;
  33195. /**
  33196. * Returns true if sampling is enabled
  33197. */
  33198. readonly isEnabled: boolean;
  33199. /**
  33200. * Resets performance monitor
  33201. */
  33202. reset(): void;
  33203. }
  33204. /**
  33205. * RollingAverage
  33206. *
  33207. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33208. */
  33209. export class RollingAverage {
  33210. /**
  33211. * Current average
  33212. */
  33213. average: number;
  33214. /**
  33215. * Current variance
  33216. */
  33217. variance: number;
  33218. protected _samples: Array<number>;
  33219. protected _sampleCount: number;
  33220. protected _pos: number;
  33221. protected _m2: number;
  33222. /**
  33223. * constructor
  33224. * @param length The number of samples required to saturate the sliding window
  33225. */
  33226. constructor(length: number);
  33227. /**
  33228. * Adds a sample to the sample set
  33229. * @param v The sample value
  33230. */
  33231. add(v: number): void;
  33232. /**
  33233. * Returns previously added values or null if outside of history or outside the sliding window domain
  33234. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33235. * @return Value previously recorded with add() or null if outside of range
  33236. */
  33237. history(i: number): number;
  33238. /**
  33239. * Returns true if enough samples have been taken to completely fill the sliding window
  33240. * @return true if sample-set saturated
  33241. */
  33242. isSaturated(): boolean;
  33243. /**
  33244. * Resets the rolling average (equivalent to 0 samples taken so far)
  33245. */
  33246. reset(): void;
  33247. /**
  33248. * Wraps a value around the sample range boundaries
  33249. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33250. * @return Wrapped position in sample range
  33251. */
  33252. protected _wrapPosition(i: number): number;
  33253. }
  33254. }
  33255. declare module "babylonjs/Misc/perfCounter" {
  33256. /**
  33257. * This class is used to track a performance counter which is number based.
  33258. * The user has access to many properties which give statistics of different nature.
  33259. *
  33260. * The implementer can track two kinds of Performance Counter: time and count.
  33261. * 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.
  33262. * 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.
  33263. */
  33264. export class PerfCounter {
  33265. /**
  33266. * Gets or sets a global boolean to turn on and off all the counters
  33267. */
  33268. static Enabled: boolean;
  33269. /**
  33270. * Returns the smallest value ever
  33271. */
  33272. readonly min: number;
  33273. /**
  33274. * Returns the biggest value ever
  33275. */
  33276. readonly max: number;
  33277. /**
  33278. * Returns the average value since the performance counter is running
  33279. */
  33280. readonly average: number;
  33281. /**
  33282. * Returns the average value of the last second the counter was monitored
  33283. */
  33284. readonly lastSecAverage: number;
  33285. /**
  33286. * Returns the current value
  33287. */
  33288. readonly current: number;
  33289. /**
  33290. * Gets the accumulated total
  33291. */
  33292. readonly total: number;
  33293. /**
  33294. * Gets the total value count
  33295. */
  33296. readonly count: number;
  33297. /**
  33298. * Creates a new counter
  33299. */
  33300. constructor();
  33301. /**
  33302. * Call this method to start monitoring a new frame.
  33303. * 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.
  33304. */
  33305. fetchNewFrame(): void;
  33306. /**
  33307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33308. * @param newCount the count value to add to the monitored count
  33309. * @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.
  33310. */
  33311. addCount(newCount: number, fetchResult: boolean): void;
  33312. /**
  33313. * Start monitoring this performance counter
  33314. */
  33315. beginMonitoring(): void;
  33316. /**
  33317. * Compute the time lapsed since the previous beginMonitoring() call.
  33318. * @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
  33319. */
  33320. endMonitoring(newFrame?: boolean): void;
  33321. private _fetchResult;
  33322. private _startMonitoringTime;
  33323. private _min;
  33324. private _max;
  33325. private _average;
  33326. private _current;
  33327. private _totalValueCount;
  33328. private _totalAccumulated;
  33329. private _lastSecAverage;
  33330. private _lastSecAccumulated;
  33331. private _lastSecTime;
  33332. private _lastSecValueCount;
  33333. }
  33334. }
  33335. declare module "babylonjs/Engines/engine" {
  33336. import { Observable } from "babylonjs/Misc/observable";
  33337. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33338. import { Scene } from "babylonjs/scene";
  33339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33340. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33342. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33343. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33344. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33345. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33346. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33347. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33349. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33350. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33351. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33352. import { Material } from "babylonjs/Materials/material";
  33353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33354. /**
  33355. * Defines the interface used by display changed events
  33356. */
  33357. export interface IDisplayChangedEventArgs {
  33358. /** Gets the vrDisplay object (if any) */
  33359. vrDisplay: Nullable<any>;
  33360. /** Gets a boolean indicating if webVR is supported */
  33361. vrSupported: boolean;
  33362. }
  33363. /**
  33364. * Defines the interface used by objects containing a viewport (like a camera)
  33365. */
  33366. interface IViewportOwnerLike {
  33367. /**
  33368. * Gets or sets the viewport
  33369. */
  33370. viewport: IViewportLike;
  33371. }
  33372. /**
  33373. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33374. */
  33375. export class Engine extends ThinEngine {
  33376. /** Defines that alpha blending is disabled */
  33377. static readonly ALPHA_DISABLE: number;
  33378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33379. static readonly ALPHA_ADD: number;
  33380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33381. static readonly ALPHA_COMBINE: number;
  33382. /** Defines that alpha blending to DEST - SRC * DEST */
  33383. static readonly ALPHA_SUBTRACT: number;
  33384. /** Defines that alpha blending to SRC * DEST */
  33385. static readonly ALPHA_MULTIPLY: number;
  33386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33387. static readonly ALPHA_MAXIMIZED: number;
  33388. /** Defines that alpha blending to SRC + DEST */
  33389. static readonly ALPHA_ONEONE: number;
  33390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33391. static readonly ALPHA_PREMULTIPLIED: number;
  33392. /**
  33393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33395. */
  33396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33398. static readonly ALPHA_INTERPOLATE: number;
  33399. /**
  33400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33402. */
  33403. static readonly ALPHA_SCREENMODE: number;
  33404. /** Defines that the ressource is not delayed*/
  33405. static readonly DELAYLOADSTATE_NONE: number;
  33406. /** Defines that the ressource was successfully delay loaded */
  33407. static readonly DELAYLOADSTATE_LOADED: number;
  33408. /** Defines that the ressource is currently delay loading */
  33409. static readonly DELAYLOADSTATE_LOADING: number;
  33410. /** Defines that the ressource is delayed and has not started loading */
  33411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33413. static readonly NEVER: number;
  33414. /** 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 */
  33415. static readonly ALWAYS: number;
  33416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33417. static readonly LESS: number;
  33418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33419. static readonly EQUAL: number;
  33420. /** 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 */
  33421. static readonly LEQUAL: number;
  33422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33423. static readonly GREATER: number;
  33424. /** 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 */
  33425. static readonly GEQUAL: number;
  33426. /** 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 */
  33427. static readonly NOTEQUAL: number;
  33428. /** Passed to stencilOperation to specify that stencil value must be kept */
  33429. static readonly KEEP: number;
  33430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33431. static readonly REPLACE: number;
  33432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33433. static readonly INCR: number;
  33434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33435. static readonly DECR: number;
  33436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33437. static readonly INVERT: number;
  33438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33439. static readonly INCR_WRAP: number;
  33440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33441. static readonly DECR_WRAP: number;
  33442. /** Texture is not repeating outside of 0..1 UVs */
  33443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33444. /** Texture is repeating outside of 0..1 UVs */
  33445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33446. /** Texture is repeating and mirrored */
  33447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33448. /** ALPHA */
  33449. static readonly TEXTUREFORMAT_ALPHA: number;
  33450. /** LUMINANCE */
  33451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33452. /** LUMINANCE_ALPHA */
  33453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33454. /** RGB */
  33455. static readonly TEXTUREFORMAT_RGB: number;
  33456. /** RGBA */
  33457. static readonly TEXTUREFORMAT_RGBA: number;
  33458. /** RED */
  33459. static readonly TEXTUREFORMAT_RED: number;
  33460. /** RED (2nd reference) */
  33461. static readonly TEXTUREFORMAT_R: number;
  33462. /** RG */
  33463. static readonly TEXTUREFORMAT_RG: number;
  33464. /** RED_INTEGER */
  33465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33466. /** RED_INTEGER (2nd reference) */
  33467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33468. /** RG_INTEGER */
  33469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33470. /** RGB_INTEGER */
  33471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33472. /** RGBA_INTEGER */
  33473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33474. /** UNSIGNED_BYTE */
  33475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33476. /** UNSIGNED_BYTE (2nd reference) */
  33477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33478. /** FLOAT */
  33479. static readonly TEXTURETYPE_FLOAT: number;
  33480. /** HALF_FLOAT */
  33481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33482. /** BYTE */
  33483. static readonly TEXTURETYPE_BYTE: number;
  33484. /** SHORT */
  33485. static readonly TEXTURETYPE_SHORT: number;
  33486. /** UNSIGNED_SHORT */
  33487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33488. /** INT */
  33489. static readonly TEXTURETYPE_INT: number;
  33490. /** UNSIGNED_INT */
  33491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33492. /** UNSIGNED_SHORT_4_4_4_4 */
  33493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33494. /** UNSIGNED_SHORT_5_5_5_1 */
  33495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33496. /** UNSIGNED_SHORT_5_6_5 */
  33497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33498. /** UNSIGNED_INT_2_10_10_10_REV */
  33499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33500. /** UNSIGNED_INT_24_8 */
  33501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33502. /** UNSIGNED_INT_10F_11F_11F_REV */
  33503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33504. /** UNSIGNED_INT_5_9_9_9_REV */
  33505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33508. /** nearest is mag = nearest and min = nearest and mip = linear */
  33509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33512. /** Trilinear is mag = linear and min = linear and mip = linear */
  33513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33514. /** nearest is mag = nearest and min = nearest and mip = linear */
  33515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33518. /** Trilinear is mag = linear and min = linear and mip = linear */
  33519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33520. /** mag = nearest and min = nearest and mip = nearest */
  33521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33522. /** mag = nearest and min = linear and mip = nearest */
  33523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33524. /** mag = nearest and min = linear and mip = linear */
  33525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33526. /** mag = nearest and min = linear and mip = none */
  33527. static readonly TEXTURE_NEAREST_LINEAR: number;
  33528. /** mag = nearest and min = nearest and mip = none */
  33529. static readonly TEXTURE_NEAREST_NEAREST: number;
  33530. /** mag = linear and min = nearest and mip = nearest */
  33531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33532. /** mag = linear and min = nearest and mip = linear */
  33533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33534. /** mag = linear and min = linear and mip = none */
  33535. static readonly TEXTURE_LINEAR_LINEAR: number;
  33536. /** mag = linear and min = nearest and mip = none */
  33537. static readonly TEXTURE_LINEAR_NEAREST: number;
  33538. /** Explicit coordinates mode */
  33539. static readonly TEXTURE_EXPLICIT_MODE: number;
  33540. /** Spherical coordinates mode */
  33541. static readonly TEXTURE_SPHERICAL_MODE: number;
  33542. /** Planar coordinates mode */
  33543. static readonly TEXTURE_PLANAR_MODE: number;
  33544. /** Cubic coordinates mode */
  33545. static readonly TEXTURE_CUBIC_MODE: number;
  33546. /** Projection coordinates mode */
  33547. static readonly TEXTURE_PROJECTION_MODE: number;
  33548. /** Skybox coordinates mode */
  33549. static readonly TEXTURE_SKYBOX_MODE: number;
  33550. /** Inverse Cubic coordinates mode */
  33551. static readonly TEXTURE_INVCUBIC_MODE: number;
  33552. /** Equirectangular coordinates mode */
  33553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33554. /** Equirectangular Fixed coordinates mode */
  33555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33556. /** Equirectangular Fixed Mirrored coordinates mode */
  33557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33559. static readonly SCALEMODE_FLOOR: number;
  33560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33561. static readonly SCALEMODE_NEAREST: number;
  33562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33563. static readonly SCALEMODE_CEILING: number;
  33564. /**
  33565. * Returns the current npm package of the sdk
  33566. */
  33567. static readonly NpmPackage: string;
  33568. /**
  33569. * Returns the current version of the framework
  33570. */
  33571. static readonly Version: string;
  33572. /** Gets the list of created engines */
  33573. static readonly Instances: Engine[];
  33574. /**
  33575. * Gets the latest created engine
  33576. */
  33577. static readonly LastCreatedEngine: Nullable<Engine>;
  33578. /**
  33579. * Gets the latest created scene
  33580. */
  33581. static readonly LastCreatedScene: Nullable<Scene>;
  33582. /**
  33583. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33584. * @param flag defines which part of the materials must be marked as dirty
  33585. * @param predicate defines a predicate used to filter which materials should be affected
  33586. */
  33587. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33588. /**
  33589. * Method called to create the default loading screen.
  33590. * This can be overriden in your own app.
  33591. * @param canvas The rendering canvas element
  33592. * @returns The loading screen
  33593. */
  33594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33595. /**
  33596. * Method called to create the default rescale post process on each engine.
  33597. */
  33598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33599. /**
  33600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33601. **/
  33602. enableOfflineSupport: boolean;
  33603. /**
  33604. * 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)
  33605. **/
  33606. disableManifestCheck: boolean;
  33607. /**
  33608. * Gets the list of created scenes
  33609. */
  33610. scenes: Scene[];
  33611. /**
  33612. * Event raised when a new scene is created
  33613. */
  33614. onNewSceneAddedObservable: Observable<Scene>;
  33615. /**
  33616. * Gets the list of created postprocesses
  33617. */
  33618. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33619. /**
  33620. * Gets a boolean indicating if the pointer is currently locked
  33621. */
  33622. isPointerLock: boolean;
  33623. /**
  33624. * Observable event triggered each time the rendering canvas is resized
  33625. */
  33626. onResizeObservable: Observable<Engine>;
  33627. /**
  33628. * Observable event triggered each time the canvas loses focus
  33629. */
  33630. onCanvasBlurObservable: Observable<Engine>;
  33631. /**
  33632. * Observable event triggered each time the canvas gains focus
  33633. */
  33634. onCanvasFocusObservable: Observable<Engine>;
  33635. /**
  33636. * Observable event triggered each time the canvas receives pointerout event
  33637. */
  33638. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33639. /**
  33640. * Observable raised when the engine begins a new frame
  33641. */
  33642. onBeginFrameObservable: Observable<Engine>;
  33643. /**
  33644. * If set, will be used to request the next animation frame for the render loop
  33645. */
  33646. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33647. /**
  33648. * Observable raised when the engine ends the current frame
  33649. */
  33650. onEndFrameObservable: Observable<Engine>;
  33651. /**
  33652. * Observable raised when the engine is about to compile a shader
  33653. */
  33654. onBeforeShaderCompilationObservable: Observable<Engine>;
  33655. /**
  33656. * Observable raised when the engine has jsut compiled a shader
  33657. */
  33658. onAfterShaderCompilationObservable: Observable<Engine>;
  33659. /**
  33660. * Gets the audio engine
  33661. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33662. * @ignorenaming
  33663. */
  33664. static audioEngine: IAudioEngine;
  33665. /**
  33666. * Default AudioEngine factory responsible of creating the Audio Engine.
  33667. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33668. */
  33669. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33670. /**
  33671. * Default offline support factory responsible of creating a tool used to store data locally.
  33672. * By default, this will create a Database object if the workload has been embedded.
  33673. */
  33674. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33675. private _loadingScreen;
  33676. private _pointerLockRequested;
  33677. private _dummyFramebuffer;
  33678. private _rescalePostProcess;
  33679. /** @hidden */
  33680. protected _alphaMode: number;
  33681. /** @hidden */
  33682. protected _alphaEquation: number;
  33683. private _deterministicLockstep;
  33684. private _lockstepMaxSteps;
  33685. private _timeStep;
  33686. protected readonly _supportsHardwareTextureRescaling: boolean;
  33687. private _fps;
  33688. private _deltaTime;
  33689. /** @hidden */
  33690. _drawCalls: PerfCounter;
  33691. /**
  33692. * Turn this value on if you want to pause FPS computation when in background
  33693. */
  33694. disablePerformanceMonitorInBackground: boolean;
  33695. private _performanceMonitor;
  33696. /**
  33697. * Gets the performance monitor attached to this engine
  33698. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33699. */
  33700. readonly performanceMonitor: PerformanceMonitor;
  33701. private _onFocus;
  33702. private _onBlur;
  33703. private _onCanvasPointerOut;
  33704. private _onCanvasBlur;
  33705. private _onCanvasFocus;
  33706. private _onFullscreenChange;
  33707. private _onPointerLockChange;
  33708. /**
  33709. * Gets the HTML element used to attach event listeners
  33710. * @returns a HTML element
  33711. */
  33712. getInputElement(): Nullable<HTMLElement>;
  33713. /**
  33714. * Creates a new engine
  33715. * @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
  33716. * @param antialias defines enable antialiasing (default: false)
  33717. * @param options defines further options to be sent to the getContext() function
  33718. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33719. */
  33720. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33721. /**
  33722. * Gets current aspect ratio
  33723. * @param viewportOwner defines the camera to use to get the aspect ratio
  33724. * @param useScreen defines if screen size must be used (or the current render target if any)
  33725. * @returns a number defining the aspect ratio
  33726. */
  33727. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33728. /**
  33729. * Gets current screen aspect ratio
  33730. * @returns a number defining the aspect ratio
  33731. */
  33732. getScreenAspectRatio(): number;
  33733. /**
  33734. * Gets the client rect of the HTML canvas attached with the current webGL context
  33735. * @returns a client rectanglee
  33736. */
  33737. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33738. /**
  33739. * Gets the client rect of the HTML element used for events
  33740. * @returns a client rectanglee
  33741. */
  33742. getInputElementClientRect(): Nullable<ClientRect>;
  33743. /**
  33744. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33746. * @returns true if engine is in deterministic lock step mode
  33747. */
  33748. isDeterministicLockStep(): boolean;
  33749. /**
  33750. * Gets the max steps when engine is running in deterministic lock step
  33751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33752. * @returns the max steps
  33753. */
  33754. getLockstepMaxSteps(): number;
  33755. /**
  33756. * Returns the time in ms between steps when using deterministic lock step.
  33757. * @returns time step in (ms)
  33758. */
  33759. getTimeStep(): number;
  33760. /**
  33761. * Force the mipmap generation for the given render target texture
  33762. * @param texture defines the render target texture to use
  33763. */
  33764. generateMipMapsForCubemap(texture: InternalTexture): void;
  33765. /** States */
  33766. /**
  33767. * Set various states to the webGL context
  33768. * @param culling defines backface culling state
  33769. * @param zOffset defines the value to apply to zOffset (0 by default)
  33770. * @param force defines if states must be applied even if cache is up to date
  33771. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33772. */
  33773. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33774. /**
  33775. * Set the z offset to apply to current rendering
  33776. * @param value defines the offset to apply
  33777. */
  33778. setZOffset(value: number): void;
  33779. /**
  33780. * Gets the current value of the zOffset
  33781. * @returns the current zOffset state
  33782. */
  33783. getZOffset(): number;
  33784. /**
  33785. * Enable or disable depth buffering
  33786. * @param enable defines the state to set
  33787. */
  33788. setDepthBuffer(enable: boolean): void;
  33789. /**
  33790. * Gets a boolean indicating if depth writing is enabled
  33791. * @returns the current depth writing state
  33792. */
  33793. getDepthWrite(): boolean;
  33794. /**
  33795. * Enable or disable depth writing
  33796. * @param enable defines the state to set
  33797. */
  33798. setDepthWrite(enable: boolean): void;
  33799. /**
  33800. * Enable or disable color writing
  33801. * @param enable defines the state to set
  33802. */
  33803. setColorWrite(enable: boolean): void;
  33804. /**
  33805. * Gets a boolean indicating if color writing is enabled
  33806. * @returns the current color writing state
  33807. */
  33808. getColorWrite(): boolean;
  33809. /**
  33810. * Sets alpha constants used by some alpha blending modes
  33811. * @param r defines the red component
  33812. * @param g defines the green component
  33813. * @param b defines the blue component
  33814. * @param a defines the alpha component
  33815. */
  33816. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33817. /**
  33818. * Sets the current alpha mode
  33819. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33820. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33822. */
  33823. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33824. /**
  33825. * Gets the current alpha mode
  33826. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33827. * @returns the current alpha mode
  33828. */
  33829. getAlphaMode(): number;
  33830. /**
  33831. * Sets the current alpha equation
  33832. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33833. */
  33834. setAlphaEquation(equation: number): void;
  33835. /**
  33836. * Gets the current alpha equation.
  33837. * @returns the current alpha equation
  33838. */
  33839. getAlphaEquation(): number;
  33840. /**
  33841. * Gets a boolean indicating if stencil buffer is enabled
  33842. * @returns the current stencil buffer state
  33843. */
  33844. getStencilBuffer(): boolean;
  33845. /**
  33846. * Enable or disable the stencil buffer
  33847. * @param enable defines if the stencil buffer must be enabled or disabled
  33848. */
  33849. setStencilBuffer(enable: boolean): void;
  33850. /**
  33851. * Gets the current stencil mask
  33852. * @returns a number defining the new stencil mask to use
  33853. */
  33854. getStencilMask(): number;
  33855. /**
  33856. * Sets the current stencil mask
  33857. * @param mask defines the new stencil mask to use
  33858. */
  33859. setStencilMask(mask: number): void;
  33860. /**
  33861. * Gets the current stencil function
  33862. * @returns a number defining the stencil function to use
  33863. */
  33864. getStencilFunction(): number;
  33865. /**
  33866. * Gets the current stencil reference value
  33867. * @returns a number defining the stencil reference value to use
  33868. */
  33869. getStencilFunctionReference(): number;
  33870. /**
  33871. * Gets the current stencil mask
  33872. * @returns a number defining the stencil mask to use
  33873. */
  33874. getStencilFunctionMask(): number;
  33875. /**
  33876. * Sets the current stencil function
  33877. * @param stencilFunc defines the new stencil function to use
  33878. */
  33879. setStencilFunction(stencilFunc: number): void;
  33880. /**
  33881. * Sets the current stencil reference
  33882. * @param reference defines the new stencil reference to use
  33883. */
  33884. setStencilFunctionReference(reference: number): void;
  33885. /**
  33886. * Sets the current stencil mask
  33887. * @param mask defines the new stencil mask to use
  33888. */
  33889. setStencilFunctionMask(mask: number): void;
  33890. /**
  33891. * Gets the current stencil operation when stencil fails
  33892. * @returns a number defining stencil operation to use when stencil fails
  33893. */
  33894. getStencilOperationFail(): number;
  33895. /**
  33896. * Gets the current stencil operation when depth fails
  33897. * @returns a number defining stencil operation to use when depth fails
  33898. */
  33899. getStencilOperationDepthFail(): number;
  33900. /**
  33901. * Gets the current stencil operation when stencil passes
  33902. * @returns a number defining stencil operation to use when stencil passes
  33903. */
  33904. getStencilOperationPass(): number;
  33905. /**
  33906. * Sets the stencil operation to use when stencil fails
  33907. * @param operation defines the stencil operation to use when stencil fails
  33908. */
  33909. setStencilOperationFail(operation: number): void;
  33910. /**
  33911. * Sets the stencil operation to use when depth fails
  33912. * @param operation defines the stencil operation to use when depth fails
  33913. */
  33914. setStencilOperationDepthFail(operation: number): void;
  33915. /**
  33916. * Sets the stencil operation to use when stencil passes
  33917. * @param operation defines the stencil operation to use when stencil passes
  33918. */
  33919. setStencilOperationPass(operation: number): void;
  33920. /**
  33921. * Sets a boolean indicating if the dithering state is enabled or disabled
  33922. * @param value defines the dithering state
  33923. */
  33924. setDitheringState(value: boolean): void;
  33925. /**
  33926. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33927. * @param value defines the rasterizer state
  33928. */
  33929. setRasterizerState(value: boolean): void;
  33930. /**
  33931. * Gets the current depth function
  33932. * @returns a number defining the depth function
  33933. */
  33934. getDepthFunction(): Nullable<number>;
  33935. /**
  33936. * Sets the current depth function
  33937. * @param depthFunc defines the function to use
  33938. */
  33939. setDepthFunction(depthFunc: number): void;
  33940. /**
  33941. * Sets the current depth function to GREATER
  33942. */
  33943. setDepthFunctionToGreater(): void;
  33944. /**
  33945. * Sets the current depth function to GEQUAL
  33946. */
  33947. setDepthFunctionToGreaterOrEqual(): void;
  33948. /**
  33949. * Sets the current depth function to LESS
  33950. */
  33951. setDepthFunctionToLess(): void;
  33952. /**
  33953. * Sets the current depth function to LEQUAL
  33954. */
  33955. setDepthFunctionToLessOrEqual(): void;
  33956. private _cachedStencilBuffer;
  33957. private _cachedStencilFunction;
  33958. private _cachedStencilMask;
  33959. private _cachedStencilOperationPass;
  33960. private _cachedStencilOperationFail;
  33961. private _cachedStencilOperationDepthFail;
  33962. private _cachedStencilReference;
  33963. /**
  33964. * Caches the the state of the stencil buffer
  33965. */
  33966. cacheStencilState(): void;
  33967. /**
  33968. * Restores the state of the stencil buffer
  33969. */
  33970. restoreStencilState(): void;
  33971. /**
  33972. * Directly set the WebGL Viewport
  33973. * @param x defines the x coordinate of the viewport (in screen space)
  33974. * @param y defines the y coordinate of the viewport (in screen space)
  33975. * @param width defines the width of the viewport (in screen space)
  33976. * @param height defines the height of the viewport (in screen space)
  33977. * @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
  33978. */
  33979. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33980. /**
  33981. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33982. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33983. * @param y defines the y-coordinate of the corner of the clear rectangle
  33984. * @param width defines the width of the clear rectangle
  33985. * @param height defines the height of the clear rectangle
  33986. * @param clearColor defines the clear color
  33987. */
  33988. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33989. /**
  33990. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33991. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33992. * @param y defines the y-coordinate of the corner of the clear rectangle
  33993. * @param width defines the width of the clear rectangle
  33994. * @param height defines the height of the clear rectangle
  33995. */
  33996. enableScissor(x: number, y: number, width: number, height: number): void;
  33997. /**
  33998. * Disable previously set scissor test rectangle
  33999. */
  34000. disableScissor(): void;
  34001. protected _reportDrawCall(): void;
  34002. /**
  34003. * Initializes a webVR display and starts listening to display change events
  34004. * The onVRDisplayChangedObservable will be notified upon these changes
  34005. * @returns The onVRDisplayChangedObservable
  34006. */
  34007. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34008. /** @hidden */
  34009. _prepareVRComponent(): void;
  34010. /** @hidden */
  34011. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34012. /** @hidden */
  34013. _submitVRFrame(): void;
  34014. /**
  34015. * Call this function to leave webVR mode
  34016. * Will do nothing if webVR is not supported or if there is no webVR device
  34017. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34018. */
  34019. disableVR(): void;
  34020. /**
  34021. * Gets a boolean indicating that the system is in VR mode and is presenting
  34022. * @returns true if VR mode is engaged
  34023. */
  34024. isVRPresenting(): boolean;
  34025. /** @hidden */
  34026. _requestVRFrame(): void;
  34027. /** @hidden */
  34028. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34029. /**
  34030. * Gets the source code of the vertex shader associated with a specific webGL program
  34031. * @param program defines the program to use
  34032. * @returns a string containing the source code of the vertex shader associated with the program
  34033. */
  34034. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34035. /**
  34036. * Gets the source code of the fragment shader associated with a specific webGL program
  34037. * @param program defines the program to use
  34038. * @returns a string containing the source code of the fragment shader associated with the program
  34039. */
  34040. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34041. /**
  34042. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34043. * @param x defines the x coordinate of the rectangle where pixels must be read
  34044. * @param y defines the y coordinate of the rectangle where pixels must be read
  34045. * @param width defines the width of the rectangle where pixels must be read
  34046. * @param height defines the height of the rectangle where pixels must be read
  34047. * @returns a Uint8Array containing RGBA colors
  34048. */
  34049. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34050. /**
  34051. * Sets a depth stencil texture from a render target to the according uniform.
  34052. * @param channel The texture channel
  34053. * @param uniform The uniform to set
  34054. * @param texture The render target texture containing the depth stencil texture to apply
  34055. */
  34056. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34057. /**
  34058. * Sets a texture to the webGL context from a postprocess
  34059. * @param channel defines the channel to use
  34060. * @param postProcess defines the source postprocess
  34061. */
  34062. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34063. /**
  34064. * Binds the output of the passed in post process to the texture channel specified
  34065. * @param channel The channel the texture should be bound to
  34066. * @param postProcess The post process which's output should be bound
  34067. */
  34068. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34069. /** @hidden */
  34070. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34071. protected _rebuildBuffers(): void;
  34072. /** @hidden */
  34073. _renderFrame(): void;
  34074. _renderLoop(): void;
  34075. /** @hidden */
  34076. _renderViews(): boolean;
  34077. /**
  34078. * Toggle full screen mode
  34079. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34080. */
  34081. switchFullscreen(requestPointerLock: boolean): void;
  34082. /**
  34083. * Enters full screen mode
  34084. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34085. */
  34086. enterFullscreen(requestPointerLock: boolean): void;
  34087. /**
  34088. * Exits full screen mode
  34089. */
  34090. exitFullscreen(): void;
  34091. /**
  34092. * Enters Pointerlock mode
  34093. */
  34094. enterPointerlock(): void;
  34095. /**
  34096. * Exits Pointerlock mode
  34097. */
  34098. exitPointerlock(): void;
  34099. /**
  34100. * Begin a new frame
  34101. */
  34102. beginFrame(): void;
  34103. /**
  34104. * Enf the current frame
  34105. */
  34106. endFrame(): void;
  34107. resize(): void;
  34108. /**
  34109. * Set the compressed texture format to use, based on the formats you have, and the formats
  34110. * supported by the hardware / browser.
  34111. *
  34112. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34113. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34114. * to API arguments needed to compressed textures. This puts the burden on the container
  34115. * generator to house the arcane code for determining these for current & future formats.
  34116. *
  34117. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34118. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34119. *
  34120. * Note: The result of this call is not taken into account when a texture is base64.
  34121. *
  34122. * @param formatsAvailable defines the list of those format families you have created
  34123. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34124. *
  34125. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34126. * @returns The extension selected.
  34127. */
  34128. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34129. /**
  34130. * Set the compressed texture extensions or file names to skip.
  34131. *
  34132. * @param skippedFiles defines the list of those texture files you want to skip
  34133. * Example: [".dds", ".env", "myfile.png"]
  34134. */
  34135. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34136. /**
  34137. * Force a specific size of the canvas
  34138. * @param width defines the new canvas' width
  34139. * @param height defines the new canvas' height
  34140. */
  34141. setSize(width: number, height: number): void;
  34142. /**
  34143. * Updates a dynamic vertex buffer.
  34144. * @param vertexBuffer the vertex buffer to update
  34145. * @param data the data used to update the vertex buffer
  34146. * @param byteOffset the byte offset of the data
  34147. * @param byteLength the byte length of the data
  34148. */
  34149. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34150. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34151. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34152. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34153. _releaseTexture(texture: InternalTexture): void;
  34154. /**
  34155. * @hidden
  34156. * Rescales a texture
  34157. * @param source input texutre
  34158. * @param destination destination texture
  34159. * @param scene scene to use to render the resize
  34160. * @param internalFormat format to use when resizing
  34161. * @param onComplete callback to be called when resize has completed
  34162. */
  34163. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34164. /**
  34165. * Gets the current framerate
  34166. * @returns a number representing the framerate
  34167. */
  34168. getFps(): number;
  34169. /**
  34170. * Gets the time spent between current and previous frame
  34171. * @returns a number representing the delta time in ms
  34172. */
  34173. getDeltaTime(): number;
  34174. private _measureFps;
  34175. /** @hidden */
  34176. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34177. /**
  34178. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34179. * @param renderTarget The render target to set the frame buffer for
  34180. */
  34181. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34182. /**
  34183. * Update a dynamic index buffer
  34184. * @param indexBuffer defines the target index buffer
  34185. * @param indices defines the data to update
  34186. * @param offset defines the offset in the target index buffer where update should start
  34187. */
  34188. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34189. /**
  34190. * Updates the sample count of a render target texture
  34191. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34192. * @param texture defines the texture to update
  34193. * @param samples defines the sample count to set
  34194. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34195. */
  34196. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34197. /**
  34198. * Updates a depth texture Comparison Mode and Function.
  34199. * If the comparison Function is equal to 0, the mode will be set to none.
  34200. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34201. * @param texture The texture to set the comparison function for
  34202. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34203. */
  34204. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34205. /**
  34206. * Creates a webGL buffer to use with instanciation
  34207. * @param capacity defines the size of the buffer
  34208. * @returns the webGL buffer
  34209. */
  34210. createInstancesBuffer(capacity: number): DataBuffer;
  34211. /**
  34212. * Delete a webGL buffer used with instanciation
  34213. * @param buffer defines the webGL buffer to delete
  34214. */
  34215. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34216. /** @hidden */
  34217. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34218. dispose(): void;
  34219. private _disableTouchAction;
  34220. /**
  34221. * Display the loading screen
  34222. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34223. */
  34224. displayLoadingUI(): void;
  34225. /**
  34226. * Hide the loading screen
  34227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34228. */
  34229. hideLoadingUI(): void;
  34230. /**
  34231. * Gets the current loading screen object
  34232. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34233. */
  34234. /**
  34235. * Sets the current loading screen object
  34236. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34237. */
  34238. loadingScreen: ILoadingScreen;
  34239. /**
  34240. * Sets the current loading screen text
  34241. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34242. */
  34243. loadingUIText: string;
  34244. /**
  34245. * Sets the current loading screen background color
  34246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34247. */
  34248. loadingUIBackgroundColor: string;
  34249. /** Pointerlock and fullscreen */
  34250. /**
  34251. * Ask the browser to promote the current element to pointerlock mode
  34252. * @param element defines the DOM element to promote
  34253. */
  34254. static _RequestPointerlock(element: HTMLElement): void;
  34255. /**
  34256. * Asks the browser to exit pointerlock mode
  34257. */
  34258. static _ExitPointerlock(): void;
  34259. /**
  34260. * Ask the browser to promote the current element to fullscreen rendering mode
  34261. * @param element defines the DOM element to promote
  34262. */
  34263. static _RequestFullscreen(element: HTMLElement): void;
  34264. /**
  34265. * Asks the browser to exit fullscreen mode
  34266. */
  34267. static _ExitFullscreen(): void;
  34268. }
  34269. }
  34270. declare module "babylonjs/Engines/engineStore" {
  34271. import { Nullable } from "babylonjs/types";
  34272. import { Engine } from "babylonjs/Engines/engine";
  34273. import { Scene } from "babylonjs/scene";
  34274. /**
  34275. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34276. * during the life time of the application.
  34277. */
  34278. export class EngineStore {
  34279. /** Gets the list of created engines */
  34280. static Instances: import("babylonjs/Engines/engine").Engine[];
  34281. /** @hidden */
  34282. static _LastCreatedScene: Nullable<Scene>;
  34283. /**
  34284. * Gets the latest created engine
  34285. */
  34286. static readonly LastCreatedEngine: Nullable<Engine>;
  34287. /**
  34288. * Gets the latest created scene
  34289. */
  34290. static readonly LastCreatedScene: Nullable<Scene>;
  34291. /**
  34292. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34293. * @ignorenaming
  34294. */
  34295. static UseFallbackTexture: boolean;
  34296. /**
  34297. * Texture content used if a texture cannot loaded
  34298. * @ignorenaming
  34299. */
  34300. static FallbackTexture: string;
  34301. }
  34302. }
  34303. declare module "babylonjs/Misc/promise" {
  34304. /**
  34305. * Helper class that provides a small promise polyfill
  34306. */
  34307. export class PromisePolyfill {
  34308. /**
  34309. * Static function used to check if the polyfill is required
  34310. * If this is the case then the function will inject the polyfill to window.Promise
  34311. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34312. */
  34313. static Apply(force?: boolean): void;
  34314. }
  34315. }
  34316. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34317. /**
  34318. * Interface for screenshot methods with describe argument called `size` as object with options
  34319. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34320. */
  34321. export interface IScreenshotSize {
  34322. /**
  34323. * number in pixels for canvas height
  34324. */
  34325. height?: number;
  34326. /**
  34327. * multiplier allowing render at a higher or lower resolution
  34328. * If value is defined then height and width will be ignored and taken from camera
  34329. */
  34330. precision?: number;
  34331. /**
  34332. * number in pixels for canvas width
  34333. */
  34334. width?: number;
  34335. }
  34336. }
  34337. declare module "babylonjs/Misc/tools" {
  34338. import { Nullable, float } from "babylonjs/types";
  34339. import { DomManagement } from "babylonjs/Misc/domManagement";
  34340. import { WebRequest } from "babylonjs/Misc/webRequest";
  34341. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34342. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34344. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34345. import { Camera } from "babylonjs/Cameras/camera";
  34346. import { Engine } from "babylonjs/Engines/engine";
  34347. interface IColor4Like {
  34348. r: float;
  34349. g: float;
  34350. b: float;
  34351. a: float;
  34352. }
  34353. /**
  34354. * Class containing a set of static utilities functions
  34355. */
  34356. export class Tools {
  34357. /**
  34358. * Gets or sets the base URL to use to load assets
  34359. */
  34360. static BaseUrl: string;
  34361. /**
  34362. * Enable/Disable Custom HTTP Request Headers globally.
  34363. * default = false
  34364. * @see CustomRequestHeaders
  34365. */
  34366. static UseCustomRequestHeaders: boolean;
  34367. /**
  34368. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34369. * i.e. when loading files, where the server/service expects an Authorization header
  34370. */
  34371. static CustomRequestHeaders: {
  34372. [key: string]: string;
  34373. };
  34374. /**
  34375. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34376. */
  34377. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34378. /**
  34379. * Default behaviour for cors in the application.
  34380. * It can be a string if the expected behavior is identical in the entire app.
  34381. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34382. */
  34383. static CorsBehavior: string | ((url: string | string[]) => string);
  34384. /**
  34385. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34386. * @ignorenaming
  34387. */
  34388. static UseFallbackTexture: boolean;
  34389. /**
  34390. * Use this object to register external classes like custom textures or material
  34391. * to allow the laoders to instantiate them
  34392. */
  34393. static RegisteredExternalClasses: {
  34394. [key: string]: Object;
  34395. };
  34396. /**
  34397. * Texture content used if a texture cannot loaded
  34398. * @ignorenaming
  34399. */
  34400. static fallbackTexture: string;
  34401. /**
  34402. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34403. * @param u defines the coordinate on X axis
  34404. * @param v defines the coordinate on Y axis
  34405. * @param width defines the width of the source data
  34406. * @param height defines the height of the source data
  34407. * @param pixels defines the source byte array
  34408. * @param color defines the output color
  34409. */
  34410. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34411. /**
  34412. * Interpolates between a and b via alpha
  34413. * @param a The lower value (returned when alpha = 0)
  34414. * @param b The upper value (returned when alpha = 1)
  34415. * @param alpha The interpolation-factor
  34416. * @return The mixed value
  34417. */
  34418. static Mix(a: number, b: number, alpha: number): number;
  34419. /**
  34420. * Tries to instantiate a new object from a given class name
  34421. * @param className defines the class name to instantiate
  34422. * @returns the new object or null if the system was not able to do the instantiation
  34423. */
  34424. static Instantiate(className: string): any;
  34425. /**
  34426. * Provides a slice function that will work even on IE
  34427. * @param data defines the array to slice
  34428. * @param start defines the start of the data (optional)
  34429. * @param end defines the end of the data (optional)
  34430. * @returns the new sliced array
  34431. */
  34432. static Slice<T>(data: T, start?: number, end?: number): T;
  34433. /**
  34434. * Polyfill for setImmediate
  34435. * @param action defines the action to execute after the current execution block
  34436. */
  34437. static SetImmediate(action: () => void): void;
  34438. /**
  34439. * Function indicating if a number is an exponent of 2
  34440. * @param value defines the value to test
  34441. * @returns true if the value is an exponent of 2
  34442. */
  34443. static IsExponentOfTwo(value: number): boolean;
  34444. private static _tmpFloatArray;
  34445. /**
  34446. * Returns the nearest 32-bit single precision float representation of a Number
  34447. * @param value A Number. If the parameter is of a different type, it will get converted
  34448. * to a number or to NaN if it cannot be converted
  34449. * @returns number
  34450. */
  34451. static FloatRound(value: number): number;
  34452. /**
  34453. * Extracts the filename from a path
  34454. * @param path defines the path to use
  34455. * @returns the filename
  34456. */
  34457. static GetFilename(path: string): string;
  34458. /**
  34459. * Extracts the "folder" part of a path (everything before the filename).
  34460. * @param uri The URI to extract the info from
  34461. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34462. * @returns The "folder" part of the path
  34463. */
  34464. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34465. /**
  34466. * Extracts text content from a DOM element hierarchy
  34467. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34468. */
  34469. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34470. /**
  34471. * Convert an angle in radians to degrees
  34472. * @param angle defines the angle to convert
  34473. * @returns the angle in degrees
  34474. */
  34475. static ToDegrees(angle: number): number;
  34476. /**
  34477. * Convert an angle in degrees to radians
  34478. * @param angle defines the angle to convert
  34479. * @returns the angle in radians
  34480. */
  34481. static ToRadians(angle: number): number;
  34482. /**
  34483. * Returns an array if obj is not an array
  34484. * @param obj defines the object to evaluate as an array
  34485. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34486. * @returns either obj directly if obj is an array or a new array containing obj
  34487. */
  34488. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34489. /**
  34490. * Gets the pointer prefix to use
  34491. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34492. */
  34493. static GetPointerPrefix(): string;
  34494. /**
  34495. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34496. * @param url define the url we are trying
  34497. * @param element define the dom element where to configure the cors policy
  34498. */
  34499. static SetCorsBehavior(url: string | string[], element: {
  34500. crossOrigin: string | null;
  34501. }): void;
  34502. /**
  34503. * Removes unwanted characters from an url
  34504. * @param url defines the url to clean
  34505. * @returns the cleaned url
  34506. */
  34507. static CleanUrl(url: string): string;
  34508. /**
  34509. * Gets or sets a function used to pre-process url before using them to load assets
  34510. */
  34511. static PreprocessUrl: (url: string) => string;
  34512. /**
  34513. * Loads an image as an HTMLImageElement.
  34514. * @param input url string, ArrayBuffer, or Blob to load
  34515. * @param onLoad callback called when the image successfully loads
  34516. * @param onError callback called when the image fails to load
  34517. * @param offlineProvider offline provider for caching
  34518. * @param mimeType optional mime type
  34519. * @returns the HTMLImageElement of the loaded image
  34520. */
  34521. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34522. /**
  34523. * Loads a file from a url
  34524. * @param url url string, ArrayBuffer, or Blob to load
  34525. * @param onSuccess callback called when the file successfully loads
  34526. * @param onProgress callback called while file is loading (if the server supports this mode)
  34527. * @param offlineProvider defines the offline provider for caching
  34528. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34529. * @param onError callback called when the file fails to load
  34530. * @returns a file request object
  34531. */
  34532. 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;
  34533. /**
  34534. * Loads a file from a url
  34535. * @param url the file url to load
  34536. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34537. */
  34538. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34539. /**
  34540. * Load a script (identified by an url). When the url returns, the
  34541. * content of this file is added into a new script element, attached to the DOM (body element)
  34542. * @param scriptUrl defines the url of the script to laod
  34543. * @param onSuccess defines the callback called when the script is loaded
  34544. * @param onError defines the callback to call if an error occurs
  34545. * @param scriptId defines the id of the script element
  34546. */
  34547. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34548. /**
  34549. * Load an asynchronous script (identified by an url). When the url returns, the
  34550. * content of this file is added into a new script element, attached to the DOM (body element)
  34551. * @param scriptUrl defines the url of the script to laod
  34552. * @param scriptId defines the id of the script element
  34553. * @returns a promise request object
  34554. */
  34555. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34556. /**
  34557. * Loads a file from a blob
  34558. * @param fileToLoad defines the blob to use
  34559. * @param callback defines the callback to call when data is loaded
  34560. * @param progressCallback defines the callback to call during loading process
  34561. * @returns a file request object
  34562. */
  34563. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34564. /**
  34565. * Reads a file from a File object
  34566. * @param file defines the file to load
  34567. * @param onSuccess defines the callback to call when data is loaded
  34568. * @param onProgress defines the callback to call during loading process
  34569. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34570. * @param onError defines the callback to call when an error occurs
  34571. * @returns a file request object
  34572. */
  34573. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34574. /**
  34575. * Creates a data url from a given string content
  34576. * @param content defines the content to convert
  34577. * @returns the new data url link
  34578. */
  34579. static FileAsURL(content: string): string;
  34580. /**
  34581. * Format the given number to a specific decimal format
  34582. * @param value defines the number to format
  34583. * @param decimals defines the number of decimals to use
  34584. * @returns the formatted string
  34585. */
  34586. static Format(value: number, decimals?: number): string;
  34587. /**
  34588. * Tries to copy an object by duplicating every property
  34589. * @param source defines the source object
  34590. * @param destination defines the target object
  34591. * @param doNotCopyList defines a list of properties to avoid
  34592. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34593. */
  34594. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34595. /**
  34596. * Gets a boolean indicating if the given object has no own property
  34597. * @param obj defines the object to test
  34598. * @returns true if object has no own property
  34599. */
  34600. static IsEmpty(obj: any): boolean;
  34601. /**
  34602. * Function used to register events at window level
  34603. * @param windowElement defines the Window object to use
  34604. * @param events defines the events to register
  34605. */
  34606. static RegisterTopRootEvents(windowElement: Window, events: {
  34607. name: string;
  34608. handler: Nullable<(e: FocusEvent) => any>;
  34609. }[]): void;
  34610. /**
  34611. * Function used to unregister events from window level
  34612. * @param windowElement defines the Window object to use
  34613. * @param events defines the events to unregister
  34614. */
  34615. static UnregisterTopRootEvents(windowElement: Window, events: {
  34616. name: string;
  34617. handler: Nullable<(e: FocusEvent) => any>;
  34618. }[]): void;
  34619. /**
  34620. * @ignore
  34621. */
  34622. static _ScreenshotCanvas: HTMLCanvasElement;
  34623. /**
  34624. * Dumps the current bound framebuffer
  34625. * @param width defines the rendering width
  34626. * @param height defines the rendering height
  34627. * @param engine defines the hosting engine
  34628. * @param successCallback defines the callback triggered once the data are available
  34629. * @param mimeType defines the mime type of the result
  34630. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34631. */
  34632. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34633. /**
  34634. * Converts the canvas data to blob.
  34635. * This acts as a polyfill for browsers not supporting the to blob function.
  34636. * @param canvas Defines the canvas to extract the data from
  34637. * @param successCallback Defines the callback triggered once the data are available
  34638. * @param mimeType Defines the mime type of the result
  34639. */
  34640. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34641. /**
  34642. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34643. * @param successCallback defines the callback triggered once the data are available
  34644. * @param mimeType defines the mime type of the result
  34645. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34646. */
  34647. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34648. /**
  34649. * Downloads a blob in the browser
  34650. * @param blob defines the blob to download
  34651. * @param fileName defines the name of the downloaded file
  34652. */
  34653. static Download(blob: Blob, fileName: string): void;
  34654. /**
  34655. * Captures a screenshot of the current rendering
  34656. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34657. * @param engine defines the rendering engine
  34658. * @param camera defines the source camera
  34659. * @param size This parameter can be set to a single number or to an object with the
  34660. * following (optional) properties: precision, width, height. If a single number is passed,
  34661. * it will be used for both width and height. If an object is passed, the screenshot size
  34662. * will be derived from the parameters. The precision property is a multiplier allowing
  34663. * rendering at a higher or lower resolution
  34664. * @param successCallback defines the callback receives a single parameter which contains the
  34665. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34666. * src parameter of an <img> to display it
  34667. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34668. * Check your browser for supported MIME types
  34669. */
  34670. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34671. /**
  34672. * Captures a screenshot of the current rendering
  34673. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34674. * @param engine defines the rendering engine
  34675. * @param camera defines the source camera
  34676. * @param size This parameter can be set to a single number or to an object with the
  34677. * following (optional) properties: precision, width, height. If a single number is passed,
  34678. * it will be used for both width and height. If an object is passed, the screenshot size
  34679. * will be derived from the parameters. The precision property is a multiplier allowing
  34680. * rendering at a higher or lower resolution
  34681. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34682. * Check your browser for supported MIME types
  34683. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34684. * to the src parameter of an <img> to display it
  34685. */
  34686. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34687. /**
  34688. * Generates an image screenshot from the specified camera.
  34689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34690. * @param engine The engine to use for rendering
  34691. * @param camera The camera to use for rendering
  34692. * @param size This parameter can be set to a single number or to an object with the
  34693. * following (optional) properties: precision, width, height. If a single number is passed,
  34694. * it will be used for both width and height. If an object is passed, the screenshot size
  34695. * will be derived from the parameters. The precision property is a multiplier allowing
  34696. * rendering at a higher or lower resolution
  34697. * @param successCallback The callback receives a single parameter which contains the
  34698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34699. * src parameter of an <img> to display it
  34700. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34701. * Check your browser for supported MIME types
  34702. * @param samples Texture samples (default: 1)
  34703. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34704. * @param fileName A name for for the downloaded file.
  34705. */
  34706. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34707. /**
  34708. * Generates an image screenshot from the specified camera.
  34709. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34710. * @param engine The engine to use for rendering
  34711. * @param camera The camera to use for rendering
  34712. * @param size This parameter can be set to a single number or to an object with the
  34713. * following (optional) properties: precision, width, height. If a single number is passed,
  34714. * it will be used for both width and height. If an object is passed, the screenshot size
  34715. * will be derived from the parameters. The precision property is a multiplier allowing
  34716. * rendering at a higher or lower resolution
  34717. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34718. * Check your browser for supported MIME types
  34719. * @param samples Texture samples (default: 1)
  34720. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34721. * @param fileName A name for for the downloaded file.
  34722. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34723. * to the src parameter of an <img> to display it
  34724. */
  34725. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34726. /**
  34727. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34728. * Be aware Math.random() could cause collisions, but:
  34729. * "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"
  34730. * @returns a pseudo random id
  34731. */
  34732. static RandomId(): string;
  34733. /**
  34734. * Test if the given uri is a base64 string
  34735. * @param uri The uri to test
  34736. * @return True if the uri is a base64 string or false otherwise
  34737. */
  34738. static IsBase64(uri: string): boolean;
  34739. /**
  34740. * Decode the given base64 uri.
  34741. * @param uri The uri to decode
  34742. * @return The decoded base64 data.
  34743. */
  34744. static DecodeBase64(uri: string): ArrayBuffer;
  34745. /**
  34746. * Gets the absolute url.
  34747. * @param url the input url
  34748. * @return the absolute url
  34749. */
  34750. static GetAbsoluteUrl(url: string): string;
  34751. /**
  34752. * No log
  34753. */
  34754. static readonly NoneLogLevel: number;
  34755. /**
  34756. * Only message logs
  34757. */
  34758. static readonly MessageLogLevel: number;
  34759. /**
  34760. * Only warning logs
  34761. */
  34762. static readonly WarningLogLevel: number;
  34763. /**
  34764. * Only error logs
  34765. */
  34766. static readonly ErrorLogLevel: number;
  34767. /**
  34768. * All logs
  34769. */
  34770. static readonly AllLogLevel: number;
  34771. /**
  34772. * Gets a value indicating the number of loading errors
  34773. * @ignorenaming
  34774. */
  34775. static readonly errorsCount: number;
  34776. /**
  34777. * Callback called when a new log is added
  34778. */
  34779. static OnNewCacheEntry: (entry: string) => void;
  34780. /**
  34781. * Log a message to the console
  34782. * @param message defines the message to log
  34783. */
  34784. static Log(message: string): void;
  34785. /**
  34786. * Write a warning message to the console
  34787. * @param message defines the message to log
  34788. */
  34789. static Warn(message: string): void;
  34790. /**
  34791. * Write an error message to the console
  34792. * @param message defines the message to log
  34793. */
  34794. static Error(message: string): void;
  34795. /**
  34796. * Gets current log cache (list of logs)
  34797. */
  34798. static readonly LogCache: string;
  34799. /**
  34800. * Clears the log cache
  34801. */
  34802. static ClearLogCache(): void;
  34803. /**
  34804. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34805. */
  34806. static LogLevels: number;
  34807. /**
  34808. * Checks if the window object exists
  34809. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34810. */
  34811. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34812. /**
  34813. * No performance log
  34814. */
  34815. static readonly PerformanceNoneLogLevel: number;
  34816. /**
  34817. * Use user marks to log performance
  34818. */
  34819. static readonly PerformanceUserMarkLogLevel: number;
  34820. /**
  34821. * Log performance to the console
  34822. */
  34823. static readonly PerformanceConsoleLogLevel: number;
  34824. private static _performance;
  34825. /**
  34826. * Sets the current performance log level
  34827. */
  34828. static PerformanceLogLevel: number;
  34829. private static _StartPerformanceCounterDisabled;
  34830. private static _EndPerformanceCounterDisabled;
  34831. private static _StartUserMark;
  34832. private static _EndUserMark;
  34833. private static _StartPerformanceConsole;
  34834. private static _EndPerformanceConsole;
  34835. /**
  34836. * Starts a performance counter
  34837. */
  34838. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34839. /**
  34840. * Ends a specific performance coutner
  34841. */
  34842. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34843. /**
  34844. * Gets either window.performance.now() if supported or Date.now() else
  34845. */
  34846. static readonly Now: number;
  34847. /**
  34848. * This method will return the name of the class used to create the instance of the given object.
  34849. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34850. * @param object the object to get the class name from
  34851. * @param isType defines if the object is actually a type
  34852. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34853. */
  34854. static GetClassName(object: any, isType?: boolean): string;
  34855. /**
  34856. * Gets the first element of an array satisfying a given predicate
  34857. * @param array defines the array to browse
  34858. * @param predicate defines the predicate to use
  34859. * @returns null if not found or the element
  34860. */
  34861. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34862. /**
  34863. * This method will return the name of the full name of the class, including its owning module (if any).
  34864. * 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).
  34865. * @param object the object to get the class name from
  34866. * @param isType defines if the object is actually a type
  34867. * @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.
  34868. * @ignorenaming
  34869. */
  34870. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34871. /**
  34872. * Returns a promise that resolves after the given amount of time.
  34873. * @param delay Number of milliseconds to delay
  34874. * @returns Promise that resolves after the given amount of time
  34875. */
  34876. static DelayAsync(delay: number): Promise<void>;
  34877. }
  34878. /**
  34879. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34880. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34881. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34882. * @param name The name of the class, case should be preserved
  34883. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34884. */
  34885. export function className(name: string, module?: string): (target: Object) => void;
  34886. /**
  34887. * An implementation of a loop for asynchronous functions.
  34888. */
  34889. export class AsyncLoop {
  34890. /**
  34891. * Defines the number of iterations for the loop
  34892. */
  34893. iterations: number;
  34894. /**
  34895. * Defines the current index of the loop.
  34896. */
  34897. index: number;
  34898. private _done;
  34899. private _fn;
  34900. private _successCallback;
  34901. /**
  34902. * Constructor.
  34903. * @param iterations the number of iterations.
  34904. * @param func the function to run each iteration
  34905. * @param successCallback the callback that will be called upon succesful execution
  34906. * @param offset starting offset.
  34907. */
  34908. constructor(
  34909. /**
  34910. * Defines the number of iterations for the loop
  34911. */
  34912. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34913. /**
  34914. * Execute the next iteration. Must be called after the last iteration was finished.
  34915. */
  34916. executeNext(): void;
  34917. /**
  34918. * Break the loop and run the success callback.
  34919. */
  34920. breakLoop(): void;
  34921. /**
  34922. * Create and run an async loop.
  34923. * @param iterations the number of iterations.
  34924. * @param fn the function to run each iteration
  34925. * @param successCallback the callback that will be called upon succesful execution
  34926. * @param offset starting offset.
  34927. * @returns the created async loop object
  34928. */
  34929. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34930. /**
  34931. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34932. * @param iterations total number of iterations
  34933. * @param syncedIterations number of synchronous iterations in each async iteration.
  34934. * @param fn the function to call each iteration.
  34935. * @param callback a success call back that will be called when iterating stops.
  34936. * @param breakFunction a break condition (optional)
  34937. * @param timeout timeout settings for the setTimeout function. default - 0.
  34938. * @returns the created async loop object
  34939. */
  34940. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34941. }
  34942. }
  34943. declare module "babylonjs/Misc/stringDictionary" {
  34944. import { Nullable } from "babylonjs/types";
  34945. /**
  34946. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34947. * The underlying implementation relies on an associative array to ensure the best performances.
  34948. * The value can be anything including 'null' but except 'undefined'
  34949. */
  34950. export class StringDictionary<T> {
  34951. /**
  34952. * This will clear this dictionary and copy the content from the 'source' one.
  34953. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34954. * @param source the dictionary to take the content from and copy to this dictionary
  34955. */
  34956. copyFrom(source: StringDictionary<T>): void;
  34957. /**
  34958. * Get a value based from its key
  34959. * @param key the given key to get the matching value from
  34960. * @return the value if found, otherwise undefined is returned
  34961. */
  34962. get(key: string): T | undefined;
  34963. /**
  34964. * Get a value from its key or add it if it doesn't exist.
  34965. * This method will ensure you that a given key/data will be present in the dictionary.
  34966. * @param key the given key to get the matching value from
  34967. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34968. * The factory will only be invoked if there's no data for the given key.
  34969. * @return the value corresponding to the key.
  34970. */
  34971. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34972. /**
  34973. * Get a value from its key if present in the dictionary otherwise add it
  34974. * @param key the key to get the value from
  34975. * @param val if there's no such key/value pair in the dictionary add it with this value
  34976. * @return the value corresponding to the key
  34977. */
  34978. getOrAdd(key: string, val: T): T;
  34979. /**
  34980. * Check if there's a given key in the dictionary
  34981. * @param key the key to check for
  34982. * @return true if the key is present, false otherwise
  34983. */
  34984. contains(key: string): boolean;
  34985. /**
  34986. * Add a new key and its corresponding value
  34987. * @param key the key to add
  34988. * @param value the value corresponding to the key
  34989. * @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
  34990. */
  34991. add(key: string, value: T): boolean;
  34992. /**
  34993. * Update a specific value associated to a key
  34994. * @param key defines the key to use
  34995. * @param value defines the value to store
  34996. * @returns true if the value was updated (or false if the key was not found)
  34997. */
  34998. set(key: string, value: T): boolean;
  34999. /**
  35000. * Get the element of the given key and remove it from the dictionary
  35001. * @param key defines the key to search
  35002. * @returns the value associated with the key or null if not found
  35003. */
  35004. getAndRemove(key: string): Nullable<T>;
  35005. /**
  35006. * Remove a key/value from the dictionary.
  35007. * @param key the key to remove
  35008. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35009. */
  35010. remove(key: string): boolean;
  35011. /**
  35012. * Clear the whole content of the dictionary
  35013. */
  35014. clear(): void;
  35015. /**
  35016. * Gets the current count
  35017. */
  35018. readonly count: number;
  35019. /**
  35020. * Execute a callback on each key/val of the dictionary.
  35021. * Note that you can remove any element in this dictionary in the callback implementation
  35022. * @param callback the callback to execute on a given key/value pair
  35023. */
  35024. forEach(callback: (key: string, val: T) => void): void;
  35025. /**
  35026. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35027. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35028. * Note that you can remove any element in this dictionary in the callback implementation
  35029. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35030. * @returns the first item
  35031. */
  35032. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35033. private _count;
  35034. private _data;
  35035. }
  35036. }
  35037. declare module "babylonjs/Collisions/collisionCoordinator" {
  35038. import { Nullable } from "babylonjs/types";
  35039. import { Scene } from "babylonjs/scene";
  35040. import { Vector3 } from "babylonjs/Maths/math.vector";
  35041. import { Collider } from "babylonjs/Collisions/collider";
  35042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35043. /** @hidden */
  35044. export interface ICollisionCoordinator {
  35045. createCollider(): Collider;
  35046. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35047. init(scene: Scene): void;
  35048. }
  35049. /** @hidden */
  35050. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35051. private _scene;
  35052. private _scaledPosition;
  35053. private _scaledVelocity;
  35054. private _finalPosition;
  35055. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35056. createCollider(): Collider;
  35057. init(scene: Scene): void;
  35058. private _collideWithWorld;
  35059. }
  35060. }
  35061. declare module "babylonjs/Inputs/scene.inputManager" {
  35062. import { Nullable } from "babylonjs/types";
  35063. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35064. import { Vector2 } from "babylonjs/Maths/math.vector";
  35065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35066. import { Scene } from "babylonjs/scene";
  35067. /**
  35068. * Class used to manage all inputs for the scene.
  35069. */
  35070. export class InputManager {
  35071. /** The distance in pixel that you have to move to prevent some events */
  35072. static DragMovementThreshold: number;
  35073. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35074. static LongPressDelay: number;
  35075. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35076. static DoubleClickDelay: number;
  35077. /** If you need to check double click without raising a single click at first click, enable this flag */
  35078. static ExclusiveDoubleClickMode: boolean;
  35079. private _wheelEventName;
  35080. private _onPointerMove;
  35081. private _onPointerDown;
  35082. private _onPointerUp;
  35083. private _initClickEvent;
  35084. private _initActionManager;
  35085. private _delayedSimpleClick;
  35086. private _delayedSimpleClickTimeout;
  35087. private _previousDelayedSimpleClickTimeout;
  35088. private _meshPickProceed;
  35089. private _previousButtonPressed;
  35090. private _currentPickResult;
  35091. private _previousPickResult;
  35092. private _totalPointersPressed;
  35093. private _doubleClickOccured;
  35094. private _pointerOverMesh;
  35095. private _pickedDownMesh;
  35096. private _pickedUpMesh;
  35097. private _pointerX;
  35098. private _pointerY;
  35099. private _unTranslatedPointerX;
  35100. private _unTranslatedPointerY;
  35101. private _startingPointerPosition;
  35102. private _previousStartingPointerPosition;
  35103. private _startingPointerTime;
  35104. private _previousStartingPointerTime;
  35105. private _pointerCaptures;
  35106. private _onKeyDown;
  35107. private _onKeyUp;
  35108. private _onCanvasFocusObserver;
  35109. private _onCanvasBlurObserver;
  35110. private _scene;
  35111. /**
  35112. * Creates a new InputManager
  35113. * @param scene defines the hosting scene
  35114. */
  35115. constructor(scene: Scene);
  35116. /**
  35117. * Gets the mesh that is currently under the pointer
  35118. */
  35119. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35120. /**
  35121. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35122. */
  35123. readonly unTranslatedPointer: Vector2;
  35124. /**
  35125. * Gets or sets the current on-screen X position of the pointer
  35126. */
  35127. pointerX: number;
  35128. /**
  35129. * Gets or sets the current on-screen Y position of the pointer
  35130. */
  35131. pointerY: number;
  35132. private _updatePointerPosition;
  35133. private _processPointerMove;
  35134. private _setRayOnPointerInfo;
  35135. private _checkPrePointerObservable;
  35136. /**
  35137. * Use this method to simulate a pointer move on a mesh
  35138. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35139. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35140. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35141. */
  35142. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35143. /**
  35144. * Use this method to simulate a pointer down on a mesh
  35145. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35146. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35147. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35148. */
  35149. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35150. private _processPointerDown;
  35151. /** @hidden */
  35152. _isPointerSwiping(): boolean;
  35153. /**
  35154. * Use this method to simulate a pointer up on a mesh
  35155. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35156. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35157. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35158. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35159. */
  35160. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35161. private _processPointerUp;
  35162. /**
  35163. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35164. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35165. * @returns true if the pointer was captured
  35166. */
  35167. isPointerCaptured(pointerId?: number): boolean;
  35168. /**
  35169. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35170. * @param attachUp defines if you want to attach events to pointerup
  35171. * @param attachDown defines if you want to attach events to pointerdown
  35172. * @param attachMove defines if you want to attach events to pointermove
  35173. */
  35174. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35175. /**
  35176. * Detaches all event handlers
  35177. */
  35178. detachControl(): void;
  35179. /**
  35180. * Force the value of meshUnderPointer
  35181. * @param mesh defines the mesh to use
  35182. */
  35183. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35184. /**
  35185. * Gets the mesh under the pointer
  35186. * @returns a Mesh or null if no mesh is under the pointer
  35187. */
  35188. getPointerOverMesh(): Nullable<AbstractMesh>;
  35189. }
  35190. }
  35191. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35192. /**
  35193. * Helper class used to generate session unique ID
  35194. */
  35195. export class UniqueIdGenerator {
  35196. private static _UniqueIdCounter;
  35197. /**
  35198. * Gets an unique (relatively to the current scene) Id
  35199. */
  35200. static readonly UniqueId: number;
  35201. }
  35202. }
  35203. declare module "babylonjs/Animations/animationGroup" {
  35204. import { Animatable } from "babylonjs/Animations/animatable";
  35205. import { Animation } from "babylonjs/Animations/animation";
  35206. import { Scene, IDisposable } from "babylonjs/scene";
  35207. import { Observable } from "babylonjs/Misc/observable";
  35208. import { Nullable } from "babylonjs/types";
  35209. import "babylonjs/Animations/animatable";
  35210. /**
  35211. * This class defines the direct association between an animation and a target
  35212. */
  35213. export class TargetedAnimation {
  35214. /**
  35215. * Animation to perform
  35216. */
  35217. animation: Animation;
  35218. /**
  35219. * Target to animate
  35220. */
  35221. target: any;
  35222. /**
  35223. * Serialize the object
  35224. * @returns the JSON object representing the current entity
  35225. */
  35226. serialize(): any;
  35227. }
  35228. /**
  35229. * Use this class to create coordinated animations on multiple targets
  35230. */
  35231. export class AnimationGroup implements IDisposable {
  35232. /** The name of the animation group */
  35233. name: string;
  35234. private _scene;
  35235. private _targetedAnimations;
  35236. private _animatables;
  35237. private _from;
  35238. private _to;
  35239. private _isStarted;
  35240. private _isPaused;
  35241. private _speedRatio;
  35242. private _loopAnimation;
  35243. /**
  35244. * Gets or sets the unique id of the node
  35245. */
  35246. uniqueId: number;
  35247. /**
  35248. * This observable will notify when one animation have ended
  35249. */
  35250. onAnimationEndObservable: Observable<TargetedAnimation>;
  35251. /**
  35252. * Observer raised when one animation loops
  35253. */
  35254. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35255. /**
  35256. * Observer raised when all animations have looped
  35257. */
  35258. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35259. /**
  35260. * This observable will notify when all animations have ended.
  35261. */
  35262. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35263. /**
  35264. * This observable will notify when all animations have paused.
  35265. */
  35266. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35267. /**
  35268. * This observable will notify when all animations are playing.
  35269. */
  35270. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35271. /**
  35272. * Gets the first frame
  35273. */
  35274. readonly from: number;
  35275. /**
  35276. * Gets the last frame
  35277. */
  35278. readonly to: number;
  35279. /**
  35280. * Define if the animations are started
  35281. */
  35282. readonly isStarted: boolean;
  35283. /**
  35284. * Gets a value indicating that the current group is playing
  35285. */
  35286. readonly isPlaying: boolean;
  35287. /**
  35288. * Gets or sets the speed ratio to use for all animations
  35289. */
  35290. /**
  35291. * Gets or sets the speed ratio to use for all animations
  35292. */
  35293. speedRatio: number;
  35294. /**
  35295. * Gets or sets if all animations should loop or not
  35296. */
  35297. loopAnimation: boolean;
  35298. /**
  35299. * Gets the targeted animations for this animation group
  35300. */
  35301. readonly targetedAnimations: Array<TargetedAnimation>;
  35302. /**
  35303. * returning the list of animatables controlled by this animation group.
  35304. */
  35305. readonly animatables: Array<Animatable>;
  35306. /**
  35307. * Instantiates a new Animation Group.
  35308. * This helps managing several animations at once.
  35309. * @see http://doc.babylonjs.com/how_to/group
  35310. * @param name Defines the name of the group
  35311. * @param scene Defines the scene the group belongs to
  35312. */
  35313. constructor(
  35314. /** The name of the animation group */
  35315. name: string, scene?: Nullable<Scene>);
  35316. /**
  35317. * Add an animation (with its target) in the group
  35318. * @param animation defines the animation we want to add
  35319. * @param target defines the target of the animation
  35320. * @returns the TargetedAnimation object
  35321. */
  35322. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35323. /**
  35324. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35325. * It can add constant keys at begin or end
  35326. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35327. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35328. * @returns the animation group
  35329. */
  35330. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35331. private _animationLoopCount;
  35332. private _animationLoopFlags;
  35333. private _processLoop;
  35334. /**
  35335. * Start all animations on given targets
  35336. * @param loop defines if animations must loop
  35337. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35338. * @param from defines the from key (optional)
  35339. * @param to defines the to key (optional)
  35340. * @returns the current animation group
  35341. */
  35342. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35343. /**
  35344. * Pause all animations
  35345. * @returns the animation group
  35346. */
  35347. pause(): AnimationGroup;
  35348. /**
  35349. * Play all animations to initial state
  35350. * This function will start() the animations if they were not started or will restart() them if they were paused
  35351. * @param loop defines if animations must loop
  35352. * @returns the animation group
  35353. */
  35354. play(loop?: boolean): AnimationGroup;
  35355. /**
  35356. * Reset all animations to initial state
  35357. * @returns the animation group
  35358. */
  35359. reset(): AnimationGroup;
  35360. /**
  35361. * Restart animations from key 0
  35362. * @returns the animation group
  35363. */
  35364. restart(): AnimationGroup;
  35365. /**
  35366. * Stop all animations
  35367. * @returns the animation group
  35368. */
  35369. stop(): AnimationGroup;
  35370. /**
  35371. * Set animation weight for all animatables
  35372. * @param weight defines the weight to use
  35373. * @return the animationGroup
  35374. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35375. */
  35376. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35377. /**
  35378. * Synchronize and normalize all animatables with a source animatable
  35379. * @param root defines the root animatable to synchronize with
  35380. * @return the animationGroup
  35381. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35382. */
  35383. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35384. /**
  35385. * Goes to a specific frame in this animation group
  35386. * @param frame the frame number to go to
  35387. * @return the animationGroup
  35388. */
  35389. goToFrame(frame: number): AnimationGroup;
  35390. /**
  35391. * Dispose all associated resources
  35392. */
  35393. dispose(): void;
  35394. private _checkAnimationGroupEnded;
  35395. /**
  35396. * Clone the current animation group and returns a copy
  35397. * @param newName defines the name of the new group
  35398. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35399. * @returns the new aniamtion group
  35400. */
  35401. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35402. /**
  35403. * Serializes the animationGroup to an object
  35404. * @returns Serialized object
  35405. */
  35406. serialize(): any;
  35407. /**
  35408. * Returns a new AnimationGroup object parsed from the source provided.
  35409. * @param parsedAnimationGroup defines the source
  35410. * @param scene defines the scene that will receive the animationGroup
  35411. * @returns a new AnimationGroup
  35412. */
  35413. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35414. /**
  35415. * Returns the string "AnimationGroup"
  35416. * @returns "AnimationGroup"
  35417. */
  35418. getClassName(): string;
  35419. /**
  35420. * Creates a detailled string about the object
  35421. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35422. * @returns a string representing the object
  35423. */
  35424. toString(fullDetails?: boolean): string;
  35425. }
  35426. }
  35427. declare module "babylonjs/scene" {
  35428. import { Nullable } from "babylonjs/types";
  35429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35430. import { Observable } from "babylonjs/Misc/observable";
  35431. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35432. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35433. import { Geometry } from "babylonjs/Meshes/geometry";
  35434. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35437. import { Mesh } from "babylonjs/Meshes/mesh";
  35438. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35439. import { Bone } from "babylonjs/Bones/bone";
  35440. import { Skeleton } from "babylonjs/Bones/skeleton";
  35441. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35442. import { Camera } from "babylonjs/Cameras/camera";
  35443. import { AbstractScene } from "babylonjs/abstractScene";
  35444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35445. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35446. import { Material } from "babylonjs/Materials/material";
  35447. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35448. import { Effect } from "babylonjs/Materials/effect";
  35449. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35450. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35451. import { Light } from "babylonjs/Lights/light";
  35452. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35453. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35454. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35455. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35457. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35459. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35460. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35461. import { Engine } from "babylonjs/Engines/engine";
  35462. import { Node } from "babylonjs/node";
  35463. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35464. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35465. import { WebRequest } from "babylonjs/Misc/webRequest";
  35466. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35467. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35468. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35469. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35470. import { Plane } from "babylonjs/Maths/math.plane";
  35471. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35472. import { Ray } from "babylonjs/Culling/ray";
  35473. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35474. import { Animation } from "babylonjs/Animations/animation";
  35475. import { Animatable } from "babylonjs/Animations/animatable";
  35476. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35477. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35478. import { Collider } from "babylonjs/Collisions/collider";
  35479. /**
  35480. * Define an interface for all classes that will hold resources
  35481. */
  35482. export interface IDisposable {
  35483. /**
  35484. * Releases all held resources
  35485. */
  35486. dispose(): void;
  35487. }
  35488. /** Interface defining initialization parameters for Scene class */
  35489. export interface SceneOptions {
  35490. /**
  35491. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35492. * It will improve performance when the number of geometries becomes important.
  35493. */
  35494. useGeometryUniqueIdsMap?: boolean;
  35495. /**
  35496. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35497. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35498. */
  35499. useMaterialMeshMap?: boolean;
  35500. /**
  35501. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35502. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35503. */
  35504. useClonedMeshhMap?: boolean;
  35505. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35506. virtual?: boolean;
  35507. }
  35508. /**
  35509. * Represents a scene to be rendered by the engine.
  35510. * @see http://doc.babylonjs.com/features/scene
  35511. */
  35512. export class Scene extends AbstractScene implements IAnimatable {
  35513. /** The fog is deactivated */
  35514. static readonly FOGMODE_NONE: number;
  35515. /** The fog density is following an exponential function */
  35516. static readonly FOGMODE_EXP: number;
  35517. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35518. static readonly FOGMODE_EXP2: number;
  35519. /** The fog density is following a linear function. */
  35520. static readonly FOGMODE_LINEAR: number;
  35521. /**
  35522. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35523. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35524. */
  35525. static MinDeltaTime: number;
  35526. /**
  35527. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35529. */
  35530. static MaxDeltaTime: number;
  35531. /**
  35532. * Factory used to create the default material.
  35533. * @param name The name of the material to create
  35534. * @param scene The scene to create the material for
  35535. * @returns The default material
  35536. */
  35537. static DefaultMaterialFactory(scene: Scene): Material;
  35538. /**
  35539. * Factory used to create the a collision coordinator.
  35540. * @returns The collision coordinator
  35541. */
  35542. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35543. /** @hidden */
  35544. _inputManager: InputManager;
  35545. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35546. cameraToUseForPointers: Nullable<Camera>;
  35547. /** @hidden */
  35548. readonly _isScene: boolean;
  35549. /**
  35550. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35551. */
  35552. autoClear: boolean;
  35553. /**
  35554. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35555. */
  35556. autoClearDepthAndStencil: boolean;
  35557. /**
  35558. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35559. */
  35560. clearColor: Color4;
  35561. /**
  35562. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35563. */
  35564. ambientColor: Color3;
  35565. /**
  35566. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35567. * It should only be one of the following (if not the default embedded one):
  35568. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35569. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35570. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35571. * The material properties need to be setup according to the type of texture in use.
  35572. */
  35573. environmentBRDFTexture: BaseTexture;
  35574. /** @hidden */
  35575. protected _environmentTexture: Nullable<BaseTexture>;
  35576. /**
  35577. * Texture used in all pbr material as the reflection texture.
  35578. * As in the majority of the scene they are the same (exception for multi room and so on),
  35579. * this is easier to reference from here than from all the materials.
  35580. */
  35581. /**
  35582. * Texture used in all pbr material as the reflection texture.
  35583. * As in the majority of the scene they are the same (exception for multi room and so on),
  35584. * this is easier to set here than in all the materials.
  35585. */
  35586. environmentTexture: Nullable<BaseTexture>;
  35587. /** @hidden */
  35588. protected _environmentIntensity: number;
  35589. /**
  35590. * Intensity of the environment in all pbr material.
  35591. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35592. * As in the majority of the scene they are the same (exception for multi room and so on),
  35593. * this is easier to reference from here than from all the materials.
  35594. */
  35595. /**
  35596. * Intensity of the environment in all pbr material.
  35597. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35598. * As in the majority of the scene they are the same (exception for multi room and so on),
  35599. * this is easier to set here than in all the materials.
  35600. */
  35601. environmentIntensity: number;
  35602. /** @hidden */
  35603. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35604. /**
  35605. * Default image processing configuration used either in the rendering
  35606. * Forward main pass or through the imageProcessingPostProcess if present.
  35607. * As in the majority of the scene they are the same (exception for multi camera),
  35608. * this is easier to reference from here than from all the materials and post process.
  35609. *
  35610. * No setter as we it is a shared configuration, you can set the values instead.
  35611. */
  35612. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35613. private _forceWireframe;
  35614. /**
  35615. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35616. */
  35617. forceWireframe: boolean;
  35618. private _forcePointsCloud;
  35619. /**
  35620. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35621. */
  35622. forcePointsCloud: boolean;
  35623. /**
  35624. * Gets or sets the active clipplane 1
  35625. */
  35626. clipPlane: Nullable<Plane>;
  35627. /**
  35628. * Gets or sets the active clipplane 2
  35629. */
  35630. clipPlane2: Nullable<Plane>;
  35631. /**
  35632. * Gets or sets the active clipplane 3
  35633. */
  35634. clipPlane3: Nullable<Plane>;
  35635. /**
  35636. * Gets or sets the active clipplane 4
  35637. */
  35638. clipPlane4: Nullable<Plane>;
  35639. /**
  35640. * Gets or sets a boolean indicating if animations are enabled
  35641. */
  35642. animationsEnabled: boolean;
  35643. private _animationPropertiesOverride;
  35644. /**
  35645. * Gets or sets the animation properties override
  35646. */
  35647. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35648. /**
  35649. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35650. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35651. */
  35652. useConstantAnimationDeltaTime: boolean;
  35653. /**
  35654. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35655. * Please note that it requires to run a ray cast through the scene on every frame
  35656. */
  35657. constantlyUpdateMeshUnderPointer: boolean;
  35658. /**
  35659. * Defines the HTML cursor to use when hovering over interactive elements
  35660. */
  35661. hoverCursor: string;
  35662. /**
  35663. * Defines the HTML default cursor to use (empty by default)
  35664. */
  35665. defaultCursor: string;
  35666. /**
  35667. * Defines wether cursors are handled by the scene.
  35668. */
  35669. doNotHandleCursors: boolean;
  35670. /**
  35671. * This is used to call preventDefault() on pointer down
  35672. * in order to block unwanted artifacts like system double clicks
  35673. */
  35674. preventDefaultOnPointerDown: boolean;
  35675. /**
  35676. * This is used to call preventDefault() on pointer up
  35677. * in order to block unwanted artifacts like system double clicks
  35678. */
  35679. preventDefaultOnPointerUp: boolean;
  35680. /**
  35681. * Gets or sets user defined metadata
  35682. */
  35683. metadata: any;
  35684. /**
  35685. * For internal use only. Please do not use.
  35686. */
  35687. reservedDataStore: any;
  35688. /**
  35689. * Gets the name of the plugin used to load this scene (null by default)
  35690. */
  35691. loadingPluginName: string;
  35692. /**
  35693. * Use this array to add regular expressions used to disable offline support for specific urls
  35694. */
  35695. disableOfflineSupportExceptionRules: RegExp[];
  35696. /**
  35697. * An event triggered when the scene is disposed.
  35698. */
  35699. onDisposeObservable: Observable<Scene>;
  35700. private _onDisposeObserver;
  35701. /** Sets a function to be executed when this scene is disposed. */
  35702. onDispose: () => void;
  35703. /**
  35704. * An event triggered before rendering the scene (right after animations and physics)
  35705. */
  35706. onBeforeRenderObservable: Observable<Scene>;
  35707. private _onBeforeRenderObserver;
  35708. /** Sets a function to be executed before rendering this scene */
  35709. beforeRender: Nullable<() => void>;
  35710. /**
  35711. * An event triggered after rendering the scene
  35712. */
  35713. onAfterRenderObservable: Observable<Scene>;
  35714. /**
  35715. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35716. */
  35717. onAfterRenderCameraObservable: Observable<Camera>;
  35718. private _onAfterRenderObserver;
  35719. /** Sets a function to be executed after rendering this scene */
  35720. afterRender: Nullable<() => void>;
  35721. /**
  35722. * An event triggered before animating the scene
  35723. */
  35724. onBeforeAnimationsObservable: Observable<Scene>;
  35725. /**
  35726. * An event triggered after animations processing
  35727. */
  35728. onAfterAnimationsObservable: Observable<Scene>;
  35729. /**
  35730. * An event triggered before draw calls are ready to be sent
  35731. */
  35732. onBeforeDrawPhaseObservable: Observable<Scene>;
  35733. /**
  35734. * An event triggered after draw calls have been sent
  35735. */
  35736. onAfterDrawPhaseObservable: Observable<Scene>;
  35737. /**
  35738. * An event triggered when the scene is ready
  35739. */
  35740. onReadyObservable: Observable<Scene>;
  35741. /**
  35742. * An event triggered before rendering a camera
  35743. */
  35744. onBeforeCameraRenderObservable: Observable<Camera>;
  35745. private _onBeforeCameraRenderObserver;
  35746. /** Sets a function to be executed before rendering a camera*/
  35747. beforeCameraRender: () => void;
  35748. /**
  35749. * An event triggered after rendering a camera
  35750. */
  35751. onAfterCameraRenderObservable: Observable<Camera>;
  35752. private _onAfterCameraRenderObserver;
  35753. /** Sets a function to be executed after rendering a camera*/
  35754. afterCameraRender: () => void;
  35755. /**
  35756. * An event triggered when active meshes evaluation is about to start
  35757. */
  35758. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35759. /**
  35760. * An event triggered when active meshes evaluation is done
  35761. */
  35762. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35763. /**
  35764. * An event triggered when particles rendering is about to start
  35765. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35766. */
  35767. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35768. /**
  35769. * An event triggered when particles rendering is done
  35770. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35771. */
  35772. onAfterParticlesRenderingObservable: Observable<Scene>;
  35773. /**
  35774. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35775. */
  35776. onDataLoadedObservable: Observable<Scene>;
  35777. /**
  35778. * An event triggered when a camera is created
  35779. */
  35780. onNewCameraAddedObservable: Observable<Camera>;
  35781. /**
  35782. * An event triggered when a camera is removed
  35783. */
  35784. onCameraRemovedObservable: Observable<Camera>;
  35785. /**
  35786. * An event triggered when a light is created
  35787. */
  35788. onNewLightAddedObservable: Observable<Light>;
  35789. /**
  35790. * An event triggered when a light is removed
  35791. */
  35792. onLightRemovedObservable: Observable<Light>;
  35793. /**
  35794. * An event triggered when a geometry is created
  35795. */
  35796. onNewGeometryAddedObservable: Observable<Geometry>;
  35797. /**
  35798. * An event triggered when a geometry is removed
  35799. */
  35800. onGeometryRemovedObservable: Observable<Geometry>;
  35801. /**
  35802. * An event triggered when a transform node is created
  35803. */
  35804. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35805. /**
  35806. * An event triggered when a transform node is removed
  35807. */
  35808. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35809. /**
  35810. * An event triggered when a mesh is created
  35811. */
  35812. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35813. /**
  35814. * An event triggered when a mesh is removed
  35815. */
  35816. onMeshRemovedObservable: Observable<AbstractMesh>;
  35817. /**
  35818. * An event triggered when a skeleton is created
  35819. */
  35820. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35821. /**
  35822. * An event triggered when a skeleton is removed
  35823. */
  35824. onSkeletonRemovedObservable: Observable<Skeleton>;
  35825. /**
  35826. * An event triggered when a material is created
  35827. */
  35828. onNewMaterialAddedObservable: Observable<Material>;
  35829. /**
  35830. * An event triggered when a material is removed
  35831. */
  35832. onMaterialRemovedObservable: Observable<Material>;
  35833. /**
  35834. * An event triggered when a texture is created
  35835. */
  35836. onNewTextureAddedObservable: Observable<BaseTexture>;
  35837. /**
  35838. * An event triggered when a texture is removed
  35839. */
  35840. onTextureRemovedObservable: Observable<BaseTexture>;
  35841. /**
  35842. * An event triggered when render targets are about to be rendered
  35843. * Can happen multiple times per frame.
  35844. */
  35845. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35846. /**
  35847. * An event triggered when render targets were rendered.
  35848. * Can happen multiple times per frame.
  35849. */
  35850. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35851. /**
  35852. * An event triggered before calculating deterministic simulation step
  35853. */
  35854. onBeforeStepObservable: Observable<Scene>;
  35855. /**
  35856. * An event triggered after calculating deterministic simulation step
  35857. */
  35858. onAfterStepObservable: Observable<Scene>;
  35859. /**
  35860. * An event triggered when the activeCamera property is updated
  35861. */
  35862. onActiveCameraChanged: Observable<Scene>;
  35863. /**
  35864. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35865. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35866. * 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)
  35867. */
  35868. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35869. /**
  35870. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35871. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35872. * 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)
  35873. */
  35874. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35875. /**
  35876. * This Observable will when a mesh has been imported into the scene.
  35877. */
  35878. onMeshImportedObservable: Observable<AbstractMesh>;
  35879. /**
  35880. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35881. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35882. */
  35883. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35884. /** @hidden */
  35885. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35886. /**
  35887. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35888. */
  35889. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35890. /**
  35891. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35892. */
  35893. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35894. /**
  35895. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35896. */
  35897. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35898. /** Callback called when a pointer move is detected */
  35899. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35900. /** Callback called when a pointer down is detected */
  35901. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35902. /** Callback called when a pointer up is detected */
  35903. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35904. /** Callback called when a pointer pick is detected */
  35905. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35906. /**
  35907. * 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).
  35908. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35909. */
  35910. onPrePointerObservable: Observable<PointerInfoPre>;
  35911. /**
  35912. * Observable event triggered each time an input event is received from the rendering canvas
  35913. */
  35914. onPointerObservable: Observable<PointerInfo>;
  35915. /**
  35916. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35917. */
  35918. readonly unTranslatedPointer: Vector2;
  35919. /**
  35920. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35921. */
  35922. static DragMovementThreshold: number;
  35923. /**
  35924. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35925. */
  35926. static LongPressDelay: number;
  35927. /**
  35928. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35929. */
  35930. static DoubleClickDelay: number;
  35931. /** If you need to check double click without raising a single click at first click, enable this flag */
  35932. static ExclusiveDoubleClickMode: boolean;
  35933. /** @hidden */
  35934. _mirroredCameraPosition: Nullable<Vector3>;
  35935. /**
  35936. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35937. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35938. */
  35939. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35940. /**
  35941. * Observable event triggered each time an keyboard event is received from the hosting window
  35942. */
  35943. onKeyboardObservable: Observable<KeyboardInfo>;
  35944. private _useRightHandedSystem;
  35945. /**
  35946. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35947. */
  35948. useRightHandedSystem: boolean;
  35949. private _timeAccumulator;
  35950. private _currentStepId;
  35951. private _currentInternalStep;
  35952. /**
  35953. * Sets the step Id used by deterministic lock step
  35954. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35955. * @param newStepId defines the step Id
  35956. */
  35957. setStepId(newStepId: number): void;
  35958. /**
  35959. * Gets the step Id used by deterministic lock step
  35960. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35961. * @returns the step Id
  35962. */
  35963. getStepId(): number;
  35964. /**
  35965. * Gets the internal step used by deterministic lock step
  35966. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35967. * @returns the internal step
  35968. */
  35969. getInternalStep(): number;
  35970. private _fogEnabled;
  35971. /**
  35972. * Gets or sets a boolean indicating if fog is enabled on this scene
  35973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35974. * (Default is true)
  35975. */
  35976. fogEnabled: boolean;
  35977. private _fogMode;
  35978. /**
  35979. * Gets or sets the fog mode to use
  35980. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35981. * | mode | value |
  35982. * | --- | --- |
  35983. * | FOGMODE_NONE | 0 |
  35984. * | FOGMODE_EXP | 1 |
  35985. * | FOGMODE_EXP2 | 2 |
  35986. * | FOGMODE_LINEAR | 3 |
  35987. */
  35988. fogMode: number;
  35989. /**
  35990. * Gets or sets the fog color to use
  35991. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35992. * (Default is Color3(0.2, 0.2, 0.3))
  35993. */
  35994. fogColor: Color3;
  35995. /**
  35996. * Gets or sets the fog density to use
  35997. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35998. * (Default is 0.1)
  35999. */
  36000. fogDensity: number;
  36001. /**
  36002. * Gets or sets the fog start distance to use
  36003. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36004. * (Default is 0)
  36005. */
  36006. fogStart: number;
  36007. /**
  36008. * Gets or sets the fog end distance to use
  36009. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36010. * (Default is 1000)
  36011. */
  36012. fogEnd: number;
  36013. private _shadowsEnabled;
  36014. /**
  36015. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36016. */
  36017. shadowsEnabled: boolean;
  36018. private _lightsEnabled;
  36019. /**
  36020. * Gets or sets a boolean indicating if lights are enabled on this scene
  36021. */
  36022. lightsEnabled: boolean;
  36023. /** All of the active cameras added to this scene. */
  36024. activeCameras: Camera[];
  36025. /** @hidden */
  36026. _activeCamera: Nullable<Camera>;
  36027. /** Gets or sets the current active camera */
  36028. activeCamera: Nullable<Camera>;
  36029. private _defaultMaterial;
  36030. /** The default material used on meshes when no material is affected */
  36031. /** The default material used on meshes when no material is affected */
  36032. defaultMaterial: Material;
  36033. private _texturesEnabled;
  36034. /**
  36035. * Gets or sets a boolean indicating if textures are enabled on this scene
  36036. */
  36037. texturesEnabled: boolean;
  36038. /**
  36039. * Gets or sets a boolean indicating if particles are enabled on this scene
  36040. */
  36041. particlesEnabled: boolean;
  36042. /**
  36043. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36044. */
  36045. spritesEnabled: boolean;
  36046. private _skeletonsEnabled;
  36047. /**
  36048. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36049. */
  36050. skeletonsEnabled: boolean;
  36051. /**
  36052. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36053. */
  36054. lensFlaresEnabled: boolean;
  36055. /**
  36056. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36058. */
  36059. collisionsEnabled: boolean;
  36060. private _collisionCoordinator;
  36061. /** @hidden */
  36062. readonly collisionCoordinator: ICollisionCoordinator;
  36063. /**
  36064. * Defines the gravity applied to this scene (used only for collisions)
  36065. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36066. */
  36067. gravity: Vector3;
  36068. /**
  36069. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36070. */
  36071. postProcessesEnabled: boolean;
  36072. /**
  36073. * The list of postprocesses added to the scene
  36074. */
  36075. postProcesses: PostProcess[];
  36076. /**
  36077. * Gets the current postprocess manager
  36078. */
  36079. postProcessManager: PostProcessManager;
  36080. /**
  36081. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36082. */
  36083. renderTargetsEnabled: boolean;
  36084. /**
  36085. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36086. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36087. */
  36088. dumpNextRenderTargets: boolean;
  36089. /**
  36090. * The list of user defined render targets added to the scene
  36091. */
  36092. customRenderTargets: RenderTargetTexture[];
  36093. /**
  36094. * Defines if texture loading must be delayed
  36095. * If true, textures will only be loaded when they need to be rendered
  36096. */
  36097. useDelayedTextureLoading: boolean;
  36098. /**
  36099. * Gets the list of meshes imported to the scene through SceneLoader
  36100. */
  36101. importedMeshesFiles: String[];
  36102. /**
  36103. * Gets or sets a boolean indicating if probes are enabled on this scene
  36104. */
  36105. probesEnabled: boolean;
  36106. /**
  36107. * Gets or sets the current offline provider to use to store scene data
  36108. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36109. */
  36110. offlineProvider: IOfflineProvider;
  36111. /**
  36112. * Gets or sets the action manager associated with the scene
  36113. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36114. */
  36115. actionManager: AbstractActionManager;
  36116. private _meshesForIntersections;
  36117. /**
  36118. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36119. */
  36120. proceduralTexturesEnabled: boolean;
  36121. private _engine;
  36122. private _totalVertices;
  36123. /** @hidden */
  36124. _activeIndices: PerfCounter;
  36125. /** @hidden */
  36126. _activeParticles: PerfCounter;
  36127. /** @hidden */
  36128. _activeBones: PerfCounter;
  36129. private _animationRatio;
  36130. /** @hidden */
  36131. _animationTimeLast: number;
  36132. /** @hidden */
  36133. _animationTime: number;
  36134. /**
  36135. * Gets or sets a general scale for animation speed
  36136. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36137. */
  36138. animationTimeScale: number;
  36139. /** @hidden */
  36140. _cachedMaterial: Nullable<Material>;
  36141. /** @hidden */
  36142. _cachedEffect: Nullable<Effect>;
  36143. /** @hidden */
  36144. _cachedVisibility: Nullable<number>;
  36145. private _renderId;
  36146. private _frameId;
  36147. private _executeWhenReadyTimeoutId;
  36148. private _intermediateRendering;
  36149. private _viewUpdateFlag;
  36150. private _projectionUpdateFlag;
  36151. /** @hidden */
  36152. _toBeDisposed: Nullable<IDisposable>[];
  36153. private _activeRequests;
  36154. /** @hidden */
  36155. _pendingData: any[];
  36156. private _isDisposed;
  36157. /**
  36158. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36159. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36160. */
  36161. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36162. private _activeMeshes;
  36163. private _processedMaterials;
  36164. private _renderTargets;
  36165. /** @hidden */
  36166. _activeParticleSystems: SmartArray<IParticleSystem>;
  36167. private _activeSkeletons;
  36168. private _softwareSkinnedMeshes;
  36169. private _renderingManager;
  36170. /** @hidden */
  36171. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36172. private _transformMatrix;
  36173. private _sceneUbo;
  36174. /** @hidden */
  36175. _viewMatrix: Matrix;
  36176. private _projectionMatrix;
  36177. /** @hidden */
  36178. _forcedViewPosition: Nullable<Vector3>;
  36179. /** @hidden */
  36180. _frustumPlanes: Plane[];
  36181. /**
  36182. * Gets the list of frustum planes (built from the active camera)
  36183. */
  36184. readonly frustumPlanes: Plane[];
  36185. /**
  36186. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36187. * This is useful if there are more lights that the maximum simulteanous authorized
  36188. */
  36189. requireLightSorting: boolean;
  36190. /** @hidden */
  36191. readonly useMaterialMeshMap: boolean;
  36192. /** @hidden */
  36193. readonly useClonedMeshhMap: boolean;
  36194. private _externalData;
  36195. private _uid;
  36196. /**
  36197. * @hidden
  36198. * Backing store of defined scene components.
  36199. */
  36200. _components: ISceneComponent[];
  36201. /**
  36202. * @hidden
  36203. * Backing store of defined scene components.
  36204. */
  36205. _serializableComponents: ISceneSerializableComponent[];
  36206. /**
  36207. * List of components to register on the next registration step.
  36208. */
  36209. private _transientComponents;
  36210. /**
  36211. * Registers the transient components if needed.
  36212. */
  36213. private _registerTransientComponents;
  36214. /**
  36215. * @hidden
  36216. * Add a component to the scene.
  36217. * Note that the ccomponent could be registered on th next frame if this is called after
  36218. * the register component stage.
  36219. * @param component Defines the component to add to the scene
  36220. */
  36221. _addComponent(component: ISceneComponent): void;
  36222. /**
  36223. * @hidden
  36224. * Gets a component from the scene.
  36225. * @param name defines the name of the component to retrieve
  36226. * @returns the component or null if not present
  36227. */
  36228. _getComponent(name: string): Nullable<ISceneComponent>;
  36229. /**
  36230. * @hidden
  36231. * Defines the actions happening before camera updates.
  36232. */
  36233. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36234. /**
  36235. * @hidden
  36236. * Defines the actions happening before clear the canvas.
  36237. */
  36238. _beforeClearStage: Stage<SimpleStageAction>;
  36239. /**
  36240. * @hidden
  36241. * Defines the actions when collecting render targets for the frame.
  36242. */
  36243. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36244. /**
  36245. * @hidden
  36246. * Defines the actions happening for one camera in the frame.
  36247. */
  36248. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36249. /**
  36250. * @hidden
  36251. * Defines the actions happening during the per mesh ready checks.
  36252. */
  36253. _isReadyForMeshStage: Stage<MeshStageAction>;
  36254. /**
  36255. * @hidden
  36256. * Defines the actions happening before evaluate active mesh checks.
  36257. */
  36258. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36259. /**
  36260. * @hidden
  36261. * Defines the actions happening during the evaluate sub mesh checks.
  36262. */
  36263. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36264. /**
  36265. * @hidden
  36266. * Defines the actions happening during the active mesh stage.
  36267. */
  36268. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36269. /**
  36270. * @hidden
  36271. * Defines the actions happening during the per camera render target step.
  36272. */
  36273. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36274. /**
  36275. * @hidden
  36276. * Defines the actions happening just before the active camera is drawing.
  36277. */
  36278. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36279. /**
  36280. * @hidden
  36281. * Defines the actions happening just before a render target is drawing.
  36282. */
  36283. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36284. /**
  36285. * @hidden
  36286. * Defines the actions happening just before a rendering group is drawing.
  36287. */
  36288. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36289. /**
  36290. * @hidden
  36291. * Defines the actions happening just before a mesh is drawing.
  36292. */
  36293. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36294. /**
  36295. * @hidden
  36296. * Defines the actions happening just after a mesh has been drawn.
  36297. */
  36298. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36299. /**
  36300. * @hidden
  36301. * Defines the actions happening just after a rendering group has been drawn.
  36302. */
  36303. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36304. /**
  36305. * @hidden
  36306. * Defines the actions happening just after the active camera has been drawn.
  36307. */
  36308. _afterCameraDrawStage: Stage<CameraStageAction>;
  36309. /**
  36310. * @hidden
  36311. * Defines the actions happening just after a render target has been drawn.
  36312. */
  36313. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36314. /**
  36315. * @hidden
  36316. * Defines the actions happening just after rendering all cameras and computing intersections.
  36317. */
  36318. _afterRenderStage: Stage<SimpleStageAction>;
  36319. /**
  36320. * @hidden
  36321. * Defines the actions happening when a pointer move event happens.
  36322. */
  36323. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36324. /**
  36325. * @hidden
  36326. * Defines the actions happening when a pointer down event happens.
  36327. */
  36328. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36329. /**
  36330. * @hidden
  36331. * Defines the actions happening when a pointer up event happens.
  36332. */
  36333. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36334. /**
  36335. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36336. */
  36337. private geometriesByUniqueId;
  36338. /**
  36339. * Creates a new Scene
  36340. * @param engine defines the engine to use to render this scene
  36341. * @param options defines the scene options
  36342. */
  36343. constructor(engine: Engine, options?: SceneOptions);
  36344. /**
  36345. * Gets a string idenfifying the name of the class
  36346. * @returns "Scene" string
  36347. */
  36348. getClassName(): string;
  36349. private _defaultMeshCandidates;
  36350. /**
  36351. * @hidden
  36352. */
  36353. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36354. private _defaultSubMeshCandidates;
  36355. /**
  36356. * @hidden
  36357. */
  36358. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36359. /**
  36360. * Sets the default candidate providers for the scene.
  36361. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36362. * and getCollidingSubMeshCandidates to their default function
  36363. */
  36364. setDefaultCandidateProviders(): void;
  36365. /**
  36366. * Gets the mesh that is currently under the pointer
  36367. */
  36368. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36369. /**
  36370. * Gets or sets the current on-screen X position of the pointer
  36371. */
  36372. pointerX: number;
  36373. /**
  36374. * Gets or sets the current on-screen Y position of the pointer
  36375. */
  36376. pointerY: number;
  36377. /**
  36378. * Gets the cached material (ie. the latest rendered one)
  36379. * @returns the cached material
  36380. */
  36381. getCachedMaterial(): Nullable<Material>;
  36382. /**
  36383. * Gets the cached effect (ie. the latest rendered one)
  36384. * @returns the cached effect
  36385. */
  36386. getCachedEffect(): Nullable<Effect>;
  36387. /**
  36388. * Gets the cached visibility state (ie. the latest rendered one)
  36389. * @returns the cached visibility state
  36390. */
  36391. getCachedVisibility(): Nullable<number>;
  36392. /**
  36393. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36394. * @param material defines the current material
  36395. * @param effect defines the current effect
  36396. * @param visibility defines the current visibility state
  36397. * @returns true if one parameter is not cached
  36398. */
  36399. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36400. /**
  36401. * Gets the engine associated with the scene
  36402. * @returns an Engine
  36403. */
  36404. getEngine(): Engine;
  36405. /**
  36406. * Gets the total number of vertices rendered per frame
  36407. * @returns the total number of vertices rendered per frame
  36408. */
  36409. getTotalVertices(): number;
  36410. /**
  36411. * Gets the performance counter for total vertices
  36412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36413. */
  36414. readonly totalVerticesPerfCounter: PerfCounter;
  36415. /**
  36416. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36417. * @returns the total number of active indices rendered per frame
  36418. */
  36419. getActiveIndices(): number;
  36420. /**
  36421. * Gets the performance counter for active indices
  36422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36423. */
  36424. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36425. /**
  36426. * Gets the total number of active particles rendered per frame
  36427. * @returns the total number of active particles rendered per frame
  36428. */
  36429. getActiveParticles(): number;
  36430. /**
  36431. * Gets the performance counter for active particles
  36432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36433. */
  36434. readonly activeParticlesPerfCounter: PerfCounter;
  36435. /**
  36436. * Gets the total number of active bones rendered per frame
  36437. * @returns the total number of active bones rendered per frame
  36438. */
  36439. getActiveBones(): number;
  36440. /**
  36441. * Gets the performance counter for active bones
  36442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36443. */
  36444. readonly activeBonesPerfCounter: PerfCounter;
  36445. /**
  36446. * Gets the array of active meshes
  36447. * @returns an array of AbstractMesh
  36448. */
  36449. getActiveMeshes(): SmartArray<AbstractMesh>;
  36450. /**
  36451. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36452. * @returns a number
  36453. */
  36454. getAnimationRatio(): number;
  36455. /**
  36456. * Gets an unique Id for the current render phase
  36457. * @returns a number
  36458. */
  36459. getRenderId(): number;
  36460. /**
  36461. * Gets an unique Id for the current frame
  36462. * @returns a number
  36463. */
  36464. getFrameId(): number;
  36465. /** Call this function if you want to manually increment the render Id*/
  36466. incrementRenderId(): void;
  36467. private _createUbo;
  36468. /**
  36469. * Use this method to simulate a pointer move on a mesh
  36470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36473. * @returns the current scene
  36474. */
  36475. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36476. /**
  36477. * Use this method to simulate a pointer down on a mesh
  36478. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36479. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36480. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36481. * @returns the current scene
  36482. */
  36483. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36484. /**
  36485. * Use this method to simulate a pointer up on a mesh
  36486. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36487. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36488. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36489. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36490. * @returns the current scene
  36491. */
  36492. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36493. /**
  36494. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36495. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36496. * @returns true if the pointer was captured
  36497. */
  36498. isPointerCaptured(pointerId?: number): boolean;
  36499. /**
  36500. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36501. * @param attachUp defines if you want to attach events to pointerup
  36502. * @param attachDown defines if you want to attach events to pointerdown
  36503. * @param attachMove defines if you want to attach events to pointermove
  36504. */
  36505. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36506. /** Detaches all event handlers*/
  36507. detachControl(): void;
  36508. /**
  36509. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36510. * Delay loaded resources are not taking in account
  36511. * @return true if all required resources are ready
  36512. */
  36513. isReady(): boolean;
  36514. /** Resets all cached information relative to material (including effect and visibility) */
  36515. resetCachedMaterial(): void;
  36516. /**
  36517. * Registers a function to be called before every frame render
  36518. * @param func defines the function to register
  36519. */
  36520. registerBeforeRender(func: () => void): void;
  36521. /**
  36522. * Unregisters a function called before every frame render
  36523. * @param func defines the function to unregister
  36524. */
  36525. unregisterBeforeRender(func: () => void): void;
  36526. /**
  36527. * Registers a function to be called after every frame render
  36528. * @param func defines the function to register
  36529. */
  36530. registerAfterRender(func: () => void): void;
  36531. /**
  36532. * Unregisters a function called after every frame render
  36533. * @param func defines the function to unregister
  36534. */
  36535. unregisterAfterRender(func: () => void): void;
  36536. private _executeOnceBeforeRender;
  36537. /**
  36538. * The provided function will run before render once and will be disposed afterwards.
  36539. * A timeout delay can be provided so that the function will be executed in N ms.
  36540. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36541. * @param func The function to be executed.
  36542. * @param timeout optional delay in ms
  36543. */
  36544. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36545. /** @hidden */
  36546. _addPendingData(data: any): void;
  36547. /** @hidden */
  36548. _removePendingData(data: any): void;
  36549. /**
  36550. * Returns the number of items waiting to be loaded
  36551. * @returns the number of items waiting to be loaded
  36552. */
  36553. getWaitingItemsCount(): number;
  36554. /**
  36555. * Returns a boolean indicating if the scene is still loading data
  36556. */
  36557. readonly isLoading: boolean;
  36558. /**
  36559. * Registers a function to be executed when the scene is ready
  36560. * @param {Function} func - the function to be executed
  36561. */
  36562. executeWhenReady(func: () => void): void;
  36563. /**
  36564. * Returns a promise that resolves when the scene is ready
  36565. * @returns A promise that resolves when the scene is ready
  36566. */
  36567. whenReadyAsync(): Promise<void>;
  36568. /** @hidden */
  36569. _checkIsReady(): void;
  36570. /**
  36571. * Gets all animatable attached to the scene
  36572. */
  36573. readonly animatables: Animatable[];
  36574. /**
  36575. * Resets the last animation time frame.
  36576. * Useful to override when animations start running when loading a scene for the first time.
  36577. */
  36578. resetLastAnimationTimeFrame(): void;
  36579. /**
  36580. * Gets the current view matrix
  36581. * @returns a Matrix
  36582. */
  36583. getViewMatrix(): Matrix;
  36584. /**
  36585. * Gets the current projection matrix
  36586. * @returns a Matrix
  36587. */
  36588. getProjectionMatrix(): Matrix;
  36589. /**
  36590. * Gets the current transform matrix
  36591. * @returns a Matrix made of View * Projection
  36592. */
  36593. getTransformMatrix(): Matrix;
  36594. /**
  36595. * Sets the current transform matrix
  36596. * @param viewL defines the View matrix to use
  36597. * @param projectionL defines the Projection matrix to use
  36598. * @param viewR defines the right View matrix to use (if provided)
  36599. * @param projectionR defines the right Projection matrix to use (if provided)
  36600. */
  36601. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36602. /**
  36603. * Gets the uniform buffer used to store scene data
  36604. * @returns a UniformBuffer
  36605. */
  36606. getSceneUniformBuffer(): UniformBuffer;
  36607. /**
  36608. * Gets an unique (relatively to the current scene) Id
  36609. * @returns an unique number for the scene
  36610. */
  36611. getUniqueId(): number;
  36612. /**
  36613. * Add a mesh to the list of scene's meshes
  36614. * @param newMesh defines the mesh to add
  36615. * @param recursive if all child meshes should also be added to the scene
  36616. */
  36617. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36618. /**
  36619. * Remove a mesh for the list of scene's meshes
  36620. * @param toRemove defines the mesh to remove
  36621. * @param recursive if all child meshes should also be removed from the scene
  36622. * @returns the index where the mesh was in the mesh list
  36623. */
  36624. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36625. /**
  36626. * Add a transform node to the list of scene's transform nodes
  36627. * @param newTransformNode defines the transform node to add
  36628. */
  36629. addTransformNode(newTransformNode: TransformNode): void;
  36630. /**
  36631. * Remove a transform node for the list of scene's transform nodes
  36632. * @param toRemove defines the transform node to remove
  36633. * @returns the index where the transform node was in the transform node list
  36634. */
  36635. removeTransformNode(toRemove: TransformNode): number;
  36636. /**
  36637. * Remove a skeleton for the list of scene's skeletons
  36638. * @param toRemove defines the skeleton to remove
  36639. * @returns the index where the skeleton was in the skeleton list
  36640. */
  36641. removeSkeleton(toRemove: Skeleton): number;
  36642. /**
  36643. * Remove a morph target for the list of scene's morph targets
  36644. * @param toRemove defines the morph target to remove
  36645. * @returns the index where the morph target was in the morph target list
  36646. */
  36647. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36648. /**
  36649. * Remove a light for the list of scene's lights
  36650. * @param toRemove defines the light to remove
  36651. * @returns the index where the light was in the light list
  36652. */
  36653. removeLight(toRemove: Light): number;
  36654. /**
  36655. * Remove a camera for the list of scene's cameras
  36656. * @param toRemove defines the camera to remove
  36657. * @returns the index where the camera was in the camera list
  36658. */
  36659. removeCamera(toRemove: Camera): number;
  36660. /**
  36661. * Remove a particle system for the list of scene's particle systems
  36662. * @param toRemove defines the particle system to remove
  36663. * @returns the index where the particle system was in the particle system list
  36664. */
  36665. removeParticleSystem(toRemove: IParticleSystem): number;
  36666. /**
  36667. * Remove a animation for the list of scene's animations
  36668. * @param toRemove defines the animation to remove
  36669. * @returns the index where the animation was in the animation list
  36670. */
  36671. removeAnimation(toRemove: Animation): number;
  36672. /**
  36673. * Will stop the animation of the given target
  36674. * @param target - the target
  36675. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36676. * @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)
  36677. */
  36678. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36679. /**
  36680. * Removes the given animation group from this scene.
  36681. * @param toRemove The animation group to remove
  36682. * @returns The index of the removed animation group
  36683. */
  36684. removeAnimationGroup(toRemove: AnimationGroup): number;
  36685. /**
  36686. * Removes the given multi-material from this scene.
  36687. * @param toRemove The multi-material to remove
  36688. * @returns The index of the removed multi-material
  36689. */
  36690. removeMultiMaterial(toRemove: MultiMaterial): number;
  36691. /**
  36692. * Removes the given material from this scene.
  36693. * @param toRemove The material to remove
  36694. * @returns The index of the removed material
  36695. */
  36696. removeMaterial(toRemove: Material): number;
  36697. /**
  36698. * Removes the given action manager from this scene.
  36699. * @param toRemove The action manager to remove
  36700. * @returns The index of the removed action manager
  36701. */
  36702. removeActionManager(toRemove: AbstractActionManager): number;
  36703. /**
  36704. * Removes the given texture from this scene.
  36705. * @param toRemove The texture to remove
  36706. * @returns The index of the removed texture
  36707. */
  36708. removeTexture(toRemove: BaseTexture): number;
  36709. /**
  36710. * Adds the given light to this scene
  36711. * @param newLight The light to add
  36712. */
  36713. addLight(newLight: Light): void;
  36714. /**
  36715. * Sorts the list list based on light priorities
  36716. */
  36717. sortLightsByPriority(): void;
  36718. /**
  36719. * Adds the given camera to this scene
  36720. * @param newCamera The camera to add
  36721. */
  36722. addCamera(newCamera: Camera): void;
  36723. /**
  36724. * Adds the given skeleton to this scene
  36725. * @param newSkeleton The skeleton to add
  36726. */
  36727. addSkeleton(newSkeleton: Skeleton): void;
  36728. /**
  36729. * Adds the given particle system to this scene
  36730. * @param newParticleSystem The particle system to add
  36731. */
  36732. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36733. /**
  36734. * Adds the given animation to this scene
  36735. * @param newAnimation The animation to add
  36736. */
  36737. addAnimation(newAnimation: Animation): void;
  36738. /**
  36739. * Adds the given animation group to this scene.
  36740. * @param newAnimationGroup The animation group to add
  36741. */
  36742. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36743. /**
  36744. * Adds the given multi-material to this scene
  36745. * @param newMultiMaterial The multi-material to add
  36746. */
  36747. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36748. /**
  36749. * Adds the given material to this scene
  36750. * @param newMaterial The material to add
  36751. */
  36752. addMaterial(newMaterial: Material): void;
  36753. /**
  36754. * Adds the given morph target to this scene
  36755. * @param newMorphTargetManager The morph target to add
  36756. */
  36757. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36758. /**
  36759. * Adds the given geometry to this scene
  36760. * @param newGeometry The geometry to add
  36761. */
  36762. addGeometry(newGeometry: Geometry): void;
  36763. /**
  36764. * Adds the given action manager to this scene
  36765. * @param newActionManager The action manager to add
  36766. */
  36767. addActionManager(newActionManager: AbstractActionManager): void;
  36768. /**
  36769. * Adds the given texture to this scene.
  36770. * @param newTexture The texture to add
  36771. */
  36772. addTexture(newTexture: BaseTexture): void;
  36773. /**
  36774. * Switch active camera
  36775. * @param newCamera defines the new active camera
  36776. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36777. */
  36778. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36779. /**
  36780. * sets the active camera of the scene using its ID
  36781. * @param id defines the camera's ID
  36782. * @return the new active camera or null if none found.
  36783. */
  36784. setActiveCameraByID(id: string): Nullable<Camera>;
  36785. /**
  36786. * sets the active camera of the scene using its name
  36787. * @param name defines the camera's name
  36788. * @returns the new active camera or null if none found.
  36789. */
  36790. setActiveCameraByName(name: string): Nullable<Camera>;
  36791. /**
  36792. * get an animation group using its name
  36793. * @param name defines the material's name
  36794. * @return the animation group or null if none found.
  36795. */
  36796. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36797. /**
  36798. * Get a material using its unique id
  36799. * @param uniqueId defines the material's unique id
  36800. * @return the material or null if none found.
  36801. */
  36802. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36803. /**
  36804. * get a material using its id
  36805. * @param id defines the material's ID
  36806. * @return the material or null if none found.
  36807. */
  36808. getMaterialByID(id: string): Nullable<Material>;
  36809. /**
  36810. * Gets a the last added material using a given id
  36811. * @param id defines the material's ID
  36812. * @return the last material with the given id or null if none found.
  36813. */
  36814. getLastMaterialByID(id: string): Nullable<Material>;
  36815. /**
  36816. * Gets a material using its name
  36817. * @param name defines the material's name
  36818. * @return the material or null if none found.
  36819. */
  36820. getMaterialByName(name: string): Nullable<Material>;
  36821. /**
  36822. * Get a texture using its unique id
  36823. * @param uniqueId defines the texture's unique id
  36824. * @return the texture or null if none found.
  36825. */
  36826. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36827. /**
  36828. * Gets a camera using its id
  36829. * @param id defines the id to look for
  36830. * @returns the camera or null if not found
  36831. */
  36832. getCameraByID(id: string): Nullable<Camera>;
  36833. /**
  36834. * Gets a camera using its unique id
  36835. * @param uniqueId defines the unique id to look for
  36836. * @returns the camera or null if not found
  36837. */
  36838. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36839. /**
  36840. * Gets a camera using its name
  36841. * @param name defines the camera's name
  36842. * @return the camera or null if none found.
  36843. */
  36844. getCameraByName(name: string): Nullable<Camera>;
  36845. /**
  36846. * Gets a bone using its id
  36847. * @param id defines the bone's id
  36848. * @return the bone or null if not found
  36849. */
  36850. getBoneByID(id: string): Nullable<Bone>;
  36851. /**
  36852. * Gets a bone using its id
  36853. * @param name defines the bone's name
  36854. * @return the bone or null if not found
  36855. */
  36856. getBoneByName(name: string): Nullable<Bone>;
  36857. /**
  36858. * Gets a light node using its name
  36859. * @param name defines the the light's name
  36860. * @return the light or null if none found.
  36861. */
  36862. getLightByName(name: string): Nullable<Light>;
  36863. /**
  36864. * Gets a light node using its id
  36865. * @param id defines the light's id
  36866. * @return the light or null if none found.
  36867. */
  36868. getLightByID(id: string): Nullable<Light>;
  36869. /**
  36870. * Gets a light node using its scene-generated unique ID
  36871. * @param uniqueId defines the light's unique id
  36872. * @return the light or null if none found.
  36873. */
  36874. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36875. /**
  36876. * Gets a particle system by id
  36877. * @param id defines the particle system id
  36878. * @return the corresponding system or null if none found
  36879. */
  36880. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36881. /**
  36882. * Gets a geometry using its ID
  36883. * @param id defines the geometry's id
  36884. * @return the geometry or null if none found.
  36885. */
  36886. getGeometryByID(id: string): Nullable<Geometry>;
  36887. private _getGeometryByUniqueID;
  36888. /**
  36889. * Add a new geometry to this scene
  36890. * @param geometry defines the geometry to be added to the scene.
  36891. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36892. * @return a boolean defining if the geometry was added or not
  36893. */
  36894. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36895. /**
  36896. * Removes an existing geometry
  36897. * @param geometry defines the geometry to be removed from the scene
  36898. * @return a boolean defining if the geometry was removed or not
  36899. */
  36900. removeGeometry(geometry: Geometry): boolean;
  36901. /**
  36902. * Gets the list of geometries attached to the scene
  36903. * @returns an array of Geometry
  36904. */
  36905. getGeometries(): Geometry[];
  36906. /**
  36907. * Gets the first added mesh found of a given ID
  36908. * @param id defines the id to search for
  36909. * @return the mesh found or null if not found at all
  36910. */
  36911. getMeshByID(id: string): Nullable<AbstractMesh>;
  36912. /**
  36913. * Gets a list of meshes using their id
  36914. * @param id defines the id to search for
  36915. * @returns a list of meshes
  36916. */
  36917. getMeshesByID(id: string): Array<AbstractMesh>;
  36918. /**
  36919. * Gets the first added transform node found of a given ID
  36920. * @param id defines the id to search for
  36921. * @return the found transform node or null if not found at all.
  36922. */
  36923. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36924. /**
  36925. * Gets a transform node with its auto-generated unique id
  36926. * @param uniqueId efines the unique id to search for
  36927. * @return the found transform node or null if not found at all.
  36928. */
  36929. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36930. /**
  36931. * Gets a list of transform nodes using their id
  36932. * @param id defines the id to search for
  36933. * @returns a list of transform nodes
  36934. */
  36935. getTransformNodesByID(id: string): Array<TransformNode>;
  36936. /**
  36937. * Gets a mesh with its auto-generated unique id
  36938. * @param uniqueId defines the unique id to search for
  36939. * @return the found mesh or null if not found at all.
  36940. */
  36941. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36942. /**
  36943. * Gets a the last added mesh using a given id
  36944. * @param id defines the id to search for
  36945. * @return the found mesh or null if not found at all.
  36946. */
  36947. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36948. /**
  36949. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36950. * @param id defines the id to search for
  36951. * @return the found node or null if not found at all
  36952. */
  36953. getLastEntryByID(id: string): Nullable<Node>;
  36954. /**
  36955. * Gets a node (Mesh, Camera, Light) using a given id
  36956. * @param id defines the id to search for
  36957. * @return the found node or null if not found at all
  36958. */
  36959. getNodeByID(id: string): Nullable<Node>;
  36960. /**
  36961. * Gets a node (Mesh, Camera, Light) using a given name
  36962. * @param name defines the name to search for
  36963. * @return the found node or null if not found at all.
  36964. */
  36965. getNodeByName(name: string): Nullable<Node>;
  36966. /**
  36967. * Gets a mesh using a given name
  36968. * @param name defines the name to search for
  36969. * @return the found mesh or null if not found at all.
  36970. */
  36971. getMeshByName(name: string): Nullable<AbstractMesh>;
  36972. /**
  36973. * Gets a transform node using a given name
  36974. * @param name defines the name to search for
  36975. * @return the found transform node or null if not found at all.
  36976. */
  36977. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36978. /**
  36979. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36980. * @param id defines the id to search for
  36981. * @return the found skeleton or null if not found at all.
  36982. */
  36983. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36984. /**
  36985. * Gets a skeleton using a given auto generated unique id
  36986. * @param uniqueId defines the unique id to search for
  36987. * @return the found skeleton or null if not found at all.
  36988. */
  36989. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36990. /**
  36991. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36992. * @param id defines the id to search for
  36993. * @return the found skeleton or null if not found at all.
  36994. */
  36995. getSkeletonById(id: string): Nullable<Skeleton>;
  36996. /**
  36997. * Gets a skeleton using a given name
  36998. * @param name defines the name to search for
  36999. * @return the found skeleton or null if not found at all.
  37000. */
  37001. getSkeletonByName(name: string): Nullable<Skeleton>;
  37002. /**
  37003. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37004. * @param id defines the id to search for
  37005. * @return the found morph target manager or null if not found at all.
  37006. */
  37007. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37008. /**
  37009. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37010. * @param id defines the id to search for
  37011. * @return the found morph target or null if not found at all.
  37012. */
  37013. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37014. /**
  37015. * Gets a boolean indicating if the given mesh is active
  37016. * @param mesh defines the mesh to look for
  37017. * @returns true if the mesh is in the active list
  37018. */
  37019. isActiveMesh(mesh: AbstractMesh): boolean;
  37020. /**
  37021. * Return a unique id as a string which can serve as an identifier for the scene
  37022. */
  37023. readonly uid: string;
  37024. /**
  37025. * Add an externaly attached data from its key.
  37026. * This method call will fail and return false, if such key already exists.
  37027. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37028. * @param key the unique key that identifies the data
  37029. * @param data the data object to associate to the key for this Engine instance
  37030. * @return true if no such key were already present and the data was added successfully, false otherwise
  37031. */
  37032. addExternalData<T>(key: string, data: T): boolean;
  37033. /**
  37034. * Get an externaly attached data from its key
  37035. * @param key the unique key that identifies the data
  37036. * @return the associated data, if present (can be null), or undefined if not present
  37037. */
  37038. getExternalData<T>(key: string): Nullable<T>;
  37039. /**
  37040. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37041. * @param key the unique key that identifies the data
  37042. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37043. * @return the associated data, can be null if the factory returned null.
  37044. */
  37045. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37046. /**
  37047. * Remove an externaly attached data from the Engine instance
  37048. * @param key the unique key that identifies the data
  37049. * @return true if the data was successfully removed, false if it doesn't exist
  37050. */
  37051. removeExternalData(key: string): boolean;
  37052. private _evaluateSubMesh;
  37053. /**
  37054. * Clear the processed materials smart array preventing retention point in material dispose.
  37055. */
  37056. freeProcessedMaterials(): void;
  37057. private _preventFreeActiveMeshesAndRenderingGroups;
  37058. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37059. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37060. * when disposing several meshes in a row or a hierarchy of meshes.
  37061. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37062. */
  37063. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37064. /**
  37065. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37066. */
  37067. freeActiveMeshes(): void;
  37068. /**
  37069. * Clear the info related to rendering groups preventing retention points during dispose.
  37070. */
  37071. freeRenderingGroups(): void;
  37072. /** @hidden */
  37073. _isInIntermediateRendering(): boolean;
  37074. /**
  37075. * Lambda returning the list of potentially active meshes.
  37076. */
  37077. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37078. /**
  37079. * Lambda returning the list of potentially active sub meshes.
  37080. */
  37081. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37082. /**
  37083. * Lambda returning the list of potentially intersecting sub meshes.
  37084. */
  37085. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37086. /**
  37087. * Lambda returning the list of potentially colliding sub meshes.
  37088. */
  37089. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37090. private _activeMeshesFrozen;
  37091. private _skipEvaluateActiveMeshesCompletely;
  37092. /**
  37093. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37094. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37095. * @returns the current scene
  37096. */
  37097. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37098. /**
  37099. * Use this function to restart evaluating active meshes on every frame
  37100. * @returns the current scene
  37101. */
  37102. unfreezeActiveMeshes(): Scene;
  37103. private _evaluateActiveMeshes;
  37104. private _activeMesh;
  37105. /**
  37106. * Update the transform matrix to update from the current active camera
  37107. * @param force defines a boolean used to force the update even if cache is up to date
  37108. */
  37109. updateTransformMatrix(force?: boolean): void;
  37110. private _bindFrameBuffer;
  37111. /** @hidden */
  37112. _allowPostProcessClearColor: boolean;
  37113. /** @hidden */
  37114. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37115. private _processSubCameras;
  37116. private _checkIntersections;
  37117. /** @hidden */
  37118. _advancePhysicsEngineStep(step: number): void;
  37119. /**
  37120. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37121. */
  37122. getDeterministicFrameTime: () => number;
  37123. /** @hidden */
  37124. _animate(): void;
  37125. /** Execute all animations (for a frame) */
  37126. animate(): void;
  37127. /**
  37128. * Render the scene
  37129. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37130. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37131. */
  37132. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37133. /**
  37134. * Freeze all materials
  37135. * A frozen material will not be updatable but should be faster to render
  37136. */
  37137. freezeMaterials(): void;
  37138. /**
  37139. * Unfreeze all materials
  37140. * A frozen material will not be updatable but should be faster to render
  37141. */
  37142. unfreezeMaterials(): void;
  37143. /**
  37144. * Releases all held ressources
  37145. */
  37146. dispose(): void;
  37147. /**
  37148. * Gets if the scene is already disposed
  37149. */
  37150. readonly isDisposed: boolean;
  37151. /**
  37152. * Call this function to reduce memory footprint of the scene.
  37153. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37154. */
  37155. clearCachedVertexData(): void;
  37156. /**
  37157. * This function will remove the local cached buffer data from texture.
  37158. * It will save memory but will prevent the texture from being rebuilt
  37159. */
  37160. cleanCachedTextureBuffer(): void;
  37161. /**
  37162. * Get the world extend vectors with an optional filter
  37163. *
  37164. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37165. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37166. */
  37167. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37168. min: Vector3;
  37169. max: Vector3;
  37170. };
  37171. /**
  37172. * Creates a ray that can be used to pick in the scene
  37173. * @param x defines the x coordinate of the origin (on-screen)
  37174. * @param y defines the y coordinate of the origin (on-screen)
  37175. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37176. * @param camera defines the camera to use for the picking
  37177. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37178. * @returns a Ray
  37179. */
  37180. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37181. /**
  37182. * Creates a ray that can be used to pick in the scene
  37183. * @param x defines the x coordinate of the origin (on-screen)
  37184. * @param y defines the y coordinate of the origin (on-screen)
  37185. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37186. * @param result defines the ray where to store the picking ray
  37187. * @param camera defines the camera to use for the picking
  37188. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37189. * @returns the current scene
  37190. */
  37191. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37192. /**
  37193. * Creates a ray that can be used to pick in the scene
  37194. * @param x defines the x coordinate of the origin (on-screen)
  37195. * @param y defines the y coordinate of the origin (on-screen)
  37196. * @param camera defines the camera to use for the picking
  37197. * @returns a Ray
  37198. */
  37199. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37200. /**
  37201. * Creates a ray that can be used to pick in the scene
  37202. * @param x defines the x coordinate of the origin (on-screen)
  37203. * @param y defines the y coordinate of the origin (on-screen)
  37204. * @param result defines the ray where to store the picking ray
  37205. * @param camera defines the camera to use for the picking
  37206. * @returns the current scene
  37207. */
  37208. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37209. /** Launch a ray to try to pick a mesh in the scene
  37210. * @param x position on screen
  37211. * @param y position on screen
  37212. * @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
  37213. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37214. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37215. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37216. * @returns a PickingInfo
  37217. */
  37218. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37219. /** Use the given ray to pick a mesh in the scene
  37220. * @param ray The ray to use to pick meshes
  37221. * @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
  37222. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37224. * @returns a PickingInfo
  37225. */
  37226. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37227. /**
  37228. * Launch a ray to try to pick a mesh in the scene
  37229. * @param x X position on screen
  37230. * @param y Y position on screen
  37231. * @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
  37232. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37233. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37234. * @returns an array of PickingInfo
  37235. */
  37236. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37237. /**
  37238. * Launch a ray to try to pick a mesh in the scene
  37239. * @param ray Ray to use
  37240. * @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
  37241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37242. * @returns an array of PickingInfo
  37243. */
  37244. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37245. /**
  37246. * Force the value of meshUnderPointer
  37247. * @param mesh defines the mesh to use
  37248. */
  37249. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37250. /**
  37251. * Gets the mesh under the pointer
  37252. * @returns a Mesh or null if no mesh is under the pointer
  37253. */
  37254. getPointerOverMesh(): Nullable<AbstractMesh>;
  37255. /** @hidden */
  37256. _rebuildGeometries(): void;
  37257. /** @hidden */
  37258. _rebuildTextures(): void;
  37259. private _getByTags;
  37260. /**
  37261. * Get a list of meshes by tags
  37262. * @param tagsQuery defines the tags query to use
  37263. * @param forEach defines a predicate used to filter results
  37264. * @returns an array of Mesh
  37265. */
  37266. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37267. /**
  37268. * Get a list of cameras by tags
  37269. * @param tagsQuery defines the tags query to use
  37270. * @param forEach defines a predicate used to filter results
  37271. * @returns an array of Camera
  37272. */
  37273. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37274. /**
  37275. * Get a list of lights by tags
  37276. * @param tagsQuery defines the tags query to use
  37277. * @param forEach defines a predicate used to filter results
  37278. * @returns an array of Light
  37279. */
  37280. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37281. /**
  37282. * Get a list of materials by tags
  37283. * @param tagsQuery defines the tags query to use
  37284. * @param forEach defines a predicate used to filter results
  37285. * @returns an array of Material
  37286. */
  37287. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37288. /**
  37289. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37290. * This allowed control for front to back rendering or reversly depending of the special needs.
  37291. *
  37292. * @param renderingGroupId The rendering group id corresponding to its index
  37293. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37294. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37295. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37296. */
  37297. 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;
  37298. /**
  37299. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37300. *
  37301. * @param renderingGroupId The rendering group id corresponding to its index
  37302. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37303. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37304. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37305. */
  37306. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37307. /**
  37308. * Gets the current auto clear configuration for one rendering group of the rendering
  37309. * manager.
  37310. * @param index the rendering group index to get the information for
  37311. * @returns The auto clear setup for the requested rendering group
  37312. */
  37313. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37314. private _blockMaterialDirtyMechanism;
  37315. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37316. blockMaterialDirtyMechanism: boolean;
  37317. /**
  37318. * Will flag all materials as dirty to trigger new shader compilation
  37319. * @param flag defines the flag used to specify which material part must be marked as dirty
  37320. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37321. */
  37322. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37323. /** @hidden */
  37324. _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;
  37325. /** @hidden */
  37326. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37327. /** @hidden */
  37328. _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;
  37329. /** @hidden */
  37330. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37331. /** @hidden */
  37332. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37333. /** @hidden */
  37334. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37335. }
  37336. }
  37337. declare module "babylonjs/assetContainer" {
  37338. import { AbstractScene } from "babylonjs/abstractScene";
  37339. import { Scene } from "babylonjs/scene";
  37340. import { Mesh } from "babylonjs/Meshes/mesh";
  37341. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37342. import { Skeleton } from "babylonjs/Bones/skeleton";
  37343. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37344. /**
  37345. * Set of assets to keep when moving a scene into an asset container.
  37346. */
  37347. export class KeepAssets extends AbstractScene {
  37348. }
  37349. /**
  37350. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37351. */
  37352. export class InstantiatedEntries {
  37353. /**
  37354. * List of new root nodes (eg. nodes with no parent)
  37355. */
  37356. rootNodes: TransformNode[];
  37357. /**
  37358. * List of new skeletons
  37359. */
  37360. skeletons: Skeleton[];
  37361. /**
  37362. * List of new animation groups
  37363. */
  37364. animationGroups: AnimationGroup[];
  37365. }
  37366. /**
  37367. * Container with a set of assets that can be added or removed from a scene.
  37368. */
  37369. export class AssetContainer extends AbstractScene {
  37370. /**
  37371. * The scene the AssetContainer belongs to.
  37372. */
  37373. scene: Scene;
  37374. /**
  37375. * Instantiates an AssetContainer.
  37376. * @param scene The scene the AssetContainer belongs to.
  37377. */
  37378. constructor(scene: Scene);
  37379. /**
  37380. * Instantiate or clone all meshes and add the new ones to the scene.
  37381. * Skeletons and animation groups will all be cloned
  37382. * @param nameFunction defines an optional function used to get new names for clones
  37383. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37384. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37385. */
  37386. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37387. /**
  37388. * Adds all the assets from the container to the scene.
  37389. */
  37390. addAllToScene(): void;
  37391. /**
  37392. * Removes all the assets in the container from the scene
  37393. */
  37394. removeAllFromScene(): void;
  37395. /**
  37396. * Disposes all the assets in the container
  37397. */
  37398. dispose(): void;
  37399. private _moveAssets;
  37400. /**
  37401. * Removes all the assets contained in the scene and adds them to the container.
  37402. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37403. */
  37404. moveAllFromScene(keepAssets?: KeepAssets): void;
  37405. /**
  37406. * 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.
  37407. * @returns the root mesh
  37408. */
  37409. createRootMesh(): Mesh;
  37410. }
  37411. }
  37412. declare module "babylonjs/abstractScene" {
  37413. import { Scene } from "babylonjs/scene";
  37414. import { Nullable } from "babylonjs/types";
  37415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37416. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37417. import { Geometry } from "babylonjs/Meshes/geometry";
  37418. import { Skeleton } from "babylonjs/Bones/skeleton";
  37419. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37420. import { AssetContainer } from "babylonjs/assetContainer";
  37421. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37422. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37424. import { Material } from "babylonjs/Materials/material";
  37425. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37426. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37427. import { Camera } from "babylonjs/Cameras/camera";
  37428. import { Light } from "babylonjs/Lights/light";
  37429. import { Node } from "babylonjs/node";
  37430. import { Animation } from "babylonjs/Animations/animation";
  37431. /**
  37432. * Defines how the parser contract is defined.
  37433. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37434. */
  37435. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37436. /**
  37437. * Defines how the individual parser contract is defined.
  37438. * These parser can parse an individual asset
  37439. */
  37440. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37441. /**
  37442. * Base class of the scene acting as a container for the different elements composing a scene.
  37443. * This class is dynamically extended by the different components of the scene increasing
  37444. * flexibility and reducing coupling
  37445. */
  37446. export abstract class AbstractScene {
  37447. /**
  37448. * Stores the list of available parsers in the application.
  37449. */
  37450. private static _BabylonFileParsers;
  37451. /**
  37452. * Stores the list of available individual parsers in the application.
  37453. */
  37454. private static _IndividualBabylonFileParsers;
  37455. /**
  37456. * Adds a parser in the list of available ones
  37457. * @param name Defines the name of the parser
  37458. * @param parser Defines the parser to add
  37459. */
  37460. static AddParser(name: string, parser: BabylonFileParser): void;
  37461. /**
  37462. * Gets a general parser from the list of avaialble ones
  37463. * @param name Defines the name of the parser
  37464. * @returns the requested parser or null
  37465. */
  37466. static GetParser(name: string): Nullable<BabylonFileParser>;
  37467. /**
  37468. * Adds n individual parser in the list of available ones
  37469. * @param name Defines the name of the parser
  37470. * @param parser Defines the parser to add
  37471. */
  37472. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37473. /**
  37474. * Gets an individual parser from the list of avaialble ones
  37475. * @param name Defines the name of the parser
  37476. * @returns the requested parser or null
  37477. */
  37478. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37479. /**
  37480. * Parser json data and populate both a scene and its associated container object
  37481. * @param jsonData Defines the data to parse
  37482. * @param scene Defines the scene to parse the data for
  37483. * @param container Defines the container attached to the parsing sequence
  37484. * @param rootUrl Defines the root url of the data
  37485. */
  37486. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37487. /**
  37488. * Gets the list of root nodes (ie. nodes with no parent)
  37489. */
  37490. rootNodes: Node[];
  37491. /** All of the cameras added to this scene
  37492. * @see http://doc.babylonjs.com/babylon101/cameras
  37493. */
  37494. cameras: Camera[];
  37495. /**
  37496. * All of the lights added to this scene
  37497. * @see http://doc.babylonjs.com/babylon101/lights
  37498. */
  37499. lights: Light[];
  37500. /**
  37501. * All of the (abstract) meshes added to this scene
  37502. */
  37503. meshes: AbstractMesh[];
  37504. /**
  37505. * The list of skeletons added to the scene
  37506. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37507. */
  37508. skeletons: Skeleton[];
  37509. /**
  37510. * All of the particle systems added to this scene
  37511. * @see http://doc.babylonjs.com/babylon101/particles
  37512. */
  37513. particleSystems: IParticleSystem[];
  37514. /**
  37515. * Gets a list of Animations associated with the scene
  37516. */
  37517. animations: Animation[];
  37518. /**
  37519. * All of the animation groups added to this scene
  37520. * @see http://doc.babylonjs.com/how_to/group
  37521. */
  37522. animationGroups: AnimationGroup[];
  37523. /**
  37524. * All of the multi-materials added to this scene
  37525. * @see http://doc.babylonjs.com/how_to/multi_materials
  37526. */
  37527. multiMaterials: MultiMaterial[];
  37528. /**
  37529. * All of the materials added to this scene
  37530. * In the context of a Scene, it is not supposed to be modified manually.
  37531. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37532. * Note also that the order of the Material within the array is not significant and might change.
  37533. * @see http://doc.babylonjs.com/babylon101/materials
  37534. */
  37535. materials: Material[];
  37536. /**
  37537. * The list of morph target managers added to the scene
  37538. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37539. */
  37540. morphTargetManagers: MorphTargetManager[];
  37541. /**
  37542. * The list of geometries used in the scene.
  37543. */
  37544. geometries: Geometry[];
  37545. /**
  37546. * All of the tranform nodes added to this scene
  37547. * In the context of a Scene, it is not supposed to be modified manually.
  37548. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37549. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37550. * @see http://doc.babylonjs.com/how_to/transformnode
  37551. */
  37552. transformNodes: TransformNode[];
  37553. /**
  37554. * ActionManagers available on the scene.
  37555. */
  37556. actionManagers: AbstractActionManager[];
  37557. /**
  37558. * Textures to keep.
  37559. */
  37560. textures: BaseTexture[];
  37561. /**
  37562. * Environment texture for the scene
  37563. */
  37564. environmentTexture: Nullable<BaseTexture>;
  37565. }
  37566. }
  37567. declare module "babylonjs/Audio/sound" {
  37568. import { Observable } from "babylonjs/Misc/observable";
  37569. import { Vector3 } from "babylonjs/Maths/math.vector";
  37570. import { Nullable } from "babylonjs/types";
  37571. import { Scene } from "babylonjs/scene";
  37572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37573. /**
  37574. * Interface used to define options for Sound class
  37575. */
  37576. export interface ISoundOptions {
  37577. /**
  37578. * Does the sound autoplay once loaded.
  37579. */
  37580. autoplay?: boolean;
  37581. /**
  37582. * Does the sound loop after it finishes playing once.
  37583. */
  37584. loop?: boolean;
  37585. /**
  37586. * Sound's volume
  37587. */
  37588. volume?: number;
  37589. /**
  37590. * Is it a spatial sound?
  37591. */
  37592. spatialSound?: boolean;
  37593. /**
  37594. * Maximum distance to hear that sound
  37595. */
  37596. maxDistance?: number;
  37597. /**
  37598. * Uses user defined attenuation function
  37599. */
  37600. useCustomAttenuation?: boolean;
  37601. /**
  37602. * Define the roll off factor of spatial sounds.
  37603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37604. */
  37605. rolloffFactor?: number;
  37606. /**
  37607. * Define the reference distance the sound should be heard perfectly.
  37608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37609. */
  37610. refDistance?: number;
  37611. /**
  37612. * Define the distance attenuation model the sound will follow.
  37613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37614. */
  37615. distanceModel?: string;
  37616. /**
  37617. * Defines the playback speed (1 by default)
  37618. */
  37619. playbackRate?: number;
  37620. /**
  37621. * Defines if the sound is from a streaming source
  37622. */
  37623. streaming?: boolean;
  37624. /**
  37625. * Defines an optional length (in seconds) inside the sound file
  37626. */
  37627. length?: number;
  37628. /**
  37629. * Defines an optional offset (in seconds) inside the sound file
  37630. */
  37631. offset?: number;
  37632. /**
  37633. * If true, URLs will not be required to state the audio file codec to use.
  37634. */
  37635. skipCodecCheck?: boolean;
  37636. }
  37637. /**
  37638. * Defines a sound that can be played in the application.
  37639. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37641. */
  37642. export class Sound {
  37643. /**
  37644. * The name of the sound in the scene.
  37645. */
  37646. name: string;
  37647. /**
  37648. * Does the sound autoplay once loaded.
  37649. */
  37650. autoplay: boolean;
  37651. /**
  37652. * Does the sound loop after it finishes playing once.
  37653. */
  37654. loop: boolean;
  37655. /**
  37656. * Does the sound use a custom attenuation curve to simulate the falloff
  37657. * happening when the source gets further away from the camera.
  37658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37659. */
  37660. useCustomAttenuation: boolean;
  37661. /**
  37662. * The sound track id this sound belongs to.
  37663. */
  37664. soundTrackId: number;
  37665. /**
  37666. * Is this sound currently played.
  37667. */
  37668. isPlaying: boolean;
  37669. /**
  37670. * Is this sound currently paused.
  37671. */
  37672. isPaused: boolean;
  37673. /**
  37674. * Does this sound enables spatial sound.
  37675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37676. */
  37677. spatialSound: boolean;
  37678. /**
  37679. * Define the reference distance the sound should be heard perfectly.
  37680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37681. */
  37682. refDistance: number;
  37683. /**
  37684. * Define the roll off factor of spatial sounds.
  37685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37686. */
  37687. rolloffFactor: number;
  37688. /**
  37689. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37691. */
  37692. maxDistance: number;
  37693. /**
  37694. * Define the distance attenuation model the sound will follow.
  37695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37696. */
  37697. distanceModel: string;
  37698. /**
  37699. * @hidden
  37700. * Back Compat
  37701. **/
  37702. onended: () => any;
  37703. /**
  37704. * Observable event when the current playing sound finishes.
  37705. */
  37706. onEndedObservable: Observable<Sound>;
  37707. private _panningModel;
  37708. private _playbackRate;
  37709. private _streaming;
  37710. private _startTime;
  37711. private _startOffset;
  37712. private _position;
  37713. /** @hidden */
  37714. _positionInEmitterSpace: boolean;
  37715. private _localDirection;
  37716. private _volume;
  37717. private _isReadyToPlay;
  37718. private _isDirectional;
  37719. private _readyToPlayCallback;
  37720. private _audioBuffer;
  37721. private _soundSource;
  37722. private _streamingSource;
  37723. private _soundPanner;
  37724. private _soundGain;
  37725. private _inputAudioNode;
  37726. private _outputAudioNode;
  37727. private _coneInnerAngle;
  37728. private _coneOuterAngle;
  37729. private _coneOuterGain;
  37730. private _scene;
  37731. private _connectedTransformNode;
  37732. private _customAttenuationFunction;
  37733. private _registerFunc;
  37734. private _isOutputConnected;
  37735. private _htmlAudioElement;
  37736. private _urlType;
  37737. private _length?;
  37738. private _offset?;
  37739. /** @hidden */
  37740. static _SceneComponentInitialization: (scene: Scene) => void;
  37741. /**
  37742. * Create a sound and attach it to a scene
  37743. * @param name Name of your sound
  37744. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37745. * @param scene defines the scene the sound belongs to
  37746. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37747. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37748. */
  37749. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37750. /**
  37751. * Release the sound and its associated resources
  37752. */
  37753. dispose(): void;
  37754. /**
  37755. * Gets if the sounds is ready to be played or not.
  37756. * @returns true if ready, otherwise false
  37757. */
  37758. isReady(): boolean;
  37759. private _soundLoaded;
  37760. /**
  37761. * Sets the data of the sound from an audiobuffer
  37762. * @param audioBuffer The audioBuffer containing the data
  37763. */
  37764. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37765. /**
  37766. * Updates the current sounds options such as maxdistance, loop...
  37767. * @param options A JSON object containing values named as the object properties
  37768. */
  37769. updateOptions(options: ISoundOptions): void;
  37770. private _createSpatialParameters;
  37771. private _updateSpatialParameters;
  37772. /**
  37773. * Switch the panning model to HRTF:
  37774. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37775. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37776. */
  37777. switchPanningModelToHRTF(): void;
  37778. /**
  37779. * Switch the panning model to Equal Power:
  37780. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37782. */
  37783. switchPanningModelToEqualPower(): void;
  37784. private _switchPanningModel;
  37785. /**
  37786. * Connect this sound to a sound track audio node like gain...
  37787. * @param soundTrackAudioNode the sound track audio node to connect to
  37788. */
  37789. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37790. /**
  37791. * Transform this sound into a directional source
  37792. * @param coneInnerAngle Size of the inner cone in degree
  37793. * @param coneOuterAngle Size of the outer cone in degree
  37794. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37795. */
  37796. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37797. /**
  37798. * Gets or sets the inner angle for the directional cone.
  37799. */
  37800. /**
  37801. * Gets or sets the inner angle for the directional cone.
  37802. */
  37803. directionalConeInnerAngle: number;
  37804. /**
  37805. * Gets or sets the outer angle for the directional cone.
  37806. */
  37807. /**
  37808. * Gets or sets the outer angle for the directional cone.
  37809. */
  37810. directionalConeOuterAngle: number;
  37811. /**
  37812. * Sets the position of the emitter if spatial sound is enabled
  37813. * @param newPosition Defines the new posisiton
  37814. */
  37815. setPosition(newPosition: Vector3): void;
  37816. /**
  37817. * Sets the local direction of the emitter if spatial sound is enabled
  37818. * @param newLocalDirection Defines the new local direction
  37819. */
  37820. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37821. private _updateDirection;
  37822. /** @hidden */
  37823. updateDistanceFromListener(): void;
  37824. /**
  37825. * Sets a new custom attenuation function for the sound.
  37826. * @param callback Defines the function used for the attenuation
  37827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37828. */
  37829. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37830. /**
  37831. * Play the sound
  37832. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37833. * @param offset (optional) Start the sound at a specific time in seconds
  37834. * @param length (optional) Sound duration (in seconds)
  37835. */
  37836. play(time?: number, offset?: number, length?: number): void;
  37837. private _onended;
  37838. /**
  37839. * Stop the sound
  37840. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37841. */
  37842. stop(time?: number): void;
  37843. /**
  37844. * Put the sound in pause
  37845. */
  37846. pause(): void;
  37847. /**
  37848. * Sets a dedicated volume for this sounds
  37849. * @param newVolume Define the new volume of the sound
  37850. * @param time Define time for gradual change to new volume
  37851. */
  37852. setVolume(newVolume: number, time?: number): void;
  37853. /**
  37854. * Set the sound play back rate
  37855. * @param newPlaybackRate Define the playback rate the sound should be played at
  37856. */
  37857. setPlaybackRate(newPlaybackRate: number): void;
  37858. /**
  37859. * Gets the volume of the sound.
  37860. * @returns the volume of the sound
  37861. */
  37862. getVolume(): number;
  37863. /**
  37864. * Attach the sound to a dedicated mesh
  37865. * @param transformNode The transform node to connect the sound with
  37866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37867. */
  37868. attachToMesh(transformNode: TransformNode): void;
  37869. /**
  37870. * Detach the sound from the previously attached mesh
  37871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37872. */
  37873. detachFromMesh(): void;
  37874. private _onRegisterAfterWorldMatrixUpdate;
  37875. /**
  37876. * Clone the current sound in the scene.
  37877. * @returns the new sound clone
  37878. */
  37879. clone(): Nullable<Sound>;
  37880. /**
  37881. * Gets the current underlying audio buffer containing the data
  37882. * @returns the audio buffer
  37883. */
  37884. getAudioBuffer(): Nullable<AudioBuffer>;
  37885. /**
  37886. * Serializes the Sound in a JSON representation
  37887. * @returns the JSON representation of the sound
  37888. */
  37889. serialize(): any;
  37890. /**
  37891. * Parse a JSON representation of a sound to innstantiate in a given scene
  37892. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37893. * @param scene Define the scene the new parsed sound should be created in
  37894. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37895. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37896. * @returns the newly parsed sound
  37897. */
  37898. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37899. }
  37900. }
  37901. declare module "babylonjs/Actions/directAudioActions" {
  37902. import { Action } from "babylonjs/Actions/action";
  37903. import { Condition } from "babylonjs/Actions/condition";
  37904. import { Sound } from "babylonjs/Audio/sound";
  37905. /**
  37906. * This defines an action helpful to play a defined sound on a triggered action.
  37907. */
  37908. export class PlaySoundAction extends Action {
  37909. private _sound;
  37910. /**
  37911. * Instantiate the action
  37912. * @param triggerOptions defines the trigger options
  37913. * @param sound defines the sound to play
  37914. * @param condition defines the trigger related conditions
  37915. */
  37916. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37917. /** @hidden */
  37918. _prepare(): void;
  37919. /**
  37920. * Execute the action and play the sound.
  37921. */
  37922. execute(): void;
  37923. /**
  37924. * Serializes the actions and its related information.
  37925. * @param parent defines the object to serialize in
  37926. * @returns the serialized object
  37927. */
  37928. serialize(parent: any): any;
  37929. }
  37930. /**
  37931. * This defines an action helpful to stop a defined sound on a triggered action.
  37932. */
  37933. export class StopSoundAction extends Action {
  37934. private _sound;
  37935. /**
  37936. * Instantiate the action
  37937. * @param triggerOptions defines the trigger options
  37938. * @param sound defines the sound to stop
  37939. * @param condition defines the trigger related conditions
  37940. */
  37941. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37942. /** @hidden */
  37943. _prepare(): void;
  37944. /**
  37945. * Execute the action and stop the sound.
  37946. */
  37947. execute(): void;
  37948. /**
  37949. * Serializes the actions and its related information.
  37950. * @param parent defines the object to serialize in
  37951. * @returns the serialized object
  37952. */
  37953. serialize(parent: any): any;
  37954. }
  37955. }
  37956. declare module "babylonjs/Actions/interpolateValueAction" {
  37957. import { Action } from "babylonjs/Actions/action";
  37958. import { Condition } from "babylonjs/Actions/condition";
  37959. import { Observable } from "babylonjs/Misc/observable";
  37960. /**
  37961. * This defines an action responsible to change the value of a property
  37962. * by interpolating between its current value and the newly set one once triggered.
  37963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37964. */
  37965. export class InterpolateValueAction extends Action {
  37966. /**
  37967. * Defines the path of the property where the value should be interpolated
  37968. */
  37969. propertyPath: string;
  37970. /**
  37971. * Defines the target value at the end of the interpolation.
  37972. */
  37973. value: any;
  37974. /**
  37975. * Defines the time it will take for the property to interpolate to the value.
  37976. */
  37977. duration: number;
  37978. /**
  37979. * Defines if the other scene animations should be stopped when the action has been triggered
  37980. */
  37981. stopOtherAnimations?: boolean;
  37982. /**
  37983. * Defines a callback raised once the interpolation animation has been done.
  37984. */
  37985. onInterpolationDone?: () => void;
  37986. /**
  37987. * Observable triggered once the interpolation animation has been done.
  37988. */
  37989. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37990. private _target;
  37991. private _effectiveTarget;
  37992. private _property;
  37993. /**
  37994. * Instantiate the action
  37995. * @param triggerOptions defines the trigger options
  37996. * @param target defines the object containing the value to interpolate
  37997. * @param propertyPath defines the path to the property in the target object
  37998. * @param value defines the target value at the end of the interpolation
  37999. * @param duration deines the time it will take for the property to interpolate to the value.
  38000. * @param condition defines the trigger related conditions
  38001. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38002. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38003. */
  38004. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38005. /** @hidden */
  38006. _prepare(): void;
  38007. /**
  38008. * Execute the action starts the value interpolation.
  38009. */
  38010. execute(): void;
  38011. /**
  38012. * Serializes the actions and its related information.
  38013. * @param parent defines the object to serialize in
  38014. * @returns the serialized object
  38015. */
  38016. serialize(parent: any): any;
  38017. }
  38018. }
  38019. declare module "babylonjs/Actions/index" {
  38020. export * from "babylonjs/Actions/abstractActionManager";
  38021. export * from "babylonjs/Actions/action";
  38022. export * from "babylonjs/Actions/actionEvent";
  38023. export * from "babylonjs/Actions/actionManager";
  38024. export * from "babylonjs/Actions/condition";
  38025. export * from "babylonjs/Actions/directActions";
  38026. export * from "babylonjs/Actions/directAudioActions";
  38027. export * from "babylonjs/Actions/interpolateValueAction";
  38028. }
  38029. declare module "babylonjs/Animations/index" {
  38030. export * from "babylonjs/Animations/animatable";
  38031. export * from "babylonjs/Animations/animation";
  38032. export * from "babylonjs/Animations/animationGroup";
  38033. export * from "babylonjs/Animations/animationPropertiesOverride";
  38034. export * from "babylonjs/Animations/easing";
  38035. export * from "babylonjs/Animations/runtimeAnimation";
  38036. export * from "babylonjs/Animations/animationEvent";
  38037. export * from "babylonjs/Animations/animationGroup";
  38038. export * from "babylonjs/Animations/animationKey";
  38039. export * from "babylonjs/Animations/animationRange";
  38040. export * from "babylonjs/Animations/animatable.interface";
  38041. }
  38042. declare module "babylonjs/Audio/soundTrack" {
  38043. import { Sound } from "babylonjs/Audio/sound";
  38044. import { Analyser } from "babylonjs/Audio/analyser";
  38045. import { Scene } from "babylonjs/scene";
  38046. /**
  38047. * Options allowed during the creation of a sound track.
  38048. */
  38049. export interface ISoundTrackOptions {
  38050. /**
  38051. * The volume the sound track should take during creation
  38052. */
  38053. volume?: number;
  38054. /**
  38055. * Define if the sound track is the main sound track of the scene
  38056. */
  38057. mainTrack?: boolean;
  38058. }
  38059. /**
  38060. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38061. * It will be also used in a future release to apply effects on a specific track.
  38062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38063. */
  38064. export class SoundTrack {
  38065. /**
  38066. * The unique identifier of the sound track in the scene.
  38067. */
  38068. id: number;
  38069. /**
  38070. * The list of sounds included in the sound track.
  38071. */
  38072. soundCollection: Array<Sound>;
  38073. private _outputAudioNode;
  38074. private _scene;
  38075. private _connectedAnalyser;
  38076. private _options;
  38077. private _isInitialized;
  38078. /**
  38079. * Creates a new sound track.
  38080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38081. * @param scene Define the scene the sound track belongs to
  38082. * @param options
  38083. */
  38084. constructor(scene: Scene, options?: ISoundTrackOptions);
  38085. private _initializeSoundTrackAudioGraph;
  38086. /**
  38087. * Release the sound track and its associated resources
  38088. */
  38089. dispose(): void;
  38090. /**
  38091. * Adds a sound to this sound track
  38092. * @param sound define the cound to add
  38093. * @ignoreNaming
  38094. */
  38095. AddSound(sound: Sound): void;
  38096. /**
  38097. * Removes a sound to this sound track
  38098. * @param sound define the cound to remove
  38099. * @ignoreNaming
  38100. */
  38101. RemoveSound(sound: Sound): void;
  38102. /**
  38103. * Set a global volume for the full sound track.
  38104. * @param newVolume Define the new volume of the sound track
  38105. */
  38106. setVolume(newVolume: number): void;
  38107. /**
  38108. * Switch the panning model to HRTF:
  38109. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38111. */
  38112. switchPanningModelToHRTF(): void;
  38113. /**
  38114. * Switch the panning model to Equal Power:
  38115. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38117. */
  38118. switchPanningModelToEqualPower(): void;
  38119. /**
  38120. * Connect the sound track to an audio analyser allowing some amazing
  38121. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38123. * @param analyser The analyser to connect to the engine
  38124. */
  38125. connectToAnalyser(analyser: Analyser): void;
  38126. }
  38127. }
  38128. declare module "babylonjs/Audio/audioSceneComponent" {
  38129. import { Sound } from "babylonjs/Audio/sound";
  38130. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38131. import { Nullable } from "babylonjs/types";
  38132. import { Vector3 } from "babylonjs/Maths/math.vector";
  38133. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38134. import { Scene } from "babylonjs/scene";
  38135. import { AbstractScene } from "babylonjs/abstractScene";
  38136. import "babylonjs/Audio/audioEngine";
  38137. module "babylonjs/abstractScene" {
  38138. interface AbstractScene {
  38139. /**
  38140. * The list of sounds used in the scene.
  38141. */
  38142. sounds: Nullable<Array<Sound>>;
  38143. }
  38144. }
  38145. module "babylonjs/scene" {
  38146. interface Scene {
  38147. /**
  38148. * @hidden
  38149. * Backing field
  38150. */
  38151. _mainSoundTrack: SoundTrack;
  38152. /**
  38153. * The main sound track played by the scene.
  38154. * It cotains your primary collection of sounds.
  38155. */
  38156. mainSoundTrack: SoundTrack;
  38157. /**
  38158. * The list of sound tracks added to the scene
  38159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38160. */
  38161. soundTracks: Nullable<Array<SoundTrack>>;
  38162. /**
  38163. * Gets a sound using a given name
  38164. * @param name defines the name to search for
  38165. * @return the found sound or null if not found at all.
  38166. */
  38167. getSoundByName(name: string): Nullable<Sound>;
  38168. /**
  38169. * Gets or sets if audio support is enabled
  38170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38171. */
  38172. audioEnabled: boolean;
  38173. /**
  38174. * Gets or sets if audio will be output to headphones
  38175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38176. */
  38177. headphone: boolean;
  38178. /**
  38179. * Gets or sets custom audio listener position provider
  38180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38181. */
  38182. audioListenerPositionProvider: Nullable<() => Vector3>;
  38183. /**
  38184. * Gets or sets a refresh rate when using 3D audio positioning
  38185. */
  38186. audioPositioningRefreshRate: number;
  38187. }
  38188. }
  38189. /**
  38190. * Defines the sound scene component responsible to manage any sounds
  38191. * in a given scene.
  38192. */
  38193. export class AudioSceneComponent implements ISceneSerializableComponent {
  38194. /**
  38195. * The component name helpfull to identify the component in the list of scene components.
  38196. */
  38197. readonly name: string;
  38198. /**
  38199. * The scene the component belongs to.
  38200. */
  38201. scene: Scene;
  38202. private _audioEnabled;
  38203. /**
  38204. * Gets whether audio is enabled or not.
  38205. * Please use related enable/disable method to switch state.
  38206. */
  38207. readonly audioEnabled: boolean;
  38208. private _headphone;
  38209. /**
  38210. * Gets whether audio is outputing to headphone or not.
  38211. * Please use the according Switch methods to change output.
  38212. */
  38213. readonly headphone: boolean;
  38214. /**
  38215. * Gets or sets a refresh rate when using 3D audio positioning
  38216. */
  38217. audioPositioningRefreshRate: number;
  38218. private _audioListenerPositionProvider;
  38219. /**
  38220. * Gets the current audio listener position provider
  38221. */
  38222. /**
  38223. * Sets a custom listener position for all sounds in the scene
  38224. * By default, this is the position of the first active camera
  38225. */
  38226. audioListenerPositionProvider: Nullable<() => Vector3>;
  38227. /**
  38228. * Creates a new instance of the component for the given scene
  38229. * @param scene Defines the scene to register the component in
  38230. */
  38231. constructor(scene: Scene);
  38232. /**
  38233. * Registers the component in a given scene
  38234. */
  38235. register(): void;
  38236. /**
  38237. * Rebuilds the elements related to this component in case of
  38238. * context lost for instance.
  38239. */
  38240. rebuild(): void;
  38241. /**
  38242. * Serializes the component data to the specified json object
  38243. * @param serializationObject The object to serialize to
  38244. */
  38245. serialize(serializationObject: any): void;
  38246. /**
  38247. * Adds all the elements from the container to the scene
  38248. * @param container the container holding the elements
  38249. */
  38250. addFromContainer(container: AbstractScene): void;
  38251. /**
  38252. * Removes all the elements in the container from the scene
  38253. * @param container contains the elements to remove
  38254. * @param dispose if the removed element should be disposed (default: false)
  38255. */
  38256. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38257. /**
  38258. * Disposes the component and the associated ressources.
  38259. */
  38260. dispose(): void;
  38261. /**
  38262. * Disables audio in the associated scene.
  38263. */
  38264. disableAudio(): void;
  38265. /**
  38266. * Enables audio in the associated scene.
  38267. */
  38268. enableAudio(): void;
  38269. /**
  38270. * Switch audio to headphone output.
  38271. */
  38272. switchAudioModeForHeadphones(): void;
  38273. /**
  38274. * Switch audio to normal speakers.
  38275. */
  38276. switchAudioModeForNormalSpeakers(): void;
  38277. private _cachedCameraDirection;
  38278. private _cachedCameraPosition;
  38279. private _lastCheck;
  38280. private _afterRender;
  38281. }
  38282. }
  38283. declare module "babylonjs/Audio/weightedsound" {
  38284. import { Sound } from "babylonjs/Audio/sound";
  38285. /**
  38286. * Wraps one or more Sound objects and selects one with random weight for playback.
  38287. */
  38288. export class WeightedSound {
  38289. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38290. loop: boolean;
  38291. private _coneInnerAngle;
  38292. private _coneOuterAngle;
  38293. private _volume;
  38294. /** A Sound is currently playing. */
  38295. isPlaying: boolean;
  38296. /** A Sound is currently paused. */
  38297. isPaused: boolean;
  38298. private _sounds;
  38299. private _weights;
  38300. private _currentIndex?;
  38301. /**
  38302. * Creates a new WeightedSound from the list of sounds given.
  38303. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38304. * @param sounds Array of Sounds that will be selected from.
  38305. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38306. */
  38307. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38308. /**
  38309. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38310. */
  38311. /**
  38312. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38313. */
  38314. directionalConeInnerAngle: number;
  38315. /**
  38316. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38317. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38318. */
  38319. /**
  38320. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38321. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38322. */
  38323. directionalConeOuterAngle: number;
  38324. /**
  38325. * Playback volume.
  38326. */
  38327. /**
  38328. * Playback volume.
  38329. */
  38330. volume: number;
  38331. private _onended;
  38332. /**
  38333. * Suspend playback
  38334. */
  38335. pause(): void;
  38336. /**
  38337. * Stop playback
  38338. */
  38339. stop(): void;
  38340. /**
  38341. * Start playback.
  38342. * @param startOffset Position the clip head at a specific time in seconds.
  38343. */
  38344. play(startOffset?: number): void;
  38345. }
  38346. }
  38347. declare module "babylonjs/Audio/index" {
  38348. export * from "babylonjs/Audio/analyser";
  38349. export * from "babylonjs/Audio/audioEngine";
  38350. export * from "babylonjs/Audio/audioSceneComponent";
  38351. export * from "babylonjs/Audio/sound";
  38352. export * from "babylonjs/Audio/soundTrack";
  38353. export * from "babylonjs/Audio/weightedsound";
  38354. }
  38355. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38356. import { Behavior } from "babylonjs/Behaviors/behavior";
  38357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38358. import { BackEase } from "babylonjs/Animations/easing";
  38359. /**
  38360. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38362. */
  38363. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38364. /**
  38365. * Gets the name of the behavior.
  38366. */
  38367. readonly name: string;
  38368. /**
  38369. * The easing function used by animations
  38370. */
  38371. static EasingFunction: BackEase;
  38372. /**
  38373. * The easing mode used by animations
  38374. */
  38375. static EasingMode: number;
  38376. /**
  38377. * The duration of the animation, in milliseconds
  38378. */
  38379. transitionDuration: number;
  38380. /**
  38381. * Length of the distance animated by the transition when lower radius is reached
  38382. */
  38383. lowerRadiusTransitionRange: number;
  38384. /**
  38385. * Length of the distance animated by the transition when upper radius is reached
  38386. */
  38387. upperRadiusTransitionRange: number;
  38388. private _autoTransitionRange;
  38389. /**
  38390. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38391. */
  38392. /**
  38393. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38394. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38395. */
  38396. autoTransitionRange: boolean;
  38397. private _attachedCamera;
  38398. private _onAfterCheckInputsObserver;
  38399. private _onMeshTargetChangedObserver;
  38400. /**
  38401. * Initializes the behavior.
  38402. */
  38403. init(): void;
  38404. /**
  38405. * Attaches the behavior to its arc rotate camera.
  38406. * @param camera Defines the camera to attach the behavior to
  38407. */
  38408. attach(camera: ArcRotateCamera): void;
  38409. /**
  38410. * Detaches the behavior from its current arc rotate camera.
  38411. */
  38412. detach(): void;
  38413. private _radiusIsAnimating;
  38414. private _radiusBounceTransition;
  38415. private _animatables;
  38416. private _cachedWheelPrecision;
  38417. /**
  38418. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38419. * @param radiusLimit The limit to check against.
  38420. * @return Bool to indicate if at limit.
  38421. */
  38422. private _isRadiusAtLimit;
  38423. /**
  38424. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38425. * @param radiusDelta The delta by which to animate to. Can be negative.
  38426. */
  38427. private _applyBoundRadiusAnimation;
  38428. /**
  38429. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38430. */
  38431. protected _clearAnimationLocks(): void;
  38432. /**
  38433. * Stops and removes all animations that have been applied to the camera
  38434. */
  38435. stopAllAnimations(): void;
  38436. }
  38437. }
  38438. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38439. import { Behavior } from "babylonjs/Behaviors/behavior";
  38440. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38441. import { ExponentialEase } from "babylonjs/Animations/easing";
  38442. import { Nullable } from "babylonjs/types";
  38443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38444. import { Vector3 } from "babylonjs/Maths/math.vector";
  38445. /**
  38446. * 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.
  38447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38448. */
  38449. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38450. /**
  38451. * Gets the name of the behavior.
  38452. */
  38453. readonly name: string;
  38454. private _mode;
  38455. private _radiusScale;
  38456. private _positionScale;
  38457. private _defaultElevation;
  38458. private _elevationReturnTime;
  38459. private _elevationReturnWaitTime;
  38460. private _zoomStopsAnimation;
  38461. private _framingTime;
  38462. /**
  38463. * The easing function used by animations
  38464. */
  38465. static EasingFunction: ExponentialEase;
  38466. /**
  38467. * The easing mode used by animations
  38468. */
  38469. static EasingMode: number;
  38470. /**
  38471. * Sets the current mode used by the behavior
  38472. */
  38473. /**
  38474. * Gets current mode used by the behavior.
  38475. */
  38476. mode: number;
  38477. /**
  38478. * Sets the scale applied to the radius (1 by default)
  38479. */
  38480. /**
  38481. * Gets the scale applied to the radius
  38482. */
  38483. radiusScale: number;
  38484. /**
  38485. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38486. */
  38487. /**
  38488. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38489. */
  38490. positionScale: number;
  38491. /**
  38492. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38493. * behaviour is triggered, in radians.
  38494. */
  38495. /**
  38496. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38497. * behaviour is triggered, in radians.
  38498. */
  38499. defaultElevation: number;
  38500. /**
  38501. * Sets the time (in milliseconds) taken to return to the default beta position.
  38502. * Negative value indicates camera should not return to default.
  38503. */
  38504. /**
  38505. * Gets the time (in milliseconds) taken to return to the default beta position.
  38506. * Negative value indicates camera should not return to default.
  38507. */
  38508. elevationReturnTime: number;
  38509. /**
  38510. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38511. */
  38512. /**
  38513. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38514. */
  38515. elevationReturnWaitTime: number;
  38516. /**
  38517. * Sets the flag that indicates if user zooming should stop animation.
  38518. */
  38519. /**
  38520. * Gets the flag that indicates if user zooming should stop animation.
  38521. */
  38522. zoomStopsAnimation: boolean;
  38523. /**
  38524. * Sets the transition time when framing the mesh, in milliseconds
  38525. */
  38526. /**
  38527. * Gets the transition time when framing the mesh, in milliseconds
  38528. */
  38529. framingTime: number;
  38530. /**
  38531. * Define if the behavior should automatically change the configured
  38532. * camera limits and sensibilities.
  38533. */
  38534. autoCorrectCameraLimitsAndSensibility: boolean;
  38535. private _onPrePointerObservableObserver;
  38536. private _onAfterCheckInputsObserver;
  38537. private _onMeshTargetChangedObserver;
  38538. private _attachedCamera;
  38539. private _isPointerDown;
  38540. private _lastInteractionTime;
  38541. /**
  38542. * Initializes the behavior.
  38543. */
  38544. init(): void;
  38545. /**
  38546. * Attaches the behavior to its arc rotate camera.
  38547. * @param camera Defines the camera to attach the behavior to
  38548. */
  38549. attach(camera: ArcRotateCamera): void;
  38550. /**
  38551. * Detaches the behavior from its current arc rotate camera.
  38552. */
  38553. detach(): void;
  38554. private _animatables;
  38555. private _betaIsAnimating;
  38556. private _betaTransition;
  38557. private _radiusTransition;
  38558. private _vectorTransition;
  38559. /**
  38560. * Targets the given mesh and updates zoom level accordingly.
  38561. * @param mesh The mesh to target.
  38562. * @param radius Optional. If a cached radius position already exists, overrides default.
  38563. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38564. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38565. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38566. */
  38567. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38568. /**
  38569. * Targets the given mesh with its children and updates zoom level accordingly.
  38570. * @param mesh The mesh to target.
  38571. * @param radius Optional. If a cached radius position already exists, overrides default.
  38572. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38575. */
  38576. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38577. /**
  38578. * Targets the given meshes with their children and updates zoom level accordingly.
  38579. * @param meshes The mesh to target.
  38580. * @param radius Optional. If a cached radius position already exists, overrides default.
  38581. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38582. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38583. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38584. */
  38585. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38586. /**
  38587. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38588. * @param minimumWorld Determines the smaller position of the bounding box extend
  38589. * @param maximumWorld Determines the bigger position of the bounding box extend
  38590. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38591. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38592. */
  38593. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38594. /**
  38595. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38596. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38597. * frustum width.
  38598. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38599. * to fully enclose the mesh in the viewing frustum.
  38600. */
  38601. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38602. /**
  38603. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38604. * is automatically returned to its default position (expected to be above ground plane).
  38605. */
  38606. private _maintainCameraAboveGround;
  38607. /**
  38608. * Returns the frustum slope based on the canvas ratio and camera FOV
  38609. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38610. */
  38611. private _getFrustumSlope;
  38612. /**
  38613. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38614. */
  38615. private _clearAnimationLocks;
  38616. /**
  38617. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38618. */
  38619. private _applyUserInteraction;
  38620. /**
  38621. * Stops and removes all animations that have been applied to the camera
  38622. */
  38623. stopAllAnimations(): void;
  38624. /**
  38625. * Gets a value indicating if the user is moving the camera
  38626. */
  38627. readonly isUserIsMoving: boolean;
  38628. /**
  38629. * The camera can move all the way towards the mesh.
  38630. */
  38631. static IgnoreBoundsSizeMode: number;
  38632. /**
  38633. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38634. */
  38635. static FitFrustumSidesMode: number;
  38636. }
  38637. }
  38638. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38639. import { Nullable } from "babylonjs/types";
  38640. import { Camera } from "babylonjs/Cameras/camera";
  38641. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38642. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38643. /**
  38644. * Base class for Camera Pointer Inputs.
  38645. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38646. * for example usage.
  38647. */
  38648. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38649. /**
  38650. * Defines the camera the input is attached to.
  38651. */
  38652. abstract camera: Camera;
  38653. /**
  38654. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38655. */
  38656. protected _altKey: boolean;
  38657. protected _ctrlKey: boolean;
  38658. protected _metaKey: boolean;
  38659. protected _shiftKey: boolean;
  38660. /**
  38661. * Which mouse buttons were pressed at time of last mouse event.
  38662. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38663. */
  38664. protected _buttonsPressed: number;
  38665. /**
  38666. * Defines the buttons associated with the input to handle camera move.
  38667. */
  38668. buttons: number[];
  38669. /**
  38670. * Attach the input controls to a specific dom element to get the input from.
  38671. * @param element Defines the element the controls should be listened from
  38672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38673. */
  38674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38675. /**
  38676. * Detach the current controls from the specified dom element.
  38677. * @param element Defines the element to stop listening the inputs from
  38678. */
  38679. detachControl(element: Nullable<HTMLElement>): void;
  38680. /**
  38681. * Gets the class name of the current input.
  38682. * @returns the class name
  38683. */
  38684. getClassName(): string;
  38685. /**
  38686. * Get the friendly name associated with the input class.
  38687. * @returns the input friendly name
  38688. */
  38689. getSimpleName(): string;
  38690. /**
  38691. * Called on pointer POINTERDOUBLETAP event.
  38692. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38693. */
  38694. protected onDoubleTap(type: string): void;
  38695. /**
  38696. * Called on pointer POINTERMOVE event if only a single touch is active.
  38697. * Override this method to provide functionality.
  38698. */
  38699. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38700. /**
  38701. * Called on pointer POINTERMOVE event if multiple touches are active.
  38702. * Override this method to provide functionality.
  38703. */
  38704. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38705. /**
  38706. * Called on JS contextmenu event.
  38707. * Override this method to provide functionality.
  38708. */
  38709. protected onContextMenu(evt: PointerEvent): void;
  38710. /**
  38711. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38712. * press.
  38713. * Override this method to provide functionality.
  38714. */
  38715. protected onButtonDown(evt: PointerEvent): void;
  38716. /**
  38717. * Called each time a new POINTERUP event occurs. Ie, for each button
  38718. * release.
  38719. * Override this method to provide functionality.
  38720. */
  38721. protected onButtonUp(evt: PointerEvent): void;
  38722. /**
  38723. * Called when window becomes inactive.
  38724. * Override this method to provide functionality.
  38725. */
  38726. protected onLostFocus(): void;
  38727. private _pointerInput;
  38728. private _observer;
  38729. private _onLostFocus;
  38730. private pointA;
  38731. private pointB;
  38732. }
  38733. }
  38734. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38735. import { Nullable } from "babylonjs/types";
  38736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38737. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38738. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38739. /**
  38740. * Manage the pointers inputs to control an arc rotate camera.
  38741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38742. */
  38743. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38744. /**
  38745. * Defines the camera the input is attached to.
  38746. */
  38747. camera: ArcRotateCamera;
  38748. /**
  38749. * Gets the class name of the current input.
  38750. * @returns the class name
  38751. */
  38752. getClassName(): string;
  38753. /**
  38754. * Defines the buttons associated with the input to handle camera move.
  38755. */
  38756. buttons: number[];
  38757. /**
  38758. * Defines the pointer angular sensibility along the X axis or how fast is
  38759. * the camera rotating.
  38760. */
  38761. angularSensibilityX: number;
  38762. /**
  38763. * Defines the pointer angular sensibility along the Y axis or how fast is
  38764. * the camera rotating.
  38765. */
  38766. angularSensibilityY: number;
  38767. /**
  38768. * Defines the pointer pinch precision or how fast is the camera zooming.
  38769. */
  38770. pinchPrecision: number;
  38771. /**
  38772. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38773. * from 0.
  38774. * It defines the percentage of current camera.radius to use as delta when
  38775. * pinch zoom is used.
  38776. */
  38777. pinchDeltaPercentage: number;
  38778. /**
  38779. * Defines the pointer panning sensibility or how fast is the camera moving.
  38780. */
  38781. panningSensibility: number;
  38782. /**
  38783. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38784. */
  38785. multiTouchPanning: boolean;
  38786. /**
  38787. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38788. * zoom (pinch) through multitouch.
  38789. */
  38790. multiTouchPanAndZoom: boolean;
  38791. /**
  38792. * Revers pinch action direction.
  38793. */
  38794. pinchInwards: boolean;
  38795. private _isPanClick;
  38796. private _twoFingerActivityCount;
  38797. private _isPinching;
  38798. /**
  38799. * Called on pointer POINTERMOVE event if only a single touch is active.
  38800. */
  38801. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38802. /**
  38803. * Called on pointer POINTERDOUBLETAP event.
  38804. */
  38805. protected onDoubleTap(type: string): void;
  38806. /**
  38807. * Called on pointer POINTERMOVE event if multiple touches are active.
  38808. */
  38809. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38810. /**
  38811. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38812. * press.
  38813. */
  38814. protected onButtonDown(evt: PointerEvent): void;
  38815. /**
  38816. * Called each time a new POINTERUP event occurs. Ie, for each button
  38817. * release.
  38818. */
  38819. protected onButtonUp(evt: PointerEvent): void;
  38820. /**
  38821. * Called when window becomes inactive.
  38822. */
  38823. protected onLostFocus(): void;
  38824. }
  38825. }
  38826. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38827. import { Nullable } from "babylonjs/types";
  38828. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38829. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38830. /**
  38831. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38833. */
  38834. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38835. /**
  38836. * Defines the camera the input is attached to.
  38837. */
  38838. camera: ArcRotateCamera;
  38839. /**
  38840. * Defines the list of key codes associated with the up action (increase alpha)
  38841. */
  38842. keysUp: number[];
  38843. /**
  38844. * Defines the list of key codes associated with the down action (decrease alpha)
  38845. */
  38846. keysDown: number[];
  38847. /**
  38848. * Defines the list of key codes associated with the left action (increase beta)
  38849. */
  38850. keysLeft: number[];
  38851. /**
  38852. * Defines the list of key codes associated with the right action (decrease beta)
  38853. */
  38854. keysRight: number[];
  38855. /**
  38856. * Defines the list of key codes associated with the reset action.
  38857. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38858. */
  38859. keysReset: number[];
  38860. /**
  38861. * Defines the panning sensibility of the inputs.
  38862. * (How fast is the camera paning)
  38863. */
  38864. panningSensibility: number;
  38865. /**
  38866. * Defines the zooming sensibility of the inputs.
  38867. * (How fast is the camera zooming)
  38868. */
  38869. zoomingSensibility: number;
  38870. /**
  38871. * Defines wether maintaining the alt key down switch the movement mode from
  38872. * orientation to zoom.
  38873. */
  38874. useAltToZoom: boolean;
  38875. /**
  38876. * Rotation speed of the camera
  38877. */
  38878. angularSpeed: number;
  38879. private _keys;
  38880. private _ctrlPressed;
  38881. private _altPressed;
  38882. private _onCanvasBlurObserver;
  38883. private _onKeyboardObserver;
  38884. private _engine;
  38885. private _scene;
  38886. /**
  38887. * Attach the input controls to a specific dom element to get the input from.
  38888. * @param element Defines the element the controls should be listened from
  38889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38890. */
  38891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38892. /**
  38893. * Detach the current controls from the specified dom element.
  38894. * @param element Defines the element to stop listening the inputs from
  38895. */
  38896. detachControl(element: Nullable<HTMLElement>): void;
  38897. /**
  38898. * Update the current camera state depending on the inputs that have been used this frame.
  38899. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38900. */
  38901. checkInputs(): void;
  38902. /**
  38903. * Gets the class name of the current intput.
  38904. * @returns the class name
  38905. */
  38906. getClassName(): string;
  38907. /**
  38908. * Get the friendly name associated with the input class.
  38909. * @returns the input friendly name
  38910. */
  38911. getSimpleName(): string;
  38912. }
  38913. }
  38914. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38915. import { Nullable } from "babylonjs/types";
  38916. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38917. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38918. /**
  38919. * Manage the mouse wheel inputs to control an arc rotate camera.
  38920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38921. */
  38922. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38923. /**
  38924. * Defines the camera the input is attached to.
  38925. */
  38926. camera: ArcRotateCamera;
  38927. /**
  38928. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38929. */
  38930. wheelPrecision: number;
  38931. /**
  38932. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38933. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38934. */
  38935. wheelDeltaPercentage: number;
  38936. private _wheel;
  38937. private _observer;
  38938. private computeDeltaFromMouseWheelLegacyEvent;
  38939. /**
  38940. * Attach the input controls to a specific dom element to get the input from.
  38941. * @param element Defines the element the controls should be listened from
  38942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38943. */
  38944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38945. /**
  38946. * Detach the current controls from the specified dom element.
  38947. * @param element Defines the element to stop listening the inputs from
  38948. */
  38949. detachControl(element: Nullable<HTMLElement>): void;
  38950. /**
  38951. * Gets the class name of the current intput.
  38952. * @returns the class name
  38953. */
  38954. getClassName(): string;
  38955. /**
  38956. * Get the friendly name associated with the input class.
  38957. * @returns the input friendly name
  38958. */
  38959. getSimpleName(): string;
  38960. }
  38961. }
  38962. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38963. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38964. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38965. /**
  38966. * Default Inputs manager for the ArcRotateCamera.
  38967. * It groups all the default supported inputs for ease of use.
  38968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38969. */
  38970. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38971. /**
  38972. * Instantiates a new ArcRotateCameraInputsManager.
  38973. * @param camera Defines the camera the inputs belong to
  38974. */
  38975. constructor(camera: ArcRotateCamera);
  38976. /**
  38977. * Add mouse wheel input support to the input manager.
  38978. * @returns the current input manager
  38979. */
  38980. addMouseWheel(): ArcRotateCameraInputsManager;
  38981. /**
  38982. * Add pointers input support to the input manager.
  38983. * @returns the current input manager
  38984. */
  38985. addPointers(): ArcRotateCameraInputsManager;
  38986. /**
  38987. * Add keyboard input support to the input manager.
  38988. * @returns the current input manager
  38989. */
  38990. addKeyboard(): ArcRotateCameraInputsManager;
  38991. }
  38992. }
  38993. declare module "babylonjs/Cameras/arcRotateCamera" {
  38994. import { Observable } from "babylonjs/Misc/observable";
  38995. import { Nullable } from "babylonjs/types";
  38996. import { Scene } from "babylonjs/scene";
  38997. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  38998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38999. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39000. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39001. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39002. import { Camera } from "babylonjs/Cameras/camera";
  39003. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39004. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39005. import { Collider } from "babylonjs/Collisions/collider";
  39006. /**
  39007. * This represents an orbital type of camera.
  39008. *
  39009. * 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.
  39010. * 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.
  39011. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39012. */
  39013. export class ArcRotateCamera extends TargetCamera {
  39014. /**
  39015. * Defines the rotation angle of the camera along the longitudinal axis.
  39016. */
  39017. alpha: number;
  39018. /**
  39019. * Defines the rotation angle of the camera along the latitudinal axis.
  39020. */
  39021. beta: number;
  39022. /**
  39023. * Defines the radius of the camera from it s target point.
  39024. */
  39025. radius: number;
  39026. protected _target: Vector3;
  39027. protected _targetHost: Nullable<AbstractMesh>;
  39028. /**
  39029. * Defines the target point of the camera.
  39030. * The camera looks towards it form the radius distance.
  39031. */
  39032. target: Vector3;
  39033. /**
  39034. * Define the current local position of the camera in the scene
  39035. */
  39036. position: Vector3;
  39037. protected _upVector: Vector3;
  39038. protected _upToYMatrix: Matrix;
  39039. protected _YToUpMatrix: Matrix;
  39040. /**
  39041. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39042. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39043. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39044. */
  39045. upVector: Vector3;
  39046. /**
  39047. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39048. */
  39049. setMatUp(): void;
  39050. /**
  39051. * Current inertia value on the longitudinal axis.
  39052. * The bigger this number the longer it will take for the camera to stop.
  39053. */
  39054. inertialAlphaOffset: number;
  39055. /**
  39056. * Current inertia value on the latitudinal axis.
  39057. * The bigger this number the longer it will take for the camera to stop.
  39058. */
  39059. inertialBetaOffset: number;
  39060. /**
  39061. * Current inertia value on the radius axis.
  39062. * The bigger this number the longer it will take for the camera to stop.
  39063. */
  39064. inertialRadiusOffset: number;
  39065. /**
  39066. * Minimum allowed angle on the longitudinal axis.
  39067. * This can help limiting how the Camera is able to move in the scene.
  39068. */
  39069. lowerAlphaLimit: Nullable<number>;
  39070. /**
  39071. * Maximum allowed angle on the longitudinal axis.
  39072. * This can help limiting how the Camera is able to move in the scene.
  39073. */
  39074. upperAlphaLimit: Nullable<number>;
  39075. /**
  39076. * Minimum allowed angle on the latitudinal axis.
  39077. * This can help limiting how the Camera is able to move in the scene.
  39078. */
  39079. lowerBetaLimit: number;
  39080. /**
  39081. * Maximum allowed angle on the latitudinal axis.
  39082. * This can help limiting how the Camera is able to move in the scene.
  39083. */
  39084. upperBetaLimit: number;
  39085. /**
  39086. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39087. * This can help limiting how the Camera is able to move in the scene.
  39088. */
  39089. lowerRadiusLimit: Nullable<number>;
  39090. /**
  39091. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39092. * This can help limiting how the Camera is able to move in the scene.
  39093. */
  39094. upperRadiusLimit: Nullable<number>;
  39095. /**
  39096. * Defines the current inertia value used during panning of the camera along the X axis.
  39097. */
  39098. inertialPanningX: number;
  39099. /**
  39100. * Defines the current inertia value used during panning of the camera along the Y axis.
  39101. */
  39102. inertialPanningY: number;
  39103. /**
  39104. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39105. * Basically if your fingers moves away from more than this distance you will be considered
  39106. * in pinch mode.
  39107. */
  39108. pinchToPanMaxDistance: number;
  39109. /**
  39110. * Defines the maximum distance the camera can pan.
  39111. * This could help keeping the cammera always in your scene.
  39112. */
  39113. panningDistanceLimit: Nullable<number>;
  39114. /**
  39115. * Defines the target of the camera before paning.
  39116. */
  39117. panningOriginTarget: Vector3;
  39118. /**
  39119. * Defines the value of the inertia used during panning.
  39120. * 0 would mean stop inertia and one would mean no decelleration at all.
  39121. */
  39122. panningInertia: number;
  39123. /**
  39124. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39125. */
  39126. angularSensibilityX: number;
  39127. /**
  39128. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39129. */
  39130. angularSensibilityY: number;
  39131. /**
  39132. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39133. */
  39134. pinchPrecision: number;
  39135. /**
  39136. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39137. * It will be used instead of pinchDeltaPrecision if different from 0.
  39138. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39139. */
  39140. pinchDeltaPercentage: number;
  39141. /**
  39142. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39143. */
  39144. panningSensibility: number;
  39145. /**
  39146. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39147. */
  39148. keysUp: number[];
  39149. /**
  39150. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39151. */
  39152. keysDown: number[];
  39153. /**
  39154. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39155. */
  39156. keysLeft: number[];
  39157. /**
  39158. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39159. */
  39160. keysRight: number[];
  39161. /**
  39162. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39163. */
  39164. wheelPrecision: number;
  39165. /**
  39166. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39167. * It will be used instead of pinchDeltaPrecision if different from 0.
  39168. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39169. */
  39170. wheelDeltaPercentage: number;
  39171. /**
  39172. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39173. */
  39174. zoomOnFactor: number;
  39175. /**
  39176. * Defines a screen offset for the camera position.
  39177. */
  39178. targetScreenOffset: Vector2;
  39179. /**
  39180. * Allows the camera to be completely reversed.
  39181. * If false the camera can not arrive upside down.
  39182. */
  39183. allowUpsideDown: boolean;
  39184. /**
  39185. * Define if double tap/click is used to restore the previously saved state of the camera.
  39186. */
  39187. useInputToRestoreState: boolean;
  39188. /** @hidden */
  39189. _viewMatrix: Matrix;
  39190. /** @hidden */
  39191. _useCtrlForPanning: boolean;
  39192. /** @hidden */
  39193. _panningMouseButton: number;
  39194. /**
  39195. * Defines the input associated to the camera.
  39196. */
  39197. inputs: ArcRotateCameraInputsManager;
  39198. /** @hidden */
  39199. _reset: () => void;
  39200. /**
  39201. * Defines the allowed panning axis.
  39202. */
  39203. panningAxis: Vector3;
  39204. protected _localDirection: Vector3;
  39205. protected _transformedDirection: Vector3;
  39206. private _bouncingBehavior;
  39207. /**
  39208. * Gets the bouncing behavior of the camera if it has been enabled.
  39209. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39210. */
  39211. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39212. /**
  39213. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39214. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39215. */
  39216. useBouncingBehavior: boolean;
  39217. private _framingBehavior;
  39218. /**
  39219. * Gets the framing behavior of the camera if it has been enabled.
  39220. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39221. */
  39222. readonly framingBehavior: Nullable<FramingBehavior>;
  39223. /**
  39224. * Defines if the framing behavior of the camera is enabled on the camera.
  39225. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39226. */
  39227. useFramingBehavior: boolean;
  39228. private _autoRotationBehavior;
  39229. /**
  39230. * Gets the auto rotation behavior of the camera if it has been enabled.
  39231. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39232. */
  39233. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39234. /**
  39235. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39236. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39237. */
  39238. useAutoRotationBehavior: boolean;
  39239. /**
  39240. * Observable triggered when the mesh target has been changed on the camera.
  39241. */
  39242. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39243. /**
  39244. * Event raised when the camera is colliding with a mesh.
  39245. */
  39246. onCollide: (collidedMesh: AbstractMesh) => void;
  39247. /**
  39248. * Defines whether the camera should check collision with the objects oh the scene.
  39249. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39250. */
  39251. checkCollisions: boolean;
  39252. /**
  39253. * Defines the collision radius of the camera.
  39254. * This simulates a sphere around the camera.
  39255. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39256. */
  39257. collisionRadius: Vector3;
  39258. protected _collider: Collider;
  39259. protected _previousPosition: Vector3;
  39260. protected _collisionVelocity: Vector3;
  39261. protected _newPosition: Vector3;
  39262. protected _previousAlpha: number;
  39263. protected _previousBeta: number;
  39264. protected _previousRadius: number;
  39265. protected _collisionTriggered: boolean;
  39266. protected _targetBoundingCenter: Nullable<Vector3>;
  39267. private _computationVector;
  39268. /**
  39269. * Instantiates a new ArcRotateCamera in a given scene
  39270. * @param name Defines the name of the camera
  39271. * @param alpha Defines the camera rotation along the logitudinal axis
  39272. * @param beta Defines the camera rotation along the latitudinal axis
  39273. * @param radius Defines the camera distance from its target
  39274. * @param target Defines the camera target
  39275. * @param scene Defines the scene the camera belongs to
  39276. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39277. */
  39278. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39279. /** @hidden */
  39280. _initCache(): void;
  39281. /** @hidden */
  39282. _updateCache(ignoreParentClass?: boolean): void;
  39283. protected _getTargetPosition(): Vector3;
  39284. private _storedAlpha;
  39285. private _storedBeta;
  39286. private _storedRadius;
  39287. private _storedTarget;
  39288. private _storedTargetScreenOffset;
  39289. /**
  39290. * Stores the current state of the camera (alpha, beta, radius and target)
  39291. * @returns the camera itself
  39292. */
  39293. storeState(): Camera;
  39294. /**
  39295. * @hidden
  39296. * Restored camera state. You must call storeState() first
  39297. */
  39298. _restoreStateValues(): boolean;
  39299. /** @hidden */
  39300. _isSynchronizedViewMatrix(): boolean;
  39301. /**
  39302. * Attached controls to the current camera.
  39303. * @param element Defines the element the controls should be listened from
  39304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39305. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39306. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39307. */
  39308. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39309. /**
  39310. * Detach the current controls from the camera.
  39311. * The camera will stop reacting to inputs.
  39312. * @param element Defines the element to stop listening the inputs from
  39313. */
  39314. detachControl(element: HTMLElement): void;
  39315. /** @hidden */
  39316. _checkInputs(): void;
  39317. protected _checkLimits(): void;
  39318. /**
  39319. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39320. */
  39321. rebuildAnglesAndRadius(): void;
  39322. /**
  39323. * Use a position to define the current camera related information like alpha, beta and radius
  39324. * @param position Defines the position to set the camera at
  39325. */
  39326. setPosition(position: Vector3): void;
  39327. /**
  39328. * Defines the target the camera should look at.
  39329. * This will automatically adapt alpha beta and radius to fit within the new target.
  39330. * @param target Defines the new target as a Vector or a mesh
  39331. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39332. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39333. */
  39334. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39335. /** @hidden */
  39336. _getViewMatrix(): Matrix;
  39337. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39338. /**
  39339. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39340. * @param meshes Defines the mesh to zoom on
  39341. * @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)
  39342. */
  39343. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39344. /**
  39345. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39346. * The target will be changed but the radius
  39347. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39348. * @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)
  39349. */
  39350. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39351. min: Vector3;
  39352. max: Vector3;
  39353. distance: number;
  39354. }, doNotUpdateMaxZ?: boolean): void;
  39355. /**
  39356. * @override
  39357. * Override Camera.createRigCamera
  39358. */
  39359. createRigCamera(name: string, cameraIndex: number): Camera;
  39360. /**
  39361. * @hidden
  39362. * @override
  39363. * Override Camera._updateRigCameras
  39364. */
  39365. _updateRigCameras(): void;
  39366. /**
  39367. * Destroy the camera and release the current resources hold by it.
  39368. */
  39369. dispose(): void;
  39370. /**
  39371. * Gets the current object class name.
  39372. * @return the class name
  39373. */
  39374. getClassName(): string;
  39375. }
  39376. }
  39377. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39378. import { Behavior } from "babylonjs/Behaviors/behavior";
  39379. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39380. /**
  39381. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39382. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39383. */
  39384. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39385. /**
  39386. * Gets the name of the behavior.
  39387. */
  39388. readonly name: string;
  39389. private _zoomStopsAnimation;
  39390. private _idleRotationSpeed;
  39391. private _idleRotationWaitTime;
  39392. private _idleRotationSpinupTime;
  39393. /**
  39394. * Sets the flag that indicates if user zooming should stop animation.
  39395. */
  39396. /**
  39397. * Gets the flag that indicates if user zooming should stop animation.
  39398. */
  39399. zoomStopsAnimation: boolean;
  39400. /**
  39401. * Sets the default speed at which the camera rotates around the model.
  39402. */
  39403. /**
  39404. * Gets the default speed at which the camera rotates around the model.
  39405. */
  39406. idleRotationSpeed: number;
  39407. /**
  39408. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39409. */
  39410. /**
  39411. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39412. */
  39413. idleRotationWaitTime: number;
  39414. /**
  39415. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39416. */
  39417. /**
  39418. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39419. */
  39420. idleRotationSpinupTime: number;
  39421. /**
  39422. * Gets a value indicating if the camera is currently rotating because of this behavior
  39423. */
  39424. readonly rotationInProgress: boolean;
  39425. private _onPrePointerObservableObserver;
  39426. private _onAfterCheckInputsObserver;
  39427. private _attachedCamera;
  39428. private _isPointerDown;
  39429. private _lastFrameTime;
  39430. private _lastInteractionTime;
  39431. private _cameraRotationSpeed;
  39432. /**
  39433. * Initializes the behavior.
  39434. */
  39435. init(): void;
  39436. /**
  39437. * Attaches the behavior to its arc rotate camera.
  39438. * @param camera Defines the camera to attach the behavior to
  39439. */
  39440. attach(camera: ArcRotateCamera): void;
  39441. /**
  39442. * Detaches the behavior from its current arc rotate camera.
  39443. */
  39444. detach(): void;
  39445. /**
  39446. * Returns true if user is scrolling.
  39447. * @return true if user is scrolling.
  39448. */
  39449. private _userIsZooming;
  39450. private _lastFrameRadius;
  39451. private _shouldAnimationStopForInteraction;
  39452. /**
  39453. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39454. */
  39455. private _applyUserInteraction;
  39456. private _userIsMoving;
  39457. }
  39458. }
  39459. declare module "babylonjs/Behaviors/Cameras/index" {
  39460. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39461. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39462. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39463. }
  39464. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39465. import { Mesh } from "babylonjs/Meshes/mesh";
  39466. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39467. import { Behavior } from "babylonjs/Behaviors/behavior";
  39468. /**
  39469. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39470. */
  39471. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39472. private ui;
  39473. /**
  39474. * The name of the behavior
  39475. */
  39476. name: string;
  39477. /**
  39478. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39479. */
  39480. distanceAwayFromFace: number;
  39481. /**
  39482. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39483. */
  39484. distanceAwayFromBottomOfFace: number;
  39485. private _faceVectors;
  39486. private _target;
  39487. private _scene;
  39488. private _onRenderObserver;
  39489. private _tmpMatrix;
  39490. private _tmpVector;
  39491. /**
  39492. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39493. * @param ui The transform node that should be attched to the mesh
  39494. */
  39495. constructor(ui: TransformNode);
  39496. /**
  39497. * Initializes the behavior
  39498. */
  39499. init(): void;
  39500. private _closestFace;
  39501. private _zeroVector;
  39502. private _lookAtTmpMatrix;
  39503. private _lookAtToRef;
  39504. /**
  39505. * Attaches the AttachToBoxBehavior to the passed in mesh
  39506. * @param target The mesh that the specified node will be attached to
  39507. */
  39508. attach(target: Mesh): void;
  39509. /**
  39510. * Detaches the behavior from the mesh
  39511. */
  39512. detach(): void;
  39513. }
  39514. }
  39515. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39516. import { Behavior } from "babylonjs/Behaviors/behavior";
  39517. import { Mesh } from "babylonjs/Meshes/mesh";
  39518. /**
  39519. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39520. */
  39521. export class FadeInOutBehavior implements Behavior<Mesh> {
  39522. /**
  39523. * Time in milliseconds to delay before fading in (Default: 0)
  39524. */
  39525. delay: number;
  39526. /**
  39527. * Time in milliseconds for the mesh to fade in (Default: 300)
  39528. */
  39529. fadeInTime: number;
  39530. private _millisecondsPerFrame;
  39531. private _hovered;
  39532. private _hoverValue;
  39533. private _ownerNode;
  39534. /**
  39535. * Instatiates the FadeInOutBehavior
  39536. */
  39537. constructor();
  39538. /**
  39539. * The name of the behavior
  39540. */
  39541. readonly name: string;
  39542. /**
  39543. * Initializes the behavior
  39544. */
  39545. init(): void;
  39546. /**
  39547. * Attaches the fade behavior on the passed in mesh
  39548. * @param ownerNode The mesh that will be faded in/out once attached
  39549. */
  39550. attach(ownerNode: Mesh): void;
  39551. /**
  39552. * Detaches the behavior from the mesh
  39553. */
  39554. detach(): void;
  39555. /**
  39556. * Triggers the mesh to begin fading in or out
  39557. * @param value if the object should fade in or out (true to fade in)
  39558. */
  39559. fadeIn(value: boolean): void;
  39560. private _update;
  39561. private _setAllVisibility;
  39562. }
  39563. }
  39564. declare module "babylonjs/Misc/pivotTools" {
  39565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39566. /**
  39567. * Class containing a set of static utilities functions for managing Pivots
  39568. * @hidden
  39569. */
  39570. export class PivotTools {
  39571. private static _PivotCached;
  39572. private static _OldPivotPoint;
  39573. private static _PivotTranslation;
  39574. private static _PivotTmpVector;
  39575. /** @hidden */
  39576. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39577. /** @hidden */
  39578. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39579. }
  39580. }
  39581. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39582. import { Scene } from "babylonjs/scene";
  39583. import { Vector4 } from "babylonjs/Maths/math.vector";
  39584. import { Mesh } from "babylonjs/Meshes/mesh";
  39585. import { Nullable } from "babylonjs/types";
  39586. import { Plane } from "babylonjs/Maths/math.plane";
  39587. /**
  39588. * Class containing static functions to help procedurally build meshes
  39589. */
  39590. export class PlaneBuilder {
  39591. /**
  39592. * Creates a plane mesh
  39593. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39594. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39595. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39599. * @param name defines the name of the mesh
  39600. * @param options defines the options used to create the mesh
  39601. * @param scene defines the hosting scene
  39602. * @returns the plane mesh
  39603. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39604. */
  39605. static CreatePlane(name: string, options: {
  39606. size?: number;
  39607. width?: number;
  39608. height?: number;
  39609. sideOrientation?: number;
  39610. frontUVs?: Vector4;
  39611. backUVs?: Vector4;
  39612. updatable?: boolean;
  39613. sourcePlane?: Plane;
  39614. }, scene?: Nullable<Scene>): Mesh;
  39615. }
  39616. }
  39617. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39618. import { Behavior } from "babylonjs/Behaviors/behavior";
  39619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39620. import { Observable } from "babylonjs/Misc/observable";
  39621. import { Vector3 } from "babylonjs/Maths/math.vector";
  39622. import { Ray } from "babylonjs/Culling/ray";
  39623. import "babylonjs/Meshes/Builders/planeBuilder";
  39624. /**
  39625. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39626. */
  39627. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39628. private static _AnyMouseID;
  39629. /**
  39630. * Abstract mesh the behavior is set on
  39631. */
  39632. attachedNode: AbstractMesh;
  39633. private _dragPlane;
  39634. private _scene;
  39635. private _pointerObserver;
  39636. private _beforeRenderObserver;
  39637. private static _planeScene;
  39638. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39639. /**
  39640. * 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)
  39641. */
  39642. maxDragAngle: number;
  39643. /**
  39644. * @hidden
  39645. */
  39646. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39647. /**
  39648. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39649. */
  39650. currentDraggingPointerID: number;
  39651. /**
  39652. * The last position where the pointer hit the drag plane in world space
  39653. */
  39654. lastDragPosition: Vector3;
  39655. /**
  39656. * If the behavior is currently in a dragging state
  39657. */
  39658. dragging: boolean;
  39659. /**
  39660. * 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)
  39661. */
  39662. dragDeltaRatio: number;
  39663. /**
  39664. * If the drag plane orientation should be updated during the dragging (Default: true)
  39665. */
  39666. updateDragPlane: boolean;
  39667. private _debugMode;
  39668. private _moving;
  39669. /**
  39670. * Fires each time the attached mesh is dragged with the pointer
  39671. * * delta between last drag position and current drag position in world space
  39672. * * dragDistance along the drag axis
  39673. * * dragPlaneNormal normal of the current drag plane used during the drag
  39674. * * dragPlanePoint in world space where the drag intersects the drag plane
  39675. */
  39676. onDragObservable: Observable<{
  39677. delta: Vector3;
  39678. dragPlanePoint: Vector3;
  39679. dragPlaneNormal: Vector3;
  39680. dragDistance: number;
  39681. pointerId: number;
  39682. }>;
  39683. /**
  39684. * Fires each time a drag begins (eg. mouse down on mesh)
  39685. */
  39686. onDragStartObservable: Observable<{
  39687. dragPlanePoint: Vector3;
  39688. pointerId: number;
  39689. }>;
  39690. /**
  39691. * Fires each time a drag ends (eg. mouse release after drag)
  39692. */
  39693. onDragEndObservable: Observable<{
  39694. dragPlanePoint: Vector3;
  39695. pointerId: number;
  39696. }>;
  39697. /**
  39698. * If the attached mesh should be moved when dragged
  39699. */
  39700. moveAttached: boolean;
  39701. /**
  39702. * If the drag behavior will react to drag events (Default: true)
  39703. */
  39704. enabled: boolean;
  39705. /**
  39706. * If pointer events should start and release the drag (Default: true)
  39707. */
  39708. startAndReleaseDragOnPointerEvents: boolean;
  39709. /**
  39710. * If camera controls should be detached during the drag
  39711. */
  39712. detachCameraControls: boolean;
  39713. /**
  39714. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39715. */
  39716. useObjectOrienationForDragging: boolean;
  39717. private _options;
  39718. /**
  39719. * Gets the options used by the behavior
  39720. */
  39721. /**
  39722. * Sets the options used by the behavior
  39723. */
  39724. options: {
  39725. dragAxis?: Vector3;
  39726. dragPlaneNormal?: Vector3;
  39727. };
  39728. /**
  39729. * Creates a pointer drag behavior that can be attached to a mesh
  39730. * @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)
  39731. */
  39732. constructor(options?: {
  39733. dragAxis?: Vector3;
  39734. dragPlaneNormal?: Vector3;
  39735. });
  39736. /**
  39737. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39738. */
  39739. validateDrag: (targetPosition: Vector3) => boolean;
  39740. /**
  39741. * The name of the behavior
  39742. */
  39743. readonly name: string;
  39744. /**
  39745. * Initializes the behavior
  39746. */
  39747. init(): void;
  39748. private _tmpVector;
  39749. private _alternatePickedPoint;
  39750. private _worldDragAxis;
  39751. private _targetPosition;
  39752. private _attachedElement;
  39753. /**
  39754. * Attaches the drag behavior the passed in mesh
  39755. * @param ownerNode The mesh that will be dragged around once attached
  39756. * @param predicate Predicate to use for pick filtering
  39757. */
  39758. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39759. /**
  39760. * Force relase the drag action by code.
  39761. */
  39762. releaseDrag(): void;
  39763. private _startDragRay;
  39764. private _lastPointerRay;
  39765. /**
  39766. * Simulates the start of a pointer drag event on the behavior
  39767. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39768. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39769. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39770. */
  39771. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39772. private _startDrag;
  39773. private _dragDelta;
  39774. private _moveDrag;
  39775. private _pickWithRayOnDragPlane;
  39776. private _pointA;
  39777. private _pointB;
  39778. private _pointC;
  39779. private _lineA;
  39780. private _lineB;
  39781. private _localAxis;
  39782. private _lookAt;
  39783. private _updateDragPlanePosition;
  39784. /**
  39785. * Detaches the behavior from the mesh
  39786. */
  39787. detach(): void;
  39788. }
  39789. }
  39790. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39791. import { Mesh } from "babylonjs/Meshes/mesh";
  39792. import { Behavior } from "babylonjs/Behaviors/behavior";
  39793. /**
  39794. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39795. */
  39796. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39797. private _dragBehaviorA;
  39798. private _dragBehaviorB;
  39799. private _startDistance;
  39800. private _initialScale;
  39801. private _targetScale;
  39802. private _ownerNode;
  39803. private _sceneRenderObserver;
  39804. /**
  39805. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39806. */
  39807. constructor();
  39808. /**
  39809. * The name of the behavior
  39810. */
  39811. readonly name: string;
  39812. /**
  39813. * Initializes the behavior
  39814. */
  39815. init(): void;
  39816. private _getCurrentDistance;
  39817. /**
  39818. * Attaches the scale behavior the passed in mesh
  39819. * @param ownerNode The mesh that will be scaled around once attached
  39820. */
  39821. attach(ownerNode: Mesh): void;
  39822. /**
  39823. * Detaches the behavior from the mesh
  39824. */
  39825. detach(): void;
  39826. }
  39827. }
  39828. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39829. import { Behavior } from "babylonjs/Behaviors/behavior";
  39830. import { Mesh } from "babylonjs/Meshes/mesh";
  39831. import { Observable } from "babylonjs/Misc/observable";
  39832. /**
  39833. * 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
  39834. */
  39835. export class SixDofDragBehavior implements Behavior<Mesh> {
  39836. private static _virtualScene;
  39837. private _ownerNode;
  39838. private _sceneRenderObserver;
  39839. private _scene;
  39840. private _targetPosition;
  39841. private _virtualOriginMesh;
  39842. private _virtualDragMesh;
  39843. private _pointerObserver;
  39844. private _moving;
  39845. private _startingOrientation;
  39846. /**
  39847. * 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)
  39848. */
  39849. private zDragFactor;
  39850. /**
  39851. * If the object should rotate to face the drag origin
  39852. */
  39853. rotateDraggedObject: boolean;
  39854. /**
  39855. * If the behavior is currently in a dragging state
  39856. */
  39857. dragging: boolean;
  39858. /**
  39859. * 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)
  39860. */
  39861. dragDeltaRatio: number;
  39862. /**
  39863. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39864. */
  39865. currentDraggingPointerID: number;
  39866. /**
  39867. * If camera controls should be detached during the drag
  39868. */
  39869. detachCameraControls: boolean;
  39870. /**
  39871. * Fires each time a drag starts
  39872. */
  39873. onDragStartObservable: Observable<{}>;
  39874. /**
  39875. * Fires each time a drag ends (eg. mouse release after drag)
  39876. */
  39877. onDragEndObservable: Observable<{}>;
  39878. /**
  39879. * 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
  39880. */
  39881. constructor();
  39882. /**
  39883. * The name of the behavior
  39884. */
  39885. readonly name: string;
  39886. /**
  39887. * Initializes the behavior
  39888. */
  39889. init(): void;
  39890. /**
  39891. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39892. */
  39893. private readonly _pointerCamera;
  39894. /**
  39895. * Attaches the scale behavior the passed in mesh
  39896. * @param ownerNode The mesh that will be scaled around once attached
  39897. */
  39898. attach(ownerNode: Mesh): void;
  39899. /**
  39900. * Detaches the behavior from the mesh
  39901. */
  39902. detach(): void;
  39903. }
  39904. }
  39905. declare module "babylonjs/Behaviors/Meshes/index" {
  39906. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39907. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39908. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39909. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39910. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39911. }
  39912. declare module "babylonjs/Behaviors/index" {
  39913. export * from "babylonjs/Behaviors/behavior";
  39914. export * from "babylonjs/Behaviors/Cameras/index";
  39915. export * from "babylonjs/Behaviors/Meshes/index";
  39916. }
  39917. declare module "babylonjs/Bones/boneIKController" {
  39918. import { Bone } from "babylonjs/Bones/bone";
  39919. import { Vector3 } from "babylonjs/Maths/math.vector";
  39920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39921. import { Nullable } from "babylonjs/types";
  39922. /**
  39923. * Class used to apply inverse kinematics to bones
  39924. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39925. */
  39926. export class BoneIKController {
  39927. private static _tmpVecs;
  39928. private static _tmpQuat;
  39929. private static _tmpMats;
  39930. /**
  39931. * Gets or sets the target mesh
  39932. */
  39933. targetMesh: AbstractMesh;
  39934. /** Gets or sets the mesh used as pole */
  39935. poleTargetMesh: AbstractMesh;
  39936. /**
  39937. * Gets or sets the bone used as pole
  39938. */
  39939. poleTargetBone: Nullable<Bone>;
  39940. /**
  39941. * Gets or sets the target position
  39942. */
  39943. targetPosition: Vector3;
  39944. /**
  39945. * Gets or sets the pole target position
  39946. */
  39947. poleTargetPosition: Vector3;
  39948. /**
  39949. * Gets or sets the pole target local offset
  39950. */
  39951. poleTargetLocalOffset: Vector3;
  39952. /**
  39953. * Gets or sets the pole angle
  39954. */
  39955. poleAngle: number;
  39956. /**
  39957. * Gets or sets the mesh associated with the controller
  39958. */
  39959. mesh: AbstractMesh;
  39960. /**
  39961. * 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)
  39962. */
  39963. slerpAmount: number;
  39964. private _bone1Quat;
  39965. private _bone1Mat;
  39966. private _bone2Ang;
  39967. private _bone1;
  39968. private _bone2;
  39969. private _bone1Length;
  39970. private _bone2Length;
  39971. private _maxAngle;
  39972. private _maxReach;
  39973. private _rightHandedSystem;
  39974. private _bendAxis;
  39975. private _slerping;
  39976. private _adjustRoll;
  39977. /**
  39978. * Gets or sets maximum allowed angle
  39979. */
  39980. maxAngle: number;
  39981. /**
  39982. * Creates a new BoneIKController
  39983. * @param mesh defines the mesh to control
  39984. * @param bone defines the bone to control
  39985. * @param options defines options to set up the controller
  39986. */
  39987. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39988. targetMesh?: AbstractMesh;
  39989. poleTargetMesh?: AbstractMesh;
  39990. poleTargetBone?: Bone;
  39991. poleTargetLocalOffset?: Vector3;
  39992. poleAngle?: number;
  39993. bendAxis?: Vector3;
  39994. maxAngle?: number;
  39995. slerpAmount?: number;
  39996. });
  39997. private _setMaxAngle;
  39998. /**
  39999. * Force the controller to update the bones
  40000. */
  40001. update(): void;
  40002. }
  40003. }
  40004. declare module "babylonjs/Bones/boneLookController" {
  40005. import { Vector3 } from "babylonjs/Maths/math.vector";
  40006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40007. import { Bone } from "babylonjs/Bones/bone";
  40008. import { Space } from "babylonjs/Maths/math.axis";
  40009. /**
  40010. * Class used to make a bone look toward a point in space
  40011. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40012. */
  40013. export class BoneLookController {
  40014. private static _tmpVecs;
  40015. private static _tmpQuat;
  40016. private static _tmpMats;
  40017. /**
  40018. * The target Vector3 that the bone will look at
  40019. */
  40020. target: Vector3;
  40021. /**
  40022. * The mesh that the bone is attached to
  40023. */
  40024. mesh: AbstractMesh;
  40025. /**
  40026. * The bone that will be looking to the target
  40027. */
  40028. bone: Bone;
  40029. /**
  40030. * The up axis of the coordinate system that is used when the bone is rotated
  40031. */
  40032. upAxis: Vector3;
  40033. /**
  40034. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40035. */
  40036. upAxisSpace: Space;
  40037. /**
  40038. * Used to make an adjustment to the yaw of the bone
  40039. */
  40040. adjustYaw: number;
  40041. /**
  40042. * Used to make an adjustment to the pitch of the bone
  40043. */
  40044. adjustPitch: number;
  40045. /**
  40046. * Used to make an adjustment to the roll of the bone
  40047. */
  40048. adjustRoll: number;
  40049. /**
  40050. * 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)
  40051. */
  40052. slerpAmount: number;
  40053. private _minYaw;
  40054. private _maxYaw;
  40055. private _minPitch;
  40056. private _maxPitch;
  40057. private _minYawSin;
  40058. private _minYawCos;
  40059. private _maxYawSin;
  40060. private _maxYawCos;
  40061. private _midYawConstraint;
  40062. private _minPitchTan;
  40063. private _maxPitchTan;
  40064. private _boneQuat;
  40065. private _slerping;
  40066. private _transformYawPitch;
  40067. private _transformYawPitchInv;
  40068. private _firstFrameSkipped;
  40069. private _yawRange;
  40070. private _fowardAxis;
  40071. /**
  40072. * Gets or sets the minimum yaw angle that the bone can look to
  40073. */
  40074. minYaw: number;
  40075. /**
  40076. * Gets or sets the maximum yaw angle that the bone can look to
  40077. */
  40078. maxYaw: number;
  40079. /**
  40080. * Gets or sets the minimum pitch angle that the bone can look to
  40081. */
  40082. minPitch: number;
  40083. /**
  40084. * Gets or sets the maximum pitch angle that the bone can look to
  40085. */
  40086. maxPitch: number;
  40087. /**
  40088. * Create a BoneLookController
  40089. * @param mesh the mesh that the bone belongs to
  40090. * @param bone the bone that will be looking to the target
  40091. * @param target the target Vector3 to look at
  40092. * @param options optional settings:
  40093. * * maxYaw: the maximum angle the bone will yaw to
  40094. * * minYaw: the minimum angle the bone will yaw to
  40095. * * maxPitch: the maximum angle the bone will pitch to
  40096. * * minPitch: the minimum angle the bone will yaw to
  40097. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40098. * * upAxis: the up axis of the coordinate system
  40099. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40100. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40101. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40102. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40103. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40104. * * adjustRoll: used to make an adjustment to the roll of the bone
  40105. **/
  40106. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40107. maxYaw?: number;
  40108. minYaw?: number;
  40109. maxPitch?: number;
  40110. minPitch?: number;
  40111. slerpAmount?: number;
  40112. upAxis?: Vector3;
  40113. upAxisSpace?: Space;
  40114. yawAxis?: Vector3;
  40115. pitchAxis?: Vector3;
  40116. adjustYaw?: number;
  40117. adjustPitch?: number;
  40118. adjustRoll?: number;
  40119. });
  40120. /**
  40121. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40122. */
  40123. update(): void;
  40124. private _getAngleDiff;
  40125. private _getAngleBetween;
  40126. private _isAngleBetween;
  40127. }
  40128. }
  40129. declare module "babylonjs/Bones/index" {
  40130. export * from "babylonjs/Bones/bone";
  40131. export * from "babylonjs/Bones/boneIKController";
  40132. export * from "babylonjs/Bones/boneLookController";
  40133. export * from "babylonjs/Bones/skeleton";
  40134. }
  40135. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40136. import { Nullable } from "babylonjs/types";
  40137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40139. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40140. /**
  40141. * Manage the gamepad inputs to control an arc rotate camera.
  40142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40143. */
  40144. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40145. /**
  40146. * Defines the camera the input is attached to.
  40147. */
  40148. camera: ArcRotateCamera;
  40149. /**
  40150. * Defines the gamepad the input is gathering event from.
  40151. */
  40152. gamepad: Nullable<Gamepad>;
  40153. /**
  40154. * Defines the gamepad rotation sensiblity.
  40155. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40156. */
  40157. gamepadRotationSensibility: number;
  40158. /**
  40159. * Defines the gamepad move sensiblity.
  40160. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40161. */
  40162. gamepadMoveSensibility: number;
  40163. private _yAxisScale;
  40164. /**
  40165. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40166. */
  40167. invertYAxis: boolean;
  40168. private _onGamepadConnectedObserver;
  40169. private _onGamepadDisconnectedObserver;
  40170. /**
  40171. * Attach the input controls to a specific dom element to get the input from.
  40172. * @param element Defines the element the controls should be listened from
  40173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40174. */
  40175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40176. /**
  40177. * Detach the current controls from the specified dom element.
  40178. * @param element Defines the element to stop listening the inputs from
  40179. */
  40180. detachControl(element: Nullable<HTMLElement>): void;
  40181. /**
  40182. * Update the current camera state depending on the inputs that have been used this frame.
  40183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40184. */
  40185. checkInputs(): void;
  40186. /**
  40187. * Gets the class name of the current intput.
  40188. * @returns the class name
  40189. */
  40190. getClassName(): string;
  40191. /**
  40192. * Get the friendly name associated with the input class.
  40193. * @returns the input friendly name
  40194. */
  40195. getSimpleName(): string;
  40196. }
  40197. }
  40198. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40199. import { Nullable } from "babylonjs/types";
  40200. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40201. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40202. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40203. interface ArcRotateCameraInputsManager {
  40204. /**
  40205. * Add orientation input support to the input manager.
  40206. * @returns the current input manager
  40207. */
  40208. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40209. }
  40210. }
  40211. /**
  40212. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40213. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40214. */
  40215. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40216. /**
  40217. * Defines the camera the input is attached to.
  40218. */
  40219. camera: ArcRotateCamera;
  40220. /**
  40221. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40222. */
  40223. alphaCorrection: number;
  40224. /**
  40225. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40226. */
  40227. gammaCorrection: number;
  40228. private _alpha;
  40229. private _gamma;
  40230. private _dirty;
  40231. private _deviceOrientationHandler;
  40232. /**
  40233. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40234. */
  40235. constructor();
  40236. /**
  40237. * Attach the input controls to a specific dom element to get the input from.
  40238. * @param element Defines the element the controls should be listened from
  40239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40240. */
  40241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40242. /** @hidden */
  40243. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40244. /**
  40245. * Update the current camera state depending on the inputs that have been used this frame.
  40246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40247. */
  40248. checkInputs(): void;
  40249. /**
  40250. * Detach the current controls from the specified dom element.
  40251. * @param element Defines the element to stop listening the inputs from
  40252. */
  40253. detachControl(element: Nullable<HTMLElement>): void;
  40254. /**
  40255. * Gets the class name of the current intput.
  40256. * @returns the class name
  40257. */
  40258. getClassName(): string;
  40259. /**
  40260. * Get the friendly name associated with the input class.
  40261. * @returns the input friendly name
  40262. */
  40263. getSimpleName(): string;
  40264. }
  40265. }
  40266. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40267. import { Nullable } from "babylonjs/types";
  40268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40269. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40270. /**
  40271. * Listen to mouse events to control the camera.
  40272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40273. */
  40274. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40275. /**
  40276. * Defines the camera the input is attached to.
  40277. */
  40278. camera: FlyCamera;
  40279. /**
  40280. * Defines if touch is enabled. (Default is true.)
  40281. */
  40282. touchEnabled: boolean;
  40283. /**
  40284. * Defines the buttons associated with the input to handle camera rotation.
  40285. */
  40286. buttons: number[];
  40287. /**
  40288. * Assign buttons for Yaw control.
  40289. */
  40290. buttonsYaw: number[];
  40291. /**
  40292. * Assign buttons for Pitch control.
  40293. */
  40294. buttonsPitch: number[];
  40295. /**
  40296. * Assign buttons for Roll control.
  40297. */
  40298. buttonsRoll: number[];
  40299. /**
  40300. * Detect if any button is being pressed while mouse is moved.
  40301. * -1 = Mouse locked.
  40302. * 0 = Left button.
  40303. * 1 = Middle Button.
  40304. * 2 = Right Button.
  40305. */
  40306. activeButton: number;
  40307. /**
  40308. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40309. * Higher values reduce its sensitivity.
  40310. */
  40311. angularSensibility: number;
  40312. private _mousemoveCallback;
  40313. private _observer;
  40314. private _rollObserver;
  40315. private previousPosition;
  40316. private noPreventDefault;
  40317. private element;
  40318. /**
  40319. * Listen to mouse events to control the camera.
  40320. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40322. */
  40323. constructor(touchEnabled?: boolean);
  40324. /**
  40325. * Attach the mouse control to the HTML DOM element.
  40326. * @param element Defines the element that listens to the input events.
  40327. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40328. */
  40329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40330. /**
  40331. * Detach the current controls from the specified dom element.
  40332. * @param element Defines the element to stop listening the inputs from
  40333. */
  40334. detachControl(element: Nullable<HTMLElement>): void;
  40335. /**
  40336. * Gets the class name of the current input.
  40337. * @returns the class name.
  40338. */
  40339. getClassName(): string;
  40340. /**
  40341. * Get the friendly name associated with the input class.
  40342. * @returns the input's friendly name.
  40343. */
  40344. getSimpleName(): string;
  40345. private _pointerInput;
  40346. private _onMouseMove;
  40347. /**
  40348. * Rotate camera by mouse offset.
  40349. */
  40350. private rotateCamera;
  40351. }
  40352. }
  40353. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40354. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40355. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40356. /**
  40357. * Default Inputs manager for the FlyCamera.
  40358. * It groups all the default supported inputs for ease of use.
  40359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40360. */
  40361. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40362. /**
  40363. * Instantiates a new FlyCameraInputsManager.
  40364. * @param camera Defines the camera the inputs belong to.
  40365. */
  40366. constructor(camera: FlyCamera);
  40367. /**
  40368. * Add keyboard input support to the input manager.
  40369. * @returns the new FlyCameraKeyboardMoveInput().
  40370. */
  40371. addKeyboard(): FlyCameraInputsManager;
  40372. /**
  40373. * Add mouse input support to the input manager.
  40374. * @param touchEnabled Enable touch screen support.
  40375. * @returns the new FlyCameraMouseInput().
  40376. */
  40377. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40378. }
  40379. }
  40380. declare module "babylonjs/Cameras/flyCamera" {
  40381. import { Scene } from "babylonjs/scene";
  40382. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40384. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40385. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40386. /**
  40387. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40388. * such as in a 3D Space Shooter or a Flight Simulator.
  40389. */
  40390. export class FlyCamera extends TargetCamera {
  40391. /**
  40392. * Define the collision ellipsoid of the camera.
  40393. * This is helpful for simulating a camera body, like a player's body.
  40394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40395. */
  40396. ellipsoid: Vector3;
  40397. /**
  40398. * Define an offset for the position of the ellipsoid around the camera.
  40399. * This can be helpful if the camera is attached away from the player's body center,
  40400. * such as at its head.
  40401. */
  40402. ellipsoidOffset: Vector3;
  40403. /**
  40404. * Enable or disable collisions of the camera with the rest of the scene objects.
  40405. */
  40406. checkCollisions: boolean;
  40407. /**
  40408. * Enable or disable gravity on the camera.
  40409. */
  40410. applyGravity: boolean;
  40411. /**
  40412. * Define the current direction the camera is moving to.
  40413. */
  40414. cameraDirection: Vector3;
  40415. /**
  40416. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40417. * This overrides and empties cameraRotation.
  40418. */
  40419. rotationQuaternion: Quaternion;
  40420. /**
  40421. * Track Roll to maintain the wanted Rolling when looking around.
  40422. */
  40423. _trackRoll: number;
  40424. /**
  40425. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40426. */
  40427. rollCorrect: number;
  40428. /**
  40429. * Mimic a banked turn, Rolling the camera when Yawing.
  40430. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40431. */
  40432. bankedTurn: boolean;
  40433. /**
  40434. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40435. */
  40436. bankedTurnLimit: number;
  40437. /**
  40438. * Value of 0 disables the banked Roll.
  40439. * Value of 1 is equal to the Yaw angle in radians.
  40440. */
  40441. bankedTurnMultiplier: number;
  40442. /**
  40443. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40444. */
  40445. inputs: FlyCameraInputsManager;
  40446. /**
  40447. * Gets the input sensibility for mouse input.
  40448. * Higher values reduce sensitivity.
  40449. */
  40450. /**
  40451. * Sets the input sensibility for a mouse input.
  40452. * Higher values reduce sensitivity.
  40453. */
  40454. angularSensibility: number;
  40455. /**
  40456. * Get the keys for camera movement forward.
  40457. */
  40458. /**
  40459. * Set the keys for camera movement forward.
  40460. */
  40461. keysForward: number[];
  40462. /**
  40463. * Get the keys for camera movement backward.
  40464. */
  40465. keysBackward: number[];
  40466. /**
  40467. * Get the keys for camera movement up.
  40468. */
  40469. /**
  40470. * Set the keys for camera movement up.
  40471. */
  40472. keysUp: number[];
  40473. /**
  40474. * Get the keys for camera movement down.
  40475. */
  40476. /**
  40477. * Set the keys for camera movement down.
  40478. */
  40479. keysDown: number[];
  40480. /**
  40481. * Get the keys for camera movement left.
  40482. */
  40483. /**
  40484. * Set the keys for camera movement left.
  40485. */
  40486. keysLeft: number[];
  40487. /**
  40488. * Set the keys for camera movement right.
  40489. */
  40490. /**
  40491. * Set the keys for camera movement right.
  40492. */
  40493. keysRight: number[];
  40494. /**
  40495. * Event raised when the camera collides with a mesh in the scene.
  40496. */
  40497. onCollide: (collidedMesh: AbstractMesh) => void;
  40498. private _collider;
  40499. private _needMoveForGravity;
  40500. private _oldPosition;
  40501. private _diffPosition;
  40502. private _newPosition;
  40503. /** @hidden */
  40504. _localDirection: Vector3;
  40505. /** @hidden */
  40506. _transformedDirection: Vector3;
  40507. /**
  40508. * Instantiates a FlyCamera.
  40509. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40510. * such as in a 3D Space Shooter or a Flight Simulator.
  40511. * @param name Define the name of the camera in the scene.
  40512. * @param position Define the starting position of the camera in the scene.
  40513. * @param scene Define the scene the camera belongs to.
  40514. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40515. */
  40516. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40517. /**
  40518. * Attach a control to the HTML DOM element.
  40519. * @param element Defines the element that listens to the input events.
  40520. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40521. */
  40522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40523. /**
  40524. * Detach a control from the HTML DOM element.
  40525. * The camera will stop reacting to that input.
  40526. * @param element Defines the element that listens to the input events.
  40527. */
  40528. detachControl(element: HTMLElement): void;
  40529. private _collisionMask;
  40530. /**
  40531. * Get the mask that the camera ignores in collision events.
  40532. */
  40533. /**
  40534. * Set the mask that the camera ignores in collision events.
  40535. */
  40536. collisionMask: number;
  40537. /** @hidden */
  40538. _collideWithWorld(displacement: Vector3): void;
  40539. /** @hidden */
  40540. private _onCollisionPositionChange;
  40541. /** @hidden */
  40542. _checkInputs(): void;
  40543. /** @hidden */
  40544. _decideIfNeedsToMove(): boolean;
  40545. /** @hidden */
  40546. _updatePosition(): void;
  40547. /**
  40548. * Restore the Roll to its target value at the rate specified.
  40549. * @param rate - Higher means slower restoring.
  40550. * @hidden
  40551. */
  40552. restoreRoll(rate: number): void;
  40553. /**
  40554. * Destroy the camera and release the current resources held by it.
  40555. */
  40556. dispose(): void;
  40557. /**
  40558. * Get the current object class name.
  40559. * @returns the class name.
  40560. */
  40561. getClassName(): string;
  40562. }
  40563. }
  40564. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40565. import { Nullable } from "babylonjs/types";
  40566. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40567. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40568. /**
  40569. * Listen to keyboard events to control the camera.
  40570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40571. */
  40572. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40573. /**
  40574. * Defines the camera the input is attached to.
  40575. */
  40576. camera: FlyCamera;
  40577. /**
  40578. * The list of keyboard keys used to control the forward move of the camera.
  40579. */
  40580. keysForward: number[];
  40581. /**
  40582. * The list of keyboard keys used to control the backward move of the camera.
  40583. */
  40584. keysBackward: number[];
  40585. /**
  40586. * The list of keyboard keys used to control the forward move of the camera.
  40587. */
  40588. keysUp: number[];
  40589. /**
  40590. * The list of keyboard keys used to control the backward move of the camera.
  40591. */
  40592. keysDown: number[];
  40593. /**
  40594. * The list of keyboard keys used to control the right strafe move of the camera.
  40595. */
  40596. keysRight: number[];
  40597. /**
  40598. * The list of keyboard keys used to control the left strafe move of the camera.
  40599. */
  40600. keysLeft: number[];
  40601. private _keys;
  40602. private _onCanvasBlurObserver;
  40603. private _onKeyboardObserver;
  40604. private _engine;
  40605. private _scene;
  40606. /**
  40607. * Attach the input controls to a specific dom element to get the input from.
  40608. * @param element Defines the element the controls should be listened from
  40609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40610. */
  40611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40612. /**
  40613. * Detach the current controls from the specified dom element.
  40614. * @param element Defines the element to stop listening the inputs from
  40615. */
  40616. detachControl(element: Nullable<HTMLElement>): void;
  40617. /**
  40618. * Gets the class name of the current intput.
  40619. * @returns the class name
  40620. */
  40621. getClassName(): string;
  40622. /** @hidden */
  40623. _onLostFocus(e: FocusEvent): void;
  40624. /**
  40625. * Get the friendly name associated with the input class.
  40626. * @returns the input friendly name
  40627. */
  40628. getSimpleName(): string;
  40629. /**
  40630. * Update the current camera state depending on the inputs that have been used this frame.
  40631. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40632. */
  40633. checkInputs(): void;
  40634. }
  40635. }
  40636. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40637. import { Nullable } from "babylonjs/types";
  40638. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40640. /**
  40641. * Manage the mouse wheel inputs to control a follow camera.
  40642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40643. */
  40644. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40645. /**
  40646. * Defines the camera the input is attached to.
  40647. */
  40648. camera: FollowCamera;
  40649. /**
  40650. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40651. */
  40652. axisControlRadius: boolean;
  40653. /**
  40654. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40655. */
  40656. axisControlHeight: boolean;
  40657. /**
  40658. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40659. */
  40660. axisControlRotation: boolean;
  40661. /**
  40662. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40663. * relation to mouseWheel events.
  40664. */
  40665. wheelPrecision: number;
  40666. /**
  40667. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40668. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40669. */
  40670. wheelDeltaPercentage: number;
  40671. private _wheel;
  40672. private _observer;
  40673. /**
  40674. * Attach the input controls to a specific dom element to get the input from.
  40675. * @param element Defines the element the controls should be listened from
  40676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40677. */
  40678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40679. /**
  40680. * Detach the current controls from the specified dom element.
  40681. * @param element Defines the element to stop listening the inputs from
  40682. */
  40683. detachControl(element: Nullable<HTMLElement>): void;
  40684. /**
  40685. * Gets the class name of the current intput.
  40686. * @returns the class name
  40687. */
  40688. getClassName(): string;
  40689. /**
  40690. * Get the friendly name associated with the input class.
  40691. * @returns the input friendly name
  40692. */
  40693. getSimpleName(): string;
  40694. }
  40695. }
  40696. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40697. import { Nullable } from "babylonjs/types";
  40698. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40699. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40700. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40701. /**
  40702. * Manage the pointers inputs to control an follow camera.
  40703. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40704. */
  40705. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40706. /**
  40707. * Defines the camera the input is attached to.
  40708. */
  40709. camera: FollowCamera;
  40710. /**
  40711. * Gets the class name of the current input.
  40712. * @returns the class name
  40713. */
  40714. getClassName(): string;
  40715. /**
  40716. * Defines the pointer angular sensibility along the X axis or how fast is
  40717. * the camera rotating.
  40718. * A negative number will reverse the axis direction.
  40719. */
  40720. angularSensibilityX: number;
  40721. /**
  40722. * Defines the pointer angular sensibility along the Y axis or how fast is
  40723. * the camera rotating.
  40724. * A negative number will reverse the axis direction.
  40725. */
  40726. angularSensibilityY: number;
  40727. /**
  40728. * Defines the pointer pinch precision or how fast is the camera zooming.
  40729. * A negative number will reverse the axis direction.
  40730. */
  40731. pinchPrecision: number;
  40732. /**
  40733. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40734. * from 0.
  40735. * It defines the percentage of current camera.radius to use as delta when
  40736. * pinch zoom is used.
  40737. */
  40738. pinchDeltaPercentage: number;
  40739. /**
  40740. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40741. */
  40742. axisXControlRadius: boolean;
  40743. /**
  40744. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40745. */
  40746. axisXControlHeight: boolean;
  40747. /**
  40748. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40749. */
  40750. axisXControlRotation: boolean;
  40751. /**
  40752. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40753. */
  40754. axisYControlRadius: boolean;
  40755. /**
  40756. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40757. */
  40758. axisYControlHeight: boolean;
  40759. /**
  40760. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40761. */
  40762. axisYControlRotation: boolean;
  40763. /**
  40764. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40765. */
  40766. axisPinchControlRadius: boolean;
  40767. /**
  40768. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40769. */
  40770. axisPinchControlHeight: boolean;
  40771. /**
  40772. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40773. */
  40774. axisPinchControlRotation: boolean;
  40775. /**
  40776. * Log error messages if basic misconfiguration has occurred.
  40777. */
  40778. warningEnable: boolean;
  40779. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40780. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40781. private _warningCounter;
  40782. private _warning;
  40783. }
  40784. }
  40785. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40786. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40787. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40788. /**
  40789. * Default Inputs manager for the FollowCamera.
  40790. * It groups all the default supported inputs for ease of use.
  40791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40792. */
  40793. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40794. /**
  40795. * Instantiates a new FollowCameraInputsManager.
  40796. * @param camera Defines the camera the inputs belong to
  40797. */
  40798. constructor(camera: FollowCamera);
  40799. /**
  40800. * Add keyboard input support to the input manager.
  40801. * @returns the current input manager
  40802. */
  40803. addKeyboard(): FollowCameraInputsManager;
  40804. /**
  40805. * Add mouse wheel input support to the input manager.
  40806. * @returns the current input manager
  40807. */
  40808. addMouseWheel(): FollowCameraInputsManager;
  40809. /**
  40810. * Add pointers input support to the input manager.
  40811. * @returns the current input manager
  40812. */
  40813. addPointers(): FollowCameraInputsManager;
  40814. /**
  40815. * Add orientation input support to the input manager.
  40816. * @returns the current input manager
  40817. */
  40818. addVRDeviceOrientation(): FollowCameraInputsManager;
  40819. }
  40820. }
  40821. declare module "babylonjs/Cameras/followCamera" {
  40822. import { Nullable } from "babylonjs/types";
  40823. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40824. import { Scene } from "babylonjs/scene";
  40825. import { Vector3 } from "babylonjs/Maths/math.vector";
  40826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40827. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40828. /**
  40829. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40830. * an arc rotate version arcFollowCamera are available.
  40831. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40832. */
  40833. export class FollowCamera extends TargetCamera {
  40834. /**
  40835. * Distance the follow camera should follow an object at
  40836. */
  40837. radius: number;
  40838. /**
  40839. * Minimum allowed distance of the camera to the axis of rotation
  40840. * (The camera can not get closer).
  40841. * This can help limiting how the Camera is able to move in the scene.
  40842. */
  40843. lowerRadiusLimit: Nullable<number>;
  40844. /**
  40845. * Maximum allowed distance of the camera to the axis of rotation
  40846. * (The camera can not get further).
  40847. * This can help limiting how the Camera is able to move in the scene.
  40848. */
  40849. upperRadiusLimit: Nullable<number>;
  40850. /**
  40851. * Define a rotation offset between the camera and the object it follows
  40852. */
  40853. rotationOffset: number;
  40854. /**
  40855. * Minimum allowed angle to camera position relative to target object.
  40856. * This can help limiting how the Camera is able to move in the scene.
  40857. */
  40858. lowerRotationOffsetLimit: Nullable<number>;
  40859. /**
  40860. * Maximum allowed angle to camera position relative to target object.
  40861. * This can help limiting how the Camera is able to move in the scene.
  40862. */
  40863. upperRotationOffsetLimit: Nullable<number>;
  40864. /**
  40865. * Define a height offset between the camera and the object it follows.
  40866. * It can help following an object from the top (like a car chaing a plane)
  40867. */
  40868. heightOffset: number;
  40869. /**
  40870. * Minimum allowed height of camera position relative to target object.
  40871. * This can help limiting how the Camera is able to move in the scene.
  40872. */
  40873. lowerHeightOffsetLimit: Nullable<number>;
  40874. /**
  40875. * Maximum allowed height of camera position relative to target object.
  40876. * This can help limiting how the Camera is able to move in the scene.
  40877. */
  40878. upperHeightOffsetLimit: Nullable<number>;
  40879. /**
  40880. * Define how fast the camera can accelerate to follow it s target.
  40881. */
  40882. cameraAcceleration: number;
  40883. /**
  40884. * Define the speed limit of the camera following an object.
  40885. */
  40886. maxCameraSpeed: number;
  40887. /**
  40888. * Define the target of the camera.
  40889. */
  40890. lockedTarget: Nullable<AbstractMesh>;
  40891. /**
  40892. * Defines the input associated with the camera.
  40893. */
  40894. inputs: FollowCameraInputsManager;
  40895. /**
  40896. * Instantiates the follow camera.
  40897. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40898. * @param name Define the name of the camera in the scene
  40899. * @param position Define the position of the camera
  40900. * @param scene Define the scene the camera belong to
  40901. * @param lockedTarget Define the target of the camera
  40902. */
  40903. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40904. private _follow;
  40905. /**
  40906. * Attached controls to the current camera.
  40907. * @param element Defines the element the controls should be listened from
  40908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40909. */
  40910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40911. /**
  40912. * Detach the current controls from the camera.
  40913. * The camera will stop reacting to inputs.
  40914. * @param element Defines the element to stop listening the inputs from
  40915. */
  40916. detachControl(element: HTMLElement): void;
  40917. /** @hidden */
  40918. _checkInputs(): void;
  40919. private _checkLimits;
  40920. /**
  40921. * Gets the camera class name.
  40922. * @returns the class name
  40923. */
  40924. getClassName(): string;
  40925. }
  40926. /**
  40927. * Arc Rotate version of the follow camera.
  40928. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40929. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40930. */
  40931. export class ArcFollowCamera extends TargetCamera {
  40932. /** The longitudinal angle of the camera */
  40933. alpha: number;
  40934. /** The latitudinal angle of the camera */
  40935. beta: number;
  40936. /** The radius of the camera from its target */
  40937. radius: number;
  40938. /** Define the camera target (the messh it should follow) */
  40939. target: Nullable<AbstractMesh>;
  40940. private _cartesianCoordinates;
  40941. /**
  40942. * Instantiates a new ArcFollowCamera
  40943. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40944. * @param name Define the name of the camera
  40945. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40946. * @param beta Define the rotation angle of the camera around the elevation axis
  40947. * @param radius Define the radius of the camera from its target point
  40948. * @param target Define the target of the camera
  40949. * @param scene Define the scene the camera belongs to
  40950. */
  40951. constructor(name: string,
  40952. /** The longitudinal angle of the camera */
  40953. alpha: number,
  40954. /** The latitudinal angle of the camera */
  40955. beta: number,
  40956. /** The radius of the camera from its target */
  40957. radius: number,
  40958. /** Define the camera target (the messh it should follow) */
  40959. target: Nullable<AbstractMesh>, scene: Scene);
  40960. private _follow;
  40961. /** @hidden */
  40962. _checkInputs(): void;
  40963. /**
  40964. * Returns the class name of the object.
  40965. * It is mostly used internally for serialization purposes.
  40966. */
  40967. getClassName(): string;
  40968. }
  40969. }
  40970. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  40971. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40972. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40973. import { Nullable } from "babylonjs/types";
  40974. /**
  40975. * Manage the keyboard inputs to control the movement of a follow camera.
  40976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40977. */
  40978. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40979. /**
  40980. * Defines the camera the input is attached to.
  40981. */
  40982. camera: FollowCamera;
  40983. /**
  40984. * Defines the list of key codes associated with the up action (increase heightOffset)
  40985. */
  40986. keysHeightOffsetIncr: number[];
  40987. /**
  40988. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40989. */
  40990. keysHeightOffsetDecr: number[];
  40991. /**
  40992. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40993. */
  40994. keysHeightOffsetModifierAlt: boolean;
  40995. /**
  40996. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40997. */
  40998. keysHeightOffsetModifierCtrl: boolean;
  40999. /**
  41000. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41001. */
  41002. keysHeightOffsetModifierShift: boolean;
  41003. /**
  41004. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41005. */
  41006. keysRotationOffsetIncr: number[];
  41007. /**
  41008. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41009. */
  41010. keysRotationOffsetDecr: number[];
  41011. /**
  41012. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41013. */
  41014. keysRotationOffsetModifierAlt: boolean;
  41015. /**
  41016. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41017. */
  41018. keysRotationOffsetModifierCtrl: boolean;
  41019. /**
  41020. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41021. */
  41022. keysRotationOffsetModifierShift: boolean;
  41023. /**
  41024. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41025. */
  41026. keysRadiusIncr: number[];
  41027. /**
  41028. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41029. */
  41030. keysRadiusDecr: number[];
  41031. /**
  41032. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41033. */
  41034. keysRadiusModifierAlt: boolean;
  41035. /**
  41036. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41037. */
  41038. keysRadiusModifierCtrl: boolean;
  41039. /**
  41040. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41041. */
  41042. keysRadiusModifierShift: boolean;
  41043. /**
  41044. * Defines the rate of change of heightOffset.
  41045. */
  41046. heightSensibility: number;
  41047. /**
  41048. * Defines the rate of change of rotationOffset.
  41049. */
  41050. rotationSensibility: number;
  41051. /**
  41052. * Defines the rate of change of radius.
  41053. */
  41054. radiusSensibility: number;
  41055. private _keys;
  41056. private _ctrlPressed;
  41057. private _altPressed;
  41058. private _shiftPressed;
  41059. private _onCanvasBlurObserver;
  41060. private _onKeyboardObserver;
  41061. private _engine;
  41062. private _scene;
  41063. /**
  41064. * Attach the input controls to a specific dom element to get the input from.
  41065. * @param element Defines the element the controls should be listened from
  41066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41067. */
  41068. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41069. /**
  41070. * Detach the current controls from the specified dom element.
  41071. * @param element Defines the element to stop listening the inputs from
  41072. */
  41073. detachControl(element: Nullable<HTMLElement>): void;
  41074. /**
  41075. * Update the current camera state depending on the inputs that have been used this frame.
  41076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41077. */
  41078. checkInputs(): void;
  41079. /**
  41080. * Gets the class name of the current input.
  41081. * @returns the class name
  41082. */
  41083. getClassName(): string;
  41084. /**
  41085. * Get the friendly name associated with the input class.
  41086. * @returns the input friendly name
  41087. */
  41088. getSimpleName(): string;
  41089. /**
  41090. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41091. * allow modification of the heightOffset value.
  41092. */
  41093. private _modifierHeightOffset;
  41094. /**
  41095. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41096. * allow modification of the rotationOffset value.
  41097. */
  41098. private _modifierRotationOffset;
  41099. /**
  41100. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41101. * allow modification of the radius value.
  41102. */
  41103. private _modifierRadius;
  41104. }
  41105. }
  41106. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41107. import { Nullable } from "babylonjs/types";
  41108. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41109. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41110. import { Observable } from "babylonjs/Misc/observable";
  41111. module "babylonjs/Cameras/freeCameraInputsManager" {
  41112. interface FreeCameraInputsManager {
  41113. /**
  41114. * @hidden
  41115. */
  41116. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41117. /**
  41118. * Add orientation input support to the input manager.
  41119. * @returns the current input manager
  41120. */
  41121. addDeviceOrientation(): FreeCameraInputsManager;
  41122. }
  41123. }
  41124. /**
  41125. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41126. * Screen rotation is taken into account.
  41127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41128. */
  41129. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41130. private _camera;
  41131. private _screenOrientationAngle;
  41132. private _constantTranform;
  41133. private _screenQuaternion;
  41134. private _alpha;
  41135. private _beta;
  41136. private _gamma;
  41137. /**
  41138. * Can be used to detect if a device orientation sensor is availible on a device
  41139. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41140. * @returns a promise that will resolve on orientation change
  41141. */
  41142. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41143. /**
  41144. * @hidden
  41145. */
  41146. _onDeviceOrientationChangedObservable: Observable<void>;
  41147. /**
  41148. * Instantiates a new input
  41149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41150. */
  41151. constructor();
  41152. /**
  41153. * Define the camera controlled by the input.
  41154. */
  41155. camera: FreeCamera;
  41156. /**
  41157. * Attach the input controls to a specific dom element to get the input from.
  41158. * @param element Defines the element the controls should be listened from
  41159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41160. */
  41161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41162. private _orientationChanged;
  41163. private _deviceOrientation;
  41164. /**
  41165. * Detach the current controls from the specified dom element.
  41166. * @param element Defines the element to stop listening the inputs from
  41167. */
  41168. detachControl(element: Nullable<HTMLElement>): void;
  41169. /**
  41170. * Update the current camera state depending on the inputs that have been used this frame.
  41171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41172. */
  41173. checkInputs(): void;
  41174. /**
  41175. * Gets the class name of the current intput.
  41176. * @returns the class name
  41177. */
  41178. getClassName(): string;
  41179. /**
  41180. * Get the friendly name associated with the input class.
  41181. * @returns the input friendly name
  41182. */
  41183. getSimpleName(): string;
  41184. }
  41185. }
  41186. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41187. import { Nullable } from "babylonjs/types";
  41188. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41189. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41190. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41191. /**
  41192. * Manage the gamepad inputs to control a free camera.
  41193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41194. */
  41195. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41196. /**
  41197. * Define the camera the input is attached to.
  41198. */
  41199. camera: FreeCamera;
  41200. /**
  41201. * Define the Gamepad controlling the input
  41202. */
  41203. gamepad: Nullable<Gamepad>;
  41204. /**
  41205. * Defines the gamepad rotation sensiblity.
  41206. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41207. */
  41208. gamepadAngularSensibility: number;
  41209. /**
  41210. * Defines the gamepad move sensiblity.
  41211. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41212. */
  41213. gamepadMoveSensibility: number;
  41214. private _yAxisScale;
  41215. /**
  41216. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41217. */
  41218. invertYAxis: boolean;
  41219. private _onGamepadConnectedObserver;
  41220. private _onGamepadDisconnectedObserver;
  41221. private _cameraTransform;
  41222. private _deltaTransform;
  41223. private _vector3;
  41224. private _vector2;
  41225. /**
  41226. * Attach the input controls to a specific dom element to get the input from.
  41227. * @param element Defines the element the controls should be listened from
  41228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41229. */
  41230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41231. /**
  41232. * Detach the current controls from the specified dom element.
  41233. * @param element Defines the element to stop listening the inputs from
  41234. */
  41235. detachControl(element: Nullable<HTMLElement>): void;
  41236. /**
  41237. * Update the current camera state depending on the inputs that have been used this frame.
  41238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41239. */
  41240. checkInputs(): void;
  41241. /**
  41242. * Gets the class name of the current intput.
  41243. * @returns the class name
  41244. */
  41245. getClassName(): string;
  41246. /**
  41247. * Get the friendly name associated with the input class.
  41248. * @returns the input friendly name
  41249. */
  41250. getSimpleName(): string;
  41251. }
  41252. }
  41253. declare module "babylonjs/Misc/virtualJoystick" {
  41254. import { Nullable } from "babylonjs/types";
  41255. import { Vector3 } from "babylonjs/Maths/math.vector";
  41256. /**
  41257. * Defines the potential axis of a Joystick
  41258. */
  41259. export enum JoystickAxis {
  41260. /** X axis */
  41261. X = 0,
  41262. /** Y axis */
  41263. Y = 1,
  41264. /** Z axis */
  41265. Z = 2
  41266. }
  41267. /**
  41268. * Class used to define virtual joystick (used in touch mode)
  41269. */
  41270. export class VirtualJoystick {
  41271. /**
  41272. * Gets or sets a boolean indicating that left and right values must be inverted
  41273. */
  41274. reverseLeftRight: boolean;
  41275. /**
  41276. * Gets or sets a boolean indicating that up and down values must be inverted
  41277. */
  41278. reverseUpDown: boolean;
  41279. /**
  41280. * Gets the offset value for the position (ie. the change of the position value)
  41281. */
  41282. deltaPosition: Vector3;
  41283. /**
  41284. * Gets a boolean indicating if the virtual joystick was pressed
  41285. */
  41286. pressed: boolean;
  41287. /**
  41288. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41289. */
  41290. static Canvas: Nullable<HTMLCanvasElement>;
  41291. private static _globalJoystickIndex;
  41292. private static vjCanvasContext;
  41293. private static vjCanvasWidth;
  41294. private static vjCanvasHeight;
  41295. private static halfWidth;
  41296. private _action;
  41297. private _axisTargetedByLeftAndRight;
  41298. private _axisTargetedByUpAndDown;
  41299. private _joystickSensibility;
  41300. private _inversedSensibility;
  41301. private _joystickPointerID;
  41302. private _joystickColor;
  41303. private _joystickPointerPos;
  41304. private _joystickPreviousPointerPos;
  41305. private _joystickPointerStartPos;
  41306. private _deltaJoystickVector;
  41307. private _leftJoystick;
  41308. private _touches;
  41309. private _onPointerDownHandlerRef;
  41310. private _onPointerMoveHandlerRef;
  41311. private _onPointerUpHandlerRef;
  41312. private _onResize;
  41313. /**
  41314. * Creates a new virtual joystick
  41315. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41316. */
  41317. constructor(leftJoystick?: boolean);
  41318. /**
  41319. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41320. * @param newJoystickSensibility defines the new sensibility
  41321. */
  41322. setJoystickSensibility(newJoystickSensibility: number): void;
  41323. private _onPointerDown;
  41324. private _onPointerMove;
  41325. private _onPointerUp;
  41326. /**
  41327. * Change the color of the virtual joystick
  41328. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41329. */
  41330. setJoystickColor(newColor: string): void;
  41331. /**
  41332. * Defines a callback to call when the joystick is touched
  41333. * @param action defines the callback
  41334. */
  41335. setActionOnTouch(action: () => any): void;
  41336. /**
  41337. * Defines which axis you'd like to control for left & right
  41338. * @param axis defines the axis to use
  41339. */
  41340. setAxisForLeftRight(axis: JoystickAxis): void;
  41341. /**
  41342. * Defines which axis you'd like to control for up & down
  41343. * @param axis defines the axis to use
  41344. */
  41345. setAxisForUpDown(axis: JoystickAxis): void;
  41346. private _drawVirtualJoystick;
  41347. /**
  41348. * Release internal HTML canvas
  41349. */
  41350. releaseCanvas(): void;
  41351. }
  41352. }
  41353. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41354. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41355. import { Nullable } from "babylonjs/types";
  41356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41357. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41358. module "babylonjs/Cameras/freeCameraInputsManager" {
  41359. interface FreeCameraInputsManager {
  41360. /**
  41361. * Add virtual joystick input support to the input manager.
  41362. * @returns the current input manager
  41363. */
  41364. addVirtualJoystick(): FreeCameraInputsManager;
  41365. }
  41366. }
  41367. /**
  41368. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41370. */
  41371. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41372. /**
  41373. * Defines the camera the input is attached to.
  41374. */
  41375. camera: FreeCamera;
  41376. private _leftjoystick;
  41377. private _rightjoystick;
  41378. /**
  41379. * Gets the left stick of the virtual joystick.
  41380. * @returns The virtual Joystick
  41381. */
  41382. getLeftJoystick(): VirtualJoystick;
  41383. /**
  41384. * Gets the right stick of the virtual joystick.
  41385. * @returns The virtual Joystick
  41386. */
  41387. getRightJoystick(): VirtualJoystick;
  41388. /**
  41389. * Update the current camera state depending on the inputs that have been used this frame.
  41390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41391. */
  41392. checkInputs(): void;
  41393. /**
  41394. * Attach the input controls to a specific dom element to get the input from.
  41395. * @param element Defines the element the controls should be listened from
  41396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41397. */
  41398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41399. /**
  41400. * Detach the current controls from the specified dom element.
  41401. * @param element Defines the element to stop listening the inputs from
  41402. */
  41403. detachControl(element: Nullable<HTMLElement>): void;
  41404. /**
  41405. * Gets the class name of the current intput.
  41406. * @returns the class name
  41407. */
  41408. getClassName(): string;
  41409. /**
  41410. * Get the friendly name associated with the input class.
  41411. * @returns the input friendly name
  41412. */
  41413. getSimpleName(): string;
  41414. }
  41415. }
  41416. declare module "babylonjs/Cameras/Inputs/index" {
  41417. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41418. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41419. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41420. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41421. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41422. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41423. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41424. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41425. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41426. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41427. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41428. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41429. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41430. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41431. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41432. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41433. }
  41434. declare module "babylonjs/Cameras/touchCamera" {
  41435. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41436. import { Scene } from "babylonjs/scene";
  41437. import { Vector3 } from "babylonjs/Maths/math.vector";
  41438. /**
  41439. * This represents a FPS type of camera controlled by touch.
  41440. * This is like a universal camera minus the Gamepad controls.
  41441. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41442. */
  41443. export class TouchCamera extends FreeCamera {
  41444. /**
  41445. * Defines the touch sensibility for rotation.
  41446. * The higher the faster.
  41447. */
  41448. touchAngularSensibility: number;
  41449. /**
  41450. * Defines the touch sensibility for move.
  41451. * The higher the faster.
  41452. */
  41453. touchMoveSensibility: number;
  41454. /**
  41455. * Instantiates a new touch camera.
  41456. * This represents a FPS type of camera controlled by touch.
  41457. * This is like a universal camera minus the Gamepad controls.
  41458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41459. * @param name Define the name of the camera in the scene
  41460. * @param position Define the start position of the camera in the scene
  41461. * @param scene Define the scene the camera belongs to
  41462. */
  41463. constructor(name: string, position: Vector3, scene: Scene);
  41464. /**
  41465. * Gets the current object class name.
  41466. * @return the class name
  41467. */
  41468. getClassName(): string;
  41469. /** @hidden */
  41470. _setupInputs(): void;
  41471. }
  41472. }
  41473. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41475. import { Scene } from "babylonjs/scene";
  41476. import { Vector3 } from "babylonjs/Maths/math.vector";
  41477. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41478. import { Axis } from "babylonjs/Maths/math.axis";
  41479. /**
  41480. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41481. * being tilted forward or back and left or right.
  41482. */
  41483. export class DeviceOrientationCamera extends FreeCamera {
  41484. private _initialQuaternion;
  41485. private _quaternionCache;
  41486. private _tmpDragQuaternion;
  41487. private _disablePointerInputWhenUsingDeviceOrientation;
  41488. /**
  41489. * Creates a new device orientation camera
  41490. * @param name The name of the camera
  41491. * @param position The start position camera
  41492. * @param scene The scene the camera belongs to
  41493. */
  41494. constructor(name: string, position: Vector3, scene: Scene);
  41495. /**
  41496. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41497. */
  41498. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41499. private _dragFactor;
  41500. /**
  41501. * Enabled turning on the y axis when the orientation sensor is active
  41502. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41503. */
  41504. enableHorizontalDragging(dragFactor?: number): void;
  41505. /**
  41506. * Gets the current instance class name ("DeviceOrientationCamera").
  41507. * This helps avoiding instanceof at run time.
  41508. * @returns the class name
  41509. */
  41510. getClassName(): string;
  41511. /**
  41512. * @hidden
  41513. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41514. */
  41515. _checkInputs(): void;
  41516. /**
  41517. * Reset the camera to its default orientation on the specified axis only.
  41518. * @param axis The axis to reset
  41519. */
  41520. resetToCurrentRotation(axis?: Axis): void;
  41521. }
  41522. }
  41523. declare module "babylonjs/Gamepads/xboxGamepad" {
  41524. import { Observable } from "babylonjs/Misc/observable";
  41525. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41526. /**
  41527. * Defines supported buttons for XBox360 compatible gamepads
  41528. */
  41529. export enum Xbox360Button {
  41530. /** A */
  41531. A = 0,
  41532. /** B */
  41533. B = 1,
  41534. /** X */
  41535. X = 2,
  41536. /** Y */
  41537. Y = 3,
  41538. /** Start */
  41539. Start = 4,
  41540. /** Back */
  41541. Back = 5,
  41542. /** Left button */
  41543. LB = 6,
  41544. /** Right button */
  41545. RB = 7,
  41546. /** Left stick */
  41547. LeftStick = 8,
  41548. /** Right stick */
  41549. RightStick = 9
  41550. }
  41551. /** Defines values for XBox360 DPad */
  41552. export enum Xbox360Dpad {
  41553. /** Up */
  41554. Up = 0,
  41555. /** Down */
  41556. Down = 1,
  41557. /** Left */
  41558. Left = 2,
  41559. /** Right */
  41560. Right = 3
  41561. }
  41562. /**
  41563. * Defines a XBox360 gamepad
  41564. */
  41565. export class Xbox360Pad extends Gamepad {
  41566. private _leftTrigger;
  41567. private _rightTrigger;
  41568. private _onlefttriggerchanged;
  41569. private _onrighttriggerchanged;
  41570. private _onbuttondown;
  41571. private _onbuttonup;
  41572. private _ondpaddown;
  41573. private _ondpadup;
  41574. /** Observable raised when a button is pressed */
  41575. onButtonDownObservable: Observable<Xbox360Button>;
  41576. /** Observable raised when a button is released */
  41577. onButtonUpObservable: Observable<Xbox360Button>;
  41578. /** Observable raised when a pad is pressed */
  41579. onPadDownObservable: Observable<Xbox360Dpad>;
  41580. /** Observable raised when a pad is released */
  41581. onPadUpObservable: Observable<Xbox360Dpad>;
  41582. private _buttonA;
  41583. private _buttonB;
  41584. private _buttonX;
  41585. private _buttonY;
  41586. private _buttonBack;
  41587. private _buttonStart;
  41588. private _buttonLB;
  41589. private _buttonRB;
  41590. private _buttonLeftStick;
  41591. private _buttonRightStick;
  41592. private _dPadUp;
  41593. private _dPadDown;
  41594. private _dPadLeft;
  41595. private _dPadRight;
  41596. private _isXboxOnePad;
  41597. /**
  41598. * Creates a new XBox360 gamepad object
  41599. * @param id defines the id of this gamepad
  41600. * @param index defines its index
  41601. * @param gamepad defines the internal HTML gamepad object
  41602. * @param xboxOne defines if it is a XBox One gamepad
  41603. */
  41604. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41605. /**
  41606. * Defines the callback to call when left trigger is pressed
  41607. * @param callback defines the callback to use
  41608. */
  41609. onlefttriggerchanged(callback: (value: number) => void): void;
  41610. /**
  41611. * Defines the callback to call when right trigger is pressed
  41612. * @param callback defines the callback to use
  41613. */
  41614. onrighttriggerchanged(callback: (value: number) => void): void;
  41615. /**
  41616. * Gets the left trigger value
  41617. */
  41618. /**
  41619. * Sets the left trigger value
  41620. */
  41621. leftTrigger: number;
  41622. /**
  41623. * Gets the right trigger value
  41624. */
  41625. /**
  41626. * Sets the right trigger value
  41627. */
  41628. rightTrigger: number;
  41629. /**
  41630. * Defines the callback to call when a button is pressed
  41631. * @param callback defines the callback to use
  41632. */
  41633. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41634. /**
  41635. * Defines the callback to call when a button is released
  41636. * @param callback defines the callback to use
  41637. */
  41638. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41639. /**
  41640. * Defines the callback to call when a pad is pressed
  41641. * @param callback defines the callback to use
  41642. */
  41643. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41644. /**
  41645. * Defines the callback to call when a pad is released
  41646. * @param callback defines the callback to use
  41647. */
  41648. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41649. private _setButtonValue;
  41650. private _setDPadValue;
  41651. /**
  41652. * Gets the value of the `A` button
  41653. */
  41654. /**
  41655. * Sets the value of the `A` button
  41656. */
  41657. buttonA: number;
  41658. /**
  41659. * Gets the value of the `B` button
  41660. */
  41661. /**
  41662. * Sets the value of the `B` button
  41663. */
  41664. buttonB: number;
  41665. /**
  41666. * Gets the value of the `X` button
  41667. */
  41668. /**
  41669. * Sets the value of the `X` button
  41670. */
  41671. buttonX: number;
  41672. /**
  41673. * Gets the value of the `Y` button
  41674. */
  41675. /**
  41676. * Sets the value of the `Y` button
  41677. */
  41678. buttonY: number;
  41679. /**
  41680. * Gets the value of the `Start` button
  41681. */
  41682. /**
  41683. * Sets the value of the `Start` button
  41684. */
  41685. buttonStart: number;
  41686. /**
  41687. * Gets the value of the `Back` button
  41688. */
  41689. /**
  41690. * Sets the value of the `Back` button
  41691. */
  41692. buttonBack: number;
  41693. /**
  41694. * Gets the value of the `Left` button
  41695. */
  41696. /**
  41697. * Sets the value of the `Left` button
  41698. */
  41699. buttonLB: number;
  41700. /**
  41701. * Gets the value of the `Right` button
  41702. */
  41703. /**
  41704. * Sets the value of the `Right` button
  41705. */
  41706. buttonRB: number;
  41707. /**
  41708. * Gets the value of the Left joystick
  41709. */
  41710. /**
  41711. * Sets the value of the Left joystick
  41712. */
  41713. buttonLeftStick: number;
  41714. /**
  41715. * Gets the value of the Right joystick
  41716. */
  41717. /**
  41718. * Sets the value of the Right joystick
  41719. */
  41720. buttonRightStick: number;
  41721. /**
  41722. * Gets the value of D-pad up
  41723. */
  41724. /**
  41725. * Sets the value of D-pad up
  41726. */
  41727. dPadUp: number;
  41728. /**
  41729. * Gets the value of D-pad down
  41730. */
  41731. /**
  41732. * Sets the value of D-pad down
  41733. */
  41734. dPadDown: number;
  41735. /**
  41736. * Gets the value of D-pad left
  41737. */
  41738. /**
  41739. * Sets the value of D-pad left
  41740. */
  41741. dPadLeft: number;
  41742. /**
  41743. * Gets the value of D-pad right
  41744. */
  41745. /**
  41746. * Sets the value of D-pad right
  41747. */
  41748. dPadRight: number;
  41749. /**
  41750. * Force the gamepad to synchronize with device values
  41751. */
  41752. update(): void;
  41753. /**
  41754. * Disposes the gamepad
  41755. */
  41756. dispose(): void;
  41757. }
  41758. }
  41759. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41760. import { Observable } from "babylonjs/Misc/observable";
  41761. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41762. /**
  41763. * Defines supported buttons for DualShock compatible gamepads
  41764. */
  41765. export enum DualShockButton {
  41766. /** Cross */
  41767. Cross = 0,
  41768. /** Circle */
  41769. Circle = 1,
  41770. /** Square */
  41771. Square = 2,
  41772. /** Triangle */
  41773. Triangle = 3,
  41774. /** Options */
  41775. Options = 4,
  41776. /** Share */
  41777. Share = 5,
  41778. /** L1 */
  41779. L1 = 6,
  41780. /** R1 */
  41781. R1 = 7,
  41782. /** Left stick */
  41783. LeftStick = 8,
  41784. /** Right stick */
  41785. RightStick = 9
  41786. }
  41787. /** Defines values for DualShock DPad */
  41788. export enum DualShockDpad {
  41789. /** Up */
  41790. Up = 0,
  41791. /** Down */
  41792. Down = 1,
  41793. /** Left */
  41794. Left = 2,
  41795. /** Right */
  41796. Right = 3
  41797. }
  41798. /**
  41799. * Defines a DualShock gamepad
  41800. */
  41801. export class DualShockPad extends Gamepad {
  41802. private _leftTrigger;
  41803. private _rightTrigger;
  41804. private _onlefttriggerchanged;
  41805. private _onrighttriggerchanged;
  41806. private _onbuttondown;
  41807. private _onbuttonup;
  41808. private _ondpaddown;
  41809. private _ondpadup;
  41810. /** Observable raised when a button is pressed */
  41811. onButtonDownObservable: Observable<DualShockButton>;
  41812. /** Observable raised when a button is released */
  41813. onButtonUpObservable: Observable<DualShockButton>;
  41814. /** Observable raised when a pad is pressed */
  41815. onPadDownObservable: Observable<DualShockDpad>;
  41816. /** Observable raised when a pad is released */
  41817. onPadUpObservable: Observable<DualShockDpad>;
  41818. private _buttonCross;
  41819. private _buttonCircle;
  41820. private _buttonSquare;
  41821. private _buttonTriangle;
  41822. private _buttonShare;
  41823. private _buttonOptions;
  41824. private _buttonL1;
  41825. private _buttonR1;
  41826. private _buttonLeftStick;
  41827. private _buttonRightStick;
  41828. private _dPadUp;
  41829. private _dPadDown;
  41830. private _dPadLeft;
  41831. private _dPadRight;
  41832. /**
  41833. * Creates a new DualShock gamepad object
  41834. * @param id defines the id of this gamepad
  41835. * @param index defines its index
  41836. * @param gamepad defines the internal HTML gamepad object
  41837. */
  41838. constructor(id: string, index: number, gamepad: any);
  41839. /**
  41840. * Defines the callback to call when left trigger is pressed
  41841. * @param callback defines the callback to use
  41842. */
  41843. onlefttriggerchanged(callback: (value: number) => void): void;
  41844. /**
  41845. * Defines the callback to call when right trigger is pressed
  41846. * @param callback defines the callback to use
  41847. */
  41848. onrighttriggerchanged(callback: (value: number) => void): void;
  41849. /**
  41850. * Gets the left trigger value
  41851. */
  41852. /**
  41853. * Sets the left trigger value
  41854. */
  41855. leftTrigger: number;
  41856. /**
  41857. * Gets the right trigger value
  41858. */
  41859. /**
  41860. * Sets the right trigger value
  41861. */
  41862. rightTrigger: number;
  41863. /**
  41864. * Defines the callback to call when a button is pressed
  41865. * @param callback defines the callback to use
  41866. */
  41867. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41868. /**
  41869. * Defines the callback to call when a button is released
  41870. * @param callback defines the callback to use
  41871. */
  41872. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41873. /**
  41874. * Defines the callback to call when a pad is pressed
  41875. * @param callback defines the callback to use
  41876. */
  41877. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41878. /**
  41879. * Defines the callback to call when a pad is released
  41880. * @param callback defines the callback to use
  41881. */
  41882. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41883. private _setButtonValue;
  41884. private _setDPadValue;
  41885. /**
  41886. * Gets the value of the `Cross` button
  41887. */
  41888. /**
  41889. * Sets the value of the `Cross` button
  41890. */
  41891. buttonCross: number;
  41892. /**
  41893. * Gets the value of the `Circle` button
  41894. */
  41895. /**
  41896. * Sets the value of the `Circle` button
  41897. */
  41898. buttonCircle: number;
  41899. /**
  41900. * Gets the value of the `Square` button
  41901. */
  41902. /**
  41903. * Sets the value of the `Square` button
  41904. */
  41905. buttonSquare: number;
  41906. /**
  41907. * Gets the value of the `Triangle` button
  41908. */
  41909. /**
  41910. * Sets the value of the `Triangle` button
  41911. */
  41912. buttonTriangle: number;
  41913. /**
  41914. * Gets the value of the `Options` button
  41915. */
  41916. /**
  41917. * Sets the value of the `Options` button
  41918. */
  41919. buttonOptions: number;
  41920. /**
  41921. * Gets the value of the `Share` button
  41922. */
  41923. /**
  41924. * Sets the value of the `Share` button
  41925. */
  41926. buttonShare: number;
  41927. /**
  41928. * Gets the value of the `L1` button
  41929. */
  41930. /**
  41931. * Sets the value of the `L1` button
  41932. */
  41933. buttonL1: number;
  41934. /**
  41935. * Gets the value of the `R1` button
  41936. */
  41937. /**
  41938. * Sets the value of the `R1` button
  41939. */
  41940. buttonR1: number;
  41941. /**
  41942. * Gets the value of the Left joystick
  41943. */
  41944. /**
  41945. * Sets the value of the Left joystick
  41946. */
  41947. buttonLeftStick: number;
  41948. /**
  41949. * Gets the value of the Right joystick
  41950. */
  41951. /**
  41952. * Sets the value of the Right joystick
  41953. */
  41954. buttonRightStick: number;
  41955. /**
  41956. * Gets the value of D-pad up
  41957. */
  41958. /**
  41959. * Sets the value of D-pad up
  41960. */
  41961. dPadUp: number;
  41962. /**
  41963. * Gets the value of D-pad down
  41964. */
  41965. /**
  41966. * Sets the value of D-pad down
  41967. */
  41968. dPadDown: number;
  41969. /**
  41970. * Gets the value of D-pad left
  41971. */
  41972. /**
  41973. * Sets the value of D-pad left
  41974. */
  41975. dPadLeft: number;
  41976. /**
  41977. * Gets the value of D-pad right
  41978. */
  41979. /**
  41980. * Sets the value of D-pad right
  41981. */
  41982. dPadRight: number;
  41983. /**
  41984. * Force the gamepad to synchronize with device values
  41985. */
  41986. update(): void;
  41987. /**
  41988. * Disposes the gamepad
  41989. */
  41990. dispose(): void;
  41991. }
  41992. }
  41993. declare module "babylonjs/Gamepads/gamepadManager" {
  41994. import { Observable } from "babylonjs/Misc/observable";
  41995. import { Nullable } from "babylonjs/types";
  41996. import { Scene } from "babylonjs/scene";
  41997. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41998. /**
  41999. * Manager for handling gamepads
  42000. */
  42001. export class GamepadManager {
  42002. private _scene?;
  42003. private _babylonGamepads;
  42004. private _oneGamepadConnected;
  42005. /** @hidden */
  42006. _isMonitoring: boolean;
  42007. private _gamepadEventSupported;
  42008. private _gamepadSupport;
  42009. /**
  42010. * observable to be triggered when the gamepad controller has been connected
  42011. */
  42012. onGamepadConnectedObservable: Observable<Gamepad>;
  42013. /**
  42014. * observable to be triggered when the gamepad controller has been disconnected
  42015. */
  42016. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42017. private _onGamepadConnectedEvent;
  42018. private _onGamepadDisconnectedEvent;
  42019. /**
  42020. * Initializes the gamepad manager
  42021. * @param _scene BabylonJS scene
  42022. */
  42023. constructor(_scene?: Scene | undefined);
  42024. /**
  42025. * The gamepads in the game pad manager
  42026. */
  42027. readonly gamepads: Gamepad[];
  42028. /**
  42029. * Get the gamepad controllers based on type
  42030. * @param type The type of gamepad controller
  42031. * @returns Nullable gamepad
  42032. */
  42033. getGamepadByType(type?: number): Nullable<Gamepad>;
  42034. /**
  42035. * Disposes the gamepad manager
  42036. */
  42037. dispose(): void;
  42038. private _addNewGamepad;
  42039. private _startMonitoringGamepads;
  42040. private _stopMonitoringGamepads;
  42041. /** @hidden */
  42042. _checkGamepadsStatus(): void;
  42043. private _updateGamepadObjects;
  42044. }
  42045. }
  42046. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42047. import { Nullable } from "babylonjs/types";
  42048. import { Scene } from "babylonjs/scene";
  42049. import { ISceneComponent } from "babylonjs/sceneComponent";
  42050. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42051. module "babylonjs/scene" {
  42052. interface Scene {
  42053. /** @hidden */
  42054. _gamepadManager: Nullable<GamepadManager>;
  42055. /**
  42056. * Gets the gamepad manager associated with the scene
  42057. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42058. */
  42059. gamepadManager: GamepadManager;
  42060. }
  42061. }
  42062. module "babylonjs/Cameras/freeCameraInputsManager" {
  42063. /**
  42064. * Interface representing a free camera inputs manager
  42065. */
  42066. interface FreeCameraInputsManager {
  42067. /**
  42068. * Adds gamepad input support to the FreeCameraInputsManager.
  42069. * @returns the FreeCameraInputsManager
  42070. */
  42071. addGamepad(): FreeCameraInputsManager;
  42072. }
  42073. }
  42074. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42075. /**
  42076. * Interface representing an arc rotate camera inputs manager
  42077. */
  42078. interface ArcRotateCameraInputsManager {
  42079. /**
  42080. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42081. * @returns the camera inputs manager
  42082. */
  42083. addGamepad(): ArcRotateCameraInputsManager;
  42084. }
  42085. }
  42086. /**
  42087. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42088. */
  42089. export class GamepadSystemSceneComponent implements ISceneComponent {
  42090. /**
  42091. * The component name helpfull to identify the component in the list of scene components.
  42092. */
  42093. readonly name: string;
  42094. /**
  42095. * The scene the component belongs to.
  42096. */
  42097. scene: Scene;
  42098. /**
  42099. * Creates a new instance of the component for the given scene
  42100. * @param scene Defines the scene to register the component in
  42101. */
  42102. constructor(scene: Scene);
  42103. /**
  42104. * Registers the component in a given scene
  42105. */
  42106. register(): void;
  42107. /**
  42108. * Rebuilds the elements related to this component in case of
  42109. * context lost for instance.
  42110. */
  42111. rebuild(): void;
  42112. /**
  42113. * Disposes the component and the associated ressources
  42114. */
  42115. dispose(): void;
  42116. private _beforeCameraUpdate;
  42117. }
  42118. }
  42119. declare module "babylonjs/Cameras/universalCamera" {
  42120. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42121. import { Scene } from "babylonjs/scene";
  42122. import { Vector3 } from "babylonjs/Maths/math.vector";
  42123. import "babylonjs/Gamepads/gamepadSceneComponent";
  42124. /**
  42125. * 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,
  42126. * which still works and will still be found in many Playgrounds.
  42127. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42128. */
  42129. export class UniversalCamera extends TouchCamera {
  42130. /**
  42131. * Defines the gamepad rotation sensiblity.
  42132. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42133. */
  42134. gamepadAngularSensibility: number;
  42135. /**
  42136. * Defines the gamepad move sensiblity.
  42137. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42138. */
  42139. gamepadMoveSensibility: number;
  42140. /**
  42141. * 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,
  42142. * which still works and will still be found in many Playgrounds.
  42143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42144. * @param name Define the name of the camera in the scene
  42145. * @param position Define the start position of the camera in the scene
  42146. * @param scene Define the scene the camera belongs to
  42147. */
  42148. constructor(name: string, position: Vector3, scene: Scene);
  42149. /**
  42150. * Gets the current object class name.
  42151. * @return the class name
  42152. */
  42153. getClassName(): string;
  42154. }
  42155. }
  42156. declare module "babylonjs/Cameras/gamepadCamera" {
  42157. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42158. import { Scene } from "babylonjs/scene";
  42159. import { Vector3 } from "babylonjs/Maths/math.vector";
  42160. /**
  42161. * This represents a FPS type of camera. This is only here for back compat purpose.
  42162. * Please use the UniversalCamera instead as both are identical.
  42163. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42164. */
  42165. export class GamepadCamera extends UniversalCamera {
  42166. /**
  42167. * Instantiates a new Gamepad Camera
  42168. * This represents a FPS type of camera. This is only here for back compat purpose.
  42169. * Please use the UniversalCamera instead as both are identical.
  42170. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42171. * @param name Define the name of the camera in the scene
  42172. * @param position Define the start position of the camera in the scene
  42173. * @param scene Define the scene the camera belongs to
  42174. */
  42175. constructor(name: string, position: Vector3, scene: Scene);
  42176. /**
  42177. * Gets the current object class name.
  42178. * @return the class name
  42179. */
  42180. getClassName(): string;
  42181. }
  42182. }
  42183. declare module "babylonjs/Shaders/pass.fragment" {
  42184. /** @hidden */
  42185. export var passPixelShader: {
  42186. name: string;
  42187. shader: string;
  42188. };
  42189. }
  42190. declare module "babylonjs/Shaders/passCube.fragment" {
  42191. /** @hidden */
  42192. export var passCubePixelShader: {
  42193. name: string;
  42194. shader: string;
  42195. };
  42196. }
  42197. declare module "babylonjs/PostProcesses/passPostProcess" {
  42198. import { Nullable } from "babylonjs/types";
  42199. import { Camera } from "babylonjs/Cameras/camera";
  42200. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42201. import { Engine } from "babylonjs/Engines/engine";
  42202. import "babylonjs/Shaders/pass.fragment";
  42203. import "babylonjs/Shaders/passCube.fragment";
  42204. /**
  42205. * PassPostProcess which produces an output the same as it's input
  42206. */
  42207. export class PassPostProcess extends PostProcess {
  42208. /**
  42209. * Creates the PassPostProcess
  42210. * @param name The name of the effect.
  42211. * @param options The required width/height ratio to downsize to before computing the render pass.
  42212. * @param camera The camera to apply the render pass to.
  42213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42214. * @param engine The engine which the post process will be applied. (default: current engine)
  42215. * @param reusable If the post process can be reused on the same frame. (default: false)
  42216. * @param textureType The type of texture to be used when performing the post processing.
  42217. * @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)
  42218. */
  42219. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42220. }
  42221. /**
  42222. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42223. */
  42224. export class PassCubePostProcess extends PostProcess {
  42225. private _face;
  42226. /**
  42227. * Gets or sets the cube face to display.
  42228. * * 0 is +X
  42229. * * 1 is -X
  42230. * * 2 is +Y
  42231. * * 3 is -Y
  42232. * * 4 is +Z
  42233. * * 5 is -Z
  42234. */
  42235. face: number;
  42236. /**
  42237. * Creates the PassCubePostProcess
  42238. * @param name The name of the effect.
  42239. * @param options The required width/height ratio to downsize to before computing the render pass.
  42240. * @param camera The camera to apply the render pass to.
  42241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42242. * @param engine The engine which the post process will be applied. (default: current engine)
  42243. * @param reusable If the post process can be reused on the same frame. (default: false)
  42244. * @param textureType The type of texture to be used when performing the post processing.
  42245. * @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)
  42246. */
  42247. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42248. }
  42249. }
  42250. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42251. /** @hidden */
  42252. export var anaglyphPixelShader: {
  42253. name: string;
  42254. shader: string;
  42255. };
  42256. }
  42257. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42258. import { Engine } from "babylonjs/Engines/engine";
  42259. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42260. import { Camera } from "babylonjs/Cameras/camera";
  42261. import "babylonjs/Shaders/anaglyph.fragment";
  42262. /**
  42263. * Postprocess used to generate anaglyphic rendering
  42264. */
  42265. export class AnaglyphPostProcess extends PostProcess {
  42266. private _passedProcess;
  42267. /**
  42268. * Creates a new AnaglyphPostProcess
  42269. * @param name defines postprocess name
  42270. * @param options defines creation options or target ratio scale
  42271. * @param rigCameras defines cameras using this postprocess
  42272. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42273. * @param engine defines hosting engine
  42274. * @param reusable defines if the postprocess will be reused multiple times per frame
  42275. */
  42276. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42277. }
  42278. }
  42279. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42280. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42281. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42282. import { Scene } from "babylonjs/scene";
  42283. import { Vector3 } from "babylonjs/Maths/math.vector";
  42284. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42285. /**
  42286. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42287. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42288. */
  42289. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42290. /**
  42291. * Creates a new AnaglyphArcRotateCamera
  42292. * @param name defines camera name
  42293. * @param alpha defines alpha angle (in radians)
  42294. * @param beta defines beta angle (in radians)
  42295. * @param radius defines radius
  42296. * @param target defines camera target
  42297. * @param interaxialDistance defines distance between each color axis
  42298. * @param scene defines the hosting scene
  42299. */
  42300. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42301. /**
  42302. * Gets camera class name
  42303. * @returns AnaglyphArcRotateCamera
  42304. */
  42305. getClassName(): string;
  42306. }
  42307. }
  42308. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42309. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42310. import { Scene } from "babylonjs/scene";
  42311. import { Vector3 } from "babylonjs/Maths/math.vector";
  42312. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42313. /**
  42314. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42315. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42316. */
  42317. export class AnaglyphFreeCamera extends FreeCamera {
  42318. /**
  42319. * Creates a new AnaglyphFreeCamera
  42320. * @param name defines camera name
  42321. * @param position defines initial position
  42322. * @param interaxialDistance defines distance between each color axis
  42323. * @param scene defines the hosting scene
  42324. */
  42325. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42326. /**
  42327. * Gets camera class name
  42328. * @returns AnaglyphFreeCamera
  42329. */
  42330. getClassName(): string;
  42331. }
  42332. }
  42333. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42334. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42335. import { Scene } from "babylonjs/scene";
  42336. import { Vector3 } from "babylonjs/Maths/math.vector";
  42337. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42338. /**
  42339. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42340. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42341. */
  42342. export class AnaglyphGamepadCamera extends GamepadCamera {
  42343. /**
  42344. * Creates a new AnaglyphGamepadCamera
  42345. * @param name defines camera name
  42346. * @param position defines initial position
  42347. * @param interaxialDistance defines distance between each color axis
  42348. * @param scene defines the hosting scene
  42349. */
  42350. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42351. /**
  42352. * Gets camera class name
  42353. * @returns AnaglyphGamepadCamera
  42354. */
  42355. getClassName(): string;
  42356. }
  42357. }
  42358. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42359. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42360. import { Scene } from "babylonjs/scene";
  42361. import { Vector3 } from "babylonjs/Maths/math.vector";
  42362. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42363. /**
  42364. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42365. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42366. */
  42367. export class AnaglyphUniversalCamera extends UniversalCamera {
  42368. /**
  42369. * Creates a new AnaglyphUniversalCamera
  42370. * @param name defines camera name
  42371. * @param position defines initial position
  42372. * @param interaxialDistance defines distance between each color axis
  42373. * @param scene defines the hosting scene
  42374. */
  42375. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42376. /**
  42377. * Gets camera class name
  42378. * @returns AnaglyphUniversalCamera
  42379. */
  42380. getClassName(): string;
  42381. }
  42382. }
  42383. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42384. /** @hidden */
  42385. export var stereoscopicInterlacePixelShader: {
  42386. name: string;
  42387. shader: string;
  42388. };
  42389. }
  42390. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42391. import { Camera } from "babylonjs/Cameras/camera";
  42392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42393. import { Engine } from "babylonjs/Engines/engine";
  42394. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42395. /**
  42396. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42397. */
  42398. export class StereoscopicInterlacePostProcess extends PostProcess {
  42399. private _stepSize;
  42400. private _passedProcess;
  42401. /**
  42402. * Initializes a StereoscopicInterlacePostProcess
  42403. * @param name The name of the effect.
  42404. * @param rigCameras The rig cameras to be appled to the post process
  42405. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42407. * @param engine The engine which the post process will be applied. (default: current engine)
  42408. * @param reusable If the post process can be reused on the same frame. (default: false)
  42409. */
  42410. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42411. }
  42412. }
  42413. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42414. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42415. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42416. import { Scene } from "babylonjs/scene";
  42417. import { Vector3 } from "babylonjs/Maths/math.vector";
  42418. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42419. /**
  42420. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42421. * @see http://doc.babylonjs.com/features/cameras
  42422. */
  42423. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42424. /**
  42425. * Creates a new StereoscopicArcRotateCamera
  42426. * @param name defines camera name
  42427. * @param alpha defines alpha angle (in radians)
  42428. * @param beta defines beta angle (in radians)
  42429. * @param radius defines radius
  42430. * @param target defines camera target
  42431. * @param interaxialDistance defines distance between each color axis
  42432. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42433. * @param scene defines the hosting scene
  42434. */
  42435. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42436. /**
  42437. * Gets camera class name
  42438. * @returns StereoscopicArcRotateCamera
  42439. */
  42440. getClassName(): string;
  42441. }
  42442. }
  42443. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42444. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42445. import { Scene } from "babylonjs/scene";
  42446. import { Vector3 } from "babylonjs/Maths/math.vector";
  42447. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42448. /**
  42449. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42450. * @see http://doc.babylonjs.com/features/cameras
  42451. */
  42452. export class StereoscopicFreeCamera extends FreeCamera {
  42453. /**
  42454. * Creates a new StereoscopicFreeCamera
  42455. * @param name defines camera name
  42456. * @param position defines initial position
  42457. * @param interaxialDistance defines distance between each color axis
  42458. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42459. * @param scene defines the hosting scene
  42460. */
  42461. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42462. /**
  42463. * Gets camera class name
  42464. * @returns StereoscopicFreeCamera
  42465. */
  42466. getClassName(): string;
  42467. }
  42468. }
  42469. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42470. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42471. import { Scene } from "babylonjs/scene";
  42472. import { Vector3 } from "babylonjs/Maths/math.vector";
  42473. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42474. /**
  42475. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42476. * @see http://doc.babylonjs.com/features/cameras
  42477. */
  42478. export class StereoscopicGamepadCamera extends GamepadCamera {
  42479. /**
  42480. * Creates a new StereoscopicGamepadCamera
  42481. * @param name defines camera name
  42482. * @param position defines initial position
  42483. * @param interaxialDistance defines distance between each color axis
  42484. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42485. * @param scene defines the hosting scene
  42486. */
  42487. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42488. /**
  42489. * Gets camera class name
  42490. * @returns StereoscopicGamepadCamera
  42491. */
  42492. getClassName(): string;
  42493. }
  42494. }
  42495. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42496. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42497. import { Scene } from "babylonjs/scene";
  42498. import { Vector3 } from "babylonjs/Maths/math.vector";
  42499. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42500. /**
  42501. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42502. * @see http://doc.babylonjs.com/features/cameras
  42503. */
  42504. export class StereoscopicUniversalCamera extends UniversalCamera {
  42505. /**
  42506. * Creates a new StereoscopicUniversalCamera
  42507. * @param name defines camera name
  42508. * @param position defines initial position
  42509. * @param interaxialDistance defines distance between each color axis
  42510. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42511. * @param scene defines the hosting scene
  42512. */
  42513. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42514. /**
  42515. * Gets camera class name
  42516. * @returns StereoscopicUniversalCamera
  42517. */
  42518. getClassName(): string;
  42519. }
  42520. }
  42521. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42522. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42523. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42524. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42525. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42526. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42527. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42528. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42529. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42530. }
  42531. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42533. import { Scene } from "babylonjs/scene";
  42534. import { Vector3 } from "babylonjs/Maths/math.vector";
  42535. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42536. /**
  42537. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42538. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42539. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42540. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42541. */
  42542. export class VirtualJoysticksCamera extends FreeCamera {
  42543. /**
  42544. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42545. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42546. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42547. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42548. * @param name Define the name of the camera in the scene
  42549. * @param position Define the start position of the camera in the scene
  42550. * @param scene Define the scene the camera belongs to
  42551. */
  42552. constructor(name: string, position: Vector3, scene: Scene);
  42553. /**
  42554. * Gets the current object class name.
  42555. * @return the class name
  42556. */
  42557. getClassName(): string;
  42558. }
  42559. }
  42560. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42561. import { Matrix } from "babylonjs/Maths/math.vector";
  42562. /**
  42563. * This represents all the required metrics to create a VR camera.
  42564. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42565. */
  42566. export class VRCameraMetrics {
  42567. /**
  42568. * Define the horizontal resolution off the screen.
  42569. */
  42570. hResolution: number;
  42571. /**
  42572. * Define the vertical resolution off the screen.
  42573. */
  42574. vResolution: number;
  42575. /**
  42576. * Define the horizontal screen size.
  42577. */
  42578. hScreenSize: number;
  42579. /**
  42580. * Define the vertical screen size.
  42581. */
  42582. vScreenSize: number;
  42583. /**
  42584. * Define the vertical screen center position.
  42585. */
  42586. vScreenCenter: number;
  42587. /**
  42588. * Define the distance of the eyes to the screen.
  42589. */
  42590. eyeToScreenDistance: number;
  42591. /**
  42592. * Define the distance between both lenses
  42593. */
  42594. lensSeparationDistance: number;
  42595. /**
  42596. * Define the distance between both viewer's eyes.
  42597. */
  42598. interpupillaryDistance: number;
  42599. /**
  42600. * Define the distortion factor of the VR postprocess.
  42601. * Please, touch with care.
  42602. */
  42603. distortionK: number[];
  42604. /**
  42605. * Define the chromatic aberration correction factors for the VR post process.
  42606. */
  42607. chromaAbCorrection: number[];
  42608. /**
  42609. * Define the scale factor of the post process.
  42610. * The smaller the better but the slower.
  42611. */
  42612. postProcessScaleFactor: number;
  42613. /**
  42614. * Define an offset for the lens center.
  42615. */
  42616. lensCenterOffset: number;
  42617. /**
  42618. * Define if the current vr camera should compensate the distortion of the lense or not.
  42619. */
  42620. compensateDistortion: boolean;
  42621. /**
  42622. * Defines if multiview should be enabled when rendering (Default: false)
  42623. */
  42624. multiviewEnabled: boolean;
  42625. /**
  42626. * Gets the rendering aspect ratio based on the provided resolutions.
  42627. */
  42628. readonly aspectRatio: number;
  42629. /**
  42630. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42631. */
  42632. readonly aspectRatioFov: number;
  42633. /**
  42634. * @hidden
  42635. */
  42636. readonly leftHMatrix: Matrix;
  42637. /**
  42638. * @hidden
  42639. */
  42640. readonly rightHMatrix: Matrix;
  42641. /**
  42642. * @hidden
  42643. */
  42644. readonly leftPreViewMatrix: Matrix;
  42645. /**
  42646. * @hidden
  42647. */
  42648. readonly rightPreViewMatrix: Matrix;
  42649. /**
  42650. * Get the default VRMetrics based on the most generic setup.
  42651. * @returns the default vr metrics
  42652. */
  42653. static GetDefault(): VRCameraMetrics;
  42654. }
  42655. }
  42656. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42657. /** @hidden */
  42658. export var vrDistortionCorrectionPixelShader: {
  42659. name: string;
  42660. shader: string;
  42661. };
  42662. }
  42663. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42664. import { Camera } from "babylonjs/Cameras/camera";
  42665. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42666. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42667. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42668. /**
  42669. * VRDistortionCorrectionPostProcess used for mobile VR
  42670. */
  42671. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42672. private _isRightEye;
  42673. private _distortionFactors;
  42674. private _postProcessScaleFactor;
  42675. private _lensCenterOffset;
  42676. private _scaleIn;
  42677. private _scaleFactor;
  42678. private _lensCenter;
  42679. /**
  42680. * Initializes the VRDistortionCorrectionPostProcess
  42681. * @param name The name of the effect.
  42682. * @param camera The camera to apply the render pass to.
  42683. * @param isRightEye If this is for the right eye distortion
  42684. * @param vrMetrics All the required metrics for the VR camera
  42685. */
  42686. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42687. }
  42688. }
  42689. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42690. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42691. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42692. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42693. import { Scene } from "babylonjs/scene";
  42694. import { Vector3 } from "babylonjs/Maths/math.vector";
  42695. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42696. import "babylonjs/Cameras/RigModes/vrRigMode";
  42697. /**
  42698. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42699. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42700. */
  42701. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42702. /**
  42703. * Creates a new VRDeviceOrientationArcRotateCamera
  42704. * @param name defines camera name
  42705. * @param alpha defines the camera rotation along the logitudinal axis
  42706. * @param beta defines the camera rotation along the latitudinal axis
  42707. * @param radius defines the camera distance from its target
  42708. * @param target defines the camera target
  42709. * @param scene defines the scene the camera belongs to
  42710. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42711. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42712. */
  42713. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42714. /**
  42715. * Gets camera class name
  42716. * @returns VRDeviceOrientationArcRotateCamera
  42717. */
  42718. getClassName(): string;
  42719. }
  42720. }
  42721. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42722. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42723. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42724. import { Scene } from "babylonjs/scene";
  42725. import { Vector3 } from "babylonjs/Maths/math.vector";
  42726. import "babylonjs/Cameras/RigModes/vrRigMode";
  42727. /**
  42728. * Camera used to simulate VR rendering (based on FreeCamera)
  42729. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42730. */
  42731. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42732. /**
  42733. * Creates a new VRDeviceOrientationFreeCamera
  42734. * @param name defines camera name
  42735. * @param position defines the start position of the camera
  42736. * @param scene defines the scene the camera belongs to
  42737. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42738. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42739. */
  42740. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42741. /**
  42742. * Gets camera class name
  42743. * @returns VRDeviceOrientationFreeCamera
  42744. */
  42745. getClassName(): string;
  42746. }
  42747. }
  42748. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42749. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42750. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42751. import { Scene } from "babylonjs/scene";
  42752. import { Vector3 } from "babylonjs/Maths/math.vector";
  42753. import "babylonjs/Gamepads/gamepadSceneComponent";
  42754. /**
  42755. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42756. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42757. */
  42758. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42759. /**
  42760. * Creates a new VRDeviceOrientationGamepadCamera
  42761. * @param name defines camera name
  42762. * @param position defines the start position of the camera
  42763. * @param scene defines the scene the camera belongs to
  42764. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42765. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42766. */
  42767. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42768. /**
  42769. * Gets camera class name
  42770. * @returns VRDeviceOrientationGamepadCamera
  42771. */
  42772. getClassName(): string;
  42773. }
  42774. }
  42775. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42776. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42777. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42778. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42779. /** @hidden */
  42780. export var imageProcessingPixelShader: {
  42781. name: string;
  42782. shader: string;
  42783. };
  42784. }
  42785. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42786. import { Nullable } from "babylonjs/types";
  42787. import { Color4 } from "babylonjs/Maths/math.color";
  42788. import { Camera } from "babylonjs/Cameras/camera";
  42789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42790. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42791. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42793. import { Engine } from "babylonjs/Engines/engine";
  42794. import "babylonjs/Shaders/imageProcessing.fragment";
  42795. import "babylonjs/Shaders/postprocess.vertex";
  42796. /**
  42797. * ImageProcessingPostProcess
  42798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42799. */
  42800. export class ImageProcessingPostProcess extends PostProcess {
  42801. /**
  42802. * Default configuration related to image processing available in the PBR Material.
  42803. */
  42804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42805. /**
  42806. * Gets the image processing configuration used either in this material.
  42807. */
  42808. /**
  42809. * Sets the Default image processing configuration used either in the this material.
  42810. *
  42811. * If sets to null, the scene one is in use.
  42812. */
  42813. imageProcessingConfiguration: ImageProcessingConfiguration;
  42814. /**
  42815. * Keep track of the image processing observer to allow dispose and replace.
  42816. */
  42817. private _imageProcessingObserver;
  42818. /**
  42819. * Attaches a new image processing configuration to the PBR Material.
  42820. * @param configuration
  42821. */
  42822. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42823. /**
  42824. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42825. */
  42826. /**
  42827. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42828. */
  42829. colorCurves: Nullable<ColorCurves>;
  42830. /**
  42831. * Gets wether the color curves effect is enabled.
  42832. */
  42833. /**
  42834. * Sets wether the color curves effect is enabled.
  42835. */
  42836. colorCurvesEnabled: boolean;
  42837. /**
  42838. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42839. */
  42840. /**
  42841. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42842. */
  42843. colorGradingTexture: Nullable<BaseTexture>;
  42844. /**
  42845. * Gets wether the color grading effect is enabled.
  42846. */
  42847. /**
  42848. * Gets wether the color grading effect is enabled.
  42849. */
  42850. colorGradingEnabled: boolean;
  42851. /**
  42852. * Gets exposure used in the effect.
  42853. */
  42854. /**
  42855. * Sets exposure used in the effect.
  42856. */
  42857. exposure: number;
  42858. /**
  42859. * Gets wether tonemapping is enabled or not.
  42860. */
  42861. /**
  42862. * Sets wether tonemapping is enabled or not
  42863. */
  42864. toneMappingEnabled: boolean;
  42865. /**
  42866. * Gets the type of tone mapping effect.
  42867. */
  42868. /**
  42869. * Sets the type of tone mapping effect.
  42870. */
  42871. toneMappingType: number;
  42872. /**
  42873. * Gets contrast used in the effect.
  42874. */
  42875. /**
  42876. * Sets contrast used in the effect.
  42877. */
  42878. contrast: number;
  42879. /**
  42880. * Gets Vignette stretch size.
  42881. */
  42882. /**
  42883. * Sets Vignette stretch size.
  42884. */
  42885. vignetteStretch: number;
  42886. /**
  42887. * Gets Vignette centre X Offset.
  42888. */
  42889. /**
  42890. * Sets Vignette centre X Offset.
  42891. */
  42892. vignetteCentreX: number;
  42893. /**
  42894. * Gets Vignette centre Y Offset.
  42895. */
  42896. /**
  42897. * Sets Vignette centre Y Offset.
  42898. */
  42899. vignetteCentreY: number;
  42900. /**
  42901. * Gets Vignette weight or intensity of the vignette effect.
  42902. */
  42903. /**
  42904. * Sets Vignette weight or intensity of the vignette effect.
  42905. */
  42906. vignetteWeight: number;
  42907. /**
  42908. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42909. * if vignetteEnabled is set to true.
  42910. */
  42911. /**
  42912. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42913. * if vignetteEnabled is set to true.
  42914. */
  42915. vignetteColor: Color4;
  42916. /**
  42917. * Gets Camera field of view used by the Vignette effect.
  42918. */
  42919. /**
  42920. * Sets Camera field of view used by the Vignette effect.
  42921. */
  42922. vignetteCameraFov: number;
  42923. /**
  42924. * Gets the vignette blend mode allowing different kind of effect.
  42925. */
  42926. /**
  42927. * Sets the vignette blend mode allowing different kind of effect.
  42928. */
  42929. vignetteBlendMode: number;
  42930. /**
  42931. * Gets wether the vignette effect is enabled.
  42932. */
  42933. /**
  42934. * Sets wether the vignette effect is enabled.
  42935. */
  42936. vignetteEnabled: boolean;
  42937. private _fromLinearSpace;
  42938. /**
  42939. * Gets wether the input of the processing is in Gamma or Linear Space.
  42940. */
  42941. /**
  42942. * Sets wether the input of the processing is in Gamma or Linear Space.
  42943. */
  42944. fromLinearSpace: boolean;
  42945. /**
  42946. * Defines cache preventing GC.
  42947. */
  42948. private _defines;
  42949. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42950. /**
  42951. * "ImageProcessingPostProcess"
  42952. * @returns "ImageProcessingPostProcess"
  42953. */
  42954. getClassName(): string;
  42955. protected _updateParameters(): void;
  42956. dispose(camera?: Camera): void;
  42957. }
  42958. }
  42959. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42960. import { Scene } from "babylonjs/scene";
  42961. import { Color3 } from "babylonjs/Maths/math.color";
  42962. import { Mesh } from "babylonjs/Meshes/mesh";
  42963. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42964. import { Nullable } from "babylonjs/types";
  42965. /**
  42966. * Class containing static functions to help procedurally build meshes
  42967. */
  42968. export class GroundBuilder {
  42969. /**
  42970. * Creates a ground mesh
  42971. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42972. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42974. * @param name defines the name of the mesh
  42975. * @param options defines the options used to create the mesh
  42976. * @param scene defines the hosting scene
  42977. * @returns the ground mesh
  42978. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42979. */
  42980. static CreateGround(name: string, options: {
  42981. width?: number;
  42982. height?: number;
  42983. subdivisions?: number;
  42984. subdivisionsX?: number;
  42985. subdivisionsY?: number;
  42986. updatable?: boolean;
  42987. }, scene: any): Mesh;
  42988. /**
  42989. * Creates a tiled ground mesh
  42990. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42991. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42992. * * 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
  42993. * * 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
  42994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42995. * @param name defines the name of the mesh
  42996. * @param options defines the options used to create the mesh
  42997. * @param scene defines the hosting scene
  42998. * @returns the tiled ground mesh
  42999. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43000. */
  43001. static CreateTiledGround(name: string, options: {
  43002. xmin: number;
  43003. zmin: number;
  43004. xmax: number;
  43005. zmax: number;
  43006. subdivisions?: {
  43007. w: number;
  43008. h: number;
  43009. };
  43010. precision?: {
  43011. w: number;
  43012. h: number;
  43013. };
  43014. updatable?: boolean;
  43015. }, scene?: Nullable<Scene>): Mesh;
  43016. /**
  43017. * Creates a ground mesh from a height map
  43018. * * The parameter `url` sets the URL of the height map image resource.
  43019. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43020. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43021. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43022. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43023. * * 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.
  43024. * * 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).
  43025. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43027. * @param name defines the name of the mesh
  43028. * @param url defines the url to the height map
  43029. * @param options defines the options used to create the mesh
  43030. * @param scene defines the hosting scene
  43031. * @returns the ground mesh
  43032. * @see https://doc.babylonjs.com/babylon101/height_map
  43033. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43034. */
  43035. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43036. width?: number;
  43037. height?: number;
  43038. subdivisions?: number;
  43039. minHeight?: number;
  43040. maxHeight?: number;
  43041. colorFilter?: Color3;
  43042. alphaFilter?: number;
  43043. updatable?: boolean;
  43044. onReady?: (mesh: GroundMesh) => void;
  43045. }, scene?: Nullable<Scene>): GroundMesh;
  43046. }
  43047. }
  43048. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43049. import { Vector4 } from "babylonjs/Maths/math.vector";
  43050. import { Mesh } from "babylonjs/Meshes/mesh";
  43051. /**
  43052. * Class containing static functions to help procedurally build meshes
  43053. */
  43054. export class TorusBuilder {
  43055. /**
  43056. * Creates a torus mesh
  43057. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43058. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43059. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43063. * @param name defines the name of the mesh
  43064. * @param options defines the options used to create the mesh
  43065. * @param scene defines the hosting scene
  43066. * @returns the torus mesh
  43067. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43068. */
  43069. static CreateTorus(name: string, options: {
  43070. diameter?: number;
  43071. thickness?: number;
  43072. tessellation?: number;
  43073. updatable?: boolean;
  43074. sideOrientation?: number;
  43075. frontUVs?: Vector4;
  43076. backUVs?: Vector4;
  43077. }, scene: any): Mesh;
  43078. }
  43079. }
  43080. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43081. import { Vector4 } from "babylonjs/Maths/math.vector";
  43082. import { Color4 } from "babylonjs/Maths/math.color";
  43083. import { Mesh } from "babylonjs/Meshes/mesh";
  43084. /**
  43085. * Class containing static functions to help procedurally build meshes
  43086. */
  43087. export class CylinderBuilder {
  43088. /**
  43089. * Creates a cylinder or a cone mesh
  43090. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43091. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43092. * * 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.
  43093. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43094. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43095. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43096. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43097. * * 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).
  43098. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43099. * * 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).
  43100. * * 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
  43101. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43102. * * 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
  43103. * * 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.
  43104. * * If `enclose` is false, a ring surface is one element.
  43105. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43106. * * 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
  43107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43110. * @param name defines the name of the mesh
  43111. * @param options defines the options used to create the mesh
  43112. * @param scene defines the hosting scene
  43113. * @returns the cylinder mesh
  43114. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43115. */
  43116. static CreateCylinder(name: string, options: {
  43117. height?: number;
  43118. diameterTop?: number;
  43119. diameterBottom?: number;
  43120. diameter?: number;
  43121. tessellation?: number;
  43122. subdivisions?: number;
  43123. arc?: number;
  43124. faceColors?: Color4[];
  43125. faceUV?: Vector4[];
  43126. updatable?: boolean;
  43127. hasRings?: boolean;
  43128. enclose?: boolean;
  43129. cap?: number;
  43130. sideOrientation?: number;
  43131. frontUVs?: Vector4;
  43132. backUVs?: Vector4;
  43133. }, scene: any): Mesh;
  43134. }
  43135. }
  43136. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43137. import { Nullable } from "babylonjs/types";
  43138. import { IDisposable } from "babylonjs/scene";
  43139. /**
  43140. * States of the webXR experience
  43141. */
  43142. export enum WebXRState {
  43143. /**
  43144. * Transitioning to being in XR mode
  43145. */
  43146. ENTERING_XR = 0,
  43147. /**
  43148. * Transitioning to non XR mode
  43149. */
  43150. EXITING_XR = 1,
  43151. /**
  43152. * In XR mode and presenting
  43153. */
  43154. IN_XR = 2,
  43155. /**
  43156. * Not entered XR mode
  43157. */
  43158. NOT_IN_XR = 3
  43159. }
  43160. /**
  43161. * Abstraction of the XR render target
  43162. */
  43163. export interface WebXRRenderTarget extends IDisposable {
  43164. /**
  43165. * xrpresent context of the canvas which can be used to display/mirror xr content
  43166. */
  43167. canvasContext: WebGLRenderingContext;
  43168. /**
  43169. * xr layer for the canvas
  43170. */
  43171. xrLayer: Nullable<XRWebGLLayer>;
  43172. /**
  43173. * Initializes the xr layer for the session
  43174. * @param xrSession xr session
  43175. * @returns a promise that will resolve once the XR Layer has been created
  43176. */
  43177. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43178. }
  43179. }
  43180. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43181. import { Nullable } from "babylonjs/types";
  43182. import { Observable } from "babylonjs/Misc/observable";
  43183. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43184. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43185. /**
  43186. * COnfiguration object for WebXR output canvas
  43187. */
  43188. export class WebXRManagedOutputCanvasOptions {
  43189. /**
  43190. * Options for this XR Layer output
  43191. */
  43192. canvasOptions: XRWebGLLayerOptions;
  43193. /**
  43194. * CSS styling for a newly created canvas (if not provided)
  43195. */
  43196. newCanvasCssStyle?: string;
  43197. /**
  43198. * Get the default values of the configuration object
  43199. * @returns default values of this configuration object
  43200. */
  43201. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43202. }
  43203. /**
  43204. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43205. */
  43206. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43207. private configuration;
  43208. private _engine;
  43209. private _canvas;
  43210. /**
  43211. * xrpresent context of the canvas which can be used to display/mirror xr content
  43212. */
  43213. canvasContext: WebGLRenderingContext;
  43214. /**
  43215. * xr layer for the canvas
  43216. */
  43217. xrLayer: Nullable<XRWebGLLayer>;
  43218. /**
  43219. * Initializes the xr layer for the session
  43220. * @param xrSession xr session
  43221. * @returns a promise that will resolve once the XR Layer has been created
  43222. */
  43223. initializeXRLayerAsync(xrSession: any): any;
  43224. /**
  43225. * Initializes the canvas to be added/removed upon entering/exiting xr
  43226. * @param engine the Babylon engine
  43227. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43228. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43229. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43230. */
  43231. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43232. /**
  43233. * Disposes of the object
  43234. */
  43235. dispose(): void;
  43236. private _setManagedOutputCanvas;
  43237. private _addCanvas;
  43238. private _removeCanvas;
  43239. }
  43240. }
  43241. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43242. import { Observable } from "babylonjs/Misc/observable";
  43243. import { Nullable } from "babylonjs/types";
  43244. import { IDisposable, Scene } from "babylonjs/scene";
  43245. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43246. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43247. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43248. /**
  43249. * Manages an XRSession to work with Babylon's engine
  43250. * @see https://doc.babylonjs.com/how_to/webxr
  43251. */
  43252. export class WebXRSessionManager implements IDisposable {
  43253. private scene;
  43254. /**
  43255. * Fires every time a new xrFrame arrives which can be used to update the camera
  43256. */
  43257. onXRFrameObservable: Observable<any>;
  43258. /**
  43259. * Fires when the xr session is ended either by the device or manually done
  43260. */
  43261. onXRSessionEnded: Observable<any>;
  43262. /**
  43263. * Underlying xr session
  43264. */
  43265. session: XRSession;
  43266. /**
  43267. * Type of reference space used when creating the session
  43268. */
  43269. referenceSpace: XRReferenceSpace;
  43270. /**
  43271. * Current XR frame
  43272. */
  43273. currentFrame: Nullable<XRFrame>;
  43274. private _xrNavigator;
  43275. private baseLayer;
  43276. private _rttProvider;
  43277. private _sessionEnded;
  43278. /**
  43279. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43280. * @param scene The scene which the session should be created for
  43281. */
  43282. constructor(scene: Scene);
  43283. /**
  43284. * Initializes the manager
  43285. * After initialization enterXR can be called to start an XR session
  43286. * @returns Promise which resolves after it is initialized
  43287. */
  43288. initializeAsync(): Promise<void>;
  43289. /**
  43290. * Initializes an xr session
  43291. * @param xrSessionMode mode to initialize
  43292. * @param optionalFeatures defines optional values to pass to the session builder
  43293. * @returns a promise which will resolve once the session has been initialized
  43294. */
  43295. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43296. /**
  43297. * Sets the reference space on the xr session
  43298. * @param referenceSpace space to set
  43299. * @returns a promise that will resolve once the reference space has been set
  43300. */
  43301. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43302. /**
  43303. * Updates the render state of the session
  43304. * @param state state to set
  43305. * @returns a promise that resolves once the render state has been updated
  43306. */
  43307. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43308. /**
  43309. * Starts rendering to the xr layer
  43310. * @returns a promise that will resolve once rendering has started
  43311. */
  43312. startRenderingToXRAsync(): Promise<void>;
  43313. /**
  43314. * Gets the correct render target texture to be rendered this frame for this eye
  43315. * @param eye the eye for which to get the render target
  43316. * @returns the render target for the specified eye
  43317. */
  43318. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43319. /**
  43320. * Stops the xrSession and restores the renderloop
  43321. * @returns Promise which resolves after it exits XR
  43322. */
  43323. exitXRAsync(): Promise<void>;
  43324. /**
  43325. * Checks if a session would be supported for the creation options specified
  43326. * @param sessionMode session mode to check if supported eg. immersive-vr
  43327. * @returns true if supported
  43328. */
  43329. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43330. /**
  43331. * Creates a WebXRRenderTarget object for the XR session
  43332. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43333. * @param options optional options to provide when creating a new render target
  43334. * @returns a WebXR render target to which the session can render
  43335. */
  43336. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43337. /**
  43338. * @hidden
  43339. * Converts the render layer of xrSession to a render target
  43340. * @param session session to create render target for
  43341. * @param scene scene the new render target should be created for
  43342. */
  43343. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43344. /**
  43345. * Disposes of the session manager
  43346. */
  43347. dispose(): void;
  43348. /**
  43349. * Gets a promise returning true when fullfiled if the given session mode is supported
  43350. * @param sessionMode defines the session to test
  43351. * @returns a promise
  43352. */
  43353. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43354. }
  43355. }
  43356. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43357. import { Scene } from "babylonjs/scene";
  43358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43359. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43360. /**
  43361. * WebXR Camera which holds the views for the xrSession
  43362. * @see https://doc.babylonjs.com/how_to/webxr
  43363. */
  43364. export class WebXRCamera extends FreeCamera {
  43365. /**
  43366. * Is the camera in debug mode. Used when using an emulator
  43367. */
  43368. debugMode: boolean;
  43369. /**
  43370. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43371. * @param name the name of the camera
  43372. * @param scene the scene to add the camera to
  43373. */
  43374. constructor(name: string, scene: Scene);
  43375. private _updateNumberOfRigCameras;
  43376. /** @hidden */
  43377. _updateForDualEyeDebugging(): void;
  43378. /**
  43379. * Updates the cameras position from the current pose information of the XR session
  43380. * @param xrSessionManager the session containing pose information
  43381. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43382. */
  43383. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43384. }
  43385. }
  43386. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43387. import { Observable } from "babylonjs/Misc/observable";
  43388. import { IDisposable, Scene } from "babylonjs/scene";
  43389. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43391. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43392. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43393. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43394. /**
  43395. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43396. * @see https://doc.babylonjs.com/how_to/webxr
  43397. */
  43398. export class WebXRExperienceHelper implements IDisposable {
  43399. private scene;
  43400. /**
  43401. * 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
  43402. */
  43403. container: AbstractMesh;
  43404. /**
  43405. * Camera used to render xr content
  43406. */
  43407. camera: WebXRCamera;
  43408. /**
  43409. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43410. */
  43411. state: WebXRState;
  43412. private _setState;
  43413. private static _TmpVector;
  43414. /**
  43415. * Fires when the state of the experience helper has changed
  43416. */
  43417. onStateChangedObservable: Observable<WebXRState>;
  43418. /** Session manager used to keep track of xr session */
  43419. sessionManager: WebXRSessionManager;
  43420. private _nonVRCamera;
  43421. private _originalSceneAutoClear;
  43422. private _supported;
  43423. /**
  43424. * Creates the experience helper
  43425. * @param scene the scene to attach the experience helper to
  43426. * @returns a promise for the experience helper
  43427. */
  43428. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43429. /**
  43430. * Creates a WebXRExperienceHelper
  43431. * @param scene The scene the helper should be created in
  43432. */
  43433. private constructor();
  43434. /**
  43435. * Exits XR mode and returns the scene to its original state
  43436. * @returns promise that resolves after xr mode has exited
  43437. */
  43438. exitXRAsync(): Promise<void>;
  43439. /**
  43440. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43441. * @param sessionMode options for the XR session
  43442. * @param referenceSpaceType frame of reference of the XR session
  43443. * @param renderTarget the output canvas that will be used to enter XR mode
  43444. * @returns promise that resolves after xr mode has entered
  43445. */
  43446. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43447. /**
  43448. * Updates the global position of the camera by moving the camera's container
  43449. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43450. * @param position The desired global position of the camera
  43451. */
  43452. setPositionOfCameraUsingContainer(position: Vector3): void;
  43453. /**
  43454. * Rotates the xr camera by rotating the camera's container around the camera's position
  43455. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43456. * @param rotation the desired quaternion rotation to apply to the camera
  43457. */
  43458. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43459. /**
  43460. * Disposes of the experience helper
  43461. */
  43462. dispose(): void;
  43463. }
  43464. }
  43465. declare module "babylonjs/Cameras/XR/webXRController" {
  43466. import { Nullable } from "babylonjs/types";
  43467. import { Observable } from "babylonjs/Misc/observable";
  43468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43469. import { Ray } from "babylonjs/Culling/ray";
  43470. import { Scene } from "babylonjs/scene";
  43471. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43472. /**
  43473. * Represents an XR input
  43474. */
  43475. export class WebXRController {
  43476. private scene;
  43477. /** The underlying input source for the controller */
  43478. inputSource: XRInputSource;
  43479. private parentContainer;
  43480. /**
  43481. * 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
  43482. */
  43483. grip?: AbstractMesh;
  43484. /**
  43485. * Pointer which can be used to select objects or attach a visible laser to
  43486. */
  43487. pointer: AbstractMesh;
  43488. private _gamepadMode;
  43489. /**
  43490. * If available, this is the gamepad object related to this controller.
  43491. * Using this object it is possible to get click events and trackpad changes of the
  43492. * webxr controller that is currently being used.
  43493. */
  43494. gamepadController?: WebVRController;
  43495. /**
  43496. * Event that fires when the controller is removed/disposed
  43497. */
  43498. onDisposeObservable: Observable<{}>;
  43499. private _tmpQuaternion;
  43500. private _tmpVector;
  43501. /**
  43502. * Creates the controller
  43503. * @see https://doc.babylonjs.com/how_to/webxr
  43504. * @param scene the scene which the controller should be associated to
  43505. * @param inputSource the underlying input source for the controller
  43506. * @param parentContainer parent that the controller meshes should be children of
  43507. */
  43508. constructor(scene: Scene,
  43509. /** The underlying input source for the controller */
  43510. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43511. /**
  43512. * Updates the controller pose based on the given XRFrame
  43513. * @param xrFrame xr frame to update the pose with
  43514. * @param referenceSpace reference space to use
  43515. */
  43516. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43517. /**
  43518. * Gets a world space ray coming from the controller
  43519. * @param result the resulting ray
  43520. */
  43521. getWorldPointerRayToRef(result: Ray): void;
  43522. /**
  43523. * Get the scene associated with this controller
  43524. * @returns the scene object
  43525. */
  43526. getScene(): Scene;
  43527. /**
  43528. * Disposes of the object
  43529. */
  43530. dispose(): void;
  43531. }
  43532. }
  43533. declare module "babylonjs/Cameras/XR/webXRInput" {
  43534. import { Observable } from "babylonjs/Misc/observable";
  43535. import { IDisposable } from "babylonjs/scene";
  43536. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43537. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43538. /**
  43539. * XR input used to track XR inputs such as controllers/rays
  43540. */
  43541. export class WebXRInput implements IDisposable {
  43542. /**
  43543. * Base experience the input listens to
  43544. */
  43545. baseExperience: WebXRExperienceHelper;
  43546. /**
  43547. * XR controllers being tracked
  43548. */
  43549. controllers: Array<WebXRController>;
  43550. private _frameObserver;
  43551. private _stateObserver;
  43552. /**
  43553. * Event when a controller has been connected/added
  43554. */
  43555. onControllerAddedObservable: Observable<WebXRController>;
  43556. /**
  43557. * Event when a controller has been removed/disconnected
  43558. */
  43559. onControllerRemovedObservable: Observable<WebXRController>;
  43560. /**
  43561. * Initializes the WebXRInput
  43562. * @param baseExperience experience helper which the input should be created for
  43563. */
  43564. constructor(
  43565. /**
  43566. * Base experience the input listens to
  43567. */
  43568. baseExperience: WebXRExperienceHelper);
  43569. private _onInputSourcesChange;
  43570. private _addAndRemoveControllers;
  43571. /**
  43572. * Disposes of the object
  43573. */
  43574. dispose(): void;
  43575. }
  43576. }
  43577. declare module "babylonjs/Loading/sceneLoader" {
  43578. import { Observable } from "babylonjs/Misc/observable";
  43579. import { Nullable } from "babylonjs/types";
  43580. import { Scene } from "babylonjs/scene";
  43581. import { Engine } from "babylonjs/Engines/engine";
  43582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43583. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43584. import { AssetContainer } from "babylonjs/assetContainer";
  43585. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43586. import { Skeleton } from "babylonjs/Bones/skeleton";
  43587. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43588. import { WebRequest } from "babylonjs/Misc/webRequest";
  43589. /**
  43590. * Class used to represent data loading progression
  43591. */
  43592. export class SceneLoaderProgressEvent {
  43593. /** defines if data length to load can be evaluated */
  43594. readonly lengthComputable: boolean;
  43595. /** defines the loaded data length */
  43596. readonly loaded: number;
  43597. /** defines the data length to load */
  43598. readonly total: number;
  43599. /**
  43600. * Create a new progress event
  43601. * @param lengthComputable defines if data length to load can be evaluated
  43602. * @param loaded defines the loaded data length
  43603. * @param total defines the data length to load
  43604. */
  43605. constructor(
  43606. /** defines if data length to load can be evaluated */
  43607. lengthComputable: boolean,
  43608. /** defines the loaded data length */
  43609. loaded: number,
  43610. /** defines the data length to load */
  43611. total: number);
  43612. /**
  43613. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43614. * @param event defines the source event
  43615. * @returns a new SceneLoaderProgressEvent
  43616. */
  43617. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43618. }
  43619. /**
  43620. * Interface used by SceneLoader plugins to define supported file extensions
  43621. */
  43622. export interface ISceneLoaderPluginExtensions {
  43623. /**
  43624. * Defines the list of supported extensions
  43625. */
  43626. [extension: string]: {
  43627. isBinary: boolean;
  43628. };
  43629. }
  43630. /**
  43631. * Interface used by SceneLoader plugin factory
  43632. */
  43633. export interface ISceneLoaderPluginFactory {
  43634. /**
  43635. * Defines the name of the factory
  43636. */
  43637. name: string;
  43638. /**
  43639. * Function called to create a new plugin
  43640. * @return the new plugin
  43641. */
  43642. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43643. /**
  43644. * The callback that returns true if the data can be directly loaded.
  43645. * @param data string containing the file data
  43646. * @returns if the data can be loaded directly
  43647. */
  43648. canDirectLoad?(data: string): boolean;
  43649. }
  43650. /**
  43651. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43652. */
  43653. export interface ISceneLoaderPluginBase {
  43654. /**
  43655. * The friendly name of this plugin.
  43656. */
  43657. name: string;
  43658. /**
  43659. * The file extensions supported by this plugin.
  43660. */
  43661. extensions: string | ISceneLoaderPluginExtensions;
  43662. /**
  43663. * The callback called when loading from a url.
  43664. * @param scene scene loading this url
  43665. * @param url url to load
  43666. * @param onSuccess callback called when the file successfully loads
  43667. * @param onProgress callback called while file is loading (if the server supports this mode)
  43668. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43669. * @param onError callback called when the file fails to load
  43670. * @returns a file request object
  43671. */
  43672. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43673. /**
  43674. * The callback called when loading from a file object.
  43675. * @param scene scene loading this file
  43676. * @param file defines the file to load
  43677. * @param onSuccess defines the callback to call when data is loaded
  43678. * @param onProgress defines the callback to call during loading process
  43679. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43680. * @param onError defines the callback to call when an error occurs
  43681. * @returns a file request object
  43682. */
  43683. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43684. /**
  43685. * The callback that returns true if the data can be directly loaded.
  43686. * @param data string containing the file data
  43687. * @returns if the data can be loaded directly
  43688. */
  43689. canDirectLoad?(data: string): boolean;
  43690. /**
  43691. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43692. * @param scene scene loading this data
  43693. * @param data string containing the data
  43694. * @returns data to pass to the plugin
  43695. */
  43696. directLoad?(scene: Scene, data: string): any;
  43697. /**
  43698. * The callback that allows custom handling of the root url based on the response url.
  43699. * @param rootUrl the original root url
  43700. * @param responseURL the response url if available
  43701. * @returns the new root url
  43702. */
  43703. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43704. }
  43705. /**
  43706. * Interface used to define a SceneLoader plugin
  43707. */
  43708. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43709. /**
  43710. * Import meshes into a scene.
  43711. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43712. * @param scene The scene to import into
  43713. * @param data The data to import
  43714. * @param rootUrl The root url for scene and resources
  43715. * @param meshes The meshes array to import into
  43716. * @param particleSystems The particle systems array to import into
  43717. * @param skeletons The skeletons array to import into
  43718. * @param onError The callback when import fails
  43719. * @returns True if successful or false otherwise
  43720. */
  43721. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43722. /**
  43723. * Load into a scene.
  43724. * @param scene The scene to load into
  43725. * @param data The data to import
  43726. * @param rootUrl The root url for scene and resources
  43727. * @param onError The callback when import fails
  43728. * @returns True if successful or false otherwise
  43729. */
  43730. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43731. /**
  43732. * Load into an asset container.
  43733. * @param scene The scene to load into
  43734. * @param data The data to import
  43735. * @param rootUrl The root url for scene and resources
  43736. * @param onError The callback when import fails
  43737. * @returns The loaded asset container
  43738. */
  43739. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43740. }
  43741. /**
  43742. * Interface used to define an async SceneLoader plugin
  43743. */
  43744. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43745. /**
  43746. * Import meshes into a scene.
  43747. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43748. * @param scene The scene to import into
  43749. * @param data The data to import
  43750. * @param rootUrl The root url for scene and resources
  43751. * @param onProgress The callback when the load progresses
  43752. * @param fileName Defines the name of the file to load
  43753. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43754. */
  43755. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43756. meshes: AbstractMesh[];
  43757. particleSystems: IParticleSystem[];
  43758. skeletons: Skeleton[];
  43759. animationGroups: AnimationGroup[];
  43760. }>;
  43761. /**
  43762. * Load into a scene.
  43763. * @param scene The scene to load into
  43764. * @param data The data to import
  43765. * @param rootUrl The root url for scene and resources
  43766. * @param onProgress The callback when the load progresses
  43767. * @param fileName Defines the name of the file to load
  43768. * @returns Nothing
  43769. */
  43770. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43771. /**
  43772. * Load into an asset container.
  43773. * @param scene The scene to load into
  43774. * @param data The data to import
  43775. * @param rootUrl The root url for scene and resources
  43776. * @param onProgress The callback when the load progresses
  43777. * @param fileName Defines the name of the file to load
  43778. * @returns The loaded asset container
  43779. */
  43780. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43781. }
  43782. /**
  43783. * Class used to load scene from various file formats using registered plugins
  43784. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43785. */
  43786. export class SceneLoader {
  43787. /**
  43788. * No logging while loading
  43789. */
  43790. static readonly NO_LOGGING: number;
  43791. /**
  43792. * Minimal logging while loading
  43793. */
  43794. static readonly MINIMAL_LOGGING: number;
  43795. /**
  43796. * Summary logging while loading
  43797. */
  43798. static readonly SUMMARY_LOGGING: number;
  43799. /**
  43800. * Detailled logging while loading
  43801. */
  43802. static readonly DETAILED_LOGGING: number;
  43803. /**
  43804. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43805. */
  43806. static ForceFullSceneLoadingForIncremental: boolean;
  43807. /**
  43808. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43809. */
  43810. static ShowLoadingScreen: boolean;
  43811. /**
  43812. * Defines the current logging level (while loading the scene)
  43813. * @ignorenaming
  43814. */
  43815. static loggingLevel: number;
  43816. /**
  43817. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43818. */
  43819. static CleanBoneMatrixWeights: boolean;
  43820. /**
  43821. * Event raised when a plugin is used to load a scene
  43822. */
  43823. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43824. private static _registeredPlugins;
  43825. private static _getDefaultPlugin;
  43826. private static _getPluginForExtension;
  43827. private static _getPluginForDirectLoad;
  43828. private static _getPluginForFilename;
  43829. private static _getDirectLoad;
  43830. private static _loadData;
  43831. private static _getFileInfo;
  43832. /**
  43833. * Gets a plugin that can load the given extension
  43834. * @param extension defines the extension to load
  43835. * @returns a plugin or null if none works
  43836. */
  43837. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43838. /**
  43839. * Gets a boolean indicating that the given extension can be loaded
  43840. * @param extension defines the extension to load
  43841. * @returns true if the extension is supported
  43842. */
  43843. static IsPluginForExtensionAvailable(extension: string): boolean;
  43844. /**
  43845. * Adds a new plugin to the list of registered plugins
  43846. * @param plugin defines the plugin to add
  43847. */
  43848. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43849. /**
  43850. * Import meshes into a scene
  43851. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43852. * @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)
  43853. * @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)
  43854. * @param scene the instance of BABYLON.Scene to append to
  43855. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43856. * @param onProgress a callback with a progress event for each file being loaded
  43857. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43858. * @param pluginExtension the extension used to determine the plugin
  43859. * @returns The loaded plugin
  43860. */
  43861. 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>;
  43862. /**
  43863. * Import meshes into a scene
  43864. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43865. * @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)
  43866. * @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)
  43867. * @param scene the instance of BABYLON.Scene to append to
  43868. * @param onProgress a callback with a progress event for each file being loaded
  43869. * @param pluginExtension the extension used to determine the plugin
  43870. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43871. */
  43872. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43873. meshes: AbstractMesh[];
  43874. particleSystems: IParticleSystem[];
  43875. skeletons: Skeleton[];
  43876. animationGroups: AnimationGroup[];
  43877. }>;
  43878. /**
  43879. * Load a scene
  43880. * @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)
  43881. * @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)
  43882. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43883. * @param onSuccess a callback with the scene when import succeeds
  43884. * @param onProgress a callback with a progress event for each file being loaded
  43885. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43886. * @param pluginExtension the extension used to determine the plugin
  43887. * @returns The loaded plugin
  43888. */
  43889. 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>;
  43890. /**
  43891. * Load a scene
  43892. * @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)
  43893. * @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)
  43894. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43895. * @param onProgress a callback with a progress event for each file being loaded
  43896. * @param pluginExtension the extension used to determine the plugin
  43897. * @returns The loaded scene
  43898. */
  43899. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43900. /**
  43901. * Append a scene
  43902. * @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)
  43903. * @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)
  43904. * @param scene is the instance of BABYLON.Scene to append to
  43905. * @param onSuccess a callback with the scene when import succeeds
  43906. * @param onProgress a callback with a progress event for each file being loaded
  43907. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43908. * @param pluginExtension the extension used to determine the plugin
  43909. * @returns The loaded plugin
  43910. */
  43911. 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>;
  43912. /**
  43913. * Append a scene
  43914. * @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)
  43915. * @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)
  43916. * @param scene is the instance of BABYLON.Scene to append to
  43917. * @param onProgress a callback with a progress event for each file being loaded
  43918. * @param pluginExtension the extension used to determine the plugin
  43919. * @returns The given scene
  43920. */
  43921. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43922. /**
  43923. * Load a scene into an asset container
  43924. * @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)
  43925. * @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)
  43926. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43927. * @param onSuccess a callback with the scene when import succeeds
  43928. * @param onProgress a callback with a progress event for each file being loaded
  43929. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43930. * @param pluginExtension the extension used to determine the plugin
  43931. * @returns The loaded plugin
  43932. */
  43933. 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>;
  43934. /**
  43935. * Load a scene into an asset container
  43936. * @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)
  43937. * @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)
  43938. * @param scene is the instance of Scene to append to
  43939. * @param onProgress a callback with a progress event for each file being loaded
  43940. * @param pluginExtension the extension used to determine the plugin
  43941. * @returns The loaded asset container
  43942. */
  43943. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43944. }
  43945. }
  43946. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43947. import { Scene } from "babylonjs/scene";
  43948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43949. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43950. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43951. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43952. /**
  43953. * Generic Controller
  43954. */
  43955. export class GenericController extends WebVRController {
  43956. /**
  43957. * Base Url for the controller model.
  43958. */
  43959. static readonly MODEL_BASE_URL: string;
  43960. /**
  43961. * File name for the controller model.
  43962. */
  43963. static readonly MODEL_FILENAME: string;
  43964. /**
  43965. * Creates a new GenericController from a gamepad
  43966. * @param vrGamepad the gamepad that the controller should be created from
  43967. */
  43968. constructor(vrGamepad: any);
  43969. /**
  43970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43971. * @param scene scene in which to add meshes
  43972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43973. */
  43974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43975. /**
  43976. * Called once for each button that changed state since the last frame
  43977. * @param buttonIdx Which button index changed
  43978. * @param state New state of the button
  43979. * @param changes Which properties on the state changed since last frame
  43980. */
  43981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43982. }
  43983. }
  43984. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43985. import { Observable } from "babylonjs/Misc/observable";
  43986. import { Scene } from "babylonjs/scene";
  43987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43988. import { Ray } from "babylonjs/Culling/ray";
  43989. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43990. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43991. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43992. /**
  43993. * Defines the WindowsMotionController object that the state of the windows motion controller
  43994. */
  43995. export class WindowsMotionController extends WebVRController {
  43996. /**
  43997. * The base url used to load the left and right controller models
  43998. */
  43999. static MODEL_BASE_URL: string;
  44000. /**
  44001. * The name of the left controller model file
  44002. */
  44003. static MODEL_LEFT_FILENAME: string;
  44004. /**
  44005. * The name of the right controller model file
  44006. */
  44007. static MODEL_RIGHT_FILENAME: string;
  44008. /**
  44009. * The controller name prefix for this controller type
  44010. */
  44011. static readonly GAMEPAD_ID_PREFIX: string;
  44012. /**
  44013. * The controller id pattern for this controller type
  44014. */
  44015. private static readonly GAMEPAD_ID_PATTERN;
  44016. private _loadedMeshInfo;
  44017. protected readonly _mapping: {
  44018. buttons: string[];
  44019. buttonMeshNames: {
  44020. 'trigger': string;
  44021. 'menu': string;
  44022. 'grip': string;
  44023. 'thumbstick': string;
  44024. 'trackpad': string;
  44025. };
  44026. buttonObservableNames: {
  44027. 'trigger': string;
  44028. 'menu': string;
  44029. 'grip': string;
  44030. 'thumbstick': string;
  44031. 'trackpad': string;
  44032. };
  44033. axisMeshNames: string[];
  44034. pointingPoseMeshName: string;
  44035. };
  44036. /**
  44037. * Fired when the trackpad on this controller is clicked
  44038. */
  44039. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44040. /**
  44041. * Fired when the trackpad on this controller is modified
  44042. */
  44043. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44044. /**
  44045. * The current x and y values of this controller's trackpad
  44046. */
  44047. trackpad: StickValues;
  44048. /**
  44049. * Creates a new WindowsMotionController from a gamepad
  44050. * @param vrGamepad the gamepad that the controller should be created from
  44051. */
  44052. constructor(vrGamepad: any);
  44053. /**
  44054. * Fired when the trigger on this controller is modified
  44055. */
  44056. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44057. /**
  44058. * Fired when the menu button on this controller is modified
  44059. */
  44060. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44061. /**
  44062. * Fired when the grip button on this controller is modified
  44063. */
  44064. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44065. /**
  44066. * Fired when the thumbstick button on this controller is modified
  44067. */
  44068. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44069. /**
  44070. * Fired when the touchpad button on this controller is modified
  44071. */
  44072. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44073. /**
  44074. * Fired when the touchpad values on this controller are modified
  44075. */
  44076. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44077. protected _updateTrackpad(): void;
  44078. /**
  44079. * Called once per frame by the engine.
  44080. */
  44081. update(): void;
  44082. /**
  44083. * Called once for each button that changed state since the last frame
  44084. * @param buttonIdx Which button index changed
  44085. * @param state New state of the button
  44086. * @param changes Which properties on the state changed since last frame
  44087. */
  44088. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44089. /**
  44090. * Moves the buttons on the controller mesh based on their current state
  44091. * @param buttonName the name of the button to move
  44092. * @param buttonValue the value of the button which determines the buttons new position
  44093. */
  44094. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44095. /**
  44096. * Moves the axis on the controller mesh based on its current state
  44097. * @param axis the index of the axis
  44098. * @param axisValue the value of the axis which determines the meshes new position
  44099. * @hidden
  44100. */
  44101. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44102. /**
  44103. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44104. * @param scene scene in which to add meshes
  44105. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44106. */
  44107. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44108. /**
  44109. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44110. * can be transformed by button presses and axes values, based on this._mapping.
  44111. *
  44112. * @param scene scene in which the meshes exist
  44113. * @param meshes list of meshes that make up the controller model to process
  44114. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44115. */
  44116. private processModel;
  44117. private createMeshInfo;
  44118. /**
  44119. * Gets the ray of the controller in the direction the controller is pointing
  44120. * @param length the length the resulting ray should be
  44121. * @returns a ray in the direction the controller is pointing
  44122. */
  44123. getForwardRay(length?: number): Ray;
  44124. /**
  44125. * Disposes of the controller
  44126. */
  44127. dispose(): void;
  44128. }
  44129. /**
  44130. * This class represents a new windows motion controller in XR.
  44131. */
  44132. export class XRWindowsMotionController extends WindowsMotionController {
  44133. /**
  44134. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44135. */
  44136. protected readonly _mapping: {
  44137. buttons: string[];
  44138. buttonMeshNames: {
  44139. 'trigger': string;
  44140. 'menu': string;
  44141. 'grip': string;
  44142. 'thumbstick': string;
  44143. 'trackpad': string;
  44144. };
  44145. buttonObservableNames: {
  44146. 'trigger': string;
  44147. 'menu': string;
  44148. 'grip': string;
  44149. 'thumbstick': string;
  44150. 'trackpad': string;
  44151. };
  44152. axisMeshNames: string[];
  44153. pointingPoseMeshName: string;
  44154. };
  44155. /**
  44156. * Construct a new XR-Based windows motion controller
  44157. *
  44158. * @param gamepadInfo the gamepad object from the browser
  44159. */
  44160. constructor(gamepadInfo: any);
  44161. /**
  44162. * holds the thumbstick values (X,Y)
  44163. */
  44164. thumbstickValues: StickValues;
  44165. /**
  44166. * Fired when the thumbstick on this controller is clicked
  44167. */
  44168. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44169. /**
  44170. * Fired when the thumbstick on this controller is modified
  44171. */
  44172. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44173. /**
  44174. * Fired when the touchpad button on this controller is modified
  44175. */
  44176. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44177. /**
  44178. * Fired when the touchpad values on this controller are modified
  44179. */
  44180. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44181. /**
  44182. * Fired when the thumbstick button on this controller is modified
  44183. * here to prevent breaking changes
  44184. */
  44185. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44186. /**
  44187. * updating the thumbstick(!) and not the trackpad.
  44188. * This is named this way due to the difference between WebVR and XR and to avoid
  44189. * changing the parent class.
  44190. */
  44191. protected _updateTrackpad(): void;
  44192. /**
  44193. * Disposes the class with joy
  44194. */
  44195. dispose(): void;
  44196. }
  44197. }
  44198. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44199. import { Observable } from "babylonjs/Misc/observable";
  44200. import { Scene } from "babylonjs/scene";
  44201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44202. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44203. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44204. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44205. /**
  44206. * Oculus Touch Controller
  44207. */
  44208. export class OculusTouchController extends WebVRController {
  44209. /**
  44210. * Base Url for the controller model.
  44211. */
  44212. static MODEL_BASE_URL: string;
  44213. /**
  44214. * File name for the left controller model.
  44215. */
  44216. static MODEL_LEFT_FILENAME: string;
  44217. /**
  44218. * File name for the right controller model.
  44219. */
  44220. static MODEL_RIGHT_FILENAME: string;
  44221. /**
  44222. * Base Url for the Quest controller model.
  44223. */
  44224. static QUEST_MODEL_BASE_URL: string;
  44225. /**
  44226. * @hidden
  44227. * If the controllers are running on a device that needs the updated Quest controller models
  44228. */
  44229. static _IsQuest: boolean;
  44230. /**
  44231. * Fired when the secondary trigger on this controller is modified
  44232. */
  44233. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44234. /**
  44235. * Fired when the thumb rest on this controller is modified
  44236. */
  44237. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44238. /**
  44239. * Creates a new OculusTouchController from a gamepad
  44240. * @param vrGamepad the gamepad that the controller should be created from
  44241. */
  44242. constructor(vrGamepad: any);
  44243. /**
  44244. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44245. * @param scene scene in which to add meshes
  44246. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44247. */
  44248. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44249. /**
  44250. * Fired when the A button on this controller is modified
  44251. */
  44252. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44253. /**
  44254. * Fired when the B button on this controller is modified
  44255. */
  44256. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44257. /**
  44258. * Fired when the X button on this controller is modified
  44259. */
  44260. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44261. /**
  44262. * Fired when the Y button on this controller is modified
  44263. */
  44264. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44265. /**
  44266. * Called once for each button that changed state since the last frame
  44267. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44268. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44269. * 2) secondary trigger (same)
  44270. * 3) A (right) X (left), touch, pressed = value
  44271. * 4) B / Y
  44272. * 5) thumb rest
  44273. * @param buttonIdx Which button index changed
  44274. * @param state New state of the button
  44275. * @param changes Which properties on the state changed since last frame
  44276. */
  44277. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44278. }
  44279. }
  44280. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44281. import { Scene } from "babylonjs/scene";
  44282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44283. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44284. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44285. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44286. import { Observable } from "babylonjs/Misc/observable";
  44287. /**
  44288. * Vive Controller
  44289. */
  44290. export class ViveController extends WebVRController {
  44291. /**
  44292. * Base Url for the controller model.
  44293. */
  44294. static MODEL_BASE_URL: string;
  44295. /**
  44296. * File name for the controller model.
  44297. */
  44298. static MODEL_FILENAME: string;
  44299. /**
  44300. * Creates a new ViveController from a gamepad
  44301. * @param vrGamepad the gamepad that the controller should be created from
  44302. */
  44303. constructor(vrGamepad: any);
  44304. /**
  44305. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44306. * @param scene scene in which to add meshes
  44307. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44308. */
  44309. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44310. /**
  44311. * Fired when the left button on this controller is modified
  44312. */
  44313. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44314. /**
  44315. * Fired when the right button on this controller is modified
  44316. */
  44317. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44318. /**
  44319. * Fired when the menu button on this controller is modified
  44320. */
  44321. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44322. /**
  44323. * Called once for each button that changed state since the last frame
  44324. * Vive mapping:
  44325. * 0: touchpad
  44326. * 1: trigger
  44327. * 2: left AND right buttons
  44328. * 3: menu button
  44329. * @param buttonIdx Which button index changed
  44330. * @param state New state of the button
  44331. * @param changes Which properties on the state changed since last frame
  44332. */
  44333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44334. }
  44335. }
  44336. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44337. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44338. import { Observable } from "babylonjs/Misc/observable";
  44339. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44340. /**
  44341. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44342. */
  44343. export class WebXRControllerModelLoader {
  44344. /**
  44345. * an observable that triggers when a new model (the mesh itself) was initialized.
  44346. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44347. */
  44348. onControllerModelLoaded: Observable<WebXRController>;
  44349. /**
  44350. * Creates the WebXRControllerModelLoader
  44351. * @param input xr input that creates the controllers
  44352. */
  44353. constructor(input: WebXRInput);
  44354. }
  44355. }
  44356. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44357. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44358. /**
  44359. * Handles pointer input automatically for the pointer of XR controllers
  44360. */
  44361. export class WebXRControllerPointerSelection {
  44362. private static _idCounter;
  44363. private _tmpRay;
  44364. /**
  44365. * Creates a WebXRControllerPointerSelection
  44366. * @param input input manager to setup pointer selection
  44367. */
  44368. constructor(input: WebXRInput);
  44369. private _convertNormalToDirectionOfRay;
  44370. private _updatePointerDistance;
  44371. }
  44372. }
  44373. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44375. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44376. /**
  44377. * Enables teleportation
  44378. */
  44379. export class WebXRControllerTeleportation {
  44380. private _teleportationFillColor;
  44381. private _teleportationBorderColor;
  44382. private _tmpRay;
  44383. private _tmpVector;
  44384. /**
  44385. * Creates a WebXRControllerTeleportation
  44386. * @param input input manager to add teleportation to
  44387. * @param floorMeshes floormeshes which can be teleported to
  44388. */
  44389. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44390. }
  44391. }
  44392. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44393. import { Nullable } from "babylonjs/types";
  44394. import { Observable } from "babylonjs/Misc/observable";
  44395. import { IDisposable, Scene } from "babylonjs/scene";
  44396. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44397. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44398. /**
  44399. * Button which can be used to enter a different mode of XR
  44400. */
  44401. export class WebXREnterExitUIButton {
  44402. /** button element */
  44403. element: HTMLElement;
  44404. /** XR initialization options for the button */
  44405. sessionMode: XRSessionMode;
  44406. /** Reference space type */
  44407. referenceSpaceType: XRReferenceSpaceType;
  44408. /**
  44409. * Creates a WebXREnterExitUIButton
  44410. * @param element button element
  44411. * @param sessionMode XR initialization session mode
  44412. * @param referenceSpaceType the type of reference space to be used
  44413. */
  44414. constructor(
  44415. /** button element */
  44416. element: HTMLElement,
  44417. /** XR initialization options for the button */
  44418. sessionMode: XRSessionMode,
  44419. /** Reference space type */
  44420. referenceSpaceType: XRReferenceSpaceType);
  44421. /**
  44422. * Overwritable function which can be used to update the button's visuals when the state changes
  44423. * @param activeButton the current active button in the UI
  44424. */
  44425. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44426. }
  44427. /**
  44428. * Options to create the webXR UI
  44429. */
  44430. export class WebXREnterExitUIOptions {
  44431. /**
  44432. * Context to enter xr with
  44433. */
  44434. renderTarget?: Nullable<WebXRRenderTarget>;
  44435. /**
  44436. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44437. */
  44438. customButtons?: Array<WebXREnterExitUIButton>;
  44439. /**
  44440. * A session mode to use when creating the default button.
  44441. * Default is immersive-vr
  44442. */
  44443. sessionMode?: XRSessionMode;
  44444. /**
  44445. * A reference space type to use when creating the default button.
  44446. * Default is local-floor
  44447. */
  44448. referenceSpaceType?: XRReferenceSpaceType;
  44449. }
  44450. /**
  44451. * UI to allow the user to enter/exit XR mode
  44452. */
  44453. export class WebXREnterExitUI implements IDisposable {
  44454. private scene;
  44455. private _overlay;
  44456. private _buttons;
  44457. private _activeButton;
  44458. /**
  44459. * Fired every time the active button is changed.
  44460. *
  44461. * When xr is entered via a button that launches xr that button will be the callback parameter
  44462. *
  44463. * When exiting xr the callback parameter will be null)
  44464. */
  44465. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44466. /**
  44467. * Creates UI to allow the user to enter/exit XR mode
  44468. * @param scene the scene to add the ui to
  44469. * @param helper the xr experience helper to enter/exit xr with
  44470. * @param options options to configure the UI
  44471. * @returns the created ui
  44472. */
  44473. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44474. private constructor();
  44475. private _updateButtons;
  44476. /**
  44477. * Disposes of the object
  44478. */
  44479. dispose(): void;
  44480. }
  44481. }
  44482. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44483. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44484. import { Scene } from "babylonjs/scene";
  44485. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44486. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44487. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44488. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44489. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44490. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44492. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44493. /**
  44494. * Options for the default xr helper
  44495. */
  44496. export class WebXRDefaultExperienceOptions {
  44497. /**
  44498. * Floor meshes that should be used for teleporting
  44499. */
  44500. floorMeshes: Array<AbstractMesh>;
  44501. /**
  44502. * Enable or disable default UI to enter XR
  44503. */
  44504. disableDefaultUI?: boolean;
  44505. /**
  44506. * optional configuration for the output canvas
  44507. */
  44508. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44509. }
  44510. /**
  44511. * Default experience which provides a similar setup to the previous webVRExperience
  44512. */
  44513. export class WebXRDefaultExperience {
  44514. /**
  44515. * Base experience
  44516. */
  44517. baseExperience: WebXRExperienceHelper;
  44518. /**
  44519. * Input experience extension
  44520. */
  44521. input: WebXRInput;
  44522. /**
  44523. * Loads the controller models
  44524. */
  44525. controllerModelLoader: WebXRControllerModelLoader;
  44526. /**
  44527. * Enables laser pointer and selection
  44528. */
  44529. pointerSelection: WebXRControllerPointerSelection;
  44530. /**
  44531. * Enables teleportation
  44532. */
  44533. teleportation: WebXRControllerTeleportation;
  44534. /**
  44535. * Enables ui for enetering/exiting xr
  44536. */
  44537. enterExitUI: WebXREnterExitUI;
  44538. /**
  44539. * Default target xr should render to
  44540. */
  44541. renderTarget: WebXRRenderTarget;
  44542. /**
  44543. * Creates the default xr experience
  44544. * @param scene scene
  44545. * @param options options for basic configuration
  44546. * @returns resulting WebXRDefaultExperience
  44547. */
  44548. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44549. private constructor();
  44550. /**
  44551. * DIsposes of the experience helper
  44552. */
  44553. dispose(): void;
  44554. }
  44555. }
  44556. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44557. import { Observable } from "babylonjs/Misc/observable";
  44558. import { Nullable } from "babylonjs/types";
  44559. import { Camera } from "babylonjs/Cameras/camera";
  44560. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44561. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44562. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44563. import { Scene } from "babylonjs/scene";
  44564. import { Vector3 } from "babylonjs/Maths/math.vector";
  44565. import { Color3 } from "babylonjs/Maths/math.color";
  44566. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44568. import { Mesh } from "babylonjs/Meshes/mesh";
  44569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44570. import { EasingFunction } from "babylonjs/Animations/easing";
  44571. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44572. import "babylonjs/Meshes/Builders/groundBuilder";
  44573. import "babylonjs/Meshes/Builders/torusBuilder";
  44574. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44575. import "babylonjs/Gamepads/gamepadSceneComponent";
  44576. import "babylonjs/Animations/animatable";
  44577. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44578. /**
  44579. * Options to modify the vr teleportation behavior.
  44580. */
  44581. export interface VRTeleportationOptions {
  44582. /**
  44583. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44584. */
  44585. floorMeshName?: string;
  44586. /**
  44587. * A list of meshes to be used as the teleportation floor. (default: empty)
  44588. */
  44589. floorMeshes?: Mesh[];
  44590. /**
  44591. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44592. */
  44593. teleportationMode?: number;
  44594. /**
  44595. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44596. */
  44597. teleportationTime?: number;
  44598. /**
  44599. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44600. */
  44601. teleportationSpeed?: number;
  44602. /**
  44603. * The easing function used in the animation or null for Linear. (default CircleEase)
  44604. */
  44605. easingFunction?: EasingFunction;
  44606. }
  44607. /**
  44608. * Options to modify the vr experience helper's behavior.
  44609. */
  44610. export interface VRExperienceHelperOptions extends WebVROptions {
  44611. /**
  44612. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44613. */
  44614. createDeviceOrientationCamera?: boolean;
  44615. /**
  44616. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44617. */
  44618. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44619. /**
  44620. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44621. */
  44622. laserToggle?: boolean;
  44623. /**
  44624. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44625. */
  44626. floorMeshes?: Mesh[];
  44627. /**
  44628. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44629. */
  44630. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44631. /**
  44632. * Defines if WebXR should be used instead of WebVR (if available)
  44633. */
  44634. useXR?: boolean;
  44635. }
  44636. /**
  44637. * Event containing information after VR has been entered
  44638. */
  44639. export class OnAfterEnteringVRObservableEvent {
  44640. /**
  44641. * If entering vr was successful
  44642. */
  44643. success: boolean;
  44644. }
  44645. /**
  44646. * Helps to quickly add VR support to an existing scene.
  44647. * See http://doc.babylonjs.com/how_to/webvr_helper
  44648. */
  44649. export class VRExperienceHelper {
  44650. /** Options to modify the vr experience helper's behavior. */
  44651. webVROptions: VRExperienceHelperOptions;
  44652. private _scene;
  44653. private _position;
  44654. private _btnVR;
  44655. private _btnVRDisplayed;
  44656. private _webVRsupported;
  44657. private _webVRready;
  44658. private _webVRrequesting;
  44659. private _webVRpresenting;
  44660. private _hasEnteredVR;
  44661. private _fullscreenVRpresenting;
  44662. private _inputElement;
  44663. private _webVRCamera;
  44664. private _vrDeviceOrientationCamera;
  44665. private _deviceOrientationCamera;
  44666. private _existingCamera;
  44667. private _onKeyDown;
  44668. private _onVrDisplayPresentChange;
  44669. private _onVRDisplayChanged;
  44670. private _onVRRequestPresentStart;
  44671. private _onVRRequestPresentComplete;
  44672. /**
  44673. * 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)
  44674. */
  44675. enableGazeEvenWhenNoPointerLock: boolean;
  44676. /**
  44677. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44678. */
  44679. exitVROnDoubleTap: boolean;
  44680. /**
  44681. * Observable raised right before entering VR.
  44682. */
  44683. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44684. /**
  44685. * Observable raised when entering VR has completed.
  44686. */
  44687. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44688. /**
  44689. * Observable raised when exiting VR.
  44690. */
  44691. onExitingVRObservable: Observable<VRExperienceHelper>;
  44692. /**
  44693. * Observable raised when controller mesh is loaded.
  44694. */
  44695. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44696. /** Return this.onEnteringVRObservable
  44697. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44698. */
  44699. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44700. /** Return this.onExitingVRObservable
  44701. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44702. */
  44703. readonly onExitingVR: Observable<VRExperienceHelper>;
  44704. /** Return this.onControllerMeshLoadedObservable
  44705. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44706. */
  44707. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44708. private _rayLength;
  44709. private _useCustomVRButton;
  44710. private _teleportationRequested;
  44711. private _teleportActive;
  44712. private _floorMeshName;
  44713. private _floorMeshesCollection;
  44714. private _teleportationMode;
  44715. private _teleportationTime;
  44716. private _teleportationSpeed;
  44717. private _teleportationEasing;
  44718. private _rotationAllowed;
  44719. private _teleportBackwardsVector;
  44720. private _teleportationTarget;
  44721. private _isDefaultTeleportationTarget;
  44722. private _postProcessMove;
  44723. private _teleportationFillColor;
  44724. private _teleportationBorderColor;
  44725. private _rotationAngle;
  44726. private _haloCenter;
  44727. private _cameraGazer;
  44728. private _padSensibilityUp;
  44729. private _padSensibilityDown;
  44730. private _leftController;
  44731. private _rightController;
  44732. /**
  44733. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44734. */
  44735. onNewMeshSelected: Observable<AbstractMesh>;
  44736. /**
  44737. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44738. * This observable will provide the mesh and the controller used to select the mesh
  44739. */
  44740. onMeshSelectedWithController: Observable<{
  44741. mesh: AbstractMesh;
  44742. controller: WebVRController;
  44743. }>;
  44744. /**
  44745. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44746. */
  44747. onNewMeshPicked: Observable<PickingInfo>;
  44748. private _circleEase;
  44749. /**
  44750. * Observable raised before camera teleportation
  44751. */
  44752. onBeforeCameraTeleport: Observable<Vector3>;
  44753. /**
  44754. * Observable raised after camera teleportation
  44755. */
  44756. onAfterCameraTeleport: Observable<Vector3>;
  44757. /**
  44758. * Observable raised when current selected mesh gets unselected
  44759. */
  44760. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44761. private _raySelectionPredicate;
  44762. /**
  44763. * To be optionaly changed by user to define custom ray selection
  44764. */
  44765. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44766. /**
  44767. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44768. */
  44769. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44770. /**
  44771. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44772. */
  44773. teleportationEnabled: boolean;
  44774. private _defaultHeight;
  44775. private _teleportationInitialized;
  44776. private _interactionsEnabled;
  44777. private _interactionsRequested;
  44778. private _displayGaze;
  44779. private _displayLaserPointer;
  44780. /**
  44781. * The mesh used to display where the user is going to teleport.
  44782. */
  44783. /**
  44784. * Sets the mesh to be used to display where the user is going to teleport.
  44785. */
  44786. teleportationTarget: Mesh;
  44787. /**
  44788. * 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
  44789. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44790. * See http://doc.babylonjs.com/resources/baking_transformations
  44791. */
  44792. gazeTrackerMesh: Mesh;
  44793. /**
  44794. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44795. */
  44796. updateGazeTrackerScale: boolean;
  44797. /**
  44798. * If the gaze trackers color should be updated when selecting meshes
  44799. */
  44800. updateGazeTrackerColor: boolean;
  44801. /**
  44802. * If the controller laser color should be updated when selecting meshes
  44803. */
  44804. updateControllerLaserColor: boolean;
  44805. /**
  44806. * The gaze tracking mesh corresponding to the left controller
  44807. */
  44808. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44809. /**
  44810. * The gaze tracking mesh corresponding to the right controller
  44811. */
  44812. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44813. /**
  44814. * If the ray of the gaze should be displayed.
  44815. */
  44816. /**
  44817. * Sets if the ray of the gaze should be displayed.
  44818. */
  44819. displayGaze: boolean;
  44820. /**
  44821. * If the ray of the LaserPointer should be displayed.
  44822. */
  44823. /**
  44824. * Sets if the ray of the LaserPointer should be displayed.
  44825. */
  44826. displayLaserPointer: boolean;
  44827. /**
  44828. * The deviceOrientationCamera used as the camera when not in VR.
  44829. */
  44830. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44831. /**
  44832. * Based on the current WebVR support, returns the current VR camera used.
  44833. */
  44834. readonly currentVRCamera: Nullable<Camera>;
  44835. /**
  44836. * The webVRCamera which is used when in VR.
  44837. */
  44838. readonly webVRCamera: WebVRFreeCamera;
  44839. /**
  44840. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44841. */
  44842. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44843. /**
  44844. * The html button that is used to trigger entering into VR.
  44845. */
  44846. readonly vrButton: Nullable<HTMLButtonElement>;
  44847. private readonly _teleportationRequestInitiated;
  44848. /**
  44849. * Defines wether or not Pointer lock should be requested when switching to
  44850. * full screen.
  44851. */
  44852. requestPointerLockOnFullScreen: boolean;
  44853. /**
  44854. * If asking to force XR, this will be populated with the default xr experience
  44855. */
  44856. xr: WebXRDefaultExperience;
  44857. /**
  44858. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44859. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44860. */
  44861. xrTestDone: boolean;
  44862. /**
  44863. * Instantiates a VRExperienceHelper.
  44864. * Helps to quickly add VR support to an existing scene.
  44865. * @param scene The scene the VRExperienceHelper belongs to.
  44866. * @param webVROptions Options to modify the vr experience helper's behavior.
  44867. */
  44868. constructor(scene: Scene,
  44869. /** Options to modify the vr experience helper's behavior. */
  44870. webVROptions?: VRExperienceHelperOptions);
  44871. private completeVRInit;
  44872. private _onDefaultMeshLoaded;
  44873. private _onResize;
  44874. private _onFullscreenChange;
  44875. /**
  44876. * Gets a value indicating if we are currently in VR mode.
  44877. */
  44878. readonly isInVRMode: boolean;
  44879. private onVrDisplayPresentChange;
  44880. private onVRDisplayChanged;
  44881. private moveButtonToBottomRight;
  44882. private displayVRButton;
  44883. private updateButtonVisibility;
  44884. private _cachedAngularSensibility;
  44885. /**
  44886. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44887. * Otherwise, will use the fullscreen API.
  44888. */
  44889. enterVR(): void;
  44890. /**
  44891. * Attempt to exit VR, or fullscreen.
  44892. */
  44893. exitVR(): void;
  44894. /**
  44895. * The position of the vr experience helper.
  44896. */
  44897. /**
  44898. * Sets the position of the vr experience helper.
  44899. */
  44900. position: Vector3;
  44901. /**
  44902. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44903. */
  44904. enableInteractions(): void;
  44905. private readonly _noControllerIsActive;
  44906. private beforeRender;
  44907. private _isTeleportationFloor;
  44908. /**
  44909. * Adds a floor mesh to be used for teleportation.
  44910. * @param floorMesh the mesh to be used for teleportation.
  44911. */
  44912. addFloorMesh(floorMesh: Mesh): void;
  44913. /**
  44914. * Removes a floor mesh from being used for teleportation.
  44915. * @param floorMesh the mesh to be removed.
  44916. */
  44917. removeFloorMesh(floorMesh: Mesh): void;
  44918. /**
  44919. * Enables interactions and teleportation using the VR controllers and gaze.
  44920. * @param vrTeleportationOptions options to modify teleportation behavior.
  44921. */
  44922. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44923. private _onNewGamepadConnected;
  44924. private _tryEnableInteractionOnController;
  44925. private _onNewGamepadDisconnected;
  44926. private _enableInteractionOnController;
  44927. private _checkTeleportWithRay;
  44928. private _checkRotate;
  44929. private _checkTeleportBackwards;
  44930. private _enableTeleportationOnController;
  44931. private _createTeleportationCircles;
  44932. private _displayTeleportationTarget;
  44933. private _hideTeleportationTarget;
  44934. private _rotateCamera;
  44935. private _moveTeleportationSelectorTo;
  44936. private _workingVector;
  44937. private _workingQuaternion;
  44938. private _workingMatrix;
  44939. /**
  44940. * Time Constant Teleportation Mode
  44941. */
  44942. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44943. /**
  44944. * Speed Constant Teleportation Mode
  44945. */
  44946. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44947. /**
  44948. * Teleports the users feet to the desired location
  44949. * @param location The location where the user's feet should be placed
  44950. */
  44951. teleportCamera(location: Vector3): void;
  44952. private _convertNormalToDirectionOfRay;
  44953. private _castRayAndSelectObject;
  44954. private _notifySelectedMeshUnselected;
  44955. /**
  44956. * Sets the color of the laser ray from the vr controllers.
  44957. * @param color new color for the ray.
  44958. */
  44959. changeLaserColor(color: Color3): void;
  44960. /**
  44961. * Sets the color of the ray from the vr headsets gaze.
  44962. * @param color new color for the ray.
  44963. */
  44964. changeGazeColor(color: Color3): void;
  44965. /**
  44966. * Exits VR and disposes of the vr experience helper
  44967. */
  44968. dispose(): void;
  44969. /**
  44970. * Gets the name of the VRExperienceHelper class
  44971. * @returns "VRExperienceHelper"
  44972. */
  44973. getClassName(): string;
  44974. }
  44975. }
  44976. declare module "babylonjs/Cameras/VR/index" {
  44977. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44978. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44979. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44980. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  44981. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  44982. export * from "babylonjs/Cameras/VR/webVRCamera";
  44983. }
  44984. declare module "babylonjs/Cameras/XR/index" {
  44985. export * from "babylonjs/Cameras/XR/webXRCamera";
  44986. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44987. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44988. export * from "babylonjs/Cameras/XR/webXRInput";
  44989. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44990. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44991. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44992. export * from "babylonjs/Cameras/XR/webXRController";
  44993. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44994. export * from "babylonjs/Cameras/XR/webXRTypes";
  44995. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44996. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44997. }
  44998. declare module "babylonjs/Cameras/RigModes/index" {
  44999. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45000. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45001. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45002. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45003. }
  45004. declare module "babylonjs/Cameras/index" {
  45005. export * from "babylonjs/Cameras/Inputs/index";
  45006. export * from "babylonjs/Cameras/cameraInputsManager";
  45007. export * from "babylonjs/Cameras/camera";
  45008. export * from "babylonjs/Cameras/targetCamera";
  45009. export * from "babylonjs/Cameras/freeCamera";
  45010. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45011. export * from "babylonjs/Cameras/touchCamera";
  45012. export * from "babylonjs/Cameras/arcRotateCamera";
  45013. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45014. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45015. export * from "babylonjs/Cameras/flyCamera";
  45016. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45017. export * from "babylonjs/Cameras/followCamera";
  45018. export * from "babylonjs/Cameras/followCameraInputsManager";
  45019. export * from "babylonjs/Cameras/gamepadCamera";
  45020. export * from "babylonjs/Cameras/Stereoscopic/index";
  45021. export * from "babylonjs/Cameras/universalCamera";
  45022. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45023. export * from "babylonjs/Cameras/VR/index";
  45024. export * from "babylonjs/Cameras/XR/index";
  45025. export * from "babylonjs/Cameras/RigModes/index";
  45026. }
  45027. declare module "babylonjs/Collisions/index" {
  45028. export * from "babylonjs/Collisions/collider";
  45029. export * from "babylonjs/Collisions/collisionCoordinator";
  45030. export * from "babylonjs/Collisions/pickingInfo";
  45031. export * from "babylonjs/Collisions/intersectionInfo";
  45032. export * from "babylonjs/Collisions/meshCollisionData";
  45033. }
  45034. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45035. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45036. import { Vector3 } from "babylonjs/Maths/math.vector";
  45037. import { Ray } from "babylonjs/Culling/ray";
  45038. import { Plane } from "babylonjs/Maths/math.plane";
  45039. /**
  45040. * Contains an array of blocks representing the octree
  45041. */
  45042. export interface IOctreeContainer<T> {
  45043. /**
  45044. * Blocks within the octree
  45045. */
  45046. blocks: Array<OctreeBlock<T>>;
  45047. }
  45048. /**
  45049. * Class used to store a cell in an octree
  45050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45051. */
  45052. export class OctreeBlock<T> {
  45053. /**
  45054. * Gets the content of the current block
  45055. */
  45056. entries: T[];
  45057. /**
  45058. * Gets the list of block children
  45059. */
  45060. blocks: Array<OctreeBlock<T>>;
  45061. private _depth;
  45062. private _maxDepth;
  45063. private _capacity;
  45064. private _minPoint;
  45065. private _maxPoint;
  45066. private _boundingVectors;
  45067. private _creationFunc;
  45068. /**
  45069. * Creates a new block
  45070. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45071. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45072. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45073. * @param depth defines the current depth of this block in the octree
  45074. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45075. * @param creationFunc defines a callback to call when an element is added to the block
  45076. */
  45077. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45078. /**
  45079. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45080. */
  45081. readonly capacity: number;
  45082. /**
  45083. * Gets the minimum vector (in world space) of the block's bounding box
  45084. */
  45085. readonly minPoint: Vector3;
  45086. /**
  45087. * Gets the maximum vector (in world space) of the block's bounding box
  45088. */
  45089. readonly maxPoint: Vector3;
  45090. /**
  45091. * Add a new element to this block
  45092. * @param entry defines the element to add
  45093. */
  45094. addEntry(entry: T): void;
  45095. /**
  45096. * Remove an element from this block
  45097. * @param entry defines the element to remove
  45098. */
  45099. removeEntry(entry: T): void;
  45100. /**
  45101. * Add an array of elements to this block
  45102. * @param entries defines the array of elements to add
  45103. */
  45104. addEntries(entries: T[]): void;
  45105. /**
  45106. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45107. * @param frustumPlanes defines the frustum planes to test
  45108. * @param selection defines the array to store current content if selection is positive
  45109. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45110. */
  45111. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45112. /**
  45113. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45114. * @param sphereCenter defines the bounding sphere center
  45115. * @param sphereRadius defines the bounding sphere radius
  45116. * @param selection defines the array to store current content if selection is positive
  45117. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45118. */
  45119. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45120. /**
  45121. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45122. * @param ray defines the ray to test with
  45123. * @param selection defines the array to store current content if selection is positive
  45124. */
  45125. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45126. /**
  45127. * Subdivide the content into child blocks (this block will then be empty)
  45128. */
  45129. createInnerBlocks(): void;
  45130. /**
  45131. * @hidden
  45132. */
  45133. 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;
  45134. }
  45135. }
  45136. declare module "babylonjs/Culling/Octrees/octree" {
  45137. import { SmartArray } from "babylonjs/Misc/smartArray";
  45138. import { Vector3 } from "babylonjs/Maths/math.vector";
  45139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45141. import { Ray } from "babylonjs/Culling/ray";
  45142. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45143. import { Plane } from "babylonjs/Maths/math.plane";
  45144. /**
  45145. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45147. */
  45148. export class Octree<T> {
  45149. /** 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.) */
  45150. maxDepth: number;
  45151. /**
  45152. * Blocks within the octree containing objects
  45153. */
  45154. blocks: Array<OctreeBlock<T>>;
  45155. /**
  45156. * Content stored in the octree
  45157. */
  45158. dynamicContent: T[];
  45159. private _maxBlockCapacity;
  45160. private _selectionContent;
  45161. private _creationFunc;
  45162. /**
  45163. * Creates a octree
  45164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45165. * @param creationFunc function to be used to instatiate the octree
  45166. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45167. * @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.)
  45168. */
  45169. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45170. /** 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.) */
  45171. maxDepth?: number);
  45172. /**
  45173. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45174. * @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);
  45175. * @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);
  45176. * @param entries meshes to be added to the octree blocks
  45177. */
  45178. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45179. /**
  45180. * Adds a mesh to the octree
  45181. * @param entry Mesh to add to the octree
  45182. */
  45183. addMesh(entry: T): void;
  45184. /**
  45185. * Remove an element from the octree
  45186. * @param entry defines the element to remove
  45187. */
  45188. removeMesh(entry: T): void;
  45189. /**
  45190. * Selects an array of meshes within the frustum
  45191. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45192. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45193. * @returns array of meshes within the frustum
  45194. */
  45195. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45196. /**
  45197. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45198. * @param sphereCenter defines the bounding sphere center
  45199. * @param sphereRadius defines the bounding sphere radius
  45200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45201. * @returns an array of objects that intersect the sphere
  45202. */
  45203. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45204. /**
  45205. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45206. * @param ray defines the ray to test with
  45207. * @returns array of intersected objects
  45208. */
  45209. intersectsRay(ray: Ray): SmartArray<T>;
  45210. /**
  45211. * Adds a mesh into the octree block if it intersects the block
  45212. */
  45213. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45214. /**
  45215. * Adds a submesh into the octree block if it intersects the block
  45216. */
  45217. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45218. }
  45219. }
  45220. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45221. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45222. import { Scene } from "babylonjs/scene";
  45223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45225. import { Ray } from "babylonjs/Culling/ray";
  45226. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45227. import { Collider } from "babylonjs/Collisions/collider";
  45228. module "babylonjs/scene" {
  45229. interface Scene {
  45230. /**
  45231. * @hidden
  45232. * Backing Filed
  45233. */
  45234. _selectionOctree: Octree<AbstractMesh>;
  45235. /**
  45236. * Gets the octree used to boost mesh selection (picking)
  45237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45238. */
  45239. selectionOctree: Octree<AbstractMesh>;
  45240. /**
  45241. * Creates or updates the octree used to boost selection (picking)
  45242. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45243. * @param maxCapacity defines the maximum capacity per leaf
  45244. * @param maxDepth defines the maximum depth of the octree
  45245. * @returns an octree of AbstractMesh
  45246. */
  45247. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45248. }
  45249. }
  45250. module "babylonjs/Meshes/abstractMesh" {
  45251. interface AbstractMesh {
  45252. /**
  45253. * @hidden
  45254. * Backing Field
  45255. */
  45256. _submeshesOctree: Octree<SubMesh>;
  45257. /**
  45258. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45259. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45260. * @param maxCapacity defines the maximum size of each block (64 by default)
  45261. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45262. * @returns the new octree
  45263. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45264. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45265. */
  45266. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45267. }
  45268. }
  45269. /**
  45270. * Defines the octree scene component responsible to manage any octrees
  45271. * in a given scene.
  45272. */
  45273. export class OctreeSceneComponent {
  45274. /**
  45275. * The component name help to identify the component in the list of scene components.
  45276. */
  45277. readonly name: string;
  45278. /**
  45279. * The scene the component belongs to.
  45280. */
  45281. scene: Scene;
  45282. /**
  45283. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45284. */
  45285. readonly checksIsEnabled: boolean;
  45286. /**
  45287. * Creates a new instance of the component for the given scene
  45288. * @param scene Defines the scene to register the component in
  45289. */
  45290. constructor(scene: Scene);
  45291. /**
  45292. * Registers the component in a given scene
  45293. */
  45294. register(): void;
  45295. /**
  45296. * Return the list of active meshes
  45297. * @returns the list of active meshes
  45298. */
  45299. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45300. /**
  45301. * Return the list of active sub meshes
  45302. * @param mesh The mesh to get the candidates sub meshes from
  45303. * @returns the list of active sub meshes
  45304. */
  45305. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45306. private _tempRay;
  45307. /**
  45308. * Return the list of sub meshes intersecting with a given local ray
  45309. * @param mesh defines the mesh to find the submesh for
  45310. * @param localRay defines the ray in local space
  45311. * @returns the list of intersecting sub meshes
  45312. */
  45313. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45314. /**
  45315. * Return the list of sub meshes colliding with a collider
  45316. * @param mesh defines the mesh to find the submesh for
  45317. * @param collider defines the collider to evaluate the collision against
  45318. * @returns the list of colliding sub meshes
  45319. */
  45320. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45321. /**
  45322. * Rebuilds the elements related to this component in case of
  45323. * context lost for instance.
  45324. */
  45325. rebuild(): void;
  45326. /**
  45327. * Disposes the component and the associated ressources.
  45328. */
  45329. dispose(): void;
  45330. }
  45331. }
  45332. declare module "babylonjs/Culling/Octrees/index" {
  45333. export * from "babylonjs/Culling/Octrees/octree";
  45334. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45335. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45336. }
  45337. declare module "babylonjs/Culling/index" {
  45338. export * from "babylonjs/Culling/boundingBox";
  45339. export * from "babylonjs/Culling/boundingInfo";
  45340. export * from "babylonjs/Culling/boundingSphere";
  45341. export * from "babylonjs/Culling/Octrees/index";
  45342. export * from "babylonjs/Culling/ray";
  45343. }
  45344. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45345. import { IDisposable, Scene } from "babylonjs/scene";
  45346. import { Nullable } from "babylonjs/types";
  45347. import { Observable } from "babylonjs/Misc/observable";
  45348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45349. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45350. import { Camera } from "babylonjs/Cameras/camera";
  45351. /**
  45352. * Renders a layer on top of an existing scene
  45353. */
  45354. export class UtilityLayerRenderer implements IDisposable {
  45355. /** the original scene that will be rendered on top of */
  45356. originalScene: Scene;
  45357. private _pointerCaptures;
  45358. private _lastPointerEvents;
  45359. private static _DefaultUtilityLayer;
  45360. private static _DefaultKeepDepthUtilityLayer;
  45361. private _sharedGizmoLight;
  45362. private _renderCamera;
  45363. /**
  45364. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45365. * @returns the camera that is used when rendering the utility layer
  45366. */
  45367. getRenderCamera(): Nullable<Camera>;
  45368. /**
  45369. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45370. * @param cam the camera that should be used when rendering the utility layer
  45371. */
  45372. setRenderCamera(cam: Nullable<Camera>): void;
  45373. /**
  45374. * @hidden
  45375. * Light which used by gizmos to get light shading
  45376. */
  45377. _getSharedGizmoLight(): HemisphericLight;
  45378. /**
  45379. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45380. */
  45381. pickUtilitySceneFirst: boolean;
  45382. /**
  45383. * 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)
  45384. */
  45385. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45386. /**
  45387. * 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)
  45388. */
  45389. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45390. /**
  45391. * The scene that is rendered on top of the original scene
  45392. */
  45393. utilityLayerScene: Scene;
  45394. /**
  45395. * If the utility layer should automatically be rendered on top of existing scene
  45396. */
  45397. shouldRender: boolean;
  45398. /**
  45399. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45400. */
  45401. onlyCheckPointerDownEvents: boolean;
  45402. /**
  45403. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45404. */
  45405. processAllEvents: boolean;
  45406. /**
  45407. * Observable raised when the pointer move from the utility layer scene to the main scene
  45408. */
  45409. onPointerOutObservable: Observable<number>;
  45410. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45411. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45412. private _afterRenderObserver;
  45413. private _sceneDisposeObserver;
  45414. private _originalPointerObserver;
  45415. /**
  45416. * Instantiates a UtilityLayerRenderer
  45417. * @param originalScene the original scene that will be rendered on top of
  45418. * @param handleEvents boolean indicating if the utility layer should handle events
  45419. */
  45420. constructor(
  45421. /** the original scene that will be rendered on top of */
  45422. originalScene: Scene, handleEvents?: boolean);
  45423. private _notifyObservers;
  45424. /**
  45425. * Renders the utility layers scene on top of the original scene
  45426. */
  45427. render(): void;
  45428. /**
  45429. * Disposes of the renderer
  45430. */
  45431. dispose(): void;
  45432. private _updateCamera;
  45433. }
  45434. }
  45435. declare module "babylonjs/Gizmos/gizmo" {
  45436. import { Nullable } from "babylonjs/types";
  45437. import { IDisposable } from "babylonjs/scene";
  45438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45439. import { Mesh } from "babylonjs/Meshes/mesh";
  45440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45441. /**
  45442. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45443. */
  45444. export class Gizmo implements IDisposable {
  45445. /** The utility layer the gizmo will be added to */
  45446. gizmoLayer: UtilityLayerRenderer;
  45447. /**
  45448. * The root mesh of the gizmo
  45449. */
  45450. _rootMesh: Mesh;
  45451. private _attachedMesh;
  45452. /**
  45453. * Ratio for the scale of the gizmo (Default: 1)
  45454. */
  45455. scaleRatio: number;
  45456. /**
  45457. * If a custom mesh has been set (Default: false)
  45458. */
  45459. protected _customMeshSet: boolean;
  45460. /**
  45461. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45462. * * When set, interactions will be enabled
  45463. */
  45464. attachedMesh: Nullable<AbstractMesh>;
  45465. /**
  45466. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45467. * @param mesh The mesh to replace the default mesh of the gizmo
  45468. */
  45469. setCustomMesh(mesh: Mesh): void;
  45470. /**
  45471. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45472. */
  45473. updateGizmoRotationToMatchAttachedMesh: boolean;
  45474. /**
  45475. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45476. */
  45477. updateGizmoPositionToMatchAttachedMesh: boolean;
  45478. /**
  45479. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45480. */
  45481. updateScale: boolean;
  45482. protected _interactionsEnabled: boolean;
  45483. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45484. private _beforeRenderObserver;
  45485. private _tempVector;
  45486. /**
  45487. * Creates a gizmo
  45488. * @param gizmoLayer The utility layer the gizmo will be added to
  45489. */
  45490. constructor(
  45491. /** The utility layer the gizmo will be added to */
  45492. gizmoLayer?: UtilityLayerRenderer);
  45493. /**
  45494. * Updates the gizmo to match the attached mesh's position/rotation
  45495. */
  45496. protected _update(): void;
  45497. /**
  45498. * Disposes of the gizmo
  45499. */
  45500. dispose(): void;
  45501. }
  45502. }
  45503. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45504. import { Observable } from "babylonjs/Misc/observable";
  45505. import { Nullable } from "babylonjs/types";
  45506. import { Vector3 } from "babylonjs/Maths/math.vector";
  45507. import { Color3 } from "babylonjs/Maths/math.color";
  45508. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45510. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45511. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45512. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45513. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45514. import { Scene } from "babylonjs/scene";
  45515. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45516. /**
  45517. * Single plane drag gizmo
  45518. */
  45519. export class PlaneDragGizmo extends Gizmo {
  45520. /**
  45521. * Drag behavior responsible for the gizmos dragging interactions
  45522. */
  45523. dragBehavior: PointerDragBehavior;
  45524. private _pointerObserver;
  45525. /**
  45526. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45527. */
  45528. snapDistance: number;
  45529. /**
  45530. * Event that fires each time the gizmo snaps to a new location.
  45531. * * snapDistance is the the change in distance
  45532. */
  45533. onSnapObservable: Observable<{
  45534. snapDistance: number;
  45535. }>;
  45536. private _plane;
  45537. private _coloredMaterial;
  45538. private _hoverMaterial;
  45539. private _isEnabled;
  45540. private _parent;
  45541. /** @hidden */
  45542. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45543. /** @hidden */
  45544. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45545. /**
  45546. * Creates a PlaneDragGizmo
  45547. * @param gizmoLayer The utility layer the gizmo will be added to
  45548. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45549. * @param color The color of the gizmo
  45550. */
  45551. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45552. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45553. /**
  45554. * If the gizmo is enabled
  45555. */
  45556. isEnabled: boolean;
  45557. /**
  45558. * Disposes of the gizmo
  45559. */
  45560. dispose(): void;
  45561. }
  45562. }
  45563. declare module "babylonjs/Gizmos/positionGizmo" {
  45564. import { Observable } from "babylonjs/Misc/observable";
  45565. import { Nullable } from "babylonjs/types";
  45566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45567. import { Mesh } from "babylonjs/Meshes/mesh";
  45568. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45569. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45570. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45571. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45572. /**
  45573. * Gizmo that enables dragging a mesh along 3 axis
  45574. */
  45575. export class PositionGizmo extends Gizmo {
  45576. /**
  45577. * Internal gizmo used for interactions on the x axis
  45578. */
  45579. xGizmo: AxisDragGizmo;
  45580. /**
  45581. * Internal gizmo used for interactions on the y axis
  45582. */
  45583. yGizmo: AxisDragGizmo;
  45584. /**
  45585. * Internal gizmo used for interactions on the z axis
  45586. */
  45587. zGizmo: AxisDragGizmo;
  45588. /**
  45589. * Internal gizmo used for interactions on the yz plane
  45590. */
  45591. xPlaneGizmo: PlaneDragGizmo;
  45592. /**
  45593. * Internal gizmo used for interactions on the xz plane
  45594. */
  45595. yPlaneGizmo: PlaneDragGizmo;
  45596. /**
  45597. * Internal gizmo used for interactions on the xy plane
  45598. */
  45599. zPlaneGizmo: PlaneDragGizmo;
  45600. /**
  45601. * private variables
  45602. */
  45603. private _meshAttached;
  45604. private _updateGizmoRotationToMatchAttachedMesh;
  45605. private _snapDistance;
  45606. private _scaleRatio;
  45607. /** Fires an event when any of it's sub gizmos are dragged */
  45608. onDragStartObservable: Observable<unknown>;
  45609. /** Fires an event when any of it's sub gizmos are released from dragging */
  45610. onDragEndObservable: Observable<unknown>;
  45611. /**
  45612. * If set to true, planar drag is enabled
  45613. */
  45614. private _planarGizmoEnabled;
  45615. attachedMesh: Nullable<AbstractMesh>;
  45616. /**
  45617. * Creates a PositionGizmo
  45618. * @param gizmoLayer The utility layer the gizmo will be added to
  45619. */
  45620. constructor(gizmoLayer?: UtilityLayerRenderer);
  45621. /**
  45622. * If the planar drag gizmo is enabled
  45623. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45624. */
  45625. planarGizmoEnabled: boolean;
  45626. updateGizmoRotationToMatchAttachedMesh: boolean;
  45627. /**
  45628. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45629. */
  45630. snapDistance: number;
  45631. /**
  45632. * Ratio for the scale of the gizmo (Default: 1)
  45633. */
  45634. scaleRatio: number;
  45635. /**
  45636. * Disposes of the gizmo
  45637. */
  45638. dispose(): void;
  45639. /**
  45640. * CustomMeshes are not supported by this gizmo
  45641. * @param mesh The mesh to replace the default mesh of the gizmo
  45642. */
  45643. setCustomMesh(mesh: Mesh): void;
  45644. }
  45645. }
  45646. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45647. import { Observable } from "babylonjs/Misc/observable";
  45648. import { Nullable } from "babylonjs/types";
  45649. import { Vector3 } from "babylonjs/Maths/math.vector";
  45650. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45652. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45653. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45654. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45655. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45656. import { Scene } from "babylonjs/scene";
  45657. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45658. import { Color3 } from "babylonjs/Maths/math.color";
  45659. /**
  45660. * Single axis drag gizmo
  45661. */
  45662. export class AxisDragGizmo extends Gizmo {
  45663. /**
  45664. * Drag behavior responsible for the gizmos dragging interactions
  45665. */
  45666. dragBehavior: PointerDragBehavior;
  45667. private _pointerObserver;
  45668. /**
  45669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45670. */
  45671. snapDistance: number;
  45672. /**
  45673. * Event that fires each time the gizmo snaps to a new location.
  45674. * * snapDistance is the the change in distance
  45675. */
  45676. onSnapObservable: Observable<{
  45677. snapDistance: number;
  45678. }>;
  45679. private _isEnabled;
  45680. private _parent;
  45681. private _arrow;
  45682. private _coloredMaterial;
  45683. private _hoverMaterial;
  45684. /** @hidden */
  45685. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45686. /** @hidden */
  45687. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45688. /**
  45689. * Creates an AxisDragGizmo
  45690. * @param gizmoLayer The utility layer the gizmo will be added to
  45691. * @param dragAxis The axis which the gizmo will be able to drag on
  45692. * @param color The color of the gizmo
  45693. */
  45694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45696. /**
  45697. * If the gizmo is enabled
  45698. */
  45699. isEnabled: boolean;
  45700. /**
  45701. * Disposes of the gizmo
  45702. */
  45703. dispose(): void;
  45704. }
  45705. }
  45706. declare module "babylonjs/Debug/axesViewer" {
  45707. import { Vector3 } from "babylonjs/Maths/math.vector";
  45708. import { Nullable } from "babylonjs/types";
  45709. import { Scene } from "babylonjs/scene";
  45710. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45711. /**
  45712. * The Axes viewer will show 3 axes in a specific point in space
  45713. */
  45714. export class AxesViewer {
  45715. private _xAxis;
  45716. private _yAxis;
  45717. private _zAxis;
  45718. private _scaleLinesFactor;
  45719. private _instanced;
  45720. /**
  45721. * Gets the hosting scene
  45722. */
  45723. scene: Scene;
  45724. /**
  45725. * Gets or sets a number used to scale line length
  45726. */
  45727. scaleLines: number;
  45728. /** Gets the node hierarchy used to render x-axis */
  45729. readonly xAxis: TransformNode;
  45730. /** Gets the node hierarchy used to render y-axis */
  45731. readonly yAxis: TransformNode;
  45732. /** Gets the node hierarchy used to render z-axis */
  45733. readonly zAxis: TransformNode;
  45734. /**
  45735. * Creates a new AxesViewer
  45736. * @param scene defines the hosting scene
  45737. * @param scaleLines defines a number used to scale line length (1 by default)
  45738. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45739. * @param xAxis defines the node hierarchy used to render the x-axis
  45740. * @param yAxis defines the node hierarchy used to render the y-axis
  45741. * @param zAxis defines the node hierarchy used to render the z-axis
  45742. */
  45743. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45744. /**
  45745. * Force the viewer to update
  45746. * @param position defines the position of the viewer
  45747. * @param xaxis defines the x axis of the viewer
  45748. * @param yaxis defines the y axis of the viewer
  45749. * @param zaxis defines the z axis of the viewer
  45750. */
  45751. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45752. /**
  45753. * Creates an instance of this axes viewer.
  45754. * @returns a new axes viewer with instanced meshes
  45755. */
  45756. createInstance(): AxesViewer;
  45757. /** Releases resources */
  45758. dispose(): void;
  45759. private static _SetRenderingGroupId;
  45760. }
  45761. }
  45762. declare module "babylonjs/Debug/boneAxesViewer" {
  45763. import { Nullable } from "babylonjs/types";
  45764. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45765. import { Vector3 } from "babylonjs/Maths/math.vector";
  45766. import { Mesh } from "babylonjs/Meshes/mesh";
  45767. import { Bone } from "babylonjs/Bones/bone";
  45768. import { Scene } from "babylonjs/scene";
  45769. /**
  45770. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45771. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45772. */
  45773. export class BoneAxesViewer extends AxesViewer {
  45774. /**
  45775. * Gets or sets the target mesh where to display the axes viewer
  45776. */
  45777. mesh: Nullable<Mesh>;
  45778. /**
  45779. * Gets or sets the target bone where to display the axes viewer
  45780. */
  45781. bone: Nullable<Bone>;
  45782. /** Gets current position */
  45783. pos: Vector3;
  45784. /** Gets direction of X axis */
  45785. xaxis: Vector3;
  45786. /** Gets direction of Y axis */
  45787. yaxis: Vector3;
  45788. /** Gets direction of Z axis */
  45789. zaxis: Vector3;
  45790. /**
  45791. * Creates a new BoneAxesViewer
  45792. * @param scene defines the hosting scene
  45793. * @param bone defines the target bone
  45794. * @param mesh defines the target mesh
  45795. * @param scaleLines defines a scaling factor for line length (1 by default)
  45796. */
  45797. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45798. /**
  45799. * Force the viewer to update
  45800. */
  45801. update(): void;
  45802. /** Releases resources */
  45803. dispose(): void;
  45804. }
  45805. }
  45806. declare module "babylonjs/Debug/debugLayer" {
  45807. import { Scene } from "babylonjs/scene";
  45808. /**
  45809. * Interface used to define scene explorer extensibility option
  45810. */
  45811. export interface IExplorerExtensibilityOption {
  45812. /**
  45813. * Define the option label
  45814. */
  45815. label: string;
  45816. /**
  45817. * Defines the action to execute on click
  45818. */
  45819. action: (entity: any) => void;
  45820. }
  45821. /**
  45822. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45823. */
  45824. export interface IExplorerExtensibilityGroup {
  45825. /**
  45826. * Defines a predicate to test if a given type mut be extended
  45827. */
  45828. predicate: (entity: any) => boolean;
  45829. /**
  45830. * Gets the list of options added to a type
  45831. */
  45832. entries: IExplorerExtensibilityOption[];
  45833. }
  45834. /**
  45835. * Interface used to define the options to use to create the Inspector
  45836. */
  45837. export interface IInspectorOptions {
  45838. /**
  45839. * Display in overlay mode (default: false)
  45840. */
  45841. overlay?: boolean;
  45842. /**
  45843. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45844. */
  45845. globalRoot?: HTMLElement;
  45846. /**
  45847. * Display the Scene explorer
  45848. */
  45849. showExplorer?: boolean;
  45850. /**
  45851. * Display the property inspector
  45852. */
  45853. showInspector?: boolean;
  45854. /**
  45855. * Display in embed mode (both panes on the right)
  45856. */
  45857. embedMode?: boolean;
  45858. /**
  45859. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45860. */
  45861. handleResize?: boolean;
  45862. /**
  45863. * Allow the panes to popup (default: true)
  45864. */
  45865. enablePopup?: boolean;
  45866. /**
  45867. * Allow the panes to be closed by users (default: true)
  45868. */
  45869. enableClose?: boolean;
  45870. /**
  45871. * Optional list of extensibility entries
  45872. */
  45873. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45874. /**
  45875. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45876. */
  45877. inspectorURL?: string;
  45878. }
  45879. module "babylonjs/scene" {
  45880. interface Scene {
  45881. /**
  45882. * @hidden
  45883. * Backing field
  45884. */
  45885. _debugLayer: DebugLayer;
  45886. /**
  45887. * Gets the debug layer (aka Inspector) associated with the scene
  45888. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45889. */
  45890. debugLayer: DebugLayer;
  45891. }
  45892. }
  45893. /**
  45894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45895. * what is happening in your scene
  45896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45897. */
  45898. export class DebugLayer {
  45899. /**
  45900. * Define the url to get the inspector script from.
  45901. * By default it uses the babylonjs CDN.
  45902. * @ignoreNaming
  45903. */
  45904. static InspectorURL: string;
  45905. private _scene;
  45906. private BJSINSPECTOR;
  45907. private _onPropertyChangedObservable?;
  45908. /**
  45909. * Observable triggered when a property is changed through the inspector.
  45910. */
  45911. readonly onPropertyChangedObservable: any;
  45912. /**
  45913. * Instantiates a new debug layer.
  45914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45915. * what is happening in your scene
  45916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45917. * @param scene Defines the scene to inspect
  45918. */
  45919. constructor(scene: Scene);
  45920. /** Creates the inspector window. */
  45921. private _createInspector;
  45922. /**
  45923. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45924. * @param entity defines the entity to select
  45925. * @param lineContainerTitle defines the specific block to highlight
  45926. */
  45927. select(entity: any, lineContainerTitle?: string): void;
  45928. /** Get the inspector from bundle or global */
  45929. private _getGlobalInspector;
  45930. /**
  45931. * Get if the inspector is visible or not.
  45932. * @returns true if visible otherwise, false
  45933. */
  45934. isVisible(): boolean;
  45935. /**
  45936. * Hide the inspector and close its window.
  45937. */
  45938. hide(): void;
  45939. /**
  45940. * Launch the debugLayer.
  45941. * @param config Define the configuration of the inspector
  45942. * @return a promise fulfilled when the debug layer is visible
  45943. */
  45944. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45945. }
  45946. }
  45947. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45948. import { Nullable } from "babylonjs/types";
  45949. import { Scene } from "babylonjs/scene";
  45950. import { Vector4 } from "babylonjs/Maths/math.vector";
  45951. import { Color4 } from "babylonjs/Maths/math.color";
  45952. import { Mesh } from "babylonjs/Meshes/mesh";
  45953. /**
  45954. * Class containing static functions to help procedurally build meshes
  45955. */
  45956. export class BoxBuilder {
  45957. /**
  45958. * Creates a box mesh
  45959. * * The parameter `size` sets the size (float) of each box side (default 1)
  45960. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45961. * * 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)
  45962. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45966. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45967. * @param name defines the name of the mesh
  45968. * @param options defines the options used to create the mesh
  45969. * @param scene defines the hosting scene
  45970. * @returns the box mesh
  45971. */
  45972. static CreateBox(name: string, options: {
  45973. size?: number;
  45974. width?: number;
  45975. height?: number;
  45976. depth?: number;
  45977. faceUV?: Vector4[];
  45978. faceColors?: Color4[];
  45979. sideOrientation?: number;
  45980. frontUVs?: Vector4;
  45981. backUVs?: Vector4;
  45982. wrap?: boolean;
  45983. topBaseAt?: number;
  45984. bottomBaseAt?: number;
  45985. updatable?: boolean;
  45986. }, scene?: Nullable<Scene>): Mesh;
  45987. }
  45988. }
  45989. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45990. import { Vector4 } from "babylonjs/Maths/math.vector";
  45991. import { Mesh } from "babylonjs/Meshes/mesh";
  45992. import { Scene } from "babylonjs/scene";
  45993. import { Nullable } from "babylonjs/types";
  45994. /**
  45995. * Class containing static functions to help procedurally build meshes
  45996. */
  45997. export class SphereBuilder {
  45998. /**
  45999. * Creates a sphere mesh
  46000. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46001. * * 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`)
  46002. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46003. * * 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
  46004. * * 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)
  46005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46008. * @param name defines the name of the mesh
  46009. * @param options defines the options used to create the mesh
  46010. * @param scene defines the hosting scene
  46011. * @returns the sphere mesh
  46012. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46013. */
  46014. static CreateSphere(name: string, options: {
  46015. segments?: number;
  46016. diameter?: number;
  46017. diameterX?: number;
  46018. diameterY?: number;
  46019. diameterZ?: number;
  46020. arc?: number;
  46021. slice?: number;
  46022. sideOrientation?: number;
  46023. frontUVs?: Vector4;
  46024. backUVs?: Vector4;
  46025. updatable?: boolean;
  46026. }, scene?: Nullable<Scene>): Mesh;
  46027. }
  46028. }
  46029. declare module "babylonjs/Debug/physicsViewer" {
  46030. import { Nullable } from "babylonjs/types";
  46031. import { Scene } from "babylonjs/scene";
  46032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46033. import { Mesh } from "babylonjs/Meshes/mesh";
  46034. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46035. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46036. /**
  46037. * Used to show the physics impostor around the specific mesh
  46038. */
  46039. export class PhysicsViewer {
  46040. /** @hidden */
  46041. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46042. /** @hidden */
  46043. protected _meshes: Array<Nullable<AbstractMesh>>;
  46044. /** @hidden */
  46045. protected _scene: Nullable<Scene>;
  46046. /** @hidden */
  46047. protected _numMeshes: number;
  46048. /** @hidden */
  46049. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46050. private _renderFunction;
  46051. private _utilityLayer;
  46052. private _debugBoxMesh;
  46053. private _debugSphereMesh;
  46054. private _debugCylinderMesh;
  46055. private _debugMaterial;
  46056. private _debugMeshMeshes;
  46057. /**
  46058. * Creates a new PhysicsViewer
  46059. * @param scene defines the hosting scene
  46060. */
  46061. constructor(scene: Scene);
  46062. /** @hidden */
  46063. protected _updateDebugMeshes(): void;
  46064. /**
  46065. * Renders a specified physic impostor
  46066. * @param impostor defines the impostor to render
  46067. * @param targetMesh defines the mesh represented by the impostor
  46068. * @returns the new debug mesh used to render the impostor
  46069. */
  46070. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46071. /**
  46072. * Hides a specified physic impostor
  46073. * @param impostor defines the impostor to hide
  46074. */
  46075. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46076. private _getDebugMaterial;
  46077. private _getDebugBoxMesh;
  46078. private _getDebugSphereMesh;
  46079. private _getDebugCylinderMesh;
  46080. private _getDebugMeshMesh;
  46081. private _getDebugMesh;
  46082. /** Releases all resources */
  46083. dispose(): void;
  46084. }
  46085. }
  46086. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46087. import { Vector3 } from "babylonjs/Maths/math.vector";
  46088. import { Color4 } from "babylonjs/Maths/math.color";
  46089. import { Nullable } from "babylonjs/types";
  46090. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46091. import { Scene } from "babylonjs/scene";
  46092. /**
  46093. * Class containing static functions to help procedurally build meshes
  46094. */
  46095. export class LinesBuilder {
  46096. /**
  46097. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46098. * * 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
  46099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46100. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46101. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46102. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46104. * * 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
  46105. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46108. * @param name defines the name of the new line system
  46109. * @param options defines the options used to create the line system
  46110. * @param scene defines the hosting scene
  46111. * @returns a new line system mesh
  46112. */
  46113. static CreateLineSystem(name: string, options: {
  46114. lines: Vector3[][];
  46115. updatable?: boolean;
  46116. instance?: Nullable<LinesMesh>;
  46117. colors?: Nullable<Color4[][]>;
  46118. useVertexAlpha?: boolean;
  46119. }, scene: Nullable<Scene>): LinesMesh;
  46120. /**
  46121. * Creates a line mesh
  46122. * 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
  46123. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46124. * * The parameter `points` is an array successive Vector3
  46125. * * 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
  46126. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46127. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46128. * * When updating an instance, remember that only point positions can change, not the number of points
  46129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46131. * @param name defines the name of the new line system
  46132. * @param options defines the options used to create the line system
  46133. * @param scene defines the hosting scene
  46134. * @returns a new line mesh
  46135. */
  46136. static CreateLines(name: string, options: {
  46137. points: Vector3[];
  46138. updatable?: boolean;
  46139. instance?: Nullable<LinesMesh>;
  46140. colors?: Color4[];
  46141. useVertexAlpha?: boolean;
  46142. }, scene?: Nullable<Scene>): LinesMesh;
  46143. /**
  46144. * Creates a dashed line mesh
  46145. * * 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
  46146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46147. * * The parameter `points` is an array successive Vector3
  46148. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46149. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46150. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46151. * * 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
  46152. * * When updating an instance, remember that only point positions can change, not the number of points
  46153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46154. * @param name defines the name of the mesh
  46155. * @param options defines the options used to create the mesh
  46156. * @param scene defines the hosting scene
  46157. * @returns the dashed line mesh
  46158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46159. */
  46160. static CreateDashedLines(name: string, options: {
  46161. points: Vector3[];
  46162. dashSize?: number;
  46163. gapSize?: number;
  46164. dashNb?: number;
  46165. updatable?: boolean;
  46166. instance?: LinesMesh;
  46167. }, scene?: Nullable<Scene>): LinesMesh;
  46168. }
  46169. }
  46170. declare module "babylonjs/Debug/rayHelper" {
  46171. import { Nullable } from "babylonjs/types";
  46172. import { Ray } from "babylonjs/Culling/ray";
  46173. import { Vector3 } from "babylonjs/Maths/math.vector";
  46174. import { Color3 } from "babylonjs/Maths/math.color";
  46175. import { Scene } from "babylonjs/scene";
  46176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46177. import "babylonjs/Meshes/Builders/linesBuilder";
  46178. /**
  46179. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46180. * in order to better appreciate the issue one might have.
  46181. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46182. */
  46183. export class RayHelper {
  46184. /**
  46185. * Defines the ray we are currently tryin to visualize.
  46186. */
  46187. ray: Nullable<Ray>;
  46188. private _renderPoints;
  46189. private _renderLine;
  46190. private _renderFunction;
  46191. private _scene;
  46192. private _updateToMeshFunction;
  46193. private _attachedToMesh;
  46194. private _meshSpaceDirection;
  46195. private _meshSpaceOrigin;
  46196. /**
  46197. * Helper function to create a colored helper in a scene in one line.
  46198. * @param ray Defines the ray we are currently tryin to visualize
  46199. * @param scene Defines the scene the ray is used in
  46200. * @param color Defines the color we want to see the ray in
  46201. * @returns The newly created ray helper.
  46202. */
  46203. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46204. /**
  46205. * Instantiate a new ray helper.
  46206. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46207. * in order to better appreciate the issue one might have.
  46208. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46209. * @param ray Defines the ray we are currently tryin to visualize
  46210. */
  46211. constructor(ray: Ray);
  46212. /**
  46213. * Shows the ray we are willing to debug.
  46214. * @param scene Defines the scene the ray needs to be rendered in
  46215. * @param color Defines the color the ray needs to be rendered in
  46216. */
  46217. show(scene: Scene, color?: Color3): void;
  46218. /**
  46219. * Hides the ray we are debugging.
  46220. */
  46221. hide(): void;
  46222. private _render;
  46223. /**
  46224. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46225. * @param mesh Defines the mesh we want the helper attached to
  46226. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46227. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46228. * @param length Defines the length of the ray
  46229. */
  46230. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46231. /**
  46232. * Detach the ray helper from the mesh it has previously been attached to.
  46233. */
  46234. detachFromMesh(): void;
  46235. private _updateToMesh;
  46236. /**
  46237. * Dispose the helper and release its associated resources.
  46238. */
  46239. dispose(): void;
  46240. }
  46241. }
  46242. declare module "babylonjs/Debug/skeletonViewer" {
  46243. import { Color3 } from "babylonjs/Maths/math.color";
  46244. import { Scene } from "babylonjs/scene";
  46245. import { Nullable } from "babylonjs/types";
  46246. import { Skeleton } from "babylonjs/Bones/skeleton";
  46247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46248. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46249. /**
  46250. * Class used to render a debug view of a given skeleton
  46251. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46252. */
  46253. export class SkeletonViewer {
  46254. /** defines the skeleton to render */
  46255. skeleton: Skeleton;
  46256. /** defines the mesh attached to the skeleton */
  46257. mesh: AbstractMesh;
  46258. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46259. autoUpdateBonesMatrices: boolean;
  46260. /** defines the rendering group id to use with the viewer */
  46261. renderingGroupId: number;
  46262. /** Gets or sets the color used to render the skeleton */
  46263. color: Color3;
  46264. private _scene;
  46265. private _debugLines;
  46266. private _debugMesh;
  46267. private _isEnabled;
  46268. private _renderFunction;
  46269. private _utilityLayer;
  46270. /**
  46271. * Returns the mesh used to render the bones
  46272. */
  46273. readonly debugMesh: Nullable<LinesMesh>;
  46274. /**
  46275. * Creates a new SkeletonViewer
  46276. * @param skeleton defines the skeleton to render
  46277. * @param mesh defines the mesh attached to the skeleton
  46278. * @param scene defines the hosting scene
  46279. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46280. * @param renderingGroupId defines the rendering group id to use with the viewer
  46281. */
  46282. constructor(
  46283. /** defines the skeleton to render */
  46284. skeleton: Skeleton,
  46285. /** defines the mesh attached to the skeleton */
  46286. mesh: AbstractMesh, scene: Scene,
  46287. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46288. autoUpdateBonesMatrices?: boolean,
  46289. /** defines the rendering group id to use with the viewer */
  46290. renderingGroupId?: number);
  46291. /** Gets or sets a boolean indicating if the viewer is enabled */
  46292. isEnabled: boolean;
  46293. private _getBonePosition;
  46294. private _getLinesForBonesWithLength;
  46295. private _getLinesForBonesNoLength;
  46296. /** Update the viewer to sync with current skeleton state */
  46297. update(): void;
  46298. /** Release associated resources */
  46299. dispose(): void;
  46300. }
  46301. }
  46302. declare module "babylonjs/Debug/index" {
  46303. export * from "babylonjs/Debug/axesViewer";
  46304. export * from "babylonjs/Debug/boneAxesViewer";
  46305. export * from "babylonjs/Debug/debugLayer";
  46306. export * from "babylonjs/Debug/physicsViewer";
  46307. export * from "babylonjs/Debug/rayHelper";
  46308. export * from "babylonjs/Debug/skeletonViewer";
  46309. }
  46310. declare module "babylonjs/Engines/nullEngine" {
  46311. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46312. import { Scene } from "babylonjs/scene";
  46313. import { Engine } from "babylonjs/Engines/engine";
  46314. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46315. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46317. import { Effect } from "babylonjs/Materials/effect";
  46318. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46319. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46320. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46321. /**
  46322. * Options to create the null engine
  46323. */
  46324. export class NullEngineOptions {
  46325. /**
  46326. * Render width (Default: 512)
  46327. */
  46328. renderWidth: number;
  46329. /**
  46330. * Render height (Default: 256)
  46331. */
  46332. renderHeight: number;
  46333. /**
  46334. * Texture size (Default: 512)
  46335. */
  46336. textureSize: number;
  46337. /**
  46338. * If delta time between frames should be constant
  46339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46340. */
  46341. deterministicLockstep: boolean;
  46342. /**
  46343. * Maximum about of steps between frames (Default: 4)
  46344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46345. */
  46346. lockstepMaxSteps: number;
  46347. }
  46348. /**
  46349. * The null engine class provides support for headless version of babylon.js.
  46350. * This can be used in server side scenario or for testing purposes
  46351. */
  46352. export class NullEngine extends Engine {
  46353. private _options;
  46354. /**
  46355. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46357. * @returns true if engine is in deterministic lock step mode
  46358. */
  46359. isDeterministicLockStep(): boolean;
  46360. /**
  46361. * Gets the max steps when engine is running in deterministic lock step
  46362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46363. * @returns the max steps
  46364. */
  46365. getLockstepMaxSteps(): number;
  46366. /**
  46367. * Gets the current hardware scaling level.
  46368. * By default the hardware scaling level is computed from the window device ratio.
  46369. * 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.
  46370. * @returns a number indicating the current hardware scaling level
  46371. */
  46372. getHardwareScalingLevel(): number;
  46373. constructor(options?: NullEngineOptions);
  46374. /**
  46375. * Creates a vertex buffer
  46376. * @param vertices the data for the vertex buffer
  46377. * @returns the new WebGL static buffer
  46378. */
  46379. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46380. /**
  46381. * Creates a new index buffer
  46382. * @param indices defines the content of the index buffer
  46383. * @param updatable defines if the index buffer must be updatable
  46384. * @returns a new webGL buffer
  46385. */
  46386. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46387. /**
  46388. * Clear the current render buffer or the current render target (if any is set up)
  46389. * @param color defines the color to use
  46390. * @param backBuffer defines if the back buffer must be cleared
  46391. * @param depth defines if the depth buffer must be cleared
  46392. * @param stencil defines if the stencil buffer must be cleared
  46393. */
  46394. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46395. /**
  46396. * Gets the current render width
  46397. * @param useScreen defines if screen size must be used (or the current render target if any)
  46398. * @returns a number defining the current render width
  46399. */
  46400. getRenderWidth(useScreen?: boolean): number;
  46401. /**
  46402. * Gets the current render height
  46403. * @param useScreen defines if screen size must be used (or the current render target if any)
  46404. * @returns a number defining the current render height
  46405. */
  46406. getRenderHeight(useScreen?: boolean): number;
  46407. /**
  46408. * Set the WebGL's viewport
  46409. * @param viewport defines the viewport element to be used
  46410. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46411. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46412. */
  46413. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46415. /**
  46416. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46417. * @param pipelineContext defines the pipeline context to use
  46418. * @param uniformsNames defines the list of uniform names
  46419. * @returns an array of webGL uniform locations
  46420. */
  46421. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46422. /**
  46423. * Gets the lsit of active attributes for a given webGL program
  46424. * @param pipelineContext defines the pipeline context to use
  46425. * @param attributesNames defines the list of attribute names to get
  46426. * @returns an array of indices indicating the offset of each attribute
  46427. */
  46428. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46429. /**
  46430. * Binds an effect to the webGL context
  46431. * @param effect defines the effect to bind
  46432. */
  46433. bindSamplers(effect: Effect): void;
  46434. /**
  46435. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46436. * @param effect defines the effect to activate
  46437. */
  46438. enableEffect(effect: Effect): void;
  46439. /**
  46440. * Set various states to the webGL context
  46441. * @param culling defines backface culling state
  46442. * @param zOffset defines the value to apply to zOffset (0 by default)
  46443. * @param force defines if states must be applied even if cache is up to date
  46444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46445. */
  46446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46447. /**
  46448. * Set the value of an uniform to an array of int32
  46449. * @param uniform defines the webGL uniform location where to store the value
  46450. * @param array defines the array of int32 to store
  46451. */
  46452. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46453. /**
  46454. * Set the value of an uniform to an array of int32 (stored as vec2)
  46455. * @param uniform defines the webGL uniform location where to store the value
  46456. * @param array defines the array of int32 to store
  46457. */
  46458. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46459. /**
  46460. * Set the value of an uniform to an array of int32 (stored as vec3)
  46461. * @param uniform defines the webGL uniform location where to store the value
  46462. * @param array defines the array of int32 to store
  46463. */
  46464. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46465. /**
  46466. * Set the value of an uniform to an array of int32 (stored as vec4)
  46467. * @param uniform defines the webGL uniform location where to store the value
  46468. * @param array defines the array of int32 to store
  46469. */
  46470. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46471. /**
  46472. * Set the value of an uniform to an array of float32
  46473. * @param uniform defines the webGL uniform location where to store the value
  46474. * @param array defines the array of float32 to store
  46475. */
  46476. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46477. /**
  46478. * Set the value of an uniform to an array of float32 (stored as vec2)
  46479. * @param uniform defines the webGL uniform location where to store the value
  46480. * @param array defines the array of float32 to store
  46481. */
  46482. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46483. /**
  46484. * Set the value of an uniform to an array of float32 (stored as vec3)
  46485. * @param uniform defines the webGL uniform location where to store the value
  46486. * @param array defines the array of float32 to store
  46487. */
  46488. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46489. /**
  46490. * Set the value of an uniform to an array of float32 (stored as vec4)
  46491. * @param uniform defines the webGL uniform location where to store the value
  46492. * @param array defines the array of float32 to store
  46493. */
  46494. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46495. /**
  46496. * Set the value of an uniform to an array of number
  46497. * @param uniform defines the webGL uniform location where to store the value
  46498. * @param array defines the array of number to store
  46499. */
  46500. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46501. /**
  46502. * Set the value of an uniform to an array of number (stored as vec2)
  46503. * @param uniform defines the webGL uniform location where to store the value
  46504. * @param array defines the array of number to store
  46505. */
  46506. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46507. /**
  46508. * Set the value of an uniform to an array of number (stored as vec3)
  46509. * @param uniform defines the webGL uniform location where to store the value
  46510. * @param array defines the array of number to store
  46511. */
  46512. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46513. /**
  46514. * Set the value of an uniform to an array of number (stored as vec4)
  46515. * @param uniform defines the webGL uniform location where to store the value
  46516. * @param array defines the array of number to store
  46517. */
  46518. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46519. /**
  46520. * Set the value of an uniform to an array of float32 (stored as matrices)
  46521. * @param uniform defines the webGL uniform location where to store the value
  46522. * @param matrices defines the array of float32 to store
  46523. */
  46524. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46525. /**
  46526. * Set the value of an uniform to a matrix (3x3)
  46527. * @param uniform defines the webGL uniform location where to store the value
  46528. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46529. */
  46530. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46531. /**
  46532. * Set the value of an uniform to a matrix (2x2)
  46533. * @param uniform defines the webGL uniform location where to store the value
  46534. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46535. */
  46536. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46537. /**
  46538. * Set the value of an uniform to a number (float)
  46539. * @param uniform defines the webGL uniform location where to store the value
  46540. * @param value defines the float number to store
  46541. */
  46542. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46543. /**
  46544. * Set the value of an uniform to a vec2
  46545. * @param uniform defines the webGL uniform location where to store the value
  46546. * @param x defines the 1st component of the value
  46547. * @param y defines the 2nd component of the value
  46548. */
  46549. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46550. /**
  46551. * Set the value of an uniform to a vec3
  46552. * @param uniform defines the webGL uniform location where to store the value
  46553. * @param x defines the 1st component of the value
  46554. * @param y defines the 2nd component of the value
  46555. * @param z defines the 3rd component of the value
  46556. */
  46557. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46558. /**
  46559. * Set the value of an uniform to a boolean
  46560. * @param uniform defines the webGL uniform location where to store the value
  46561. * @param bool defines the boolean to store
  46562. */
  46563. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46564. /**
  46565. * Set the value of an uniform to a vec4
  46566. * @param uniform defines the webGL uniform location where to store the value
  46567. * @param x defines the 1st component of the value
  46568. * @param y defines the 2nd component of the value
  46569. * @param z defines the 3rd component of the value
  46570. * @param w defines the 4th component of the value
  46571. */
  46572. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46573. /**
  46574. * Sets the current alpha mode
  46575. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46576. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46578. */
  46579. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46580. /**
  46581. * Bind webGl buffers directly to the webGL context
  46582. * @param vertexBuffers defines the vertex buffer to bind
  46583. * @param indexBuffer defines the index buffer to bind
  46584. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46585. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46586. * @param effect defines the effect associated with the vertex buffer
  46587. */
  46588. bindBuffers(vertexBuffers: {
  46589. [key: string]: VertexBuffer;
  46590. }, indexBuffer: DataBuffer, effect: Effect): void;
  46591. /**
  46592. * Force the entire cache to be cleared
  46593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46595. */
  46596. wipeCaches(bruteForce?: boolean): void;
  46597. /**
  46598. * Send a draw order
  46599. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46600. * @param indexStart defines the starting index
  46601. * @param indexCount defines the number of index to draw
  46602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46603. */
  46604. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46605. /**
  46606. * Draw a list of indexed primitives
  46607. * @param fillMode defines the primitive to use
  46608. * @param indexStart defines the starting index
  46609. * @param indexCount defines the number of index to draw
  46610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46611. */
  46612. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46613. /**
  46614. * Draw a list of unindexed primitives
  46615. * @param fillMode defines the primitive to use
  46616. * @param verticesStart defines the index of first vertex to draw
  46617. * @param verticesCount defines the count of vertices to draw
  46618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46619. */
  46620. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46621. /** @hidden */
  46622. _createTexture(): WebGLTexture;
  46623. /** @hidden */
  46624. _releaseTexture(texture: InternalTexture): void;
  46625. /**
  46626. * Usually called from Texture.ts.
  46627. * Passed information to create a WebGLTexture
  46628. * @param urlArg defines a value which contains one of the following:
  46629. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46630. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46631. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46633. * @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)
  46634. * @param scene needed for loading to the correct scene
  46635. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46636. * @param onLoad optional callback to be called upon successful completion
  46637. * @param onError optional callback to be called upon failure
  46638. * @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
  46639. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46640. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46641. * @param forcedExtension defines the extension to use to pick the right loader
  46642. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46643. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46644. */
  46645. 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;
  46646. /**
  46647. * Creates a new render target texture
  46648. * @param size defines the size of the texture
  46649. * @param options defines the options used to create the texture
  46650. * @returns a new render target texture stored in an InternalTexture
  46651. */
  46652. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46653. /**
  46654. * Update the sampling mode of a given texture
  46655. * @param samplingMode defines the required sampling mode
  46656. * @param texture defines the texture to update
  46657. */
  46658. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46659. /**
  46660. * Binds the frame buffer to the specified texture.
  46661. * @param texture The texture to render to or null for the default canvas
  46662. * @param faceIndex The face of the texture to render to in case of cube texture
  46663. * @param requiredWidth The width of the target to render to
  46664. * @param requiredHeight The height of the target to render to
  46665. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46666. * @param depthStencilTexture The depth stencil texture to use to render
  46667. * @param lodLevel defines le lod level to bind to the frame buffer
  46668. */
  46669. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46670. /**
  46671. * Unbind the current render target texture from the webGL context
  46672. * @param texture defines the render target texture to unbind
  46673. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46674. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46675. */
  46676. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46677. /**
  46678. * Creates a dynamic vertex buffer
  46679. * @param vertices the data for the dynamic vertex buffer
  46680. * @returns the new WebGL dynamic buffer
  46681. */
  46682. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46683. /**
  46684. * Update the content of a dynamic texture
  46685. * @param texture defines the texture to update
  46686. * @param canvas defines the canvas containing the source
  46687. * @param invertY defines if data must be stored with Y axis inverted
  46688. * @param premulAlpha defines if alpha is stored as premultiplied
  46689. * @param format defines the format of the data
  46690. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46691. */
  46692. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46693. /**
  46694. * Gets a boolean indicating if all created effects are ready
  46695. * @returns true if all effects are ready
  46696. */
  46697. areAllEffectsReady(): boolean;
  46698. /**
  46699. * @hidden
  46700. * Get the current error code of the webGL context
  46701. * @returns the error code
  46702. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46703. */
  46704. getError(): number;
  46705. /** @hidden */
  46706. _getUnpackAlignement(): number;
  46707. /** @hidden */
  46708. _unpackFlipY(value: boolean): void;
  46709. /**
  46710. * Update a dynamic index buffer
  46711. * @param indexBuffer defines the target index buffer
  46712. * @param indices defines the data to update
  46713. * @param offset defines the offset in the target index buffer where update should start
  46714. */
  46715. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46716. /**
  46717. * Updates a dynamic vertex buffer.
  46718. * @param vertexBuffer the vertex buffer to update
  46719. * @param vertices the data used to update the vertex buffer
  46720. * @param byteOffset the byte offset of the data (optional)
  46721. * @param byteLength the byte length of the data (optional)
  46722. */
  46723. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46724. /** @hidden */
  46725. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46726. /** @hidden */
  46727. _bindTexture(channel: number, texture: InternalTexture): void;
  46728. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46729. /**
  46730. * 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
  46731. */
  46732. releaseEffects(): void;
  46733. displayLoadingUI(): void;
  46734. hideLoadingUI(): void;
  46735. /** @hidden */
  46736. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46737. /** @hidden */
  46738. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46739. /** @hidden */
  46740. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46741. /** @hidden */
  46742. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46743. }
  46744. }
  46745. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46746. import { Nullable, int } from "babylonjs/types";
  46747. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46748. /** @hidden */
  46749. export class _OcclusionDataStorage {
  46750. /** @hidden */
  46751. occlusionInternalRetryCounter: number;
  46752. /** @hidden */
  46753. isOcclusionQueryInProgress: boolean;
  46754. /** @hidden */
  46755. isOccluded: boolean;
  46756. /** @hidden */
  46757. occlusionRetryCount: number;
  46758. /** @hidden */
  46759. occlusionType: number;
  46760. /** @hidden */
  46761. occlusionQueryAlgorithmType: number;
  46762. }
  46763. module "babylonjs/Engines/engine" {
  46764. interface Engine {
  46765. /**
  46766. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46767. * @return the new query
  46768. */
  46769. createQuery(): WebGLQuery;
  46770. /**
  46771. * Delete and release a webGL query
  46772. * @param query defines the query to delete
  46773. * @return the current engine
  46774. */
  46775. deleteQuery(query: WebGLQuery): Engine;
  46776. /**
  46777. * Check if a given query has resolved and got its value
  46778. * @param query defines the query to check
  46779. * @returns true if the query got its value
  46780. */
  46781. isQueryResultAvailable(query: WebGLQuery): boolean;
  46782. /**
  46783. * Gets the value of a given query
  46784. * @param query defines the query to check
  46785. * @returns the value of the query
  46786. */
  46787. getQueryResult(query: WebGLQuery): number;
  46788. /**
  46789. * Initiates an occlusion query
  46790. * @param algorithmType defines the algorithm to use
  46791. * @param query defines the query to use
  46792. * @returns the current engine
  46793. * @see http://doc.babylonjs.com/features/occlusionquery
  46794. */
  46795. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46796. /**
  46797. * Ends an occlusion query
  46798. * @see http://doc.babylonjs.com/features/occlusionquery
  46799. * @param algorithmType defines the algorithm to use
  46800. * @returns the current engine
  46801. */
  46802. endOcclusionQuery(algorithmType: number): Engine;
  46803. /**
  46804. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46805. * Please note that only one query can be issued at a time
  46806. * @returns a time token used to track the time span
  46807. */
  46808. startTimeQuery(): Nullable<_TimeToken>;
  46809. /**
  46810. * Ends a time query
  46811. * @param token defines the token used to measure the time span
  46812. * @returns the time spent (in ns)
  46813. */
  46814. endTimeQuery(token: _TimeToken): int;
  46815. /** @hidden */
  46816. _currentNonTimestampToken: Nullable<_TimeToken>;
  46817. /** @hidden */
  46818. _createTimeQuery(): WebGLQuery;
  46819. /** @hidden */
  46820. _deleteTimeQuery(query: WebGLQuery): void;
  46821. /** @hidden */
  46822. _getGlAlgorithmType(algorithmType: number): number;
  46823. /** @hidden */
  46824. _getTimeQueryResult(query: WebGLQuery): any;
  46825. /** @hidden */
  46826. _getTimeQueryAvailability(query: WebGLQuery): any;
  46827. }
  46828. }
  46829. module "babylonjs/Meshes/abstractMesh" {
  46830. interface AbstractMesh {
  46831. /**
  46832. * Backing filed
  46833. * @hidden
  46834. */
  46835. __occlusionDataStorage: _OcclusionDataStorage;
  46836. /**
  46837. * Access property
  46838. * @hidden
  46839. */
  46840. _occlusionDataStorage: _OcclusionDataStorage;
  46841. /**
  46842. * 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.
  46843. * The default value is -1 which means don't break the query and wait till the result
  46844. * @see http://doc.babylonjs.com/features/occlusionquery
  46845. */
  46846. occlusionRetryCount: number;
  46847. /**
  46848. * 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:
  46849. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46850. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46851. * * 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.
  46852. * @see http://doc.babylonjs.com/features/occlusionquery
  46853. */
  46854. occlusionType: number;
  46855. /**
  46856. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46857. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46858. * * 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.
  46859. * @see http://doc.babylonjs.com/features/occlusionquery
  46860. */
  46861. occlusionQueryAlgorithmType: number;
  46862. /**
  46863. * 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
  46864. * @see http://doc.babylonjs.com/features/occlusionquery
  46865. */
  46866. isOccluded: boolean;
  46867. /**
  46868. * Flag to check the progress status of the query
  46869. * @see http://doc.babylonjs.com/features/occlusionquery
  46870. */
  46871. isOcclusionQueryInProgress: boolean;
  46872. }
  46873. }
  46874. }
  46875. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46876. import { Nullable } from "babylonjs/types";
  46877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46878. /** @hidden */
  46879. export var _forceTransformFeedbackToBundle: boolean;
  46880. module "babylonjs/Engines/engine" {
  46881. interface Engine {
  46882. /**
  46883. * Creates a webGL transform feedback object
  46884. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46885. * @returns the webGL transform feedback object
  46886. */
  46887. createTransformFeedback(): WebGLTransformFeedback;
  46888. /**
  46889. * Delete a webGL transform feedback object
  46890. * @param value defines the webGL transform feedback object to delete
  46891. */
  46892. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46893. /**
  46894. * Bind a webGL transform feedback object to the webgl context
  46895. * @param value defines the webGL transform feedback object to bind
  46896. */
  46897. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46898. /**
  46899. * Begins a transform feedback operation
  46900. * @param usePoints defines if points or triangles must be used
  46901. */
  46902. beginTransformFeedback(usePoints: boolean): void;
  46903. /**
  46904. * Ends a transform feedback operation
  46905. */
  46906. endTransformFeedback(): void;
  46907. /**
  46908. * Specify the varyings to use with transform feedback
  46909. * @param program defines the associated webGL program
  46910. * @param value defines the list of strings representing the varying names
  46911. */
  46912. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46913. /**
  46914. * Bind a webGL buffer for a transform feedback operation
  46915. * @param value defines the webGL buffer to bind
  46916. */
  46917. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46918. }
  46919. }
  46920. }
  46921. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46922. import { Scene } from "babylonjs/scene";
  46923. import { Engine } from "babylonjs/Engines/engine";
  46924. import { Texture } from "babylonjs/Materials/Textures/texture";
  46925. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46926. import "babylonjs/Engines/Extensions/engine.multiRender";
  46927. /**
  46928. * Creation options of the multi render target texture.
  46929. */
  46930. export interface IMultiRenderTargetOptions {
  46931. /**
  46932. * Define if the texture needs to create mip maps after render.
  46933. */
  46934. generateMipMaps?: boolean;
  46935. /**
  46936. * Define the types of all the draw buffers we want to create
  46937. */
  46938. types?: number[];
  46939. /**
  46940. * Define the sampling modes of all the draw buffers we want to create
  46941. */
  46942. samplingModes?: number[];
  46943. /**
  46944. * Define if a depth buffer is required
  46945. */
  46946. generateDepthBuffer?: boolean;
  46947. /**
  46948. * Define if a stencil buffer is required
  46949. */
  46950. generateStencilBuffer?: boolean;
  46951. /**
  46952. * Define if a depth texture is required instead of a depth buffer
  46953. */
  46954. generateDepthTexture?: boolean;
  46955. /**
  46956. * Define the number of desired draw buffers
  46957. */
  46958. textureCount?: number;
  46959. /**
  46960. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46961. */
  46962. doNotChangeAspectRatio?: boolean;
  46963. /**
  46964. * Define the default type of the buffers we are creating
  46965. */
  46966. defaultType?: number;
  46967. }
  46968. /**
  46969. * A multi render target, like a render target provides the ability to render to a texture.
  46970. * Unlike the render target, it can render to several draw buffers in one draw.
  46971. * This is specially interesting in deferred rendering or for any effects requiring more than
  46972. * just one color from a single pass.
  46973. */
  46974. export class MultiRenderTarget extends RenderTargetTexture {
  46975. private _internalTextures;
  46976. private _textures;
  46977. private _multiRenderTargetOptions;
  46978. /**
  46979. * Get if draw buffers are currently supported by the used hardware and browser.
  46980. */
  46981. readonly isSupported: boolean;
  46982. /**
  46983. * Get the list of textures generated by the multi render target.
  46984. */
  46985. readonly textures: Texture[];
  46986. /**
  46987. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46988. */
  46989. readonly depthTexture: Texture;
  46990. /**
  46991. * Set the wrapping mode on U of all the textures we are rendering to.
  46992. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46993. */
  46994. wrapU: number;
  46995. /**
  46996. * Set the wrapping mode on V of all the textures we are rendering to.
  46997. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46998. */
  46999. wrapV: number;
  47000. /**
  47001. * Instantiate a new multi render target texture.
  47002. * A multi render target, like a render target provides the ability to render to a texture.
  47003. * Unlike the render target, it can render to several draw buffers in one draw.
  47004. * This is specially interesting in deferred rendering or for any effects requiring more than
  47005. * just one color from a single pass.
  47006. * @param name Define the name of the texture
  47007. * @param size Define the size of the buffers to render to
  47008. * @param count Define the number of target we are rendering into
  47009. * @param scene Define the scene the texture belongs to
  47010. * @param options Define the options used to create the multi render target
  47011. */
  47012. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47013. /** @hidden */
  47014. _rebuild(): void;
  47015. private _createInternalTextures;
  47016. private _createTextures;
  47017. /**
  47018. * Define the number of samples used if MSAA is enabled.
  47019. */
  47020. samples: number;
  47021. /**
  47022. * Resize all the textures in the multi render target.
  47023. * Be carrefull as it will recreate all the data in the new texture.
  47024. * @param size Define the new size
  47025. */
  47026. resize(size: any): void;
  47027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47028. /**
  47029. * Dispose the render targets and their associated resources
  47030. */
  47031. dispose(): void;
  47032. /**
  47033. * Release all the underlying texture used as draw buffers.
  47034. */
  47035. releaseInternalTextures(): void;
  47036. }
  47037. }
  47038. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47040. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47041. import { Nullable } from "babylonjs/types";
  47042. module "babylonjs/Engines/thinEngine" {
  47043. interface ThinEngine {
  47044. /**
  47045. * Unbind a list of render target textures from the webGL context
  47046. * This is used only when drawBuffer extension or webGL2 are active
  47047. * @param textures defines the render target textures to unbind
  47048. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47049. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47050. */
  47051. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47052. /**
  47053. * Create a multi render target texture
  47054. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47055. * @param size defines the size of the texture
  47056. * @param options defines the creation options
  47057. * @returns the cube texture as an InternalTexture
  47058. */
  47059. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47060. /**
  47061. * Update the sample count for a given multiple render target texture
  47062. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47063. * @param textures defines the textures to update
  47064. * @param samples defines the sample count to set
  47065. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47066. */
  47067. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47068. }
  47069. }
  47070. }
  47071. declare module "babylonjs/Engines/Extensions/engine.views" {
  47072. import { Camera } from "babylonjs/Cameras/camera";
  47073. import { Nullable } from "babylonjs/types";
  47074. /**
  47075. * Class used to define an additional view for the engine
  47076. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47077. */
  47078. export class EngineView {
  47079. /** Defines the canvas where to render the view */
  47080. target: HTMLCanvasElement;
  47081. /** Defines an optional camera used to render the view (will use active camera else) */
  47082. camera?: Camera;
  47083. }
  47084. module "babylonjs/Engines/engine" {
  47085. interface Engine {
  47086. /**
  47087. * Gets or sets the HTML element to use for attaching events
  47088. */
  47089. inputElement: Nullable<HTMLElement>;
  47090. /**
  47091. * Gets the current engine view
  47092. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47093. */
  47094. activeView: Nullable<EngineView>;
  47095. /** Gets or sets the list of views */
  47096. views: EngineView[];
  47097. /**
  47098. * Register a new child canvas
  47099. * @param canvas defines the canvas to register
  47100. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47101. * @returns the associated view
  47102. */
  47103. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47104. /**
  47105. * Remove a registered child canvas
  47106. * @param canvas defines the canvas to remove
  47107. * @returns the current engine
  47108. */
  47109. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47110. }
  47111. }
  47112. }
  47113. declare module "babylonjs/Engines/Extensions/index" {
  47114. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47115. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47116. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47117. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47118. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47119. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47120. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47121. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47122. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47123. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47124. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47125. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47126. export * from "babylonjs/Engines/Extensions/engine.views";
  47127. }
  47128. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47129. import { Nullable } from "babylonjs/types";
  47130. /**
  47131. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47132. */
  47133. export interface CubeMapInfo {
  47134. /**
  47135. * The pixel array for the front face.
  47136. * This is stored in format, left to right, up to down format.
  47137. */
  47138. front: Nullable<ArrayBufferView>;
  47139. /**
  47140. * The pixel array for the back face.
  47141. * This is stored in format, left to right, up to down format.
  47142. */
  47143. back: Nullable<ArrayBufferView>;
  47144. /**
  47145. * The pixel array for the left face.
  47146. * This is stored in format, left to right, up to down format.
  47147. */
  47148. left: Nullable<ArrayBufferView>;
  47149. /**
  47150. * The pixel array for the right face.
  47151. * This is stored in format, left to right, up to down format.
  47152. */
  47153. right: Nullable<ArrayBufferView>;
  47154. /**
  47155. * The pixel array for the up face.
  47156. * This is stored in format, left to right, up to down format.
  47157. */
  47158. up: Nullable<ArrayBufferView>;
  47159. /**
  47160. * The pixel array for the down face.
  47161. * This is stored in format, left to right, up to down format.
  47162. */
  47163. down: Nullable<ArrayBufferView>;
  47164. /**
  47165. * The size of the cubemap stored.
  47166. *
  47167. * Each faces will be size * size pixels.
  47168. */
  47169. size: number;
  47170. /**
  47171. * The format of the texture.
  47172. *
  47173. * RGBA, RGB.
  47174. */
  47175. format: number;
  47176. /**
  47177. * The type of the texture data.
  47178. *
  47179. * UNSIGNED_INT, FLOAT.
  47180. */
  47181. type: number;
  47182. /**
  47183. * Specifies whether the texture is in gamma space.
  47184. */
  47185. gammaSpace: boolean;
  47186. }
  47187. /**
  47188. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47189. */
  47190. export class PanoramaToCubeMapTools {
  47191. private static FACE_FRONT;
  47192. private static FACE_BACK;
  47193. private static FACE_RIGHT;
  47194. private static FACE_LEFT;
  47195. private static FACE_DOWN;
  47196. private static FACE_UP;
  47197. /**
  47198. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47199. *
  47200. * @param float32Array The source data.
  47201. * @param inputWidth The width of the input panorama.
  47202. * @param inputHeight The height of the input panorama.
  47203. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47204. * @return The cubemap data
  47205. */
  47206. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47207. private static CreateCubemapTexture;
  47208. private static CalcProjectionSpherical;
  47209. }
  47210. }
  47211. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47212. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47214. import { Nullable } from "babylonjs/types";
  47215. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47216. /**
  47217. * Helper class dealing with the extraction of spherical polynomial dataArray
  47218. * from a cube map.
  47219. */
  47220. export class CubeMapToSphericalPolynomialTools {
  47221. private static FileFaces;
  47222. /**
  47223. * Converts a texture to the according Spherical Polynomial data.
  47224. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47225. *
  47226. * @param texture The texture to extract the information from.
  47227. * @return The Spherical Polynomial data.
  47228. */
  47229. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47230. /**
  47231. * Converts a cubemap to the according Spherical Polynomial data.
  47232. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47233. *
  47234. * @param cubeInfo The Cube map to extract the information from.
  47235. * @return The Spherical Polynomial data.
  47236. */
  47237. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47238. }
  47239. }
  47240. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47241. import { Nullable } from "babylonjs/types";
  47242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47243. module "babylonjs/Materials/Textures/baseTexture" {
  47244. interface BaseTexture {
  47245. /**
  47246. * Get the polynomial representation of the texture data.
  47247. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47248. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47249. */
  47250. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47251. }
  47252. }
  47253. }
  47254. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47255. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47256. /** @hidden */
  47257. export var rgbdEncodePixelShader: {
  47258. name: string;
  47259. shader: string;
  47260. };
  47261. }
  47262. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47263. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47264. /** @hidden */
  47265. export var rgbdDecodePixelShader: {
  47266. name: string;
  47267. shader: string;
  47268. };
  47269. }
  47270. declare module "babylonjs/Misc/environmentTextureTools" {
  47271. import { Nullable } from "babylonjs/types";
  47272. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47273. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47274. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47275. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47276. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47277. import "babylonjs/Shaders/rgbdEncode.fragment";
  47278. import "babylonjs/Shaders/rgbdDecode.fragment";
  47279. /**
  47280. * Raw texture data and descriptor sufficient for WebGL texture upload
  47281. */
  47282. export interface EnvironmentTextureInfo {
  47283. /**
  47284. * Version of the environment map
  47285. */
  47286. version: number;
  47287. /**
  47288. * Width of image
  47289. */
  47290. width: number;
  47291. /**
  47292. * Irradiance information stored in the file.
  47293. */
  47294. irradiance: any;
  47295. /**
  47296. * Specular information stored in the file.
  47297. */
  47298. specular: any;
  47299. }
  47300. /**
  47301. * Defines One Image in the file. It requires only the position in the file
  47302. * as well as the length.
  47303. */
  47304. interface BufferImageData {
  47305. /**
  47306. * Length of the image data.
  47307. */
  47308. length: number;
  47309. /**
  47310. * Position of the data from the null terminator delimiting the end of the JSON.
  47311. */
  47312. position: number;
  47313. }
  47314. /**
  47315. * Defines the specular data enclosed in the file.
  47316. * This corresponds to the version 1 of the data.
  47317. */
  47318. export interface EnvironmentTextureSpecularInfoV1 {
  47319. /**
  47320. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47321. */
  47322. specularDataPosition?: number;
  47323. /**
  47324. * This contains all the images data needed to reconstruct the cubemap.
  47325. */
  47326. mipmaps: Array<BufferImageData>;
  47327. /**
  47328. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47329. */
  47330. lodGenerationScale: number;
  47331. }
  47332. /**
  47333. * Sets of helpers addressing the serialization and deserialization of environment texture
  47334. * stored in a BabylonJS env file.
  47335. * Those files are usually stored as .env files.
  47336. */
  47337. export class EnvironmentTextureTools {
  47338. /**
  47339. * Magic number identifying the env file.
  47340. */
  47341. private static _MagicBytes;
  47342. /**
  47343. * Gets the environment info from an env file.
  47344. * @param data The array buffer containing the .env bytes.
  47345. * @returns the environment file info (the json header) if successfully parsed.
  47346. */
  47347. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47348. /**
  47349. * Creates an environment texture from a loaded cube texture.
  47350. * @param texture defines the cube texture to convert in env file
  47351. * @return a promise containing the environment data if succesfull.
  47352. */
  47353. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47354. /**
  47355. * Creates a JSON representation of the spherical data.
  47356. * @param texture defines the texture containing the polynomials
  47357. * @return the JSON representation of the spherical info
  47358. */
  47359. private static _CreateEnvTextureIrradiance;
  47360. /**
  47361. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47362. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47363. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47364. * @return the views described by info providing access to the underlying buffer
  47365. */
  47366. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47367. /**
  47368. * Uploads the texture info contained in the env file to the GPU.
  47369. * @param texture defines the internal texture to upload to
  47370. * @param arrayBuffer defines the buffer cotaining the data to load
  47371. * @param info defines the texture info retrieved through the GetEnvInfo method
  47372. * @returns a promise
  47373. */
  47374. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47375. private static _OnImageReadyAsync;
  47376. /**
  47377. * Uploads the levels of image data to the GPU.
  47378. * @param texture defines the internal texture to upload to
  47379. * @param imageData defines the array buffer views of image data [mipmap][face]
  47380. * @returns a promise
  47381. */
  47382. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47383. /**
  47384. * Uploads spherical polynomials information to the texture.
  47385. * @param texture defines the texture we are trying to upload the information to
  47386. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47387. */
  47388. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47389. /** @hidden */
  47390. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47391. }
  47392. }
  47393. declare module "babylonjs/Maths/math.vertexFormat" {
  47394. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47395. /**
  47396. * Contains position and normal vectors for a vertex
  47397. */
  47398. export class PositionNormalVertex {
  47399. /** the position of the vertex (defaut: 0,0,0) */
  47400. position: Vector3;
  47401. /** the normal of the vertex (defaut: 0,1,0) */
  47402. normal: Vector3;
  47403. /**
  47404. * Creates a PositionNormalVertex
  47405. * @param position the position of the vertex (defaut: 0,0,0)
  47406. * @param normal the normal of the vertex (defaut: 0,1,0)
  47407. */
  47408. constructor(
  47409. /** the position of the vertex (defaut: 0,0,0) */
  47410. position?: Vector3,
  47411. /** the normal of the vertex (defaut: 0,1,0) */
  47412. normal?: Vector3);
  47413. /**
  47414. * Clones the PositionNormalVertex
  47415. * @returns the cloned PositionNormalVertex
  47416. */
  47417. clone(): PositionNormalVertex;
  47418. }
  47419. /**
  47420. * Contains position, normal and uv vectors for a vertex
  47421. */
  47422. export class PositionNormalTextureVertex {
  47423. /** the position of the vertex (defaut: 0,0,0) */
  47424. position: Vector3;
  47425. /** the normal of the vertex (defaut: 0,1,0) */
  47426. normal: Vector3;
  47427. /** the uv of the vertex (default: 0,0) */
  47428. uv: Vector2;
  47429. /**
  47430. * Creates a PositionNormalTextureVertex
  47431. * @param position the position of the vertex (defaut: 0,0,0)
  47432. * @param normal the normal of the vertex (defaut: 0,1,0)
  47433. * @param uv the uv of the vertex (default: 0,0)
  47434. */
  47435. constructor(
  47436. /** the position of the vertex (defaut: 0,0,0) */
  47437. position?: Vector3,
  47438. /** the normal of the vertex (defaut: 0,1,0) */
  47439. normal?: Vector3,
  47440. /** the uv of the vertex (default: 0,0) */
  47441. uv?: Vector2);
  47442. /**
  47443. * Clones the PositionNormalTextureVertex
  47444. * @returns the cloned PositionNormalTextureVertex
  47445. */
  47446. clone(): PositionNormalTextureVertex;
  47447. }
  47448. }
  47449. declare module "babylonjs/Maths/math" {
  47450. export * from "babylonjs/Maths/math.axis";
  47451. export * from "babylonjs/Maths/math.color";
  47452. export * from "babylonjs/Maths/math.constants";
  47453. export * from "babylonjs/Maths/math.frustum";
  47454. export * from "babylonjs/Maths/math.path";
  47455. export * from "babylonjs/Maths/math.plane";
  47456. export * from "babylonjs/Maths/math.size";
  47457. export * from "babylonjs/Maths/math.vector";
  47458. export * from "babylonjs/Maths/math.vertexFormat";
  47459. export * from "babylonjs/Maths/math.viewport";
  47460. }
  47461. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47462. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47463. /** @hidden */
  47464. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47465. private _genericAttributeLocation;
  47466. private _varyingLocationCount;
  47467. private _varyingLocationMap;
  47468. private _replacements;
  47469. private _textureCount;
  47470. private _uniforms;
  47471. lineProcessor(line: string): string;
  47472. attributeProcessor(attribute: string): string;
  47473. varyingProcessor(varying: string, isFragment: boolean): string;
  47474. uniformProcessor(uniform: string): string;
  47475. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47476. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47477. }
  47478. }
  47479. declare module "babylonjs/Engines/nativeEngine" {
  47480. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47481. import { Engine } from "babylonjs/Engines/engine";
  47482. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47485. import { Effect } from "babylonjs/Materials/effect";
  47486. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47487. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47488. import { IColor4Like } from "babylonjs/Maths/math.like";
  47489. import { Scene } from "babylonjs/scene";
  47490. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47491. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47492. /**
  47493. * Container for accessors for natively-stored mesh data buffers.
  47494. */
  47495. class NativeDataBuffer extends DataBuffer {
  47496. /**
  47497. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47498. */
  47499. nativeIndexBuffer?: any;
  47500. /**
  47501. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47502. */
  47503. nativeVertexBuffer?: any;
  47504. }
  47505. /** @hidden */
  47506. class NativeTexture extends InternalTexture {
  47507. getInternalTexture(): InternalTexture;
  47508. getViewCount(): number;
  47509. }
  47510. /** @hidden */
  47511. export class NativeEngine extends Engine {
  47512. private readonly _native;
  47513. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47514. private readonly INVALID_HANDLE;
  47515. getHardwareScalingLevel(): number;
  47516. constructor();
  47517. /**
  47518. * Can be used to override the current requestAnimationFrame requester.
  47519. * @hidden
  47520. */
  47521. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47522. /**
  47523. * Override default engine behavior.
  47524. * @param color
  47525. * @param backBuffer
  47526. * @param depth
  47527. * @param stencil
  47528. */
  47529. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47530. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47531. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47532. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47533. recordVertexArrayObject(vertexBuffers: {
  47534. [key: string]: VertexBuffer;
  47535. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47536. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47537. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47538. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47539. /**
  47540. * Draw a list of indexed primitives
  47541. * @param fillMode defines the primitive to use
  47542. * @param indexStart defines the starting index
  47543. * @param indexCount defines the number of index to draw
  47544. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47545. */
  47546. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47547. /**
  47548. * Draw a list of unindexed primitives
  47549. * @param fillMode defines the primitive to use
  47550. * @param verticesStart defines the index of first vertex to draw
  47551. * @param verticesCount defines the count of vertices to draw
  47552. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47553. */
  47554. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47555. createPipelineContext(): IPipelineContext;
  47556. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47557. /** @hidden */
  47558. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47559. /** @hidden */
  47560. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47561. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47562. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47563. protected _setProgram(program: WebGLProgram): void;
  47564. _releaseEffect(effect: Effect): void;
  47565. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47566. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47567. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47568. bindSamplers(effect: Effect): void;
  47569. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47570. getRenderWidth(useScreen?: boolean): number;
  47571. getRenderHeight(useScreen?: boolean): number;
  47572. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47573. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47574. /**
  47575. * Set the z offset to apply to current rendering
  47576. * @param value defines the offset to apply
  47577. */
  47578. setZOffset(value: number): void;
  47579. /**
  47580. * Gets the current value of the zOffset
  47581. * @returns the current zOffset state
  47582. */
  47583. getZOffset(): number;
  47584. /**
  47585. * Enable or disable depth buffering
  47586. * @param enable defines the state to set
  47587. */
  47588. setDepthBuffer(enable: boolean): void;
  47589. /**
  47590. * Gets a boolean indicating if depth writing is enabled
  47591. * @returns the current depth writing state
  47592. */
  47593. getDepthWrite(): boolean;
  47594. /**
  47595. * Enable or disable depth writing
  47596. * @param enable defines the state to set
  47597. */
  47598. setDepthWrite(enable: boolean): void;
  47599. /**
  47600. * Enable or disable color writing
  47601. * @param enable defines the state to set
  47602. */
  47603. setColorWrite(enable: boolean): void;
  47604. /**
  47605. * Gets a boolean indicating if color writing is enabled
  47606. * @returns the current color writing state
  47607. */
  47608. getColorWrite(): boolean;
  47609. /**
  47610. * Sets alpha constants used by some alpha blending modes
  47611. * @param r defines the red component
  47612. * @param g defines the green component
  47613. * @param b defines the blue component
  47614. * @param a defines the alpha component
  47615. */
  47616. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47617. /**
  47618. * Sets the current alpha mode
  47619. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47620. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47622. */
  47623. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47624. /**
  47625. * Gets the current alpha mode
  47626. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47627. * @returns the current alpha mode
  47628. */
  47629. getAlphaMode(): number;
  47630. setInt(uniform: WebGLUniformLocation, int: number): void;
  47631. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47632. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47633. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47634. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47635. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47636. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47637. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47638. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47639. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47640. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47641. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47642. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47643. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47644. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47645. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47646. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47647. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47648. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47649. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47650. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47651. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47652. wipeCaches(bruteForce?: boolean): void;
  47653. _createTexture(): WebGLTexture;
  47654. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47655. /**
  47656. * Usually called from BABYLON.Texture.ts.
  47657. * Passed information to create a WebGLTexture
  47658. * @param urlArg defines a value which contains one of the following:
  47659. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47660. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47661. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47662. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47663. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47664. * @param scene needed for loading to the correct scene
  47665. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47666. * @param onLoad optional callback to be called upon successful completion
  47667. * @param onError optional callback to be called upon failure
  47668. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47669. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47670. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47671. * @param forcedExtension defines the extension to use to pick the right loader
  47672. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47673. */
  47674. 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;
  47675. /**
  47676. * Creates a cube texture
  47677. * @param rootUrl defines the url where the files to load is located
  47678. * @param scene defines the current scene
  47679. * @param files defines the list of files to load (1 per face)
  47680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47681. * @param onLoad defines an optional callback raised when the texture is loaded
  47682. * @param onError defines an optional callback raised if there is an issue to load the texture
  47683. * @param format defines the format of the data
  47684. * @param forcedExtension defines the extension to use to pick the right loader
  47685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47689. * @returns the cube texture as an InternalTexture
  47690. */
  47691. 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;
  47692. private _getSamplingFilter;
  47693. private static _GetNativeTextureFormat;
  47694. createRenderTargetTexture(size: number | {
  47695. width: number;
  47696. height: number;
  47697. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47698. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47701. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47702. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47703. /**
  47704. * Updates a dynamic vertex buffer.
  47705. * @param vertexBuffer the vertex buffer to update
  47706. * @param data the data used to update the vertex buffer
  47707. * @param byteOffset the byte offset of the data (optional)
  47708. * @param byteLength the byte length of the data (optional)
  47709. */
  47710. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47711. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47712. private _updateAnisotropicLevel;
  47713. private _getAddressMode;
  47714. /** @hidden */
  47715. _bindTexture(channel: number, texture: InternalTexture): void;
  47716. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47717. releaseEffects(): void;
  47718. /** @hidden */
  47719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47720. /** @hidden */
  47721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47722. /** @hidden */
  47723. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47724. /** @hidden */
  47725. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47726. }
  47727. }
  47728. declare module "babylonjs/Engines/index" {
  47729. export * from "babylonjs/Engines/constants";
  47730. export * from "babylonjs/Engines/engineCapabilities";
  47731. export * from "babylonjs/Engines/instancingAttributeInfo";
  47732. export * from "babylonjs/Engines/thinEngine";
  47733. export * from "babylonjs/Engines/engine";
  47734. export * from "babylonjs/Engines/engineStore";
  47735. export * from "babylonjs/Engines/nullEngine";
  47736. export * from "babylonjs/Engines/Extensions/index";
  47737. export * from "babylonjs/Engines/IPipelineContext";
  47738. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47739. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47740. export * from "babylonjs/Engines/nativeEngine";
  47741. }
  47742. declare module "babylonjs/Events/clipboardEvents" {
  47743. /**
  47744. * Gather the list of clipboard event types as constants.
  47745. */
  47746. export class ClipboardEventTypes {
  47747. /**
  47748. * The clipboard event is fired when a copy command is active (pressed).
  47749. */
  47750. static readonly COPY: number;
  47751. /**
  47752. * The clipboard event is fired when a cut command is active (pressed).
  47753. */
  47754. static readonly CUT: number;
  47755. /**
  47756. * The clipboard event is fired when a paste command is active (pressed).
  47757. */
  47758. static readonly PASTE: number;
  47759. }
  47760. /**
  47761. * This class is used to store clipboard related info for the onClipboardObservable event.
  47762. */
  47763. export class ClipboardInfo {
  47764. /**
  47765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47766. */
  47767. type: number;
  47768. /**
  47769. * Defines the related dom event
  47770. */
  47771. event: ClipboardEvent;
  47772. /**
  47773. *Creates an instance of ClipboardInfo.
  47774. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47775. * @param event Defines the related dom event
  47776. */
  47777. constructor(
  47778. /**
  47779. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47780. */
  47781. type: number,
  47782. /**
  47783. * Defines the related dom event
  47784. */
  47785. event: ClipboardEvent);
  47786. /**
  47787. * Get the clipboard event's type from the keycode.
  47788. * @param keyCode Defines the keyCode for the current keyboard event.
  47789. * @return {number}
  47790. */
  47791. static GetTypeFromCharacter(keyCode: number): number;
  47792. }
  47793. }
  47794. declare module "babylonjs/Events/index" {
  47795. export * from "babylonjs/Events/keyboardEvents";
  47796. export * from "babylonjs/Events/pointerEvents";
  47797. export * from "babylonjs/Events/clipboardEvents";
  47798. }
  47799. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47800. import { Scene } from "babylonjs/scene";
  47801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47802. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47804. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47805. /**
  47806. * Google Daydream controller
  47807. */
  47808. export class DaydreamController extends WebVRController {
  47809. /**
  47810. * Base Url for the controller model.
  47811. */
  47812. static MODEL_BASE_URL: string;
  47813. /**
  47814. * File name for the controller model.
  47815. */
  47816. static MODEL_FILENAME: string;
  47817. /**
  47818. * Gamepad Id prefix used to identify Daydream Controller.
  47819. */
  47820. static readonly GAMEPAD_ID_PREFIX: string;
  47821. /**
  47822. * Creates a new DaydreamController from a gamepad
  47823. * @param vrGamepad the gamepad that the controller should be created from
  47824. */
  47825. constructor(vrGamepad: any);
  47826. /**
  47827. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47828. * @param scene scene in which to add meshes
  47829. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47830. */
  47831. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47832. /**
  47833. * Called once for each button that changed state since the last frame
  47834. * @param buttonIdx Which button index changed
  47835. * @param state New state of the button
  47836. * @param changes Which properties on the state changed since last frame
  47837. */
  47838. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47839. }
  47840. }
  47841. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47842. import { Scene } from "babylonjs/scene";
  47843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47844. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47845. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47846. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47847. /**
  47848. * Gear VR Controller
  47849. */
  47850. export class GearVRController extends WebVRController {
  47851. /**
  47852. * Base Url for the controller model.
  47853. */
  47854. static MODEL_BASE_URL: string;
  47855. /**
  47856. * File name for the controller model.
  47857. */
  47858. static MODEL_FILENAME: string;
  47859. /**
  47860. * Gamepad Id prefix used to identify this controller.
  47861. */
  47862. static readonly GAMEPAD_ID_PREFIX: string;
  47863. private readonly _buttonIndexToObservableNameMap;
  47864. /**
  47865. * Creates a new GearVRController from a gamepad
  47866. * @param vrGamepad the gamepad that the controller should be created from
  47867. */
  47868. constructor(vrGamepad: any);
  47869. /**
  47870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47871. * @param scene scene in which to add meshes
  47872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47873. */
  47874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47875. /**
  47876. * Called once for each button that changed state since the last frame
  47877. * @param buttonIdx Which button index changed
  47878. * @param state New state of the button
  47879. * @param changes Which properties on the state changed since last frame
  47880. */
  47881. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47882. }
  47883. }
  47884. declare module "babylonjs/Gamepads/Controllers/index" {
  47885. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47886. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47887. export * from "babylonjs/Gamepads/Controllers/genericController";
  47888. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47889. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47890. export * from "babylonjs/Gamepads/Controllers/viveController";
  47891. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47892. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47893. }
  47894. declare module "babylonjs/Gamepads/index" {
  47895. export * from "babylonjs/Gamepads/Controllers/index";
  47896. export * from "babylonjs/Gamepads/gamepad";
  47897. export * from "babylonjs/Gamepads/gamepadManager";
  47898. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47899. export * from "babylonjs/Gamepads/xboxGamepad";
  47900. export * from "babylonjs/Gamepads/dualShockGamepad";
  47901. }
  47902. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47903. import { Scene } from "babylonjs/scene";
  47904. import { Vector4 } from "babylonjs/Maths/math.vector";
  47905. import { Color4 } from "babylonjs/Maths/math.color";
  47906. import { Mesh } from "babylonjs/Meshes/mesh";
  47907. import { Nullable } from "babylonjs/types";
  47908. /**
  47909. * Class containing static functions to help procedurally build meshes
  47910. */
  47911. export class PolyhedronBuilder {
  47912. /**
  47913. * Creates a polyhedron mesh
  47914. * * 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
  47915. * * The parameter `size` (positive float, default 1) sets the polygon size
  47916. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47917. * * 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`
  47918. * * 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
  47919. * * 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)`)
  47920. * * 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
  47921. * * 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
  47922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47925. * @param name defines the name of the mesh
  47926. * @param options defines the options used to create the mesh
  47927. * @param scene defines the hosting scene
  47928. * @returns the polyhedron mesh
  47929. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47930. */
  47931. static CreatePolyhedron(name: string, options: {
  47932. type?: number;
  47933. size?: number;
  47934. sizeX?: number;
  47935. sizeY?: number;
  47936. sizeZ?: number;
  47937. custom?: any;
  47938. faceUV?: Vector4[];
  47939. faceColors?: Color4[];
  47940. flat?: boolean;
  47941. updatable?: boolean;
  47942. sideOrientation?: number;
  47943. frontUVs?: Vector4;
  47944. backUVs?: Vector4;
  47945. }, scene?: Nullable<Scene>): Mesh;
  47946. }
  47947. }
  47948. declare module "babylonjs/Gizmos/scaleGizmo" {
  47949. import { Observable } from "babylonjs/Misc/observable";
  47950. import { Nullable } from "babylonjs/types";
  47951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47952. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47953. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47954. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47955. /**
  47956. * Gizmo that enables scaling a mesh along 3 axis
  47957. */
  47958. export class ScaleGizmo extends Gizmo {
  47959. /**
  47960. * Internal gizmo used for interactions on the x axis
  47961. */
  47962. xGizmo: AxisScaleGizmo;
  47963. /**
  47964. * Internal gizmo used for interactions on the y axis
  47965. */
  47966. yGizmo: AxisScaleGizmo;
  47967. /**
  47968. * Internal gizmo used for interactions on the z axis
  47969. */
  47970. zGizmo: AxisScaleGizmo;
  47971. /**
  47972. * Internal gizmo used to scale all axis equally
  47973. */
  47974. uniformScaleGizmo: AxisScaleGizmo;
  47975. private _meshAttached;
  47976. private _updateGizmoRotationToMatchAttachedMesh;
  47977. private _snapDistance;
  47978. private _scaleRatio;
  47979. private _uniformScalingMesh;
  47980. private _octahedron;
  47981. private _sensitivity;
  47982. /** Fires an event when any of it's sub gizmos are dragged */
  47983. onDragStartObservable: Observable<unknown>;
  47984. /** Fires an event when any of it's sub gizmos are released from dragging */
  47985. onDragEndObservable: Observable<unknown>;
  47986. attachedMesh: Nullable<AbstractMesh>;
  47987. /**
  47988. * Creates a ScaleGizmo
  47989. * @param gizmoLayer The utility layer the gizmo will be added to
  47990. */
  47991. constructor(gizmoLayer?: UtilityLayerRenderer);
  47992. updateGizmoRotationToMatchAttachedMesh: boolean;
  47993. /**
  47994. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47995. */
  47996. snapDistance: number;
  47997. /**
  47998. * Ratio for the scale of the gizmo (Default: 1)
  47999. */
  48000. scaleRatio: number;
  48001. /**
  48002. * Sensitivity factor for dragging (Default: 1)
  48003. */
  48004. sensitivity: number;
  48005. /**
  48006. * Disposes of the gizmo
  48007. */
  48008. dispose(): void;
  48009. }
  48010. }
  48011. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48012. import { Observable } from "babylonjs/Misc/observable";
  48013. import { Nullable } from "babylonjs/types";
  48014. import { Vector3 } from "babylonjs/Maths/math.vector";
  48015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48016. import { Mesh } from "babylonjs/Meshes/mesh";
  48017. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48018. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48019. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48020. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48021. import { Color3 } from "babylonjs/Maths/math.color";
  48022. /**
  48023. * Single axis scale gizmo
  48024. */
  48025. export class AxisScaleGizmo extends Gizmo {
  48026. /**
  48027. * Drag behavior responsible for the gizmos dragging interactions
  48028. */
  48029. dragBehavior: PointerDragBehavior;
  48030. private _pointerObserver;
  48031. /**
  48032. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48033. */
  48034. snapDistance: number;
  48035. /**
  48036. * Event that fires each time the gizmo snaps to a new location.
  48037. * * snapDistance is the the change in distance
  48038. */
  48039. onSnapObservable: Observable<{
  48040. snapDistance: number;
  48041. }>;
  48042. /**
  48043. * If the scaling operation should be done on all axis (default: false)
  48044. */
  48045. uniformScaling: boolean;
  48046. /**
  48047. * Custom sensitivity value for the drag strength
  48048. */
  48049. sensitivity: number;
  48050. private _isEnabled;
  48051. private _parent;
  48052. private _arrow;
  48053. private _coloredMaterial;
  48054. private _hoverMaterial;
  48055. /**
  48056. * Creates an AxisScaleGizmo
  48057. * @param gizmoLayer The utility layer the gizmo will be added to
  48058. * @param dragAxis The axis which the gizmo will be able to scale on
  48059. * @param color The color of the gizmo
  48060. */
  48061. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48062. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48063. /**
  48064. * If the gizmo is enabled
  48065. */
  48066. isEnabled: boolean;
  48067. /**
  48068. * Disposes of the gizmo
  48069. */
  48070. dispose(): void;
  48071. /**
  48072. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48073. * @param mesh The mesh to replace the default mesh of the gizmo
  48074. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48075. */
  48076. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48077. }
  48078. }
  48079. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48080. import { Observable } from "babylonjs/Misc/observable";
  48081. import { Nullable } from "babylonjs/types";
  48082. import { Vector3 } from "babylonjs/Maths/math.vector";
  48083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48084. import { Mesh } from "babylonjs/Meshes/mesh";
  48085. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48086. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48087. import { Color3 } from "babylonjs/Maths/math.color";
  48088. import "babylonjs/Meshes/Builders/boxBuilder";
  48089. /**
  48090. * Bounding box gizmo
  48091. */
  48092. export class BoundingBoxGizmo extends Gizmo {
  48093. private _lineBoundingBox;
  48094. private _rotateSpheresParent;
  48095. private _scaleBoxesParent;
  48096. private _boundingDimensions;
  48097. private _renderObserver;
  48098. private _pointerObserver;
  48099. private _scaleDragSpeed;
  48100. private _tmpQuaternion;
  48101. private _tmpVector;
  48102. private _tmpRotationMatrix;
  48103. /**
  48104. * 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)
  48105. */
  48106. ignoreChildren: boolean;
  48107. /**
  48108. * 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)
  48109. */
  48110. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48111. /**
  48112. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48113. */
  48114. rotationSphereSize: number;
  48115. /**
  48116. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48117. */
  48118. scaleBoxSize: number;
  48119. /**
  48120. * 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)
  48121. */
  48122. fixedDragMeshScreenSize: boolean;
  48123. /**
  48124. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48125. */
  48126. fixedDragMeshScreenSizeDistanceFactor: number;
  48127. /**
  48128. * Fired when a rotation sphere or scale box is dragged
  48129. */
  48130. onDragStartObservable: Observable<{}>;
  48131. /**
  48132. * Fired when a scale box is dragged
  48133. */
  48134. onScaleBoxDragObservable: Observable<{}>;
  48135. /**
  48136. * Fired when a scale box drag is ended
  48137. */
  48138. onScaleBoxDragEndObservable: Observable<{}>;
  48139. /**
  48140. * Fired when a rotation sphere is dragged
  48141. */
  48142. onRotationSphereDragObservable: Observable<{}>;
  48143. /**
  48144. * Fired when a rotation sphere drag is ended
  48145. */
  48146. onRotationSphereDragEndObservable: Observable<{}>;
  48147. /**
  48148. * 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)
  48149. */
  48150. scalePivot: Nullable<Vector3>;
  48151. /**
  48152. * Mesh used as a pivot to rotate the attached mesh
  48153. */
  48154. private _anchorMesh;
  48155. private _existingMeshScale;
  48156. private _dragMesh;
  48157. private pointerDragBehavior;
  48158. private coloredMaterial;
  48159. private hoverColoredMaterial;
  48160. /**
  48161. * Sets the color of the bounding box gizmo
  48162. * @param color the color to set
  48163. */
  48164. setColor(color: Color3): void;
  48165. /**
  48166. * Creates an BoundingBoxGizmo
  48167. * @param gizmoLayer The utility layer the gizmo will be added to
  48168. * @param color The color of the gizmo
  48169. */
  48170. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48171. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48172. private _selectNode;
  48173. /**
  48174. * Updates the bounding box information for the Gizmo
  48175. */
  48176. updateBoundingBox(): void;
  48177. private _updateRotationSpheres;
  48178. private _updateScaleBoxes;
  48179. /**
  48180. * Enables rotation on the specified axis and disables rotation on the others
  48181. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48182. */
  48183. setEnabledRotationAxis(axis: string): void;
  48184. /**
  48185. * Enables/disables scaling
  48186. * @param enable if scaling should be enabled
  48187. */
  48188. setEnabledScaling(enable: boolean): void;
  48189. private _updateDummy;
  48190. /**
  48191. * Enables a pointer drag behavior on the bounding box of the gizmo
  48192. */
  48193. enableDragBehavior(): void;
  48194. /**
  48195. * Disposes of the gizmo
  48196. */
  48197. dispose(): void;
  48198. /**
  48199. * 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)
  48200. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48201. * @returns the bounding box mesh with the passed in mesh as a child
  48202. */
  48203. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48204. /**
  48205. * CustomMeshes are not supported by this gizmo
  48206. * @param mesh The mesh to replace the default mesh of the gizmo
  48207. */
  48208. setCustomMesh(mesh: Mesh): void;
  48209. }
  48210. }
  48211. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48212. import { Observable } from "babylonjs/Misc/observable";
  48213. import { Nullable } from "babylonjs/types";
  48214. import { Vector3 } from "babylonjs/Maths/math.vector";
  48215. import { Color3 } from "babylonjs/Maths/math.color";
  48216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48217. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48218. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48219. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48220. import "babylonjs/Meshes/Builders/linesBuilder";
  48221. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48222. /**
  48223. * Single plane rotation gizmo
  48224. */
  48225. export class PlaneRotationGizmo extends Gizmo {
  48226. /**
  48227. * Drag behavior responsible for the gizmos dragging interactions
  48228. */
  48229. dragBehavior: PointerDragBehavior;
  48230. private _pointerObserver;
  48231. /**
  48232. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48233. */
  48234. snapDistance: number;
  48235. /**
  48236. * Event that fires each time the gizmo snaps to a new location.
  48237. * * snapDistance is the the change in distance
  48238. */
  48239. onSnapObservable: Observable<{
  48240. snapDistance: number;
  48241. }>;
  48242. private _isEnabled;
  48243. private _parent;
  48244. /**
  48245. * Creates a PlaneRotationGizmo
  48246. * @param gizmoLayer The utility layer the gizmo will be added to
  48247. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48248. * @param color The color of the gizmo
  48249. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48250. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48251. */
  48252. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48254. /**
  48255. * If the gizmo is enabled
  48256. */
  48257. isEnabled: boolean;
  48258. /**
  48259. * Disposes of the gizmo
  48260. */
  48261. dispose(): void;
  48262. }
  48263. }
  48264. declare module "babylonjs/Gizmos/rotationGizmo" {
  48265. import { Observable } from "babylonjs/Misc/observable";
  48266. import { Nullable } from "babylonjs/types";
  48267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48268. import { Mesh } from "babylonjs/Meshes/mesh";
  48269. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48270. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48271. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48272. /**
  48273. * Gizmo that enables rotating a mesh along 3 axis
  48274. */
  48275. export class RotationGizmo extends Gizmo {
  48276. /**
  48277. * Internal gizmo used for interactions on the x axis
  48278. */
  48279. xGizmo: PlaneRotationGizmo;
  48280. /**
  48281. * Internal gizmo used for interactions on the y axis
  48282. */
  48283. yGizmo: PlaneRotationGizmo;
  48284. /**
  48285. * Internal gizmo used for interactions on the z axis
  48286. */
  48287. zGizmo: PlaneRotationGizmo;
  48288. /** Fires an event when any of it's sub gizmos are dragged */
  48289. onDragStartObservable: Observable<unknown>;
  48290. /** Fires an event when any of it's sub gizmos are released from dragging */
  48291. onDragEndObservable: Observable<unknown>;
  48292. private _meshAttached;
  48293. attachedMesh: Nullable<AbstractMesh>;
  48294. /**
  48295. * Creates a RotationGizmo
  48296. * @param gizmoLayer The utility layer the gizmo will be added to
  48297. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48298. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48299. */
  48300. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48301. updateGizmoRotationToMatchAttachedMesh: boolean;
  48302. /**
  48303. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48304. */
  48305. snapDistance: number;
  48306. /**
  48307. * Ratio for the scale of the gizmo (Default: 1)
  48308. */
  48309. scaleRatio: number;
  48310. /**
  48311. * Disposes of the gizmo
  48312. */
  48313. dispose(): void;
  48314. /**
  48315. * CustomMeshes are not supported by this gizmo
  48316. * @param mesh The mesh to replace the default mesh of the gizmo
  48317. */
  48318. setCustomMesh(mesh: Mesh): void;
  48319. }
  48320. }
  48321. declare module "babylonjs/Gizmos/gizmoManager" {
  48322. import { Observable } from "babylonjs/Misc/observable";
  48323. import { Nullable } from "babylonjs/types";
  48324. import { Scene, IDisposable } from "babylonjs/scene";
  48325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48326. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48327. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48328. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48329. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48330. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48331. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48332. /**
  48333. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48334. */
  48335. export class GizmoManager implements IDisposable {
  48336. private scene;
  48337. /**
  48338. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48339. */
  48340. gizmos: {
  48341. positionGizmo: Nullable<PositionGizmo>;
  48342. rotationGizmo: Nullable<RotationGizmo>;
  48343. scaleGizmo: Nullable<ScaleGizmo>;
  48344. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48345. };
  48346. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48347. clearGizmoOnEmptyPointerEvent: boolean;
  48348. /** Fires an event when the manager is attached to a mesh */
  48349. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48350. private _gizmosEnabled;
  48351. private _pointerObserver;
  48352. private _attachedMesh;
  48353. private _boundingBoxColor;
  48354. private _defaultUtilityLayer;
  48355. private _defaultKeepDepthUtilityLayer;
  48356. /**
  48357. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48358. */
  48359. boundingBoxDragBehavior: SixDofDragBehavior;
  48360. /**
  48361. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48362. */
  48363. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48364. /**
  48365. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48366. */
  48367. usePointerToAttachGizmos: boolean;
  48368. /**
  48369. * Utility layer that the bounding box gizmo belongs to
  48370. */
  48371. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48372. /**
  48373. * Utility layer that all gizmos besides bounding box belong to
  48374. */
  48375. readonly utilityLayer: UtilityLayerRenderer;
  48376. /**
  48377. * Instatiates a gizmo manager
  48378. * @param scene the scene to overlay the gizmos on top of
  48379. */
  48380. constructor(scene: Scene);
  48381. /**
  48382. * Attaches a set of gizmos to the specified mesh
  48383. * @param mesh The mesh the gizmo's should be attached to
  48384. */
  48385. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48386. /**
  48387. * If the position gizmo is enabled
  48388. */
  48389. positionGizmoEnabled: boolean;
  48390. /**
  48391. * If the rotation gizmo is enabled
  48392. */
  48393. rotationGizmoEnabled: boolean;
  48394. /**
  48395. * If the scale gizmo is enabled
  48396. */
  48397. scaleGizmoEnabled: boolean;
  48398. /**
  48399. * If the boundingBox gizmo is enabled
  48400. */
  48401. boundingBoxGizmoEnabled: boolean;
  48402. /**
  48403. * Disposes of the gizmo manager
  48404. */
  48405. dispose(): void;
  48406. }
  48407. }
  48408. declare module "babylonjs/Lights/directionalLight" {
  48409. import { Camera } from "babylonjs/Cameras/camera";
  48410. import { Scene } from "babylonjs/scene";
  48411. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48413. import { Light } from "babylonjs/Lights/light";
  48414. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48415. import { Effect } from "babylonjs/Materials/effect";
  48416. /**
  48417. * A directional light is defined by a direction (what a surprise!).
  48418. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48419. * 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.
  48420. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48421. */
  48422. export class DirectionalLight extends ShadowLight {
  48423. private _shadowFrustumSize;
  48424. /**
  48425. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48426. */
  48427. /**
  48428. * Specifies a fix frustum size for the shadow generation.
  48429. */
  48430. shadowFrustumSize: number;
  48431. private _shadowOrthoScale;
  48432. /**
  48433. * Gets the shadow projection scale against the optimal computed one.
  48434. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48435. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48436. */
  48437. /**
  48438. * Sets the shadow projection scale against the optimal computed one.
  48439. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48440. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48441. */
  48442. shadowOrthoScale: number;
  48443. /**
  48444. * Automatically compute the projection matrix to best fit (including all the casters)
  48445. * on each frame.
  48446. */
  48447. autoUpdateExtends: boolean;
  48448. private _orthoLeft;
  48449. private _orthoRight;
  48450. private _orthoTop;
  48451. private _orthoBottom;
  48452. /**
  48453. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48454. * The directional light is emitted from everywhere in the given direction.
  48455. * It can cast shadows.
  48456. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48457. * @param name The friendly name of the light
  48458. * @param direction The direction of the light
  48459. * @param scene The scene the light belongs to
  48460. */
  48461. constructor(name: string, direction: Vector3, scene: Scene);
  48462. /**
  48463. * Returns the string "DirectionalLight".
  48464. * @return The class name
  48465. */
  48466. getClassName(): string;
  48467. /**
  48468. * Returns the integer 1.
  48469. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48470. */
  48471. getTypeID(): number;
  48472. /**
  48473. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48474. * Returns the DirectionalLight Shadow projection matrix.
  48475. */
  48476. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48477. /**
  48478. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48479. * Returns the DirectionalLight Shadow projection matrix.
  48480. */
  48481. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48482. /**
  48483. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48484. * Returns the DirectionalLight Shadow projection matrix.
  48485. */
  48486. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48487. protected _buildUniformLayout(): void;
  48488. /**
  48489. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48490. * @param effect The effect to update
  48491. * @param lightIndex The index of the light in the effect to update
  48492. * @returns The directional light
  48493. */
  48494. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48495. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48496. /**
  48497. * Gets the minZ used for shadow according to both the scene and the light.
  48498. *
  48499. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48500. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48501. * @param activeCamera The camera we are returning the min for
  48502. * @returns the depth min z
  48503. */
  48504. getDepthMinZ(activeCamera: Camera): number;
  48505. /**
  48506. * Gets the maxZ used for shadow according to both the scene and the light.
  48507. *
  48508. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48509. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48510. * @param activeCamera The camera we are returning the max for
  48511. * @returns the depth max z
  48512. */
  48513. getDepthMaxZ(activeCamera: Camera): number;
  48514. /**
  48515. * Prepares the list of defines specific to the light type.
  48516. * @param defines the list of defines
  48517. * @param lightIndex defines the index of the light for the effect
  48518. */
  48519. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48520. }
  48521. }
  48522. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48523. import { Mesh } from "babylonjs/Meshes/mesh";
  48524. /**
  48525. * Class containing static functions to help procedurally build meshes
  48526. */
  48527. export class HemisphereBuilder {
  48528. /**
  48529. * Creates a hemisphere mesh
  48530. * @param name defines the name of the mesh
  48531. * @param options defines the options used to create the mesh
  48532. * @param scene defines the hosting scene
  48533. * @returns the hemisphere mesh
  48534. */
  48535. static CreateHemisphere(name: string, options: {
  48536. segments?: number;
  48537. diameter?: number;
  48538. sideOrientation?: number;
  48539. }, scene: any): Mesh;
  48540. }
  48541. }
  48542. declare module "babylonjs/Lights/spotLight" {
  48543. import { Nullable } from "babylonjs/types";
  48544. import { Scene } from "babylonjs/scene";
  48545. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48547. import { Effect } from "babylonjs/Materials/effect";
  48548. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48549. import { Light } from "babylonjs/Lights/light";
  48550. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48551. /**
  48552. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48553. * These values define a cone of light starting from the position, emitting toward the direction.
  48554. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48555. * and the exponent defines the speed of the decay of the light with distance (reach).
  48556. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48557. */
  48558. export class SpotLight extends ShadowLight {
  48559. private _angle;
  48560. private _innerAngle;
  48561. private _cosHalfAngle;
  48562. private _lightAngleScale;
  48563. private _lightAngleOffset;
  48564. /**
  48565. * Gets the cone angle of the spot light in Radians.
  48566. */
  48567. /**
  48568. * Sets the cone angle of the spot light in Radians.
  48569. */
  48570. angle: number;
  48571. /**
  48572. * Only used in gltf falloff mode, this defines the angle where
  48573. * the directional falloff will start before cutting at angle which could be seen
  48574. * as outer angle.
  48575. */
  48576. /**
  48577. * Only used in gltf falloff mode, this defines the angle where
  48578. * the directional falloff will start before cutting at angle which could be seen
  48579. * as outer angle.
  48580. */
  48581. innerAngle: number;
  48582. private _shadowAngleScale;
  48583. /**
  48584. * Allows scaling the angle of the light for shadow generation only.
  48585. */
  48586. /**
  48587. * Allows scaling the angle of the light for shadow generation only.
  48588. */
  48589. shadowAngleScale: number;
  48590. /**
  48591. * The light decay speed with the distance from the emission spot.
  48592. */
  48593. exponent: number;
  48594. private _projectionTextureMatrix;
  48595. /**
  48596. * Allows reading the projecton texture
  48597. */
  48598. readonly projectionTextureMatrix: Matrix;
  48599. protected _projectionTextureLightNear: number;
  48600. /**
  48601. * Gets the near clip of the Spotlight for texture projection.
  48602. */
  48603. /**
  48604. * Sets the near clip of the Spotlight for texture projection.
  48605. */
  48606. projectionTextureLightNear: number;
  48607. protected _projectionTextureLightFar: number;
  48608. /**
  48609. * Gets the far clip of the Spotlight for texture projection.
  48610. */
  48611. /**
  48612. * Sets the far clip of the Spotlight for texture projection.
  48613. */
  48614. projectionTextureLightFar: number;
  48615. protected _projectionTextureUpDirection: Vector3;
  48616. /**
  48617. * Gets the Up vector of the Spotlight for texture projection.
  48618. */
  48619. /**
  48620. * Sets the Up vector of the Spotlight for texture projection.
  48621. */
  48622. projectionTextureUpDirection: Vector3;
  48623. private _projectionTexture;
  48624. /**
  48625. * Gets the projection texture of the light.
  48626. */
  48627. /**
  48628. * Sets the projection texture of the light.
  48629. */
  48630. projectionTexture: Nullable<BaseTexture>;
  48631. private _projectionTextureViewLightDirty;
  48632. private _projectionTextureProjectionLightDirty;
  48633. private _projectionTextureDirty;
  48634. private _projectionTextureViewTargetVector;
  48635. private _projectionTextureViewLightMatrix;
  48636. private _projectionTextureProjectionLightMatrix;
  48637. private _projectionTextureScalingMatrix;
  48638. /**
  48639. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48640. * It can cast shadows.
  48641. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48642. * @param name The light friendly name
  48643. * @param position The position of the spot light in the scene
  48644. * @param direction The direction of the light in the scene
  48645. * @param angle The cone angle of the light in Radians
  48646. * @param exponent The light decay speed with the distance from the emission spot
  48647. * @param scene The scene the lights belongs to
  48648. */
  48649. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48650. /**
  48651. * Returns the string "SpotLight".
  48652. * @returns the class name
  48653. */
  48654. getClassName(): string;
  48655. /**
  48656. * Returns the integer 2.
  48657. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48658. */
  48659. getTypeID(): number;
  48660. /**
  48661. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48662. */
  48663. protected _setDirection(value: Vector3): void;
  48664. /**
  48665. * Overrides the position setter to recompute the projection texture view light Matrix.
  48666. */
  48667. protected _setPosition(value: Vector3): void;
  48668. /**
  48669. * 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.
  48670. * Returns the SpotLight.
  48671. */
  48672. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48673. protected _computeProjectionTextureViewLightMatrix(): void;
  48674. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48675. /**
  48676. * Main function for light texture projection matrix computing.
  48677. */
  48678. protected _computeProjectionTextureMatrix(): void;
  48679. protected _buildUniformLayout(): void;
  48680. private _computeAngleValues;
  48681. /**
  48682. * Sets the passed Effect "effect" with the Light textures.
  48683. * @param effect The effect to update
  48684. * @param lightIndex The index of the light in the effect to update
  48685. * @returns The light
  48686. */
  48687. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48688. /**
  48689. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48690. * @param effect The effect to update
  48691. * @param lightIndex The index of the light in the effect to update
  48692. * @returns The spot light
  48693. */
  48694. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48695. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48696. /**
  48697. * Disposes the light and the associated resources.
  48698. */
  48699. dispose(): void;
  48700. /**
  48701. * Prepares the list of defines specific to the light type.
  48702. * @param defines the list of defines
  48703. * @param lightIndex defines the index of the light for the effect
  48704. */
  48705. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48706. }
  48707. }
  48708. declare module "babylonjs/Gizmos/lightGizmo" {
  48709. import { Nullable } from "babylonjs/types";
  48710. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48711. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48712. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48713. import { Light } from "babylonjs/Lights/light";
  48714. /**
  48715. * Gizmo that enables viewing a light
  48716. */
  48717. export class LightGizmo extends Gizmo {
  48718. private _lightMesh;
  48719. private _material;
  48720. private _cachedPosition;
  48721. private _cachedForward;
  48722. private _attachedMeshParent;
  48723. /**
  48724. * Creates a LightGizmo
  48725. * @param gizmoLayer The utility layer the gizmo will be added to
  48726. */
  48727. constructor(gizmoLayer?: UtilityLayerRenderer);
  48728. private _light;
  48729. /**
  48730. * The light that the gizmo is attached to
  48731. */
  48732. light: Nullable<Light>;
  48733. /**
  48734. * Gets the material used to render the light gizmo
  48735. */
  48736. readonly material: StandardMaterial;
  48737. /**
  48738. * @hidden
  48739. * Updates the gizmo to match the attached mesh's position/rotation
  48740. */
  48741. protected _update(): void;
  48742. private static _Scale;
  48743. /**
  48744. * Creates the lines for a light mesh
  48745. */
  48746. private static _CreateLightLines;
  48747. /**
  48748. * Disposes of the light gizmo
  48749. */
  48750. dispose(): void;
  48751. private static _CreateHemisphericLightMesh;
  48752. private static _CreatePointLightMesh;
  48753. private static _CreateSpotLightMesh;
  48754. private static _CreateDirectionalLightMesh;
  48755. }
  48756. }
  48757. declare module "babylonjs/Gizmos/index" {
  48758. export * from "babylonjs/Gizmos/axisDragGizmo";
  48759. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48760. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48761. export * from "babylonjs/Gizmos/gizmo";
  48762. export * from "babylonjs/Gizmos/gizmoManager";
  48763. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48764. export * from "babylonjs/Gizmos/positionGizmo";
  48765. export * from "babylonjs/Gizmos/rotationGizmo";
  48766. export * from "babylonjs/Gizmos/scaleGizmo";
  48767. export * from "babylonjs/Gizmos/lightGizmo";
  48768. export * from "babylonjs/Gizmos/planeDragGizmo";
  48769. }
  48770. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48771. /** @hidden */
  48772. export var backgroundFragmentDeclaration: {
  48773. name: string;
  48774. shader: string;
  48775. };
  48776. }
  48777. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48778. /** @hidden */
  48779. export var backgroundUboDeclaration: {
  48780. name: string;
  48781. shader: string;
  48782. };
  48783. }
  48784. declare module "babylonjs/Shaders/background.fragment" {
  48785. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48786. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48787. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48788. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48789. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48790. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48791. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48792. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48793. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48794. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48795. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48796. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48797. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48798. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48799. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48800. /** @hidden */
  48801. export var backgroundPixelShader: {
  48802. name: string;
  48803. shader: string;
  48804. };
  48805. }
  48806. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48807. /** @hidden */
  48808. export var backgroundVertexDeclaration: {
  48809. name: string;
  48810. shader: string;
  48811. };
  48812. }
  48813. declare module "babylonjs/Shaders/background.vertex" {
  48814. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48817. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48821. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48822. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48823. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48824. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48825. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48826. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48827. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48828. /** @hidden */
  48829. export var backgroundVertexShader: {
  48830. name: string;
  48831. shader: string;
  48832. };
  48833. }
  48834. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48835. import { Nullable, int, float } from "babylonjs/types";
  48836. import { Scene } from "babylonjs/scene";
  48837. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48838. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48840. import { Mesh } from "babylonjs/Meshes/mesh";
  48841. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48842. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48843. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48845. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48846. import { Color3 } from "babylonjs/Maths/math.color";
  48847. import "babylonjs/Shaders/background.fragment";
  48848. import "babylonjs/Shaders/background.vertex";
  48849. /**
  48850. * Background material used to create an efficient environement around your scene.
  48851. */
  48852. export class BackgroundMaterial extends PushMaterial {
  48853. /**
  48854. * Standard reflectance value at parallel view angle.
  48855. */
  48856. static StandardReflectance0: number;
  48857. /**
  48858. * Standard reflectance value at grazing angle.
  48859. */
  48860. static StandardReflectance90: number;
  48861. protected _primaryColor: Color3;
  48862. /**
  48863. * Key light Color (multiply against the environement texture)
  48864. */
  48865. primaryColor: Color3;
  48866. protected __perceptualColor: Nullable<Color3>;
  48867. /**
  48868. * Experimental Internal Use Only.
  48869. *
  48870. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48871. * This acts as a helper to set the primary color to a more "human friendly" value.
  48872. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48873. * output color as close as possible from the chosen value.
  48874. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48875. * part of lighting setup.)
  48876. */
  48877. _perceptualColor: Nullable<Color3>;
  48878. protected _primaryColorShadowLevel: float;
  48879. /**
  48880. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48881. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48882. */
  48883. primaryColorShadowLevel: float;
  48884. protected _primaryColorHighlightLevel: float;
  48885. /**
  48886. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48887. * The primary color is used at the level chosen to define what the white area would look.
  48888. */
  48889. primaryColorHighlightLevel: float;
  48890. protected _reflectionTexture: Nullable<BaseTexture>;
  48891. /**
  48892. * Reflection Texture used in the material.
  48893. * Should be author in a specific way for the best result (refer to the documentation).
  48894. */
  48895. reflectionTexture: Nullable<BaseTexture>;
  48896. protected _reflectionBlur: float;
  48897. /**
  48898. * Reflection Texture level of blur.
  48899. *
  48900. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48901. * texture twice.
  48902. */
  48903. reflectionBlur: float;
  48904. protected _diffuseTexture: Nullable<BaseTexture>;
  48905. /**
  48906. * Diffuse Texture used in the material.
  48907. * Should be author in a specific way for the best result (refer to the documentation).
  48908. */
  48909. diffuseTexture: Nullable<BaseTexture>;
  48910. protected _shadowLights: Nullable<IShadowLight[]>;
  48911. /**
  48912. * Specify the list of lights casting shadow on the material.
  48913. * All scene shadow lights will be included if null.
  48914. */
  48915. shadowLights: Nullable<IShadowLight[]>;
  48916. protected _shadowLevel: float;
  48917. /**
  48918. * Helps adjusting the shadow to a softer level if required.
  48919. * 0 means black shadows and 1 means no shadows.
  48920. */
  48921. shadowLevel: float;
  48922. protected _sceneCenter: Vector3;
  48923. /**
  48924. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48925. * It is usually zero but might be interesting to modify according to your setup.
  48926. */
  48927. sceneCenter: Vector3;
  48928. protected _opacityFresnel: boolean;
  48929. /**
  48930. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48931. * This helps ensuring a nice transition when the camera goes under the ground.
  48932. */
  48933. opacityFresnel: boolean;
  48934. protected _reflectionFresnel: boolean;
  48935. /**
  48936. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48937. * This helps adding a mirror texture on the ground.
  48938. */
  48939. reflectionFresnel: boolean;
  48940. protected _reflectionFalloffDistance: number;
  48941. /**
  48942. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48943. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48944. */
  48945. reflectionFalloffDistance: number;
  48946. protected _reflectionAmount: number;
  48947. /**
  48948. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48949. */
  48950. reflectionAmount: number;
  48951. protected _reflectionReflectance0: number;
  48952. /**
  48953. * This specifies the weight of the reflection at grazing angle.
  48954. */
  48955. reflectionReflectance0: number;
  48956. protected _reflectionReflectance90: number;
  48957. /**
  48958. * This specifies the weight of the reflection at a perpendicular point of view.
  48959. */
  48960. reflectionReflectance90: number;
  48961. /**
  48962. * Sets the reflection reflectance fresnel values according to the default standard
  48963. * empirically know to work well :-)
  48964. */
  48965. reflectionStandardFresnelWeight: number;
  48966. protected _useRGBColor: boolean;
  48967. /**
  48968. * Helps to directly use the maps channels instead of their level.
  48969. */
  48970. useRGBColor: boolean;
  48971. protected _enableNoise: boolean;
  48972. /**
  48973. * This helps reducing the banding effect that could occur on the background.
  48974. */
  48975. enableNoise: boolean;
  48976. /**
  48977. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48978. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48979. * Recommended to be keep at 1.0 except for special cases.
  48980. */
  48981. fovMultiplier: number;
  48982. private _fovMultiplier;
  48983. /**
  48984. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48985. */
  48986. useEquirectangularFOV: boolean;
  48987. private _maxSimultaneousLights;
  48988. /**
  48989. * Number of Simultaneous lights allowed on the material.
  48990. */
  48991. maxSimultaneousLights: int;
  48992. /**
  48993. * Default configuration related to image processing available in the Background Material.
  48994. */
  48995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48996. /**
  48997. * Keep track of the image processing observer to allow dispose and replace.
  48998. */
  48999. private _imageProcessingObserver;
  49000. /**
  49001. * Attaches a new image processing configuration to the PBR Material.
  49002. * @param configuration (if null the scene configuration will be use)
  49003. */
  49004. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49005. /**
  49006. * Gets the image processing configuration used either in this material.
  49007. */
  49008. /**
  49009. * Sets the Default image processing configuration used either in the this material.
  49010. *
  49011. * If sets to null, the scene one is in use.
  49012. */
  49013. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49014. /**
  49015. * Gets wether the color curves effect is enabled.
  49016. */
  49017. /**
  49018. * Sets wether the color curves effect is enabled.
  49019. */
  49020. cameraColorCurvesEnabled: boolean;
  49021. /**
  49022. * Gets wether the color grading effect is enabled.
  49023. */
  49024. /**
  49025. * Gets wether the color grading effect is enabled.
  49026. */
  49027. cameraColorGradingEnabled: boolean;
  49028. /**
  49029. * Gets wether tonemapping is enabled or not.
  49030. */
  49031. /**
  49032. * Sets wether tonemapping is enabled or not
  49033. */
  49034. cameraToneMappingEnabled: boolean;
  49035. /**
  49036. * The camera exposure used on this material.
  49037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49038. * This corresponds to a photographic exposure.
  49039. */
  49040. /**
  49041. * The camera exposure used on this material.
  49042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49043. * This corresponds to a photographic exposure.
  49044. */
  49045. cameraExposure: float;
  49046. /**
  49047. * Gets The camera contrast used on this material.
  49048. */
  49049. /**
  49050. * Sets The camera contrast used on this material.
  49051. */
  49052. cameraContrast: float;
  49053. /**
  49054. * Gets the Color Grading 2D Lookup Texture.
  49055. */
  49056. /**
  49057. * Sets the Color Grading 2D Lookup Texture.
  49058. */
  49059. cameraColorGradingTexture: Nullable<BaseTexture>;
  49060. /**
  49061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49063. * 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;
  49064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49065. */
  49066. /**
  49067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49069. * 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;
  49070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49071. */
  49072. cameraColorCurves: Nullable<ColorCurves>;
  49073. /**
  49074. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49075. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49076. */
  49077. switchToBGR: boolean;
  49078. private _renderTargets;
  49079. private _reflectionControls;
  49080. private _white;
  49081. private _primaryShadowColor;
  49082. private _primaryHighlightColor;
  49083. /**
  49084. * Instantiates a Background Material in the given scene
  49085. * @param name The friendly name of the material
  49086. * @param scene The scene to add the material to
  49087. */
  49088. constructor(name: string, scene: Scene);
  49089. /**
  49090. * Gets a boolean indicating that current material needs to register RTT
  49091. */
  49092. readonly hasRenderTargetTextures: boolean;
  49093. /**
  49094. * The entire material has been created in order to prevent overdraw.
  49095. * @returns false
  49096. */
  49097. needAlphaTesting(): boolean;
  49098. /**
  49099. * The entire material has been created in order to prevent overdraw.
  49100. * @returns true if blending is enable
  49101. */
  49102. needAlphaBlending(): boolean;
  49103. /**
  49104. * Checks wether the material is ready to be rendered for a given mesh.
  49105. * @param mesh The mesh to render
  49106. * @param subMesh The submesh to check against
  49107. * @param useInstances Specify wether or not the material is used with instances
  49108. * @returns true if all the dependencies are ready (Textures, Effects...)
  49109. */
  49110. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49111. /**
  49112. * Compute the primary color according to the chosen perceptual color.
  49113. */
  49114. private _computePrimaryColorFromPerceptualColor;
  49115. /**
  49116. * Compute the highlights and shadow colors according to their chosen levels.
  49117. */
  49118. private _computePrimaryColors;
  49119. /**
  49120. * Build the uniform buffer used in the material.
  49121. */
  49122. buildUniformLayout(): void;
  49123. /**
  49124. * Unbind the material.
  49125. */
  49126. unbind(): void;
  49127. /**
  49128. * Bind only the world matrix to the material.
  49129. * @param world The world matrix to bind.
  49130. */
  49131. bindOnlyWorldMatrix(world: Matrix): void;
  49132. /**
  49133. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49134. * @param world The world matrix to bind.
  49135. * @param subMesh The submesh to bind for.
  49136. */
  49137. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49138. /**
  49139. * Checks to see if a texture is used in the material.
  49140. * @param texture - Base texture to use.
  49141. * @returns - Boolean specifying if a texture is used in the material.
  49142. */
  49143. hasTexture(texture: BaseTexture): boolean;
  49144. /**
  49145. * Dispose the material.
  49146. * @param forceDisposeEffect Force disposal of the associated effect.
  49147. * @param forceDisposeTextures Force disposal of the associated textures.
  49148. */
  49149. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49150. /**
  49151. * Clones the material.
  49152. * @param name The cloned name.
  49153. * @returns The cloned material.
  49154. */
  49155. clone(name: string): BackgroundMaterial;
  49156. /**
  49157. * Serializes the current material to its JSON representation.
  49158. * @returns The JSON representation.
  49159. */
  49160. serialize(): any;
  49161. /**
  49162. * Gets the class name of the material
  49163. * @returns "BackgroundMaterial"
  49164. */
  49165. getClassName(): string;
  49166. /**
  49167. * Parse a JSON input to create back a background material.
  49168. * @param source The JSON data to parse
  49169. * @param scene The scene to create the parsed material in
  49170. * @param rootUrl The root url of the assets the material depends upon
  49171. * @returns the instantiated BackgroundMaterial.
  49172. */
  49173. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49174. }
  49175. }
  49176. declare module "babylonjs/Helpers/environmentHelper" {
  49177. import { Observable } from "babylonjs/Misc/observable";
  49178. import { Nullable } from "babylonjs/types";
  49179. import { Scene } from "babylonjs/scene";
  49180. import { Vector3 } from "babylonjs/Maths/math.vector";
  49181. import { Color3 } from "babylonjs/Maths/math.color";
  49182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49183. import { Mesh } from "babylonjs/Meshes/mesh";
  49184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49185. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49186. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49187. import "babylonjs/Meshes/Builders/planeBuilder";
  49188. import "babylonjs/Meshes/Builders/boxBuilder";
  49189. /**
  49190. * Represents the different options available during the creation of
  49191. * a Environment helper.
  49192. *
  49193. * This can control the default ground, skybox and image processing setup of your scene.
  49194. */
  49195. export interface IEnvironmentHelperOptions {
  49196. /**
  49197. * Specifies wether or not to create a ground.
  49198. * True by default.
  49199. */
  49200. createGround: boolean;
  49201. /**
  49202. * Specifies the ground size.
  49203. * 15 by default.
  49204. */
  49205. groundSize: number;
  49206. /**
  49207. * The texture used on the ground for the main color.
  49208. * Comes from the BabylonJS CDN by default.
  49209. *
  49210. * Remarks: Can be either a texture or a url.
  49211. */
  49212. groundTexture: string | BaseTexture;
  49213. /**
  49214. * The color mixed in the ground texture by default.
  49215. * BabylonJS clearColor by default.
  49216. */
  49217. groundColor: Color3;
  49218. /**
  49219. * Specifies the ground opacity.
  49220. * 1 by default.
  49221. */
  49222. groundOpacity: number;
  49223. /**
  49224. * Enables the ground to receive shadows.
  49225. * True by default.
  49226. */
  49227. enableGroundShadow: boolean;
  49228. /**
  49229. * Helps preventing the shadow to be fully black on the ground.
  49230. * 0.5 by default.
  49231. */
  49232. groundShadowLevel: number;
  49233. /**
  49234. * Creates a mirror texture attach to the ground.
  49235. * false by default.
  49236. */
  49237. enableGroundMirror: boolean;
  49238. /**
  49239. * Specifies the ground mirror size ratio.
  49240. * 0.3 by default as the default kernel is 64.
  49241. */
  49242. groundMirrorSizeRatio: number;
  49243. /**
  49244. * Specifies the ground mirror blur kernel size.
  49245. * 64 by default.
  49246. */
  49247. groundMirrorBlurKernel: number;
  49248. /**
  49249. * Specifies the ground mirror visibility amount.
  49250. * 1 by default
  49251. */
  49252. groundMirrorAmount: number;
  49253. /**
  49254. * Specifies the ground mirror reflectance weight.
  49255. * This uses the standard weight of the background material to setup the fresnel effect
  49256. * of the mirror.
  49257. * 1 by default.
  49258. */
  49259. groundMirrorFresnelWeight: number;
  49260. /**
  49261. * Specifies the ground mirror Falloff distance.
  49262. * This can helps reducing the size of the reflection.
  49263. * 0 by Default.
  49264. */
  49265. groundMirrorFallOffDistance: number;
  49266. /**
  49267. * Specifies the ground mirror texture type.
  49268. * Unsigned Int by Default.
  49269. */
  49270. groundMirrorTextureType: number;
  49271. /**
  49272. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49273. * the shown objects.
  49274. */
  49275. groundYBias: number;
  49276. /**
  49277. * Specifies wether or not to create a skybox.
  49278. * True by default.
  49279. */
  49280. createSkybox: boolean;
  49281. /**
  49282. * Specifies the skybox size.
  49283. * 20 by default.
  49284. */
  49285. skyboxSize: number;
  49286. /**
  49287. * The texture used on the skybox for the main color.
  49288. * Comes from the BabylonJS CDN by default.
  49289. *
  49290. * Remarks: Can be either a texture or a url.
  49291. */
  49292. skyboxTexture: string | BaseTexture;
  49293. /**
  49294. * The color mixed in the skybox texture by default.
  49295. * BabylonJS clearColor by default.
  49296. */
  49297. skyboxColor: Color3;
  49298. /**
  49299. * The background rotation around the Y axis of the scene.
  49300. * This helps aligning the key lights of your scene with the background.
  49301. * 0 by default.
  49302. */
  49303. backgroundYRotation: number;
  49304. /**
  49305. * Compute automatically the size of the elements to best fit with the scene.
  49306. */
  49307. sizeAuto: boolean;
  49308. /**
  49309. * Default position of the rootMesh if autoSize is not true.
  49310. */
  49311. rootPosition: Vector3;
  49312. /**
  49313. * Sets up the image processing in the scene.
  49314. * true by default.
  49315. */
  49316. setupImageProcessing: boolean;
  49317. /**
  49318. * The texture used as your environment texture in the scene.
  49319. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49320. *
  49321. * Remarks: Can be either a texture or a url.
  49322. */
  49323. environmentTexture: string | BaseTexture;
  49324. /**
  49325. * The value of the exposure to apply to the scene.
  49326. * 0.6 by default if setupImageProcessing is true.
  49327. */
  49328. cameraExposure: number;
  49329. /**
  49330. * The value of the contrast to apply to the scene.
  49331. * 1.6 by default if setupImageProcessing is true.
  49332. */
  49333. cameraContrast: number;
  49334. /**
  49335. * Specifies wether or not tonemapping should be enabled in the scene.
  49336. * true by default if setupImageProcessing is true.
  49337. */
  49338. toneMappingEnabled: boolean;
  49339. }
  49340. /**
  49341. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49342. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49343. * It also helps with the default setup of your imageProcessing configuration.
  49344. */
  49345. export class EnvironmentHelper {
  49346. /**
  49347. * Default ground texture URL.
  49348. */
  49349. private static _groundTextureCDNUrl;
  49350. /**
  49351. * Default skybox texture URL.
  49352. */
  49353. private static _skyboxTextureCDNUrl;
  49354. /**
  49355. * Default environment texture URL.
  49356. */
  49357. private static _environmentTextureCDNUrl;
  49358. /**
  49359. * Creates the default options for the helper.
  49360. */
  49361. private static _getDefaultOptions;
  49362. private _rootMesh;
  49363. /**
  49364. * Gets the root mesh created by the helper.
  49365. */
  49366. readonly rootMesh: Mesh;
  49367. private _skybox;
  49368. /**
  49369. * Gets the skybox created by the helper.
  49370. */
  49371. readonly skybox: Nullable<Mesh>;
  49372. private _skyboxTexture;
  49373. /**
  49374. * Gets the skybox texture created by the helper.
  49375. */
  49376. readonly skyboxTexture: Nullable<BaseTexture>;
  49377. private _skyboxMaterial;
  49378. /**
  49379. * Gets the skybox material created by the helper.
  49380. */
  49381. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49382. private _ground;
  49383. /**
  49384. * Gets the ground mesh created by the helper.
  49385. */
  49386. readonly ground: Nullable<Mesh>;
  49387. private _groundTexture;
  49388. /**
  49389. * Gets the ground texture created by the helper.
  49390. */
  49391. readonly groundTexture: Nullable<BaseTexture>;
  49392. private _groundMirror;
  49393. /**
  49394. * Gets the ground mirror created by the helper.
  49395. */
  49396. readonly groundMirror: Nullable<MirrorTexture>;
  49397. /**
  49398. * Gets the ground mirror render list to helps pushing the meshes
  49399. * you wish in the ground reflection.
  49400. */
  49401. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49402. private _groundMaterial;
  49403. /**
  49404. * Gets the ground material created by the helper.
  49405. */
  49406. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49407. /**
  49408. * Stores the creation options.
  49409. */
  49410. private readonly _scene;
  49411. private _options;
  49412. /**
  49413. * This observable will be notified with any error during the creation of the environment,
  49414. * mainly texture creation errors.
  49415. */
  49416. onErrorObservable: Observable<{
  49417. message?: string;
  49418. exception?: any;
  49419. }>;
  49420. /**
  49421. * constructor
  49422. * @param options Defines the options we want to customize the helper
  49423. * @param scene The scene to add the material to
  49424. */
  49425. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49426. /**
  49427. * Updates the background according to the new options
  49428. * @param options
  49429. */
  49430. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49431. /**
  49432. * Sets the primary color of all the available elements.
  49433. * @param color the main color to affect to the ground and the background
  49434. */
  49435. setMainColor(color: Color3): void;
  49436. /**
  49437. * Setup the image processing according to the specified options.
  49438. */
  49439. private _setupImageProcessing;
  49440. /**
  49441. * Setup the environment texture according to the specified options.
  49442. */
  49443. private _setupEnvironmentTexture;
  49444. /**
  49445. * Setup the background according to the specified options.
  49446. */
  49447. private _setupBackground;
  49448. /**
  49449. * Get the scene sizes according to the setup.
  49450. */
  49451. private _getSceneSize;
  49452. /**
  49453. * Setup the ground according to the specified options.
  49454. */
  49455. private _setupGround;
  49456. /**
  49457. * Setup the ground material according to the specified options.
  49458. */
  49459. private _setupGroundMaterial;
  49460. /**
  49461. * Setup the ground diffuse texture according to the specified options.
  49462. */
  49463. private _setupGroundDiffuseTexture;
  49464. /**
  49465. * Setup the ground mirror texture according to the specified options.
  49466. */
  49467. private _setupGroundMirrorTexture;
  49468. /**
  49469. * Setup the ground to receive the mirror texture.
  49470. */
  49471. private _setupMirrorInGroundMaterial;
  49472. /**
  49473. * Setup the skybox according to the specified options.
  49474. */
  49475. private _setupSkybox;
  49476. /**
  49477. * Setup the skybox material according to the specified options.
  49478. */
  49479. private _setupSkyboxMaterial;
  49480. /**
  49481. * Setup the skybox reflection texture according to the specified options.
  49482. */
  49483. private _setupSkyboxReflectionTexture;
  49484. private _errorHandler;
  49485. /**
  49486. * Dispose all the elements created by the Helper.
  49487. */
  49488. dispose(): void;
  49489. }
  49490. }
  49491. declare module "babylonjs/Helpers/photoDome" {
  49492. import { Observable } from "babylonjs/Misc/observable";
  49493. import { Nullable } from "babylonjs/types";
  49494. import { Scene } from "babylonjs/scene";
  49495. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49496. import { Mesh } from "babylonjs/Meshes/mesh";
  49497. import { Texture } from "babylonjs/Materials/Textures/texture";
  49498. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49499. import "babylonjs/Meshes/Builders/sphereBuilder";
  49500. /**
  49501. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49502. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49503. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49504. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49505. */
  49506. export class PhotoDome extends TransformNode {
  49507. /**
  49508. * Define the image as a Monoscopic panoramic 360 image.
  49509. */
  49510. static readonly MODE_MONOSCOPIC: number;
  49511. /**
  49512. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49513. */
  49514. static readonly MODE_TOPBOTTOM: number;
  49515. /**
  49516. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49517. */
  49518. static readonly MODE_SIDEBYSIDE: number;
  49519. private _useDirectMapping;
  49520. /**
  49521. * The texture being displayed on the sphere
  49522. */
  49523. protected _photoTexture: Texture;
  49524. /**
  49525. * Gets or sets the texture being displayed on the sphere
  49526. */
  49527. photoTexture: Texture;
  49528. /**
  49529. * Observable raised when an error occured while loading the 360 image
  49530. */
  49531. onLoadErrorObservable: Observable<string>;
  49532. /**
  49533. * The skybox material
  49534. */
  49535. protected _material: BackgroundMaterial;
  49536. /**
  49537. * The surface used for the skybox
  49538. */
  49539. protected _mesh: Mesh;
  49540. /**
  49541. * Gets the mesh used for the skybox.
  49542. */
  49543. readonly mesh: Mesh;
  49544. /**
  49545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49546. * Also see the options.resolution property.
  49547. */
  49548. fovMultiplier: number;
  49549. private _imageMode;
  49550. /**
  49551. * Gets or set the current video mode for the video. It can be:
  49552. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49553. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49554. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49555. */
  49556. imageMode: number;
  49557. /**
  49558. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49559. * @param name Element's name, child elements will append suffixes for their own names.
  49560. * @param urlsOfPhoto defines the url of the photo to display
  49561. * @param options defines an object containing optional or exposed sub element properties
  49562. * @param onError defines a callback called when an error occured while loading the texture
  49563. */
  49564. constructor(name: string, urlOfPhoto: string, options: {
  49565. resolution?: number;
  49566. size?: number;
  49567. useDirectMapping?: boolean;
  49568. faceForward?: boolean;
  49569. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49570. private _onBeforeCameraRenderObserver;
  49571. private _changeImageMode;
  49572. /**
  49573. * Releases resources associated with this node.
  49574. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49575. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49576. */
  49577. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49578. }
  49579. }
  49580. declare module "babylonjs/Misc/rgbdTextureTools" {
  49581. import "babylonjs/Shaders/rgbdDecode.fragment";
  49582. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49583. import { Texture } from "babylonjs/Materials/Textures/texture";
  49584. /**
  49585. * Class used to host RGBD texture specific utilities
  49586. */
  49587. export class RGBDTextureTools {
  49588. /**
  49589. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49590. * @param texture the texture to expand.
  49591. */
  49592. static ExpandRGBDTexture(texture: Texture): void;
  49593. }
  49594. }
  49595. declare module "babylonjs/Misc/brdfTextureTools" {
  49596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49597. import { Scene } from "babylonjs/scene";
  49598. /**
  49599. * Class used to host texture specific utilities
  49600. */
  49601. export class BRDFTextureTools {
  49602. /**
  49603. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49604. * @param scene defines the hosting scene
  49605. * @returns the environment BRDF texture
  49606. */
  49607. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49608. private static _environmentBRDFBase64Texture;
  49609. }
  49610. }
  49611. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49612. import { Nullable } from "babylonjs/types";
  49613. import { Color3 } from "babylonjs/Maths/math.color";
  49614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49615. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49616. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49617. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49618. import { Engine } from "babylonjs/Engines/engine";
  49619. import { Scene } from "babylonjs/scene";
  49620. /**
  49621. * @hidden
  49622. */
  49623. export interface IMaterialClearCoatDefines {
  49624. CLEARCOAT: boolean;
  49625. CLEARCOAT_DEFAULTIOR: boolean;
  49626. CLEARCOAT_TEXTURE: boolean;
  49627. CLEARCOAT_TEXTUREDIRECTUV: number;
  49628. CLEARCOAT_BUMP: boolean;
  49629. CLEARCOAT_BUMPDIRECTUV: number;
  49630. CLEARCOAT_TINT: boolean;
  49631. CLEARCOAT_TINT_TEXTURE: boolean;
  49632. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49633. /** @hidden */
  49634. _areTexturesDirty: boolean;
  49635. }
  49636. /**
  49637. * Define the code related to the clear coat parameters of the pbr material.
  49638. */
  49639. export class PBRClearCoatConfiguration {
  49640. /**
  49641. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49642. * The default fits with a polyurethane material.
  49643. */
  49644. private static readonly _DefaultIndexOfRefraction;
  49645. private _isEnabled;
  49646. /**
  49647. * Defines if the clear coat is enabled in the material.
  49648. */
  49649. isEnabled: boolean;
  49650. /**
  49651. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49652. */
  49653. intensity: number;
  49654. /**
  49655. * Defines the clear coat layer roughness.
  49656. */
  49657. roughness: number;
  49658. private _indexOfRefraction;
  49659. /**
  49660. * Defines the index of refraction of the clear coat.
  49661. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49662. * The default fits with a polyurethane material.
  49663. * Changing the default value is more performance intensive.
  49664. */
  49665. indexOfRefraction: number;
  49666. private _texture;
  49667. /**
  49668. * Stores the clear coat values in a texture.
  49669. */
  49670. texture: Nullable<BaseTexture>;
  49671. private _bumpTexture;
  49672. /**
  49673. * Define the clear coat specific bump texture.
  49674. */
  49675. bumpTexture: Nullable<BaseTexture>;
  49676. private _isTintEnabled;
  49677. /**
  49678. * Defines if the clear coat tint is enabled in the material.
  49679. */
  49680. isTintEnabled: boolean;
  49681. /**
  49682. * Defines the clear coat tint of the material.
  49683. * This is only use if tint is enabled
  49684. */
  49685. tintColor: Color3;
  49686. /**
  49687. * Defines the distance at which the tint color should be found in the
  49688. * clear coat media.
  49689. * This is only use if tint is enabled
  49690. */
  49691. tintColorAtDistance: number;
  49692. /**
  49693. * Defines the clear coat layer thickness.
  49694. * This is only use if tint is enabled
  49695. */
  49696. tintThickness: number;
  49697. private _tintTexture;
  49698. /**
  49699. * Stores the clear tint values in a texture.
  49700. * rgb is tint
  49701. * a is a thickness factor
  49702. */
  49703. tintTexture: Nullable<BaseTexture>;
  49704. /** @hidden */
  49705. private _internalMarkAllSubMeshesAsTexturesDirty;
  49706. /** @hidden */
  49707. _markAllSubMeshesAsTexturesDirty(): void;
  49708. /**
  49709. * Instantiate a new istance of clear coat configuration.
  49710. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49711. */
  49712. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49713. /**
  49714. * Gets wehter the submesh is ready to be used or not.
  49715. * @param defines the list of "defines" to update.
  49716. * @param scene defines the scene the material belongs to.
  49717. * @param engine defines the engine the material belongs to.
  49718. * @param disableBumpMap defines wether the material disables bump or not.
  49719. * @returns - boolean indicating that the submesh is ready or not.
  49720. */
  49721. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49722. /**
  49723. * Checks to see if a texture is used in the material.
  49724. * @param defines the list of "defines" to update.
  49725. * @param scene defines the scene to the material belongs to.
  49726. */
  49727. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49728. /**
  49729. * Binds the material data.
  49730. * @param uniformBuffer defines the Uniform buffer to fill in.
  49731. * @param scene defines the scene the material belongs to.
  49732. * @param engine defines the engine the material belongs to.
  49733. * @param disableBumpMap defines wether the material disables bump or not.
  49734. * @param isFrozen defines wether the material is frozen or not.
  49735. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49736. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49737. */
  49738. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49739. /**
  49740. * Checks to see if a texture is used in the material.
  49741. * @param texture - Base texture to use.
  49742. * @returns - Boolean specifying if a texture is used in the material.
  49743. */
  49744. hasTexture(texture: BaseTexture): boolean;
  49745. /**
  49746. * Returns an array of the actively used textures.
  49747. * @param activeTextures Array of BaseTextures
  49748. */
  49749. getActiveTextures(activeTextures: BaseTexture[]): void;
  49750. /**
  49751. * Returns the animatable textures.
  49752. * @param animatables Array of animatable textures.
  49753. */
  49754. getAnimatables(animatables: IAnimatable[]): void;
  49755. /**
  49756. * Disposes the resources of the material.
  49757. * @param forceDisposeTextures - Forces the disposal of all textures.
  49758. */
  49759. dispose(forceDisposeTextures?: boolean): void;
  49760. /**
  49761. * Get the current class name of the texture useful for serialization or dynamic coding.
  49762. * @returns "PBRClearCoatConfiguration"
  49763. */
  49764. getClassName(): string;
  49765. /**
  49766. * Add fallbacks to the effect fallbacks list.
  49767. * @param defines defines the Base texture to use.
  49768. * @param fallbacks defines the current fallback list.
  49769. * @param currentRank defines the current fallback rank.
  49770. * @returns the new fallback rank.
  49771. */
  49772. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49773. /**
  49774. * Add the required uniforms to the current list.
  49775. * @param uniforms defines the current uniform list.
  49776. */
  49777. static AddUniforms(uniforms: string[]): void;
  49778. /**
  49779. * Add the required samplers to the current list.
  49780. * @param samplers defines the current sampler list.
  49781. */
  49782. static AddSamplers(samplers: string[]): void;
  49783. /**
  49784. * Add the required uniforms to the current buffer.
  49785. * @param uniformBuffer defines the current uniform buffer.
  49786. */
  49787. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49788. /**
  49789. * Makes a duplicate of the current configuration into another one.
  49790. * @param clearCoatConfiguration define the config where to copy the info
  49791. */
  49792. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49793. /**
  49794. * Serializes this clear coat configuration.
  49795. * @returns - An object with the serialized config.
  49796. */
  49797. serialize(): any;
  49798. /**
  49799. * Parses a anisotropy Configuration from a serialized object.
  49800. * @param source - Serialized object.
  49801. * @param scene Defines the scene we are parsing for
  49802. * @param rootUrl Defines the rootUrl to load from
  49803. */
  49804. parse(source: any, scene: Scene, rootUrl: string): void;
  49805. }
  49806. }
  49807. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49808. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49810. import { Vector2 } from "babylonjs/Maths/math.vector";
  49811. import { Scene } from "babylonjs/scene";
  49812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49813. import { Nullable } from "babylonjs/types";
  49814. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49815. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49816. /**
  49817. * @hidden
  49818. */
  49819. export interface IMaterialAnisotropicDefines {
  49820. ANISOTROPIC: boolean;
  49821. ANISOTROPIC_TEXTURE: boolean;
  49822. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49823. MAINUV1: boolean;
  49824. _areTexturesDirty: boolean;
  49825. _needUVs: boolean;
  49826. }
  49827. /**
  49828. * Define the code related to the anisotropic parameters of the pbr material.
  49829. */
  49830. export class PBRAnisotropicConfiguration {
  49831. private _isEnabled;
  49832. /**
  49833. * Defines if the anisotropy is enabled in the material.
  49834. */
  49835. isEnabled: boolean;
  49836. /**
  49837. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49838. */
  49839. intensity: number;
  49840. /**
  49841. * Defines if the effect is along the tangents, bitangents or in between.
  49842. * By default, the effect is "strectching" the highlights along the tangents.
  49843. */
  49844. direction: Vector2;
  49845. private _texture;
  49846. /**
  49847. * Stores the anisotropy values in a texture.
  49848. * rg is direction (like normal from -1 to 1)
  49849. * b is a intensity
  49850. */
  49851. texture: Nullable<BaseTexture>;
  49852. /** @hidden */
  49853. private _internalMarkAllSubMeshesAsTexturesDirty;
  49854. /** @hidden */
  49855. _markAllSubMeshesAsTexturesDirty(): void;
  49856. /**
  49857. * Instantiate a new istance of anisotropy configuration.
  49858. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49859. */
  49860. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49861. /**
  49862. * Specifies that the submesh is ready to be used.
  49863. * @param defines the list of "defines" to update.
  49864. * @param scene defines the scene the material belongs to.
  49865. * @returns - boolean indicating that the submesh is ready or not.
  49866. */
  49867. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49868. /**
  49869. * Checks to see if a texture is used in the material.
  49870. * @param defines the list of "defines" to update.
  49871. * @param mesh the mesh we are preparing the defines for.
  49872. * @param scene defines the scene the material belongs to.
  49873. */
  49874. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49875. /**
  49876. * Binds the material data.
  49877. * @param uniformBuffer defines the Uniform buffer to fill in.
  49878. * @param scene defines the scene the material belongs to.
  49879. * @param isFrozen defines wether the material is frozen or not.
  49880. */
  49881. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49882. /**
  49883. * Checks to see if a texture is used in the material.
  49884. * @param texture - Base texture to use.
  49885. * @returns - Boolean specifying if a texture is used in the material.
  49886. */
  49887. hasTexture(texture: BaseTexture): boolean;
  49888. /**
  49889. * Returns an array of the actively used textures.
  49890. * @param activeTextures Array of BaseTextures
  49891. */
  49892. getActiveTextures(activeTextures: BaseTexture[]): void;
  49893. /**
  49894. * Returns the animatable textures.
  49895. * @param animatables Array of animatable textures.
  49896. */
  49897. getAnimatables(animatables: IAnimatable[]): void;
  49898. /**
  49899. * Disposes the resources of the material.
  49900. * @param forceDisposeTextures - Forces the disposal of all textures.
  49901. */
  49902. dispose(forceDisposeTextures?: boolean): void;
  49903. /**
  49904. * Get the current class name of the texture useful for serialization or dynamic coding.
  49905. * @returns "PBRAnisotropicConfiguration"
  49906. */
  49907. getClassName(): string;
  49908. /**
  49909. * Add fallbacks to the effect fallbacks list.
  49910. * @param defines defines the Base texture to use.
  49911. * @param fallbacks defines the current fallback list.
  49912. * @param currentRank defines the current fallback rank.
  49913. * @returns the new fallback rank.
  49914. */
  49915. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49916. /**
  49917. * Add the required uniforms to the current list.
  49918. * @param uniforms defines the current uniform list.
  49919. */
  49920. static AddUniforms(uniforms: string[]): void;
  49921. /**
  49922. * Add the required uniforms to the current buffer.
  49923. * @param uniformBuffer defines the current uniform buffer.
  49924. */
  49925. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49926. /**
  49927. * Add the required samplers to the current list.
  49928. * @param samplers defines the current sampler list.
  49929. */
  49930. static AddSamplers(samplers: string[]): void;
  49931. /**
  49932. * Makes a duplicate of the current configuration into another one.
  49933. * @param anisotropicConfiguration define the config where to copy the info
  49934. */
  49935. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49936. /**
  49937. * Serializes this anisotropy configuration.
  49938. * @returns - An object with the serialized config.
  49939. */
  49940. serialize(): any;
  49941. /**
  49942. * Parses a anisotropy Configuration from a serialized object.
  49943. * @param source - Serialized object.
  49944. * @param scene Defines the scene we are parsing for
  49945. * @param rootUrl Defines the rootUrl to load from
  49946. */
  49947. parse(source: any, scene: Scene, rootUrl: string): void;
  49948. }
  49949. }
  49950. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49951. import { Scene } from "babylonjs/scene";
  49952. /**
  49953. * @hidden
  49954. */
  49955. export interface IMaterialBRDFDefines {
  49956. BRDF_V_HEIGHT_CORRELATED: boolean;
  49957. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49958. SPHERICAL_HARMONICS: boolean;
  49959. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49960. /** @hidden */
  49961. _areMiscDirty: boolean;
  49962. }
  49963. /**
  49964. * Define the code related to the BRDF parameters of the pbr material.
  49965. */
  49966. export class PBRBRDFConfiguration {
  49967. /**
  49968. * Default value used for the energy conservation.
  49969. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49970. */
  49971. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49972. /**
  49973. * Default value used for the Smith Visibility Height Correlated mode.
  49974. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49975. */
  49976. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49977. /**
  49978. * Default value used for the IBL diffuse part.
  49979. * This can help switching back to the polynomials mode globally which is a tiny bit
  49980. * less GPU intensive at the drawback of a lower quality.
  49981. */
  49982. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49983. /**
  49984. * Default value used for activating energy conservation for the specular workflow.
  49985. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49986. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49987. */
  49988. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49989. private _useEnergyConservation;
  49990. /**
  49991. * Defines if the material uses energy conservation.
  49992. */
  49993. useEnergyConservation: boolean;
  49994. private _useSmithVisibilityHeightCorrelated;
  49995. /**
  49996. * LEGACY Mode set to false
  49997. * Defines if the material uses height smith correlated visibility term.
  49998. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49999. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50000. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50001. * Not relying on height correlated will also disable energy conservation.
  50002. */
  50003. useSmithVisibilityHeightCorrelated: boolean;
  50004. private _useSphericalHarmonics;
  50005. /**
  50006. * LEGACY Mode set to false
  50007. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50008. * diffuse part of the IBL.
  50009. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50010. * to the ground truth.
  50011. */
  50012. useSphericalHarmonics: boolean;
  50013. private _useSpecularGlossinessInputEnergyConservation;
  50014. /**
  50015. * Defines if the material uses energy conservation, when the specular workflow is active.
  50016. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50017. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50018. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50019. */
  50020. useSpecularGlossinessInputEnergyConservation: boolean;
  50021. /** @hidden */
  50022. private _internalMarkAllSubMeshesAsMiscDirty;
  50023. /** @hidden */
  50024. _markAllSubMeshesAsMiscDirty(): void;
  50025. /**
  50026. * Instantiate a new istance of clear coat configuration.
  50027. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50028. */
  50029. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50030. /**
  50031. * Checks to see if a texture is used in the material.
  50032. * @param defines the list of "defines" to update.
  50033. */
  50034. prepareDefines(defines: IMaterialBRDFDefines): void;
  50035. /**
  50036. * Get the current class name of the texture useful for serialization or dynamic coding.
  50037. * @returns "PBRClearCoatConfiguration"
  50038. */
  50039. getClassName(): string;
  50040. /**
  50041. * Makes a duplicate of the current configuration into another one.
  50042. * @param brdfConfiguration define the config where to copy the info
  50043. */
  50044. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50045. /**
  50046. * Serializes this BRDF configuration.
  50047. * @returns - An object with the serialized config.
  50048. */
  50049. serialize(): any;
  50050. /**
  50051. * Parses a anisotropy Configuration from a serialized object.
  50052. * @param source - Serialized object.
  50053. * @param scene Defines the scene we are parsing for
  50054. * @param rootUrl Defines the rootUrl to load from
  50055. */
  50056. parse(source: any, scene: Scene, rootUrl: string): void;
  50057. }
  50058. }
  50059. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50060. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50061. import { Color3 } from "babylonjs/Maths/math.color";
  50062. import { Scene } from "babylonjs/scene";
  50063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50064. import { Nullable } from "babylonjs/types";
  50065. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50066. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50067. /**
  50068. * @hidden
  50069. */
  50070. export interface IMaterialSheenDefines {
  50071. SHEEN: boolean;
  50072. SHEEN_TEXTURE: boolean;
  50073. SHEEN_TEXTUREDIRECTUV: number;
  50074. SHEEN_LINKWITHALBEDO: boolean;
  50075. /** @hidden */
  50076. _areTexturesDirty: boolean;
  50077. }
  50078. /**
  50079. * Define the code related to the Sheen parameters of the pbr material.
  50080. */
  50081. export class PBRSheenConfiguration {
  50082. private _isEnabled;
  50083. /**
  50084. * Defines if the material uses sheen.
  50085. */
  50086. isEnabled: boolean;
  50087. private _linkSheenWithAlbedo;
  50088. /**
  50089. * Defines if the sheen is linked to the sheen color.
  50090. */
  50091. linkSheenWithAlbedo: boolean;
  50092. /**
  50093. * Defines the sheen intensity.
  50094. */
  50095. intensity: number;
  50096. /**
  50097. * Defines the sheen color.
  50098. */
  50099. color: Color3;
  50100. private _texture;
  50101. /**
  50102. * Stores the sheen tint values in a texture.
  50103. * rgb is tint
  50104. * a is a intensity
  50105. */
  50106. texture: Nullable<BaseTexture>;
  50107. /** @hidden */
  50108. private _internalMarkAllSubMeshesAsTexturesDirty;
  50109. /** @hidden */
  50110. _markAllSubMeshesAsTexturesDirty(): void;
  50111. /**
  50112. * Instantiate a new istance of clear coat configuration.
  50113. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50114. */
  50115. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50116. /**
  50117. * Specifies that the submesh is ready to be used.
  50118. * @param defines the list of "defines" to update.
  50119. * @param scene defines the scene the material belongs to.
  50120. * @returns - boolean indicating that the submesh is ready or not.
  50121. */
  50122. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50123. /**
  50124. * Checks to see if a texture is used in the material.
  50125. * @param defines the list of "defines" to update.
  50126. * @param scene defines the scene the material belongs to.
  50127. */
  50128. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50129. /**
  50130. * Binds the material data.
  50131. * @param uniformBuffer defines the Uniform buffer to fill in.
  50132. * @param scene defines the scene the material belongs to.
  50133. * @param isFrozen defines wether the material is frozen or not.
  50134. */
  50135. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50136. /**
  50137. * Checks to see if a texture is used in the material.
  50138. * @param texture - Base texture to use.
  50139. * @returns - Boolean specifying if a texture is used in the material.
  50140. */
  50141. hasTexture(texture: BaseTexture): boolean;
  50142. /**
  50143. * Returns an array of the actively used textures.
  50144. * @param activeTextures Array of BaseTextures
  50145. */
  50146. getActiveTextures(activeTextures: BaseTexture[]): void;
  50147. /**
  50148. * Returns the animatable textures.
  50149. * @param animatables Array of animatable textures.
  50150. */
  50151. getAnimatables(animatables: IAnimatable[]): void;
  50152. /**
  50153. * Disposes the resources of the material.
  50154. * @param forceDisposeTextures - Forces the disposal of all textures.
  50155. */
  50156. dispose(forceDisposeTextures?: boolean): void;
  50157. /**
  50158. * Get the current class name of the texture useful for serialization or dynamic coding.
  50159. * @returns "PBRSheenConfiguration"
  50160. */
  50161. getClassName(): string;
  50162. /**
  50163. * Add fallbacks to the effect fallbacks list.
  50164. * @param defines defines the Base texture to use.
  50165. * @param fallbacks defines the current fallback list.
  50166. * @param currentRank defines the current fallback rank.
  50167. * @returns the new fallback rank.
  50168. */
  50169. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50170. /**
  50171. * Add the required uniforms to the current list.
  50172. * @param uniforms defines the current uniform list.
  50173. */
  50174. static AddUniforms(uniforms: string[]): void;
  50175. /**
  50176. * Add the required uniforms to the current buffer.
  50177. * @param uniformBuffer defines the current uniform buffer.
  50178. */
  50179. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50180. /**
  50181. * Add the required samplers to the current list.
  50182. * @param samplers defines the current sampler list.
  50183. */
  50184. static AddSamplers(samplers: string[]): void;
  50185. /**
  50186. * Makes a duplicate of the current configuration into another one.
  50187. * @param sheenConfiguration define the config where to copy the info
  50188. */
  50189. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50190. /**
  50191. * Serializes this BRDF configuration.
  50192. * @returns - An object with the serialized config.
  50193. */
  50194. serialize(): any;
  50195. /**
  50196. * Parses a anisotropy Configuration from a serialized object.
  50197. * @param source - Serialized object.
  50198. * @param scene Defines the scene we are parsing for
  50199. * @param rootUrl Defines the rootUrl to load from
  50200. */
  50201. parse(source: any, scene: Scene, rootUrl: string): void;
  50202. }
  50203. }
  50204. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50205. import { Nullable } from "babylonjs/types";
  50206. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50207. import { Color3 } from "babylonjs/Maths/math.color";
  50208. import { SmartArray } from "babylonjs/Misc/smartArray";
  50209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50210. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50211. import { Effect } from "babylonjs/Materials/effect";
  50212. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50213. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50214. import { Engine } from "babylonjs/Engines/engine";
  50215. import { Scene } from "babylonjs/scene";
  50216. /**
  50217. * @hidden
  50218. */
  50219. export interface IMaterialSubSurfaceDefines {
  50220. SUBSURFACE: boolean;
  50221. SS_REFRACTION: boolean;
  50222. SS_TRANSLUCENCY: boolean;
  50223. SS_SCATERRING: boolean;
  50224. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50225. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50226. SS_REFRACTIONMAP_3D: boolean;
  50227. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50228. SS_LODINREFRACTIONALPHA: boolean;
  50229. SS_GAMMAREFRACTION: boolean;
  50230. SS_RGBDREFRACTION: boolean;
  50231. SS_LINEARSPECULARREFRACTION: boolean;
  50232. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50233. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50234. /** @hidden */
  50235. _areTexturesDirty: boolean;
  50236. }
  50237. /**
  50238. * Define the code related to the sub surface parameters of the pbr material.
  50239. */
  50240. export class PBRSubSurfaceConfiguration {
  50241. private _isRefractionEnabled;
  50242. /**
  50243. * Defines if the refraction is enabled in the material.
  50244. */
  50245. isRefractionEnabled: boolean;
  50246. private _isTranslucencyEnabled;
  50247. /**
  50248. * Defines if the translucency is enabled in the material.
  50249. */
  50250. isTranslucencyEnabled: boolean;
  50251. private _isScatteringEnabled;
  50252. /**
  50253. * Defines the refraction intensity of the material.
  50254. * The refraction when enabled replaces the Diffuse part of the material.
  50255. * The intensity helps transitionning between diffuse and refraction.
  50256. */
  50257. refractionIntensity: number;
  50258. /**
  50259. * Defines the translucency intensity of the material.
  50260. * When translucency has been enabled, this defines how much of the "translucency"
  50261. * is addded to the diffuse part of the material.
  50262. */
  50263. translucencyIntensity: number;
  50264. /**
  50265. * Defines the scattering intensity of the material.
  50266. * When scattering has been enabled, this defines how much of the "scattered light"
  50267. * is addded to the diffuse part of the material.
  50268. */
  50269. scatteringIntensity: number;
  50270. private _thicknessTexture;
  50271. /**
  50272. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50273. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50274. * 0 would mean minimumThickness
  50275. * 1 would mean maximumThickness
  50276. * The other channels might be use as a mask to vary the different effects intensity.
  50277. */
  50278. thicknessTexture: Nullable<BaseTexture>;
  50279. private _refractionTexture;
  50280. /**
  50281. * Defines the texture to use for refraction.
  50282. */
  50283. refractionTexture: Nullable<BaseTexture>;
  50284. private _indexOfRefraction;
  50285. /**
  50286. * Defines the index of refraction used in the material.
  50287. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50288. */
  50289. indexOfRefraction: number;
  50290. private _invertRefractionY;
  50291. /**
  50292. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50293. */
  50294. invertRefractionY: boolean;
  50295. private _linkRefractionWithTransparency;
  50296. /**
  50297. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50298. * Materials half opaque for instance using refraction could benefit from this control.
  50299. */
  50300. linkRefractionWithTransparency: boolean;
  50301. /**
  50302. * Defines the minimum thickness stored in the thickness map.
  50303. * If no thickness map is defined, this value will be used to simulate thickness.
  50304. */
  50305. minimumThickness: number;
  50306. /**
  50307. * Defines the maximum thickness stored in the thickness map.
  50308. */
  50309. maximumThickness: number;
  50310. /**
  50311. * Defines the volume tint of the material.
  50312. * This is used for both translucency and scattering.
  50313. */
  50314. tintColor: Color3;
  50315. /**
  50316. * Defines the distance at which the tint color should be found in the media.
  50317. * This is used for refraction only.
  50318. */
  50319. tintColorAtDistance: number;
  50320. /**
  50321. * Defines how far each channel transmit through the media.
  50322. * It is defined as a color to simplify it selection.
  50323. */
  50324. diffusionDistance: Color3;
  50325. private _useMaskFromThicknessTexture;
  50326. /**
  50327. * Stores the intensity of the different subsurface effects in the thickness texture.
  50328. * * the green channel is the translucency intensity.
  50329. * * the blue channel is the scattering intensity.
  50330. * * the alpha channel is the refraction intensity.
  50331. */
  50332. useMaskFromThicknessTexture: boolean;
  50333. /** @hidden */
  50334. private _internalMarkAllSubMeshesAsTexturesDirty;
  50335. /** @hidden */
  50336. _markAllSubMeshesAsTexturesDirty(): void;
  50337. /**
  50338. * Instantiate a new istance of sub surface configuration.
  50339. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50340. */
  50341. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50342. /**
  50343. * Gets wehter the submesh is ready to be used or not.
  50344. * @param defines the list of "defines" to update.
  50345. * @param scene defines the scene the material belongs to.
  50346. * @returns - boolean indicating that the submesh is ready or not.
  50347. */
  50348. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50349. /**
  50350. * Checks to see if a texture is used in the material.
  50351. * @param defines the list of "defines" to update.
  50352. * @param scene defines the scene to the material belongs to.
  50353. */
  50354. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50355. /**
  50356. * Binds the material data.
  50357. * @param uniformBuffer defines the Uniform buffer to fill in.
  50358. * @param scene defines the scene the material belongs to.
  50359. * @param engine defines the engine the material belongs to.
  50360. * @param isFrozen defines wether the material is frozen or not.
  50361. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50362. */
  50363. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50364. /**
  50365. * Unbinds the material from the mesh.
  50366. * @param activeEffect defines the effect that should be unbound from.
  50367. * @returns true if unbound, otherwise false
  50368. */
  50369. unbind(activeEffect: Effect): boolean;
  50370. /**
  50371. * Returns the texture used for refraction or null if none is used.
  50372. * @param scene defines the scene the material belongs to.
  50373. * @returns - Refraction texture if present. If no refraction texture and refraction
  50374. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50375. */
  50376. private _getRefractionTexture;
  50377. /**
  50378. * Returns true if alpha blending should be disabled.
  50379. */
  50380. readonly disableAlphaBlending: boolean;
  50381. /**
  50382. * Fills the list of render target textures.
  50383. * @param renderTargets the list of render targets to update
  50384. */
  50385. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50386. /**
  50387. * Checks to see if a texture is used in the material.
  50388. * @param texture - Base texture to use.
  50389. * @returns - Boolean specifying if a texture is used in the material.
  50390. */
  50391. hasTexture(texture: BaseTexture): boolean;
  50392. /**
  50393. * Gets a boolean indicating that current material needs to register RTT
  50394. * @returns true if this uses a render target otherwise false.
  50395. */
  50396. hasRenderTargetTextures(): boolean;
  50397. /**
  50398. * Returns an array of the actively used textures.
  50399. * @param activeTextures Array of BaseTextures
  50400. */
  50401. getActiveTextures(activeTextures: BaseTexture[]): void;
  50402. /**
  50403. * Returns the animatable textures.
  50404. * @param animatables Array of animatable textures.
  50405. */
  50406. getAnimatables(animatables: IAnimatable[]): void;
  50407. /**
  50408. * Disposes the resources of the material.
  50409. * @param forceDisposeTextures - Forces the disposal of all textures.
  50410. */
  50411. dispose(forceDisposeTextures?: boolean): void;
  50412. /**
  50413. * Get the current class name of the texture useful for serialization or dynamic coding.
  50414. * @returns "PBRSubSurfaceConfiguration"
  50415. */
  50416. getClassName(): string;
  50417. /**
  50418. * Add fallbacks to the effect fallbacks list.
  50419. * @param defines defines the Base texture to use.
  50420. * @param fallbacks defines the current fallback list.
  50421. * @param currentRank defines the current fallback rank.
  50422. * @returns the new fallback rank.
  50423. */
  50424. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50425. /**
  50426. * Add the required uniforms to the current list.
  50427. * @param uniforms defines the current uniform list.
  50428. */
  50429. static AddUniforms(uniforms: string[]): void;
  50430. /**
  50431. * Add the required samplers to the current list.
  50432. * @param samplers defines the current sampler list.
  50433. */
  50434. static AddSamplers(samplers: string[]): void;
  50435. /**
  50436. * Add the required uniforms to the current buffer.
  50437. * @param uniformBuffer defines the current uniform buffer.
  50438. */
  50439. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50440. /**
  50441. * Makes a duplicate of the current configuration into another one.
  50442. * @param configuration define the config where to copy the info
  50443. */
  50444. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50445. /**
  50446. * Serializes this Sub Surface configuration.
  50447. * @returns - An object with the serialized config.
  50448. */
  50449. serialize(): any;
  50450. /**
  50451. * Parses a anisotropy Configuration from a serialized object.
  50452. * @param source - Serialized object.
  50453. * @param scene Defines the scene we are parsing for
  50454. * @param rootUrl Defines the rootUrl to load from
  50455. */
  50456. parse(source: any, scene: Scene, rootUrl: string): void;
  50457. }
  50458. }
  50459. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50460. /** @hidden */
  50461. export var pbrFragmentDeclaration: {
  50462. name: string;
  50463. shader: string;
  50464. };
  50465. }
  50466. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50467. /** @hidden */
  50468. export var pbrUboDeclaration: {
  50469. name: string;
  50470. shader: string;
  50471. };
  50472. }
  50473. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50474. /** @hidden */
  50475. export var pbrFragmentExtraDeclaration: {
  50476. name: string;
  50477. shader: string;
  50478. };
  50479. }
  50480. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50481. /** @hidden */
  50482. export var pbrFragmentSamplersDeclaration: {
  50483. name: string;
  50484. shader: string;
  50485. };
  50486. }
  50487. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50488. /** @hidden */
  50489. export var pbrHelperFunctions: {
  50490. name: string;
  50491. shader: string;
  50492. };
  50493. }
  50494. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50495. /** @hidden */
  50496. export var harmonicsFunctions: {
  50497. name: string;
  50498. shader: string;
  50499. };
  50500. }
  50501. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50502. /** @hidden */
  50503. export var pbrDirectLightingSetupFunctions: {
  50504. name: string;
  50505. shader: string;
  50506. };
  50507. }
  50508. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50509. /** @hidden */
  50510. export var pbrDirectLightingFalloffFunctions: {
  50511. name: string;
  50512. shader: string;
  50513. };
  50514. }
  50515. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50516. /** @hidden */
  50517. export var pbrBRDFFunctions: {
  50518. name: string;
  50519. shader: string;
  50520. };
  50521. }
  50522. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50523. /** @hidden */
  50524. export var pbrDirectLightingFunctions: {
  50525. name: string;
  50526. shader: string;
  50527. };
  50528. }
  50529. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50530. /** @hidden */
  50531. export var pbrIBLFunctions: {
  50532. name: string;
  50533. shader: string;
  50534. };
  50535. }
  50536. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50537. /** @hidden */
  50538. export var pbrDebug: {
  50539. name: string;
  50540. shader: string;
  50541. };
  50542. }
  50543. declare module "babylonjs/Shaders/pbr.fragment" {
  50544. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50545. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50546. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50547. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50548. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50549. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50550. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50551. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50552. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50553. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50554. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50555. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50556. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50557. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50558. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50559. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50560. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50561. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50562. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50563. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50564. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50565. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50567. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50568. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50569. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50570. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50571. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50572. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50573. /** @hidden */
  50574. export var pbrPixelShader: {
  50575. name: string;
  50576. shader: string;
  50577. };
  50578. }
  50579. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50580. /** @hidden */
  50581. export var pbrVertexDeclaration: {
  50582. name: string;
  50583. shader: string;
  50584. };
  50585. }
  50586. declare module "babylonjs/Shaders/pbr.vertex" {
  50587. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50588. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50589. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50590. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50591. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50592. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50593. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50594. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50595. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50596. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50597. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50598. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50599. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50600. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50601. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50602. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50603. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50604. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50605. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50606. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50607. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50608. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50609. /** @hidden */
  50610. export var pbrVertexShader: {
  50611. name: string;
  50612. shader: string;
  50613. };
  50614. }
  50615. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50616. import { Nullable } from "babylonjs/types";
  50617. import { Scene } from "babylonjs/scene";
  50618. import { Matrix } from "babylonjs/Maths/math.vector";
  50619. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50621. import { Mesh } from "babylonjs/Meshes/mesh";
  50622. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50623. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50624. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50625. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50626. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50627. import { Color3 } from "babylonjs/Maths/math.color";
  50628. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50629. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50630. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50631. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50633. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50634. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50635. import "babylonjs/Shaders/pbr.fragment";
  50636. import "babylonjs/Shaders/pbr.vertex";
  50637. /**
  50638. * Manages the defines for the PBR Material.
  50639. * @hidden
  50640. */
  50641. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50642. PBR: boolean;
  50643. MAINUV1: boolean;
  50644. MAINUV2: boolean;
  50645. UV1: boolean;
  50646. UV2: boolean;
  50647. ALBEDO: boolean;
  50648. ALBEDODIRECTUV: number;
  50649. VERTEXCOLOR: boolean;
  50650. AMBIENT: boolean;
  50651. AMBIENTDIRECTUV: number;
  50652. AMBIENTINGRAYSCALE: boolean;
  50653. OPACITY: boolean;
  50654. VERTEXALPHA: boolean;
  50655. OPACITYDIRECTUV: number;
  50656. OPACITYRGB: boolean;
  50657. ALPHATEST: boolean;
  50658. DEPTHPREPASS: boolean;
  50659. ALPHABLEND: boolean;
  50660. ALPHAFROMALBEDO: boolean;
  50661. ALPHATESTVALUE: string;
  50662. SPECULAROVERALPHA: boolean;
  50663. RADIANCEOVERALPHA: boolean;
  50664. ALPHAFRESNEL: boolean;
  50665. LINEARALPHAFRESNEL: boolean;
  50666. PREMULTIPLYALPHA: boolean;
  50667. EMISSIVE: boolean;
  50668. EMISSIVEDIRECTUV: number;
  50669. REFLECTIVITY: boolean;
  50670. REFLECTIVITYDIRECTUV: number;
  50671. SPECULARTERM: boolean;
  50672. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50673. MICROSURFACEAUTOMATIC: boolean;
  50674. LODBASEDMICROSFURACE: boolean;
  50675. MICROSURFACEMAP: boolean;
  50676. MICROSURFACEMAPDIRECTUV: number;
  50677. METALLICWORKFLOW: boolean;
  50678. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50679. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50680. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50681. AOSTOREINMETALMAPRED: boolean;
  50682. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50683. ENVIRONMENTBRDF: boolean;
  50684. ENVIRONMENTBRDF_RGBD: boolean;
  50685. NORMAL: boolean;
  50686. TANGENT: boolean;
  50687. BUMP: boolean;
  50688. BUMPDIRECTUV: number;
  50689. OBJECTSPACE_NORMALMAP: boolean;
  50690. PARALLAX: boolean;
  50691. PARALLAXOCCLUSION: boolean;
  50692. NORMALXYSCALE: boolean;
  50693. LIGHTMAP: boolean;
  50694. LIGHTMAPDIRECTUV: number;
  50695. USELIGHTMAPASSHADOWMAP: boolean;
  50696. GAMMALIGHTMAP: boolean;
  50697. RGBDLIGHTMAP: boolean;
  50698. REFLECTION: boolean;
  50699. REFLECTIONMAP_3D: boolean;
  50700. REFLECTIONMAP_SPHERICAL: boolean;
  50701. REFLECTIONMAP_PLANAR: boolean;
  50702. REFLECTIONMAP_CUBIC: boolean;
  50703. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50704. REFLECTIONMAP_PROJECTION: boolean;
  50705. REFLECTIONMAP_SKYBOX: boolean;
  50706. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50707. REFLECTIONMAP_EXPLICIT: boolean;
  50708. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50709. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50710. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50711. INVERTCUBICMAP: boolean;
  50712. USESPHERICALFROMREFLECTIONMAP: boolean;
  50713. USEIRRADIANCEMAP: boolean;
  50714. SPHERICAL_HARMONICS: boolean;
  50715. USESPHERICALINVERTEX: boolean;
  50716. REFLECTIONMAP_OPPOSITEZ: boolean;
  50717. LODINREFLECTIONALPHA: boolean;
  50718. GAMMAREFLECTION: boolean;
  50719. RGBDREFLECTION: boolean;
  50720. LINEARSPECULARREFLECTION: boolean;
  50721. RADIANCEOCCLUSION: boolean;
  50722. HORIZONOCCLUSION: boolean;
  50723. INSTANCES: boolean;
  50724. NUM_BONE_INFLUENCERS: number;
  50725. BonesPerMesh: number;
  50726. BONETEXTURE: boolean;
  50727. NONUNIFORMSCALING: boolean;
  50728. MORPHTARGETS: boolean;
  50729. MORPHTARGETS_NORMAL: boolean;
  50730. MORPHTARGETS_TANGENT: boolean;
  50731. MORPHTARGETS_UV: boolean;
  50732. NUM_MORPH_INFLUENCERS: number;
  50733. IMAGEPROCESSING: boolean;
  50734. VIGNETTE: boolean;
  50735. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50736. VIGNETTEBLENDMODEOPAQUE: boolean;
  50737. TONEMAPPING: boolean;
  50738. TONEMAPPING_ACES: boolean;
  50739. CONTRAST: boolean;
  50740. COLORCURVES: boolean;
  50741. COLORGRADING: boolean;
  50742. COLORGRADING3D: boolean;
  50743. SAMPLER3DGREENDEPTH: boolean;
  50744. SAMPLER3DBGRMAP: boolean;
  50745. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50746. EXPOSURE: boolean;
  50747. MULTIVIEW: boolean;
  50748. USEPHYSICALLIGHTFALLOFF: boolean;
  50749. USEGLTFLIGHTFALLOFF: boolean;
  50750. TWOSIDEDLIGHTING: boolean;
  50751. SHADOWFLOAT: boolean;
  50752. CLIPPLANE: boolean;
  50753. CLIPPLANE2: boolean;
  50754. CLIPPLANE3: boolean;
  50755. CLIPPLANE4: boolean;
  50756. POINTSIZE: boolean;
  50757. FOG: boolean;
  50758. LOGARITHMICDEPTH: boolean;
  50759. FORCENORMALFORWARD: boolean;
  50760. SPECULARAA: boolean;
  50761. CLEARCOAT: boolean;
  50762. CLEARCOAT_DEFAULTIOR: boolean;
  50763. CLEARCOAT_TEXTURE: boolean;
  50764. CLEARCOAT_TEXTUREDIRECTUV: number;
  50765. CLEARCOAT_BUMP: boolean;
  50766. CLEARCOAT_BUMPDIRECTUV: number;
  50767. CLEARCOAT_TINT: boolean;
  50768. CLEARCOAT_TINT_TEXTURE: boolean;
  50769. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50770. ANISOTROPIC: boolean;
  50771. ANISOTROPIC_TEXTURE: boolean;
  50772. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50773. BRDF_V_HEIGHT_CORRELATED: boolean;
  50774. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50775. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50776. SHEEN: boolean;
  50777. SHEEN_TEXTURE: boolean;
  50778. SHEEN_TEXTUREDIRECTUV: number;
  50779. SHEEN_LINKWITHALBEDO: boolean;
  50780. SUBSURFACE: boolean;
  50781. SS_REFRACTION: boolean;
  50782. SS_TRANSLUCENCY: boolean;
  50783. SS_SCATERRING: boolean;
  50784. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50785. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50786. SS_REFRACTIONMAP_3D: boolean;
  50787. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50788. SS_LODINREFRACTIONALPHA: boolean;
  50789. SS_GAMMAREFRACTION: boolean;
  50790. SS_RGBDREFRACTION: boolean;
  50791. SS_LINEARSPECULARREFRACTION: boolean;
  50792. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50793. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50794. UNLIT: boolean;
  50795. DEBUGMODE: number;
  50796. /**
  50797. * Initializes the PBR Material defines.
  50798. */
  50799. constructor();
  50800. /**
  50801. * Resets the PBR Material defines.
  50802. */
  50803. reset(): void;
  50804. }
  50805. /**
  50806. * The Physically based material base class of BJS.
  50807. *
  50808. * This offers the main features of a standard PBR material.
  50809. * For more information, please refer to the documentation :
  50810. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50811. */
  50812. export abstract class PBRBaseMaterial extends PushMaterial {
  50813. /**
  50814. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50815. */
  50816. static readonly PBRMATERIAL_OPAQUE: number;
  50817. /**
  50818. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50819. */
  50820. static readonly PBRMATERIAL_ALPHATEST: number;
  50821. /**
  50822. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50823. */
  50824. static readonly PBRMATERIAL_ALPHABLEND: number;
  50825. /**
  50826. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50827. * They are also discarded below the alpha cutoff threshold to improve performances.
  50828. */
  50829. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50830. /**
  50831. * Defines the default value of how much AO map is occluding the analytical lights
  50832. * (point spot...).
  50833. */
  50834. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50835. /**
  50836. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50837. */
  50838. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50839. /**
  50840. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50841. * to enhance interoperability with other engines.
  50842. */
  50843. static readonly LIGHTFALLOFF_GLTF: number;
  50844. /**
  50845. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50846. * to enhance interoperability with other materials.
  50847. */
  50848. static readonly LIGHTFALLOFF_STANDARD: number;
  50849. /**
  50850. * Intensity of the direct lights e.g. the four lights available in your scene.
  50851. * This impacts both the direct diffuse and specular highlights.
  50852. */
  50853. protected _directIntensity: number;
  50854. /**
  50855. * Intensity of the emissive part of the material.
  50856. * This helps controlling the emissive effect without modifying the emissive color.
  50857. */
  50858. protected _emissiveIntensity: number;
  50859. /**
  50860. * Intensity of the environment e.g. how much the environment will light the object
  50861. * either through harmonics for rough material or through the refelction for shiny ones.
  50862. */
  50863. protected _environmentIntensity: number;
  50864. /**
  50865. * This is a special control allowing the reduction of the specular highlights coming from the
  50866. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50867. */
  50868. protected _specularIntensity: number;
  50869. /**
  50870. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50871. */
  50872. private _lightingInfos;
  50873. /**
  50874. * Debug Control allowing disabling the bump map on this material.
  50875. */
  50876. protected _disableBumpMap: boolean;
  50877. /**
  50878. * AKA Diffuse Texture in standard nomenclature.
  50879. */
  50880. protected _albedoTexture: Nullable<BaseTexture>;
  50881. /**
  50882. * AKA Occlusion Texture in other nomenclature.
  50883. */
  50884. protected _ambientTexture: Nullable<BaseTexture>;
  50885. /**
  50886. * AKA Occlusion Texture Intensity in other nomenclature.
  50887. */
  50888. protected _ambientTextureStrength: number;
  50889. /**
  50890. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50891. * 1 means it completely occludes it
  50892. * 0 mean it has no impact
  50893. */
  50894. protected _ambientTextureImpactOnAnalyticalLights: number;
  50895. /**
  50896. * Stores the alpha values in a texture.
  50897. */
  50898. protected _opacityTexture: Nullable<BaseTexture>;
  50899. /**
  50900. * Stores the reflection values in a texture.
  50901. */
  50902. protected _reflectionTexture: Nullable<BaseTexture>;
  50903. /**
  50904. * Stores the emissive values in a texture.
  50905. */
  50906. protected _emissiveTexture: Nullable<BaseTexture>;
  50907. /**
  50908. * AKA Specular texture in other nomenclature.
  50909. */
  50910. protected _reflectivityTexture: Nullable<BaseTexture>;
  50911. /**
  50912. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50913. */
  50914. protected _metallicTexture: Nullable<BaseTexture>;
  50915. /**
  50916. * Specifies the metallic scalar of the metallic/roughness workflow.
  50917. * Can also be used to scale the metalness values of the metallic texture.
  50918. */
  50919. protected _metallic: Nullable<number>;
  50920. /**
  50921. * Specifies the roughness scalar of the metallic/roughness workflow.
  50922. * Can also be used to scale the roughness values of the metallic texture.
  50923. */
  50924. protected _roughness: Nullable<number>;
  50925. /**
  50926. * Specifies the an F0 factor to help configuring the material F0.
  50927. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50928. * to 0.5 the previously hard coded value stays the same.
  50929. * Can also be used to scale the F0 values of the metallic texture.
  50930. */
  50931. protected _metallicF0Factor: number;
  50932. /**
  50933. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50934. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50935. * your expectation as it multiplies with the texture data.
  50936. */
  50937. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50938. /**
  50939. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50940. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50941. */
  50942. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50943. /**
  50944. * Stores surface normal data used to displace a mesh in a texture.
  50945. */
  50946. protected _bumpTexture: Nullable<BaseTexture>;
  50947. /**
  50948. * Stores the pre-calculated light information of a mesh in a texture.
  50949. */
  50950. protected _lightmapTexture: Nullable<BaseTexture>;
  50951. /**
  50952. * The color of a material in ambient lighting.
  50953. */
  50954. protected _ambientColor: Color3;
  50955. /**
  50956. * AKA Diffuse Color in other nomenclature.
  50957. */
  50958. protected _albedoColor: Color3;
  50959. /**
  50960. * AKA Specular Color in other nomenclature.
  50961. */
  50962. protected _reflectivityColor: Color3;
  50963. /**
  50964. * The color applied when light is reflected from a material.
  50965. */
  50966. protected _reflectionColor: Color3;
  50967. /**
  50968. * The color applied when light is emitted from a material.
  50969. */
  50970. protected _emissiveColor: Color3;
  50971. /**
  50972. * AKA Glossiness in other nomenclature.
  50973. */
  50974. protected _microSurface: number;
  50975. /**
  50976. * Specifies that the material will use the light map as a show map.
  50977. */
  50978. protected _useLightmapAsShadowmap: boolean;
  50979. /**
  50980. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50981. * makes the reflect vector face the model (under horizon).
  50982. */
  50983. protected _useHorizonOcclusion: boolean;
  50984. /**
  50985. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50986. * too much the area relying on ambient texture to define their ambient occlusion.
  50987. */
  50988. protected _useRadianceOcclusion: boolean;
  50989. /**
  50990. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50991. */
  50992. protected _useAlphaFromAlbedoTexture: boolean;
  50993. /**
  50994. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50995. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50996. */
  50997. protected _useSpecularOverAlpha: boolean;
  50998. /**
  50999. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51000. */
  51001. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51002. /**
  51003. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51004. */
  51005. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51006. /**
  51007. * Specifies if the metallic texture contains the roughness information in its green channel.
  51008. */
  51009. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51010. /**
  51011. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51012. */
  51013. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51014. /**
  51015. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51016. */
  51017. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51018. /**
  51019. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51020. */
  51021. protected _useAmbientInGrayScale: boolean;
  51022. /**
  51023. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51024. * The material will try to infer what glossiness each pixel should be.
  51025. */
  51026. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51027. /**
  51028. * Defines the falloff type used in this material.
  51029. * It by default is Physical.
  51030. */
  51031. protected _lightFalloff: number;
  51032. /**
  51033. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51034. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51035. */
  51036. protected _useRadianceOverAlpha: boolean;
  51037. /**
  51038. * Allows using an object space normal map (instead of tangent space).
  51039. */
  51040. protected _useObjectSpaceNormalMap: boolean;
  51041. /**
  51042. * Allows using the bump map in parallax mode.
  51043. */
  51044. protected _useParallax: boolean;
  51045. /**
  51046. * Allows using the bump map in parallax occlusion mode.
  51047. */
  51048. protected _useParallaxOcclusion: boolean;
  51049. /**
  51050. * Controls the scale bias of the parallax mode.
  51051. */
  51052. protected _parallaxScaleBias: number;
  51053. /**
  51054. * If sets to true, disables all the lights affecting the material.
  51055. */
  51056. protected _disableLighting: boolean;
  51057. /**
  51058. * Number of Simultaneous lights allowed on the material.
  51059. */
  51060. protected _maxSimultaneousLights: number;
  51061. /**
  51062. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51063. */
  51064. protected _invertNormalMapX: boolean;
  51065. /**
  51066. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51067. */
  51068. protected _invertNormalMapY: boolean;
  51069. /**
  51070. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51071. */
  51072. protected _twoSidedLighting: boolean;
  51073. /**
  51074. * Defines the alpha limits in alpha test mode.
  51075. */
  51076. protected _alphaCutOff: number;
  51077. /**
  51078. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51079. */
  51080. protected _forceAlphaTest: boolean;
  51081. /**
  51082. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51083. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51084. */
  51085. protected _useAlphaFresnel: boolean;
  51086. /**
  51087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51088. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51089. */
  51090. protected _useLinearAlphaFresnel: boolean;
  51091. /**
  51092. * The transparency mode of the material.
  51093. */
  51094. protected _transparencyMode: Nullable<number>;
  51095. /**
  51096. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51097. * from cos thetav and roughness:
  51098. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51099. */
  51100. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51101. /**
  51102. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51103. */
  51104. protected _forceIrradianceInFragment: boolean;
  51105. /**
  51106. * Force normal to face away from face.
  51107. */
  51108. protected _forceNormalForward: boolean;
  51109. /**
  51110. * Enables specular anti aliasing in the PBR shader.
  51111. * It will both interacts on the Geometry for analytical and IBL lighting.
  51112. * It also prefilter the roughness map based on the bump values.
  51113. */
  51114. protected _enableSpecularAntiAliasing: boolean;
  51115. /**
  51116. * Default configuration related to image processing available in the PBR Material.
  51117. */
  51118. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51119. /**
  51120. * Keep track of the image processing observer to allow dispose and replace.
  51121. */
  51122. private _imageProcessingObserver;
  51123. /**
  51124. * Attaches a new image processing configuration to the PBR Material.
  51125. * @param configuration
  51126. */
  51127. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51128. /**
  51129. * Stores the available render targets.
  51130. */
  51131. private _renderTargets;
  51132. /**
  51133. * Sets the global ambient color for the material used in lighting calculations.
  51134. */
  51135. private _globalAmbientColor;
  51136. /**
  51137. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51138. */
  51139. private _useLogarithmicDepth;
  51140. /**
  51141. * If set to true, no lighting calculations will be applied.
  51142. */
  51143. private _unlit;
  51144. private _debugMode;
  51145. /**
  51146. * @hidden
  51147. * This is reserved for the inspector.
  51148. * Defines the material debug mode.
  51149. * It helps seeing only some components of the material while troubleshooting.
  51150. */
  51151. debugMode: number;
  51152. /**
  51153. * @hidden
  51154. * This is reserved for the inspector.
  51155. * Specify from where on screen the debug mode should start.
  51156. * The value goes from -1 (full screen) to 1 (not visible)
  51157. * It helps with side by side comparison against the final render
  51158. * This defaults to -1
  51159. */
  51160. private debugLimit;
  51161. /**
  51162. * @hidden
  51163. * This is reserved for the inspector.
  51164. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51165. * You can use the factor to better multiply the final value.
  51166. */
  51167. private debugFactor;
  51168. /**
  51169. * Defines the clear coat layer parameters for the material.
  51170. */
  51171. readonly clearCoat: PBRClearCoatConfiguration;
  51172. /**
  51173. * Defines the anisotropic parameters for the material.
  51174. */
  51175. readonly anisotropy: PBRAnisotropicConfiguration;
  51176. /**
  51177. * Defines the BRDF parameters for the material.
  51178. */
  51179. readonly brdf: PBRBRDFConfiguration;
  51180. /**
  51181. * Defines the Sheen parameters for the material.
  51182. */
  51183. readonly sheen: PBRSheenConfiguration;
  51184. /**
  51185. * Defines the SubSurface parameters for the material.
  51186. */
  51187. readonly subSurface: PBRSubSurfaceConfiguration;
  51188. /**
  51189. * Custom callback helping to override the default shader used in the material.
  51190. */
  51191. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51192. protected _rebuildInParallel: boolean;
  51193. /**
  51194. * Instantiates a new PBRMaterial instance.
  51195. *
  51196. * @param name The material name
  51197. * @param scene The scene the material will be use in.
  51198. */
  51199. constructor(name: string, scene: Scene);
  51200. /**
  51201. * Gets a boolean indicating that current material needs to register RTT
  51202. */
  51203. readonly hasRenderTargetTextures: boolean;
  51204. /**
  51205. * Gets the name of the material class.
  51206. */
  51207. getClassName(): string;
  51208. /**
  51209. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51210. */
  51211. /**
  51212. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51213. */
  51214. useLogarithmicDepth: boolean;
  51215. /**
  51216. * Gets the current transparency mode.
  51217. */
  51218. /**
  51219. * Sets the transparency mode of the material.
  51220. *
  51221. * | Value | Type | Description |
  51222. * | ----- | ----------------------------------- | ----------- |
  51223. * | 0 | OPAQUE | |
  51224. * | 1 | ALPHATEST | |
  51225. * | 2 | ALPHABLEND | |
  51226. * | 3 | ALPHATESTANDBLEND | |
  51227. *
  51228. */
  51229. transparencyMode: Nullable<number>;
  51230. /**
  51231. * Returns true if alpha blending should be disabled.
  51232. */
  51233. private readonly _disableAlphaBlending;
  51234. /**
  51235. * Specifies whether or not this material should be rendered in alpha blend mode.
  51236. */
  51237. needAlphaBlending(): boolean;
  51238. /**
  51239. * Specifies if the mesh will require alpha blending.
  51240. * @param mesh - BJS mesh.
  51241. */
  51242. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51243. /**
  51244. * Specifies whether or not this material should be rendered in alpha test mode.
  51245. */
  51246. needAlphaTesting(): boolean;
  51247. /**
  51248. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51249. */
  51250. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51251. /**
  51252. * Gets the texture used for the alpha test.
  51253. */
  51254. getAlphaTestTexture(): Nullable<BaseTexture>;
  51255. /**
  51256. * Specifies that the submesh is ready to be used.
  51257. * @param mesh - BJS mesh.
  51258. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51259. * @param useInstances - Specifies that instances should be used.
  51260. * @returns - boolean indicating that the submesh is ready or not.
  51261. */
  51262. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51263. /**
  51264. * Specifies if the material uses metallic roughness workflow.
  51265. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51266. */
  51267. isMetallicWorkflow(): boolean;
  51268. private _prepareEffect;
  51269. private _prepareDefines;
  51270. /**
  51271. * Force shader compilation
  51272. */
  51273. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51274. /**
  51275. * Initializes the uniform buffer layout for the shader.
  51276. */
  51277. buildUniformLayout(): void;
  51278. /**
  51279. * Unbinds the material from the mesh
  51280. */
  51281. unbind(): void;
  51282. /**
  51283. * Binds the submesh data.
  51284. * @param world - The world matrix.
  51285. * @param mesh - The BJS mesh.
  51286. * @param subMesh - A submesh of the BJS mesh.
  51287. */
  51288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51289. /**
  51290. * Returns the animatable textures.
  51291. * @returns - Array of animatable textures.
  51292. */
  51293. getAnimatables(): IAnimatable[];
  51294. /**
  51295. * Returns the texture used for reflections.
  51296. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51297. */
  51298. private _getReflectionTexture;
  51299. /**
  51300. * Returns an array of the actively used textures.
  51301. * @returns - Array of BaseTextures
  51302. */
  51303. getActiveTextures(): BaseTexture[];
  51304. /**
  51305. * Checks to see if a texture is used in the material.
  51306. * @param texture - Base texture to use.
  51307. * @returns - Boolean specifying if a texture is used in the material.
  51308. */
  51309. hasTexture(texture: BaseTexture): boolean;
  51310. /**
  51311. * Disposes the resources of the material.
  51312. * @param forceDisposeEffect - Forces the disposal of effects.
  51313. * @param forceDisposeTextures - Forces the disposal of all textures.
  51314. */
  51315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51316. }
  51317. }
  51318. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51319. import { Nullable } from "babylonjs/types";
  51320. import { Scene } from "babylonjs/scene";
  51321. import { Color3 } from "babylonjs/Maths/math.color";
  51322. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51323. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51325. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51326. /**
  51327. * The Physically based material of BJS.
  51328. *
  51329. * This offers the main features of a standard PBR material.
  51330. * For more information, please refer to the documentation :
  51331. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51332. */
  51333. export class PBRMaterial extends PBRBaseMaterial {
  51334. /**
  51335. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51336. */
  51337. static readonly PBRMATERIAL_OPAQUE: number;
  51338. /**
  51339. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51340. */
  51341. static readonly PBRMATERIAL_ALPHATEST: number;
  51342. /**
  51343. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51344. */
  51345. static readonly PBRMATERIAL_ALPHABLEND: number;
  51346. /**
  51347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51348. * They are also discarded below the alpha cutoff threshold to improve performances.
  51349. */
  51350. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51351. /**
  51352. * Defines the default value of how much AO map is occluding the analytical lights
  51353. * (point spot...).
  51354. */
  51355. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51356. /**
  51357. * Intensity of the direct lights e.g. the four lights available in your scene.
  51358. * This impacts both the direct diffuse and specular highlights.
  51359. */
  51360. directIntensity: number;
  51361. /**
  51362. * Intensity of the emissive part of the material.
  51363. * This helps controlling the emissive effect without modifying the emissive color.
  51364. */
  51365. emissiveIntensity: number;
  51366. /**
  51367. * Intensity of the environment e.g. how much the environment will light the object
  51368. * either through harmonics for rough material or through the refelction for shiny ones.
  51369. */
  51370. environmentIntensity: number;
  51371. /**
  51372. * This is a special control allowing the reduction of the specular highlights coming from the
  51373. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51374. */
  51375. specularIntensity: number;
  51376. /**
  51377. * Debug Control allowing disabling the bump map on this material.
  51378. */
  51379. disableBumpMap: boolean;
  51380. /**
  51381. * AKA Diffuse Texture in standard nomenclature.
  51382. */
  51383. albedoTexture: BaseTexture;
  51384. /**
  51385. * AKA Occlusion Texture in other nomenclature.
  51386. */
  51387. ambientTexture: BaseTexture;
  51388. /**
  51389. * AKA Occlusion Texture Intensity in other nomenclature.
  51390. */
  51391. ambientTextureStrength: number;
  51392. /**
  51393. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51394. * 1 means it completely occludes it
  51395. * 0 mean it has no impact
  51396. */
  51397. ambientTextureImpactOnAnalyticalLights: number;
  51398. /**
  51399. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51400. */
  51401. opacityTexture: BaseTexture;
  51402. /**
  51403. * Stores the reflection values in a texture.
  51404. */
  51405. reflectionTexture: Nullable<BaseTexture>;
  51406. /**
  51407. * Stores the emissive values in a texture.
  51408. */
  51409. emissiveTexture: BaseTexture;
  51410. /**
  51411. * AKA Specular texture in other nomenclature.
  51412. */
  51413. reflectivityTexture: BaseTexture;
  51414. /**
  51415. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51416. */
  51417. metallicTexture: BaseTexture;
  51418. /**
  51419. * Specifies the metallic scalar of the metallic/roughness workflow.
  51420. * Can also be used to scale the metalness values of the metallic texture.
  51421. */
  51422. metallic: Nullable<number>;
  51423. /**
  51424. * Specifies the roughness scalar of the metallic/roughness workflow.
  51425. * Can also be used to scale the roughness values of the metallic texture.
  51426. */
  51427. roughness: Nullable<number>;
  51428. /**
  51429. * Specifies the an F0 factor to help configuring the material F0.
  51430. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51431. * to 0.5 the previously hard coded value stays the same.
  51432. * Can also be used to scale the F0 values of the metallic texture.
  51433. */
  51434. metallicF0Factor: number;
  51435. /**
  51436. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51437. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51438. * your expectation as it multiplies with the texture data.
  51439. */
  51440. useMetallicF0FactorFromMetallicTexture: boolean;
  51441. /**
  51442. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51443. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51444. */
  51445. microSurfaceTexture: BaseTexture;
  51446. /**
  51447. * Stores surface normal data used to displace a mesh in a texture.
  51448. */
  51449. bumpTexture: BaseTexture;
  51450. /**
  51451. * Stores the pre-calculated light information of a mesh in a texture.
  51452. */
  51453. lightmapTexture: BaseTexture;
  51454. /**
  51455. * Stores the refracted light information in a texture.
  51456. */
  51457. refractionTexture: Nullable<BaseTexture>;
  51458. /**
  51459. * The color of a material in ambient lighting.
  51460. */
  51461. ambientColor: Color3;
  51462. /**
  51463. * AKA Diffuse Color in other nomenclature.
  51464. */
  51465. albedoColor: Color3;
  51466. /**
  51467. * AKA Specular Color in other nomenclature.
  51468. */
  51469. reflectivityColor: Color3;
  51470. /**
  51471. * The color reflected from the material.
  51472. */
  51473. reflectionColor: Color3;
  51474. /**
  51475. * The color emitted from the material.
  51476. */
  51477. emissiveColor: Color3;
  51478. /**
  51479. * AKA Glossiness in other nomenclature.
  51480. */
  51481. microSurface: number;
  51482. /**
  51483. * source material index of refraction (IOR)' / 'destination material IOR.
  51484. */
  51485. indexOfRefraction: number;
  51486. /**
  51487. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51488. */
  51489. invertRefractionY: boolean;
  51490. /**
  51491. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51492. * Materials half opaque for instance using refraction could benefit from this control.
  51493. */
  51494. linkRefractionWithTransparency: boolean;
  51495. /**
  51496. * If true, the light map contains occlusion information instead of lighting info.
  51497. */
  51498. useLightmapAsShadowmap: boolean;
  51499. /**
  51500. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51501. */
  51502. useAlphaFromAlbedoTexture: boolean;
  51503. /**
  51504. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51505. */
  51506. forceAlphaTest: boolean;
  51507. /**
  51508. * Defines the alpha limits in alpha test mode.
  51509. */
  51510. alphaCutOff: number;
  51511. /**
  51512. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51513. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51514. */
  51515. useSpecularOverAlpha: boolean;
  51516. /**
  51517. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51518. */
  51519. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51520. /**
  51521. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51522. */
  51523. useRoughnessFromMetallicTextureAlpha: boolean;
  51524. /**
  51525. * Specifies if the metallic texture contains the roughness information in its green channel.
  51526. */
  51527. useRoughnessFromMetallicTextureGreen: boolean;
  51528. /**
  51529. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51530. */
  51531. useMetallnessFromMetallicTextureBlue: boolean;
  51532. /**
  51533. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51534. */
  51535. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51536. /**
  51537. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51538. */
  51539. useAmbientInGrayScale: boolean;
  51540. /**
  51541. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51542. * The material will try to infer what glossiness each pixel should be.
  51543. */
  51544. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51545. /**
  51546. * BJS is using an harcoded light falloff based on a manually sets up range.
  51547. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51548. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51549. */
  51550. /**
  51551. * BJS is using an harcoded light falloff based on a manually sets up range.
  51552. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51553. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51554. */
  51555. usePhysicalLightFalloff: boolean;
  51556. /**
  51557. * In order to support the falloff compatibility with gltf, a special mode has been added
  51558. * to reproduce the gltf light falloff.
  51559. */
  51560. /**
  51561. * In order to support the falloff compatibility with gltf, a special mode has been added
  51562. * to reproduce the gltf light falloff.
  51563. */
  51564. useGLTFLightFalloff: boolean;
  51565. /**
  51566. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51567. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51568. */
  51569. useRadianceOverAlpha: boolean;
  51570. /**
  51571. * Allows using an object space normal map (instead of tangent space).
  51572. */
  51573. useObjectSpaceNormalMap: boolean;
  51574. /**
  51575. * Allows using the bump map in parallax mode.
  51576. */
  51577. useParallax: boolean;
  51578. /**
  51579. * Allows using the bump map in parallax occlusion mode.
  51580. */
  51581. useParallaxOcclusion: boolean;
  51582. /**
  51583. * Controls the scale bias of the parallax mode.
  51584. */
  51585. parallaxScaleBias: number;
  51586. /**
  51587. * If sets to true, disables all the lights affecting the material.
  51588. */
  51589. disableLighting: boolean;
  51590. /**
  51591. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51592. */
  51593. forceIrradianceInFragment: boolean;
  51594. /**
  51595. * Number of Simultaneous lights allowed on the material.
  51596. */
  51597. maxSimultaneousLights: number;
  51598. /**
  51599. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51600. */
  51601. invertNormalMapX: boolean;
  51602. /**
  51603. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51604. */
  51605. invertNormalMapY: boolean;
  51606. /**
  51607. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51608. */
  51609. twoSidedLighting: boolean;
  51610. /**
  51611. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51612. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51613. */
  51614. useAlphaFresnel: boolean;
  51615. /**
  51616. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51617. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51618. */
  51619. useLinearAlphaFresnel: boolean;
  51620. /**
  51621. * Let user defines the brdf lookup texture used for IBL.
  51622. * A default 8bit version is embedded but you could point at :
  51623. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51624. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51625. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51626. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51627. */
  51628. environmentBRDFTexture: Nullable<BaseTexture>;
  51629. /**
  51630. * Force normal to face away from face.
  51631. */
  51632. forceNormalForward: boolean;
  51633. /**
  51634. * Enables specular anti aliasing in the PBR shader.
  51635. * It will both interacts on the Geometry for analytical and IBL lighting.
  51636. * It also prefilter the roughness map based on the bump values.
  51637. */
  51638. enableSpecularAntiAliasing: boolean;
  51639. /**
  51640. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51641. * makes the reflect vector face the model (under horizon).
  51642. */
  51643. useHorizonOcclusion: boolean;
  51644. /**
  51645. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51646. * too much the area relying on ambient texture to define their ambient occlusion.
  51647. */
  51648. useRadianceOcclusion: boolean;
  51649. /**
  51650. * If set to true, no lighting calculations will be applied.
  51651. */
  51652. unlit: boolean;
  51653. /**
  51654. * Gets the image processing configuration used either in this material.
  51655. */
  51656. /**
  51657. * Sets the Default image processing configuration used either in the this material.
  51658. *
  51659. * If sets to null, the scene one is in use.
  51660. */
  51661. imageProcessingConfiguration: ImageProcessingConfiguration;
  51662. /**
  51663. * Gets wether the color curves effect is enabled.
  51664. */
  51665. /**
  51666. * Sets wether the color curves effect is enabled.
  51667. */
  51668. cameraColorCurvesEnabled: boolean;
  51669. /**
  51670. * Gets wether the color grading effect is enabled.
  51671. */
  51672. /**
  51673. * Gets wether the color grading effect is enabled.
  51674. */
  51675. cameraColorGradingEnabled: boolean;
  51676. /**
  51677. * Gets wether tonemapping is enabled or not.
  51678. */
  51679. /**
  51680. * Sets wether tonemapping is enabled or not
  51681. */
  51682. cameraToneMappingEnabled: boolean;
  51683. /**
  51684. * The camera exposure used on this material.
  51685. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51686. * This corresponds to a photographic exposure.
  51687. */
  51688. /**
  51689. * The camera exposure used on this material.
  51690. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51691. * This corresponds to a photographic exposure.
  51692. */
  51693. cameraExposure: number;
  51694. /**
  51695. * Gets The camera contrast used on this material.
  51696. */
  51697. /**
  51698. * Sets The camera contrast used on this material.
  51699. */
  51700. cameraContrast: number;
  51701. /**
  51702. * Gets the Color Grading 2D Lookup Texture.
  51703. */
  51704. /**
  51705. * Sets the Color Grading 2D Lookup Texture.
  51706. */
  51707. cameraColorGradingTexture: Nullable<BaseTexture>;
  51708. /**
  51709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51711. * 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;
  51712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51713. */
  51714. /**
  51715. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51716. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51717. * 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;
  51718. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51719. */
  51720. cameraColorCurves: Nullable<ColorCurves>;
  51721. /**
  51722. * Instantiates a new PBRMaterial instance.
  51723. *
  51724. * @param name The material name
  51725. * @param scene The scene the material will be use in.
  51726. */
  51727. constructor(name: string, scene: Scene);
  51728. /**
  51729. * Returns the name of this material class.
  51730. */
  51731. getClassName(): string;
  51732. /**
  51733. * Makes a duplicate of the current material.
  51734. * @param name - name to use for the new material.
  51735. */
  51736. clone(name: string): PBRMaterial;
  51737. /**
  51738. * Serializes this PBR Material.
  51739. * @returns - An object with the serialized material.
  51740. */
  51741. serialize(): any;
  51742. /**
  51743. * Parses a PBR Material from a serialized object.
  51744. * @param source - Serialized object.
  51745. * @param scene - BJS scene instance.
  51746. * @param rootUrl - url for the scene object
  51747. * @returns - PBRMaterial
  51748. */
  51749. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51750. }
  51751. }
  51752. declare module "babylonjs/Misc/dds" {
  51753. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51755. import { Nullable } from "babylonjs/types";
  51756. import { Scene } from "babylonjs/scene";
  51757. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51758. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51759. /**
  51760. * Direct draw surface info
  51761. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51762. */
  51763. export interface DDSInfo {
  51764. /**
  51765. * Width of the texture
  51766. */
  51767. width: number;
  51768. /**
  51769. * Width of the texture
  51770. */
  51771. height: number;
  51772. /**
  51773. * Number of Mipmaps for the texture
  51774. * @see https://en.wikipedia.org/wiki/Mipmap
  51775. */
  51776. mipmapCount: number;
  51777. /**
  51778. * If the textures format is a known fourCC format
  51779. * @see https://www.fourcc.org/
  51780. */
  51781. isFourCC: boolean;
  51782. /**
  51783. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51784. */
  51785. isRGB: boolean;
  51786. /**
  51787. * If the texture is a lumincance format
  51788. */
  51789. isLuminance: boolean;
  51790. /**
  51791. * If this is a cube texture
  51792. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51793. */
  51794. isCube: boolean;
  51795. /**
  51796. * If the texture is a compressed format eg. FOURCC_DXT1
  51797. */
  51798. isCompressed: boolean;
  51799. /**
  51800. * The dxgiFormat of the texture
  51801. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51802. */
  51803. dxgiFormat: number;
  51804. /**
  51805. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51806. */
  51807. textureType: number;
  51808. /**
  51809. * Sphericle polynomial created for the dds texture
  51810. */
  51811. sphericalPolynomial?: SphericalPolynomial;
  51812. }
  51813. /**
  51814. * Class used to provide DDS decompression tools
  51815. */
  51816. export class DDSTools {
  51817. /**
  51818. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51819. */
  51820. static StoreLODInAlphaChannel: boolean;
  51821. /**
  51822. * Gets DDS information from an array buffer
  51823. * @param arrayBuffer defines the array buffer to read data from
  51824. * @returns the DDS information
  51825. */
  51826. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51827. private static _FloatView;
  51828. private static _Int32View;
  51829. private static _ToHalfFloat;
  51830. private static _FromHalfFloat;
  51831. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51832. private static _GetHalfFloatRGBAArrayBuffer;
  51833. private static _GetFloatRGBAArrayBuffer;
  51834. private static _GetFloatAsUIntRGBAArrayBuffer;
  51835. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51836. private static _GetRGBAArrayBuffer;
  51837. private static _ExtractLongWordOrder;
  51838. private static _GetRGBArrayBuffer;
  51839. private static _GetLuminanceArrayBuffer;
  51840. /**
  51841. * Uploads DDS Levels to a Babylon Texture
  51842. * @hidden
  51843. */
  51844. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51845. }
  51846. module "babylonjs/Engines/thinEngine" {
  51847. interface ThinEngine {
  51848. /**
  51849. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51850. * @param rootUrl defines the url where the file to load is located
  51851. * @param scene defines the current scene
  51852. * @param lodScale defines scale to apply to the mip map selection
  51853. * @param lodOffset defines offset to apply to the mip map selection
  51854. * @param onLoad defines an optional callback raised when the texture is loaded
  51855. * @param onError defines an optional callback raised if there is an issue to load the texture
  51856. * @param format defines the format of the data
  51857. * @param forcedExtension defines the extension to use to pick the right loader
  51858. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51859. * @returns the cube texture as an InternalTexture
  51860. */
  51861. 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;
  51862. }
  51863. }
  51864. }
  51865. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51866. import { Nullable } from "babylonjs/types";
  51867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51868. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51869. /**
  51870. * Implementation of the DDS Texture Loader.
  51871. * @hidden
  51872. */
  51873. export class _DDSTextureLoader implements IInternalTextureLoader {
  51874. /**
  51875. * Defines wether the loader supports cascade loading the different faces.
  51876. */
  51877. readonly supportCascades: boolean;
  51878. /**
  51879. * This returns if the loader support the current file information.
  51880. * @param extension defines the file extension of the file being loaded
  51881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51882. * @param fallback defines the fallback internal texture if any
  51883. * @param isBase64 defines whether the texture is encoded as a base64
  51884. * @param isBuffer defines whether the texture data are stored as a buffer
  51885. * @returns true if the loader can load the specified file
  51886. */
  51887. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51888. /**
  51889. * Transform the url before loading if required.
  51890. * @param rootUrl the url of the texture
  51891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51892. * @returns the transformed texture
  51893. */
  51894. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51895. /**
  51896. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51897. * @param rootUrl the url of the texture
  51898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51899. * @returns the fallback texture
  51900. */
  51901. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51902. /**
  51903. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51904. * @param data contains the texture data
  51905. * @param texture defines the BabylonJS internal texture
  51906. * @param createPolynomials will be true if polynomials have been requested
  51907. * @param onLoad defines the callback to trigger once the texture is ready
  51908. * @param onError defines the callback to trigger in case of error
  51909. */
  51910. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51911. /**
  51912. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51913. * @param data contains the texture data
  51914. * @param texture defines the BabylonJS internal texture
  51915. * @param callback defines the method to call once ready to upload
  51916. */
  51917. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51918. }
  51919. }
  51920. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51921. import { Nullable } from "babylonjs/types";
  51922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51923. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51924. /**
  51925. * Implementation of the ENV Texture Loader.
  51926. * @hidden
  51927. */
  51928. export class _ENVTextureLoader implements IInternalTextureLoader {
  51929. /**
  51930. * Defines wether the loader supports cascade loading the different faces.
  51931. */
  51932. readonly supportCascades: boolean;
  51933. /**
  51934. * This returns if the loader support the current file information.
  51935. * @param extension defines the file extension of the file being loaded
  51936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51937. * @param fallback defines the fallback internal texture if any
  51938. * @param isBase64 defines whether the texture is encoded as a base64
  51939. * @param isBuffer defines whether the texture data are stored as a buffer
  51940. * @returns true if the loader can load the specified file
  51941. */
  51942. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51943. /**
  51944. * Transform the url before loading if required.
  51945. * @param rootUrl the url of the texture
  51946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51947. * @returns the transformed texture
  51948. */
  51949. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51950. /**
  51951. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51952. * @param rootUrl the url of the texture
  51953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51954. * @returns the fallback texture
  51955. */
  51956. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51957. /**
  51958. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51959. * @param data contains the texture data
  51960. * @param texture defines the BabylonJS internal texture
  51961. * @param createPolynomials will be true if polynomials have been requested
  51962. * @param onLoad defines the callback to trigger once the texture is ready
  51963. * @param onError defines the callback to trigger in case of error
  51964. */
  51965. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51966. /**
  51967. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51968. * @param data contains the texture data
  51969. * @param texture defines the BabylonJS internal texture
  51970. * @param callback defines the method to call once ready to upload
  51971. */
  51972. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51973. }
  51974. }
  51975. declare module "babylonjs/Misc/khronosTextureContainer" {
  51976. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51977. /**
  51978. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51979. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51980. */
  51981. export class KhronosTextureContainer {
  51982. /** contents of the KTX container file */
  51983. arrayBuffer: any;
  51984. private static HEADER_LEN;
  51985. private static COMPRESSED_2D;
  51986. private static COMPRESSED_3D;
  51987. private static TEX_2D;
  51988. private static TEX_3D;
  51989. /**
  51990. * Gets the openGL type
  51991. */
  51992. glType: number;
  51993. /**
  51994. * Gets the openGL type size
  51995. */
  51996. glTypeSize: number;
  51997. /**
  51998. * Gets the openGL format
  51999. */
  52000. glFormat: number;
  52001. /**
  52002. * Gets the openGL internal format
  52003. */
  52004. glInternalFormat: number;
  52005. /**
  52006. * Gets the base internal format
  52007. */
  52008. glBaseInternalFormat: number;
  52009. /**
  52010. * Gets image width in pixel
  52011. */
  52012. pixelWidth: number;
  52013. /**
  52014. * Gets image height in pixel
  52015. */
  52016. pixelHeight: number;
  52017. /**
  52018. * Gets image depth in pixels
  52019. */
  52020. pixelDepth: number;
  52021. /**
  52022. * Gets the number of array elements
  52023. */
  52024. numberOfArrayElements: number;
  52025. /**
  52026. * Gets the number of faces
  52027. */
  52028. numberOfFaces: number;
  52029. /**
  52030. * Gets the number of mipmap levels
  52031. */
  52032. numberOfMipmapLevels: number;
  52033. /**
  52034. * Gets the bytes of key value data
  52035. */
  52036. bytesOfKeyValueData: number;
  52037. /**
  52038. * Gets the load type
  52039. */
  52040. loadType: number;
  52041. /**
  52042. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52043. */
  52044. isInvalid: boolean;
  52045. /**
  52046. * Creates a new KhronosTextureContainer
  52047. * @param arrayBuffer contents of the KTX container file
  52048. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52049. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52050. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52051. */
  52052. constructor(
  52053. /** contents of the KTX container file */
  52054. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52055. /**
  52056. * Uploads KTX content to a Babylon Texture.
  52057. * It is assumed that the texture has already been created & is currently bound
  52058. * @hidden
  52059. */
  52060. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52061. private _upload2DCompressedLevels;
  52062. }
  52063. }
  52064. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52065. import { Nullable } from "babylonjs/types";
  52066. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52067. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52068. /**
  52069. * Implementation of the KTX Texture Loader.
  52070. * @hidden
  52071. */
  52072. export class _KTXTextureLoader implements IInternalTextureLoader {
  52073. /**
  52074. * Defines wether the loader supports cascade loading the different faces.
  52075. */
  52076. readonly supportCascades: boolean;
  52077. /**
  52078. * This returns if the loader support the current file information.
  52079. * @param extension defines the file extension of the file being loaded
  52080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52081. * @param fallback defines the fallback internal texture if any
  52082. * @param isBase64 defines whether the texture is encoded as a base64
  52083. * @param isBuffer defines whether the texture data are stored as a buffer
  52084. * @returns true if the loader can load the specified file
  52085. */
  52086. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52087. /**
  52088. * Transform the url before loading if required.
  52089. * @param rootUrl the url of the texture
  52090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52091. * @returns the transformed texture
  52092. */
  52093. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52094. /**
  52095. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52096. * @param rootUrl the url of the texture
  52097. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52098. * @returns the fallback texture
  52099. */
  52100. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52101. /**
  52102. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52103. * @param data contains the texture data
  52104. * @param texture defines the BabylonJS internal texture
  52105. * @param createPolynomials will be true if polynomials have been requested
  52106. * @param onLoad defines the callback to trigger once the texture is ready
  52107. * @param onError defines the callback to trigger in case of error
  52108. */
  52109. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52110. /**
  52111. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52112. * @param data contains the texture data
  52113. * @param texture defines the BabylonJS internal texture
  52114. * @param callback defines the method to call once ready to upload
  52115. */
  52116. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52117. }
  52118. }
  52119. declare module "babylonjs/Helpers/sceneHelpers" {
  52120. import { Nullable } from "babylonjs/types";
  52121. import { Mesh } from "babylonjs/Meshes/mesh";
  52122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52123. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52124. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52125. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52126. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52127. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52128. import "babylonjs/Meshes/Builders/boxBuilder";
  52129. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52130. /** @hidden */
  52131. export var _forceSceneHelpersToBundle: boolean;
  52132. module "babylonjs/scene" {
  52133. interface Scene {
  52134. /**
  52135. * Creates a default light for the scene.
  52136. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52137. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52138. */
  52139. createDefaultLight(replace?: boolean): void;
  52140. /**
  52141. * Creates a default camera for the scene.
  52142. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52143. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52144. * @param replace has default false, when true replaces the active camera in the scene
  52145. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52146. */
  52147. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52148. /**
  52149. * Creates a default camera and a default light.
  52150. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52151. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52152. * @param replace has the default false, when true replaces the active camera/light in the scene
  52153. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52154. */
  52155. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52156. /**
  52157. * Creates a new sky box
  52158. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52159. * @param environmentTexture defines the texture to use as environment texture
  52160. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52161. * @param scale defines the overall scale of the skybox
  52162. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52163. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52164. * @returns a new mesh holding the sky box
  52165. */
  52166. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52167. /**
  52168. * Creates a new environment
  52169. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52170. * @param options defines the options you can use to configure the environment
  52171. * @returns the new EnvironmentHelper
  52172. */
  52173. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52174. /**
  52175. * Creates a new VREXperienceHelper
  52176. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52177. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52178. * @returns a new VREXperienceHelper
  52179. */
  52180. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52181. /**
  52182. * Creates a new WebXRDefaultExperience
  52183. * @see http://doc.babylonjs.com/how_to/webxr
  52184. * @param options experience options
  52185. * @returns a promise for a new WebXRDefaultExperience
  52186. */
  52187. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52188. }
  52189. }
  52190. }
  52191. declare module "babylonjs/Helpers/videoDome" {
  52192. import { Scene } from "babylonjs/scene";
  52193. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52194. import { Mesh } from "babylonjs/Meshes/mesh";
  52195. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52196. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52197. import "babylonjs/Meshes/Builders/sphereBuilder";
  52198. /**
  52199. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52200. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52201. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52202. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52203. */
  52204. export class VideoDome extends TransformNode {
  52205. /**
  52206. * Define the video source as a Monoscopic panoramic 360 video.
  52207. */
  52208. static readonly MODE_MONOSCOPIC: number;
  52209. /**
  52210. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52211. */
  52212. static readonly MODE_TOPBOTTOM: number;
  52213. /**
  52214. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52215. */
  52216. static readonly MODE_SIDEBYSIDE: number;
  52217. private _halfDome;
  52218. private _useDirectMapping;
  52219. /**
  52220. * The video texture being displayed on the sphere
  52221. */
  52222. protected _videoTexture: VideoTexture;
  52223. /**
  52224. * Gets the video texture being displayed on the sphere
  52225. */
  52226. readonly videoTexture: VideoTexture;
  52227. /**
  52228. * The skybox material
  52229. */
  52230. protected _material: BackgroundMaterial;
  52231. /**
  52232. * The surface used for the skybox
  52233. */
  52234. protected _mesh: Mesh;
  52235. /**
  52236. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52237. */
  52238. private _halfDomeMask;
  52239. /**
  52240. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52241. * Also see the options.resolution property.
  52242. */
  52243. fovMultiplier: number;
  52244. private _videoMode;
  52245. /**
  52246. * Gets or set the current video mode for the video. It can be:
  52247. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52248. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52249. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52250. */
  52251. videoMode: number;
  52252. /**
  52253. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52254. *
  52255. */
  52256. /**
  52257. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52258. */
  52259. halfDome: boolean;
  52260. /**
  52261. * Oberserver used in Stereoscopic VR Mode.
  52262. */
  52263. private _onBeforeCameraRenderObserver;
  52264. /**
  52265. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52266. * @param name Element's name, child elements will append suffixes for their own names.
  52267. * @param urlsOrVideo defines the url(s) or the video element to use
  52268. * @param options An object containing optional or exposed sub element properties
  52269. */
  52270. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52271. resolution?: number;
  52272. clickToPlay?: boolean;
  52273. autoPlay?: boolean;
  52274. loop?: boolean;
  52275. size?: number;
  52276. poster?: string;
  52277. faceForward?: boolean;
  52278. useDirectMapping?: boolean;
  52279. halfDomeMode?: boolean;
  52280. }, scene: Scene);
  52281. private _changeVideoMode;
  52282. /**
  52283. * Releases resources associated with this node.
  52284. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52285. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52286. */
  52287. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52288. }
  52289. }
  52290. declare module "babylonjs/Helpers/index" {
  52291. export * from "babylonjs/Helpers/environmentHelper";
  52292. export * from "babylonjs/Helpers/photoDome";
  52293. export * from "babylonjs/Helpers/sceneHelpers";
  52294. export * from "babylonjs/Helpers/videoDome";
  52295. }
  52296. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52297. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52298. import { IDisposable } from "babylonjs/scene";
  52299. import { Engine } from "babylonjs/Engines/engine";
  52300. /**
  52301. * This class can be used to get instrumentation data from a Babylon engine
  52302. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52303. */
  52304. export class EngineInstrumentation implements IDisposable {
  52305. /**
  52306. * Define the instrumented engine.
  52307. */
  52308. engine: Engine;
  52309. private _captureGPUFrameTime;
  52310. private _gpuFrameTimeToken;
  52311. private _gpuFrameTime;
  52312. private _captureShaderCompilationTime;
  52313. private _shaderCompilationTime;
  52314. private _onBeginFrameObserver;
  52315. private _onEndFrameObserver;
  52316. private _onBeforeShaderCompilationObserver;
  52317. private _onAfterShaderCompilationObserver;
  52318. /**
  52319. * Gets the perf counter used for GPU frame time
  52320. */
  52321. readonly gpuFrameTimeCounter: PerfCounter;
  52322. /**
  52323. * Gets the GPU frame time capture status
  52324. */
  52325. /**
  52326. * Enable or disable the GPU frame time capture
  52327. */
  52328. captureGPUFrameTime: boolean;
  52329. /**
  52330. * Gets the perf counter used for shader compilation time
  52331. */
  52332. readonly shaderCompilationTimeCounter: PerfCounter;
  52333. /**
  52334. * Gets the shader compilation time capture status
  52335. */
  52336. /**
  52337. * Enable or disable the shader compilation time capture
  52338. */
  52339. captureShaderCompilationTime: boolean;
  52340. /**
  52341. * Instantiates a new engine instrumentation.
  52342. * This class can be used to get instrumentation data from a Babylon engine
  52343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52344. * @param engine Defines the engine to instrument
  52345. */
  52346. constructor(
  52347. /**
  52348. * Define the instrumented engine.
  52349. */
  52350. engine: Engine);
  52351. /**
  52352. * Dispose and release associated resources.
  52353. */
  52354. dispose(): void;
  52355. }
  52356. }
  52357. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52358. import { Scene, IDisposable } from "babylonjs/scene";
  52359. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52360. /**
  52361. * This class can be used to get instrumentation data from a Babylon engine
  52362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52363. */
  52364. export class SceneInstrumentation implements IDisposable {
  52365. /**
  52366. * Defines the scene to instrument
  52367. */
  52368. scene: Scene;
  52369. private _captureActiveMeshesEvaluationTime;
  52370. private _activeMeshesEvaluationTime;
  52371. private _captureRenderTargetsRenderTime;
  52372. private _renderTargetsRenderTime;
  52373. private _captureFrameTime;
  52374. private _frameTime;
  52375. private _captureRenderTime;
  52376. private _renderTime;
  52377. private _captureInterFrameTime;
  52378. private _interFrameTime;
  52379. private _captureParticlesRenderTime;
  52380. private _particlesRenderTime;
  52381. private _captureSpritesRenderTime;
  52382. private _spritesRenderTime;
  52383. private _capturePhysicsTime;
  52384. private _physicsTime;
  52385. private _captureAnimationsTime;
  52386. private _animationsTime;
  52387. private _captureCameraRenderTime;
  52388. private _cameraRenderTime;
  52389. private _onBeforeActiveMeshesEvaluationObserver;
  52390. private _onAfterActiveMeshesEvaluationObserver;
  52391. private _onBeforeRenderTargetsRenderObserver;
  52392. private _onAfterRenderTargetsRenderObserver;
  52393. private _onAfterRenderObserver;
  52394. private _onBeforeDrawPhaseObserver;
  52395. private _onAfterDrawPhaseObserver;
  52396. private _onBeforeAnimationsObserver;
  52397. private _onBeforeParticlesRenderingObserver;
  52398. private _onAfterParticlesRenderingObserver;
  52399. private _onBeforeSpritesRenderingObserver;
  52400. private _onAfterSpritesRenderingObserver;
  52401. private _onBeforePhysicsObserver;
  52402. private _onAfterPhysicsObserver;
  52403. private _onAfterAnimationsObserver;
  52404. private _onBeforeCameraRenderObserver;
  52405. private _onAfterCameraRenderObserver;
  52406. /**
  52407. * Gets the perf counter used for active meshes evaluation time
  52408. */
  52409. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52410. /**
  52411. * Gets the active meshes evaluation time capture status
  52412. */
  52413. /**
  52414. * Enable or disable the active meshes evaluation time capture
  52415. */
  52416. captureActiveMeshesEvaluationTime: boolean;
  52417. /**
  52418. * Gets the perf counter used for render targets render time
  52419. */
  52420. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52421. /**
  52422. * Gets the render targets render time capture status
  52423. */
  52424. /**
  52425. * Enable or disable the render targets render time capture
  52426. */
  52427. captureRenderTargetsRenderTime: boolean;
  52428. /**
  52429. * Gets the perf counter used for particles render time
  52430. */
  52431. readonly particlesRenderTimeCounter: PerfCounter;
  52432. /**
  52433. * Gets the particles render time capture status
  52434. */
  52435. /**
  52436. * Enable or disable the particles render time capture
  52437. */
  52438. captureParticlesRenderTime: boolean;
  52439. /**
  52440. * Gets the perf counter used for sprites render time
  52441. */
  52442. readonly spritesRenderTimeCounter: PerfCounter;
  52443. /**
  52444. * Gets the sprites render time capture status
  52445. */
  52446. /**
  52447. * Enable or disable the sprites render time capture
  52448. */
  52449. captureSpritesRenderTime: boolean;
  52450. /**
  52451. * Gets the perf counter used for physics time
  52452. */
  52453. readonly physicsTimeCounter: PerfCounter;
  52454. /**
  52455. * Gets the physics time capture status
  52456. */
  52457. /**
  52458. * Enable or disable the physics time capture
  52459. */
  52460. capturePhysicsTime: boolean;
  52461. /**
  52462. * Gets the perf counter used for animations time
  52463. */
  52464. readonly animationsTimeCounter: PerfCounter;
  52465. /**
  52466. * Gets the animations time capture status
  52467. */
  52468. /**
  52469. * Enable or disable the animations time capture
  52470. */
  52471. captureAnimationsTime: boolean;
  52472. /**
  52473. * Gets the perf counter used for frame time capture
  52474. */
  52475. readonly frameTimeCounter: PerfCounter;
  52476. /**
  52477. * Gets the frame time capture status
  52478. */
  52479. /**
  52480. * Enable or disable the frame time capture
  52481. */
  52482. captureFrameTime: boolean;
  52483. /**
  52484. * Gets the perf counter used for inter-frames time capture
  52485. */
  52486. readonly interFrameTimeCounter: PerfCounter;
  52487. /**
  52488. * Gets the inter-frames time capture status
  52489. */
  52490. /**
  52491. * Enable or disable the inter-frames time capture
  52492. */
  52493. captureInterFrameTime: boolean;
  52494. /**
  52495. * Gets the perf counter used for render time capture
  52496. */
  52497. readonly renderTimeCounter: PerfCounter;
  52498. /**
  52499. * Gets the render time capture status
  52500. */
  52501. /**
  52502. * Enable or disable the render time capture
  52503. */
  52504. captureRenderTime: boolean;
  52505. /**
  52506. * Gets the perf counter used for camera render time capture
  52507. */
  52508. readonly cameraRenderTimeCounter: PerfCounter;
  52509. /**
  52510. * Gets the camera render time capture status
  52511. */
  52512. /**
  52513. * Enable or disable the camera render time capture
  52514. */
  52515. captureCameraRenderTime: boolean;
  52516. /**
  52517. * Gets the perf counter used for draw calls
  52518. */
  52519. readonly drawCallsCounter: PerfCounter;
  52520. /**
  52521. * Instantiates a new scene instrumentation.
  52522. * This class can be used to get instrumentation data from a Babylon engine
  52523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52524. * @param scene Defines the scene to instrument
  52525. */
  52526. constructor(
  52527. /**
  52528. * Defines the scene to instrument
  52529. */
  52530. scene: Scene);
  52531. /**
  52532. * Dispose and release associated resources.
  52533. */
  52534. dispose(): void;
  52535. }
  52536. }
  52537. declare module "babylonjs/Instrumentation/index" {
  52538. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52539. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52540. export * from "babylonjs/Instrumentation/timeToken";
  52541. }
  52542. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52543. /** @hidden */
  52544. export var glowMapGenerationPixelShader: {
  52545. name: string;
  52546. shader: string;
  52547. };
  52548. }
  52549. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52550. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52553. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52554. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52555. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52556. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52557. /** @hidden */
  52558. export var glowMapGenerationVertexShader: {
  52559. name: string;
  52560. shader: string;
  52561. };
  52562. }
  52563. declare module "babylonjs/Layers/effectLayer" {
  52564. import { Observable } from "babylonjs/Misc/observable";
  52565. import { Nullable } from "babylonjs/types";
  52566. import { Camera } from "babylonjs/Cameras/camera";
  52567. import { Scene } from "babylonjs/scene";
  52568. import { ISize } from "babylonjs/Maths/math.size";
  52569. import { Color4 } from "babylonjs/Maths/math.color";
  52570. import { Engine } from "babylonjs/Engines/engine";
  52571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52573. import { Mesh } from "babylonjs/Meshes/mesh";
  52574. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52576. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52577. import { Effect } from "babylonjs/Materials/effect";
  52578. import { Material } from "babylonjs/Materials/material";
  52579. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52580. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52581. /**
  52582. * Effect layer options. This helps customizing the behaviour
  52583. * of the effect layer.
  52584. */
  52585. export interface IEffectLayerOptions {
  52586. /**
  52587. * Multiplication factor apply to the canvas size to compute the render target size
  52588. * used to generated the objects (the smaller the faster).
  52589. */
  52590. mainTextureRatio: number;
  52591. /**
  52592. * Enforces a fixed size texture to ensure effect stability across devices.
  52593. */
  52594. mainTextureFixedSize?: number;
  52595. /**
  52596. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52597. */
  52598. alphaBlendingMode: number;
  52599. /**
  52600. * The camera attached to the layer.
  52601. */
  52602. camera: Nullable<Camera>;
  52603. /**
  52604. * The rendering group to draw the layer in.
  52605. */
  52606. renderingGroupId: number;
  52607. }
  52608. /**
  52609. * The effect layer Helps adding post process effect blended with the main pass.
  52610. *
  52611. * This can be for instance use to generate glow or higlight effects on the scene.
  52612. *
  52613. * The effect layer class can not be used directly and is intented to inherited from to be
  52614. * customized per effects.
  52615. */
  52616. export abstract class EffectLayer {
  52617. private _vertexBuffers;
  52618. private _indexBuffer;
  52619. private _cachedDefines;
  52620. private _effectLayerMapGenerationEffect;
  52621. private _effectLayerOptions;
  52622. private _mergeEffect;
  52623. protected _scene: Scene;
  52624. protected _engine: Engine;
  52625. protected _maxSize: number;
  52626. protected _mainTextureDesiredSize: ISize;
  52627. protected _mainTexture: RenderTargetTexture;
  52628. protected _shouldRender: boolean;
  52629. protected _postProcesses: PostProcess[];
  52630. protected _textures: BaseTexture[];
  52631. protected _emissiveTextureAndColor: {
  52632. texture: Nullable<BaseTexture>;
  52633. color: Color4;
  52634. };
  52635. /**
  52636. * The name of the layer
  52637. */
  52638. name: string;
  52639. /**
  52640. * The clear color of the texture used to generate the glow map.
  52641. */
  52642. neutralColor: Color4;
  52643. /**
  52644. * Specifies wether the highlight layer is enabled or not.
  52645. */
  52646. isEnabled: boolean;
  52647. /**
  52648. * Gets the camera attached to the layer.
  52649. */
  52650. readonly camera: Nullable<Camera>;
  52651. /**
  52652. * Gets the rendering group id the layer should render in.
  52653. */
  52654. renderingGroupId: number;
  52655. /**
  52656. * An event triggered when the effect layer has been disposed.
  52657. */
  52658. onDisposeObservable: Observable<EffectLayer>;
  52659. /**
  52660. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52661. */
  52662. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52663. /**
  52664. * An event triggered when the generated texture is being merged in the scene.
  52665. */
  52666. onBeforeComposeObservable: Observable<EffectLayer>;
  52667. /**
  52668. * An event triggered when the mesh is rendered into the effect render target.
  52669. */
  52670. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52671. /**
  52672. * An event triggered after the mesh has been rendered into the effect render target.
  52673. */
  52674. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52675. /**
  52676. * An event triggered when the generated texture has been merged in the scene.
  52677. */
  52678. onAfterComposeObservable: Observable<EffectLayer>;
  52679. /**
  52680. * An event triggered when the efffect layer changes its size.
  52681. */
  52682. onSizeChangedObservable: Observable<EffectLayer>;
  52683. /** @hidden */
  52684. static _SceneComponentInitialization: (scene: Scene) => void;
  52685. /**
  52686. * Instantiates a new effect Layer and references it in the scene.
  52687. * @param name The name of the layer
  52688. * @param scene The scene to use the layer in
  52689. */
  52690. constructor(
  52691. /** The Friendly of the effect in the scene */
  52692. name: string, scene: Scene);
  52693. /**
  52694. * Get the effect name of the layer.
  52695. * @return The effect name
  52696. */
  52697. abstract getEffectName(): string;
  52698. /**
  52699. * Checks for the readiness of the element composing the layer.
  52700. * @param subMesh the mesh to check for
  52701. * @param useInstances specify wether or not to use instances to render the mesh
  52702. * @return true if ready otherwise, false
  52703. */
  52704. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52705. /**
  52706. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52707. * @returns true if the effect requires stencil during the main canvas render pass.
  52708. */
  52709. abstract needStencil(): boolean;
  52710. /**
  52711. * Create the merge effect. This is the shader use to blit the information back
  52712. * to the main canvas at the end of the scene rendering.
  52713. * @returns The effect containing the shader used to merge the effect on the main canvas
  52714. */
  52715. protected abstract _createMergeEffect(): Effect;
  52716. /**
  52717. * Creates the render target textures and post processes used in the effect layer.
  52718. */
  52719. protected abstract _createTextureAndPostProcesses(): void;
  52720. /**
  52721. * Implementation specific of rendering the generating effect on the main canvas.
  52722. * @param effect The effect used to render through
  52723. */
  52724. protected abstract _internalRender(effect: Effect): void;
  52725. /**
  52726. * Sets the required values for both the emissive texture and and the main color.
  52727. */
  52728. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52729. /**
  52730. * Free any resources and references associated to a mesh.
  52731. * Internal use
  52732. * @param mesh The mesh to free.
  52733. */
  52734. abstract _disposeMesh(mesh: Mesh): void;
  52735. /**
  52736. * Serializes this layer (Glow or Highlight for example)
  52737. * @returns a serialized layer object
  52738. */
  52739. abstract serialize?(): any;
  52740. /**
  52741. * Initializes the effect layer with the required options.
  52742. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52743. */
  52744. protected _init(options: Partial<IEffectLayerOptions>): void;
  52745. /**
  52746. * Generates the index buffer of the full screen quad blending to the main canvas.
  52747. */
  52748. private _generateIndexBuffer;
  52749. /**
  52750. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52751. */
  52752. private _generateVertexBuffer;
  52753. /**
  52754. * Sets the main texture desired size which is the closest power of two
  52755. * of the engine canvas size.
  52756. */
  52757. private _setMainTextureSize;
  52758. /**
  52759. * Creates the main texture for the effect layer.
  52760. */
  52761. protected _createMainTexture(): void;
  52762. /**
  52763. * Adds specific effects defines.
  52764. * @param defines The defines to add specifics to.
  52765. */
  52766. protected _addCustomEffectDefines(defines: string[]): void;
  52767. /**
  52768. * Checks for the readiness of the element composing the layer.
  52769. * @param subMesh the mesh to check for
  52770. * @param useInstances specify wether or not to use instances to render the mesh
  52771. * @param emissiveTexture the associated emissive texture used to generate the glow
  52772. * @return true if ready otherwise, false
  52773. */
  52774. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52775. /**
  52776. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52777. */
  52778. render(): void;
  52779. /**
  52780. * Determine if a given mesh will be used in the current effect.
  52781. * @param mesh mesh to test
  52782. * @returns true if the mesh will be used
  52783. */
  52784. hasMesh(mesh: AbstractMesh): boolean;
  52785. /**
  52786. * Returns true if the layer contains information to display, otherwise false.
  52787. * @returns true if the glow layer should be rendered
  52788. */
  52789. shouldRender(): boolean;
  52790. /**
  52791. * Returns true if the mesh should render, otherwise false.
  52792. * @param mesh The mesh to render
  52793. * @returns true if it should render otherwise false
  52794. */
  52795. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52796. /**
  52797. * Returns true if the mesh can be rendered, otherwise false.
  52798. * @param mesh The mesh to render
  52799. * @param material The material used on the mesh
  52800. * @returns true if it can be rendered otherwise false
  52801. */
  52802. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52803. /**
  52804. * Returns true if the mesh should render, otherwise false.
  52805. * @param mesh The mesh to render
  52806. * @returns true if it should render otherwise false
  52807. */
  52808. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52809. /**
  52810. * Renders the submesh passed in parameter to the generation map.
  52811. */
  52812. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52813. /**
  52814. * Defines wether the current material of the mesh should be use to render the effect.
  52815. * @param mesh defines the current mesh to render
  52816. */
  52817. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52818. /**
  52819. * Rebuild the required buffers.
  52820. * @hidden Internal use only.
  52821. */
  52822. _rebuild(): void;
  52823. /**
  52824. * Dispose only the render target textures and post process.
  52825. */
  52826. private _disposeTextureAndPostProcesses;
  52827. /**
  52828. * Dispose the highlight layer and free resources.
  52829. */
  52830. dispose(): void;
  52831. /**
  52832. * Gets the class name of the effect layer
  52833. * @returns the string with the class name of the effect layer
  52834. */
  52835. getClassName(): string;
  52836. /**
  52837. * Creates an effect layer from parsed effect layer data
  52838. * @param parsedEffectLayer defines effect layer data
  52839. * @param scene defines the current scene
  52840. * @param rootUrl defines the root URL containing the effect layer information
  52841. * @returns a parsed effect Layer
  52842. */
  52843. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52844. }
  52845. }
  52846. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52847. import { Scene } from "babylonjs/scene";
  52848. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52849. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52850. import { AbstractScene } from "babylonjs/abstractScene";
  52851. module "babylonjs/abstractScene" {
  52852. interface AbstractScene {
  52853. /**
  52854. * The list of effect layers (highlights/glow) added to the scene
  52855. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52856. * @see http://doc.babylonjs.com/how_to/glow_layer
  52857. */
  52858. effectLayers: Array<EffectLayer>;
  52859. /**
  52860. * Removes the given effect layer from this scene.
  52861. * @param toRemove defines the effect layer to remove
  52862. * @returns the index of the removed effect layer
  52863. */
  52864. removeEffectLayer(toRemove: EffectLayer): number;
  52865. /**
  52866. * Adds the given effect layer to this scene
  52867. * @param newEffectLayer defines the effect layer to add
  52868. */
  52869. addEffectLayer(newEffectLayer: EffectLayer): void;
  52870. }
  52871. }
  52872. /**
  52873. * Defines the layer scene component responsible to manage any effect layers
  52874. * in a given scene.
  52875. */
  52876. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52877. /**
  52878. * The component name helpfull to identify the component in the list of scene components.
  52879. */
  52880. readonly name: string;
  52881. /**
  52882. * The scene the component belongs to.
  52883. */
  52884. scene: Scene;
  52885. private _engine;
  52886. private _renderEffects;
  52887. private _needStencil;
  52888. private _previousStencilState;
  52889. /**
  52890. * Creates a new instance of the component for the given scene
  52891. * @param scene Defines the scene to register the component in
  52892. */
  52893. constructor(scene: Scene);
  52894. /**
  52895. * Registers the component in a given scene
  52896. */
  52897. register(): void;
  52898. /**
  52899. * Rebuilds the elements related to this component in case of
  52900. * context lost for instance.
  52901. */
  52902. rebuild(): void;
  52903. /**
  52904. * Serializes the component data to the specified json object
  52905. * @param serializationObject The object to serialize to
  52906. */
  52907. serialize(serializationObject: any): void;
  52908. /**
  52909. * Adds all the elements from the container to the scene
  52910. * @param container the container holding the elements
  52911. */
  52912. addFromContainer(container: AbstractScene): void;
  52913. /**
  52914. * Removes all the elements in the container from the scene
  52915. * @param container contains the elements to remove
  52916. * @param dispose if the removed element should be disposed (default: false)
  52917. */
  52918. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52919. /**
  52920. * Disposes the component and the associated ressources.
  52921. */
  52922. dispose(): void;
  52923. private _isReadyForMesh;
  52924. private _renderMainTexture;
  52925. private _setStencil;
  52926. private _setStencilBack;
  52927. private _draw;
  52928. private _drawCamera;
  52929. private _drawRenderingGroup;
  52930. }
  52931. }
  52932. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52933. /** @hidden */
  52934. export var glowMapMergePixelShader: {
  52935. name: string;
  52936. shader: string;
  52937. };
  52938. }
  52939. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52940. /** @hidden */
  52941. export var glowMapMergeVertexShader: {
  52942. name: string;
  52943. shader: string;
  52944. };
  52945. }
  52946. declare module "babylonjs/Layers/glowLayer" {
  52947. import { Nullable } from "babylonjs/types";
  52948. import { Camera } from "babylonjs/Cameras/camera";
  52949. import { Scene } from "babylonjs/scene";
  52950. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52952. import { Mesh } from "babylonjs/Meshes/mesh";
  52953. import { Texture } from "babylonjs/Materials/Textures/texture";
  52954. import { Effect } from "babylonjs/Materials/effect";
  52955. import { Material } from "babylonjs/Materials/material";
  52956. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52957. import { Color4 } from "babylonjs/Maths/math.color";
  52958. import "babylonjs/Shaders/glowMapMerge.fragment";
  52959. import "babylonjs/Shaders/glowMapMerge.vertex";
  52960. import "babylonjs/Layers/effectLayerSceneComponent";
  52961. module "babylonjs/abstractScene" {
  52962. interface AbstractScene {
  52963. /**
  52964. * Return a the first highlight layer of the scene with a given name.
  52965. * @param name The name of the highlight layer to look for.
  52966. * @return The highlight layer if found otherwise null.
  52967. */
  52968. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52969. }
  52970. }
  52971. /**
  52972. * Glow layer options. This helps customizing the behaviour
  52973. * of the glow layer.
  52974. */
  52975. export interface IGlowLayerOptions {
  52976. /**
  52977. * Multiplication factor apply to the canvas size to compute the render target size
  52978. * used to generated the glowing objects (the smaller the faster).
  52979. */
  52980. mainTextureRatio: number;
  52981. /**
  52982. * Enforces a fixed size texture to ensure resize independant blur.
  52983. */
  52984. mainTextureFixedSize?: number;
  52985. /**
  52986. * How big is the kernel of the blur texture.
  52987. */
  52988. blurKernelSize: number;
  52989. /**
  52990. * The camera attached to the layer.
  52991. */
  52992. camera: Nullable<Camera>;
  52993. /**
  52994. * Enable MSAA by chosing the number of samples.
  52995. */
  52996. mainTextureSamples?: number;
  52997. /**
  52998. * The rendering group to draw the layer in.
  52999. */
  53000. renderingGroupId: number;
  53001. }
  53002. /**
  53003. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53004. *
  53005. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53006. *
  53007. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53008. */
  53009. export class GlowLayer extends EffectLayer {
  53010. /**
  53011. * Effect Name of the layer.
  53012. */
  53013. static readonly EffectName: string;
  53014. /**
  53015. * The default blur kernel size used for the glow.
  53016. */
  53017. static DefaultBlurKernelSize: number;
  53018. /**
  53019. * The default texture size ratio used for the glow.
  53020. */
  53021. static DefaultTextureRatio: number;
  53022. /**
  53023. * Sets the kernel size of the blur.
  53024. */
  53025. /**
  53026. * Gets the kernel size of the blur.
  53027. */
  53028. blurKernelSize: number;
  53029. /**
  53030. * Sets the glow intensity.
  53031. */
  53032. /**
  53033. * Gets the glow intensity.
  53034. */
  53035. intensity: number;
  53036. private _options;
  53037. private _intensity;
  53038. private _horizontalBlurPostprocess1;
  53039. private _verticalBlurPostprocess1;
  53040. private _horizontalBlurPostprocess2;
  53041. private _verticalBlurPostprocess2;
  53042. private _blurTexture1;
  53043. private _blurTexture2;
  53044. private _postProcesses1;
  53045. private _postProcesses2;
  53046. private _includedOnlyMeshes;
  53047. private _excludedMeshes;
  53048. private _meshesUsingTheirOwnMaterials;
  53049. /**
  53050. * Callback used to let the user override the color selection on a per mesh basis
  53051. */
  53052. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53053. /**
  53054. * Callback used to let the user override the texture selection on a per mesh basis
  53055. */
  53056. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53057. /**
  53058. * Instantiates a new glow Layer and references it to the scene.
  53059. * @param name The name of the layer
  53060. * @param scene The scene to use the layer in
  53061. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53062. */
  53063. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53064. /**
  53065. * Get the effect name of the layer.
  53066. * @return The effect name
  53067. */
  53068. getEffectName(): string;
  53069. /**
  53070. * Create the merge effect. This is the shader use to blit the information back
  53071. * to the main canvas at the end of the scene rendering.
  53072. */
  53073. protected _createMergeEffect(): Effect;
  53074. /**
  53075. * Creates the render target textures and post processes used in the glow layer.
  53076. */
  53077. protected _createTextureAndPostProcesses(): void;
  53078. /**
  53079. * Checks for the readiness of the element composing the layer.
  53080. * @param subMesh the mesh to check for
  53081. * @param useInstances specify wether or not to use instances to render the mesh
  53082. * @param emissiveTexture the associated emissive texture used to generate the glow
  53083. * @return true if ready otherwise, false
  53084. */
  53085. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53086. /**
  53087. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53088. */
  53089. needStencil(): boolean;
  53090. /**
  53091. * Returns true if the mesh can be rendered, otherwise false.
  53092. * @param mesh The mesh to render
  53093. * @param material The material used on the mesh
  53094. * @returns true if it can be rendered otherwise false
  53095. */
  53096. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53097. /**
  53098. * Implementation specific of rendering the generating effect on the main canvas.
  53099. * @param effect The effect used to render through
  53100. */
  53101. protected _internalRender(effect: Effect): void;
  53102. /**
  53103. * Sets the required values for both the emissive texture and and the main color.
  53104. */
  53105. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53106. /**
  53107. * Returns true if the mesh should render, otherwise false.
  53108. * @param mesh The mesh to render
  53109. * @returns true if it should render otherwise false
  53110. */
  53111. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53112. /**
  53113. * Adds specific effects defines.
  53114. * @param defines The defines to add specifics to.
  53115. */
  53116. protected _addCustomEffectDefines(defines: string[]): void;
  53117. /**
  53118. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53119. * @param mesh The mesh to exclude from the glow layer
  53120. */
  53121. addExcludedMesh(mesh: Mesh): void;
  53122. /**
  53123. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53124. * @param mesh The mesh to remove
  53125. */
  53126. removeExcludedMesh(mesh: Mesh): void;
  53127. /**
  53128. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53129. * @param mesh The mesh to include in the glow layer
  53130. */
  53131. addIncludedOnlyMesh(mesh: Mesh): void;
  53132. /**
  53133. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53134. * @param mesh The mesh to remove
  53135. */
  53136. removeIncludedOnlyMesh(mesh: Mesh): void;
  53137. /**
  53138. * Determine if a given mesh will be used in the glow layer
  53139. * @param mesh The mesh to test
  53140. * @returns true if the mesh will be highlighted by the current glow layer
  53141. */
  53142. hasMesh(mesh: AbstractMesh): boolean;
  53143. /**
  53144. * Defines wether the current material of the mesh should be use to render the effect.
  53145. * @param mesh defines the current mesh to render
  53146. */
  53147. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53148. /**
  53149. * Add a mesh to be rendered through its own material and not with emissive only.
  53150. * @param mesh The mesh for which we need to use its material
  53151. */
  53152. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53153. /**
  53154. * Remove a mesh from being rendered through its own material and not with emissive only.
  53155. * @param mesh The mesh for which we need to not use its material
  53156. */
  53157. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53158. /**
  53159. * Free any resources and references associated to a mesh.
  53160. * Internal use
  53161. * @param mesh The mesh to free.
  53162. * @hidden
  53163. */
  53164. _disposeMesh(mesh: Mesh): void;
  53165. /**
  53166. * Gets the class name of the effect layer
  53167. * @returns the string with the class name of the effect layer
  53168. */
  53169. getClassName(): string;
  53170. /**
  53171. * Serializes this glow layer
  53172. * @returns a serialized glow layer object
  53173. */
  53174. serialize(): any;
  53175. /**
  53176. * Creates a Glow Layer from parsed glow layer data
  53177. * @param parsedGlowLayer defines glow layer data
  53178. * @param scene defines the current scene
  53179. * @param rootUrl defines the root URL containing the glow layer information
  53180. * @returns a parsed Glow Layer
  53181. */
  53182. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53183. }
  53184. }
  53185. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53186. /** @hidden */
  53187. export var glowBlurPostProcessPixelShader: {
  53188. name: string;
  53189. shader: string;
  53190. };
  53191. }
  53192. declare module "babylonjs/Layers/highlightLayer" {
  53193. import { Observable } from "babylonjs/Misc/observable";
  53194. import { Nullable } from "babylonjs/types";
  53195. import { Camera } from "babylonjs/Cameras/camera";
  53196. import { Scene } from "babylonjs/scene";
  53197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53199. import { Mesh } from "babylonjs/Meshes/mesh";
  53200. import { Effect } from "babylonjs/Materials/effect";
  53201. import { Material } from "babylonjs/Materials/material";
  53202. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53203. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53204. import "babylonjs/Shaders/glowMapMerge.fragment";
  53205. import "babylonjs/Shaders/glowMapMerge.vertex";
  53206. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53207. module "babylonjs/abstractScene" {
  53208. interface AbstractScene {
  53209. /**
  53210. * Return a the first highlight layer of the scene with a given name.
  53211. * @param name The name of the highlight layer to look for.
  53212. * @return The highlight layer if found otherwise null.
  53213. */
  53214. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53215. }
  53216. }
  53217. /**
  53218. * Highlight layer options. This helps customizing the behaviour
  53219. * of the highlight layer.
  53220. */
  53221. export interface IHighlightLayerOptions {
  53222. /**
  53223. * Multiplication factor apply to the canvas size to compute the render target size
  53224. * used to generated the glowing objects (the smaller the faster).
  53225. */
  53226. mainTextureRatio: number;
  53227. /**
  53228. * Enforces a fixed size texture to ensure resize independant blur.
  53229. */
  53230. mainTextureFixedSize?: number;
  53231. /**
  53232. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53233. * of the picture to blur (the smaller the faster).
  53234. */
  53235. blurTextureSizeRatio: number;
  53236. /**
  53237. * How big in texel of the blur texture is the vertical blur.
  53238. */
  53239. blurVerticalSize: number;
  53240. /**
  53241. * How big in texel of the blur texture is the horizontal blur.
  53242. */
  53243. blurHorizontalSize: number;
  53244. /**
  53245. * Alpha blending mode used to apply the blur. Default is combine.
  53246. */
  53247. alphaBlendingMode: number;
  53248. /**
  53249. * The camera attached to the layer.
  53250. */
  53251. camera: Nullable<Camera>;
  53252. /**
  53253. * Should we display highlight as a solid stroke?
  53254. */
  53255. isStroke?: boolean;
  53256. /**
  53257. * The rendering group to draw the layer in.
  53258. */
  53259. renderingGroupId: number;
  53260. }
  53261. /**
  53262. * The highlight layer Helps adding a glow effect around a mesh.
  53263. *
  53264. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53265. * glowy meshes to your scene.
  53266. *
  53267. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53268. */
  53269. export class HighlightLayer extends EffectLayer {
  53270. name: string;
  53271. /**
  53272. * Effect Name of the highlight layer.
  53273. */
  53274. static readonly EffectName: string;
  53275. /**
  53276. * The neutral color used during the preparation of the glow effect.
  53277. * This is black by default as the blend operation is a blend operation.
  53278. */
  53279. static NeutralColor: Color4;
  53280. /**
  53281. * Stencil value used for glowing meshes.
  53282. */
  53283. static GlowingMeshStencilReference: number;
  53284. /**
  53285. * Stencil value used for the other meshes in the scene.
  53286. */
  53287. static NormalMeshStencilReference: number;
  53288. /**
  53289. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53290. */
  53291. innerGlow: boolean;
  53292. /**
  53293. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53294. */
  53295. outerGlow: boolean;
  53296. /**
  53297. * Specifies the horizontal size of the blur.
  53298. */
  53299. /**
  53300. * Gets the horizontal size of the blur.
  53301. */
  53302. blurHorizontalSize: number;
  53303. /**
  53304. * Specifies the vertical size of the blur.
  53305. */
  53306. /**
  53307. * Gets the vertical size of the blur.
  53308. */
  53309. blurVerticalSize: number;
  53310. /**
  53311. * An event triggered when the highlight layer is being blurred.
  53312. */
  53313. onBeforeBlurObservable: Observable<HighlightLayer>;
  53314. /**
  53315. * An event triggered when the highlight layer has been blurred.
  53316. */
  53317. onAfterBlurObservable: Observable<HighlightLayer>;
  53318. private _instanceGlowingMeshStencilReference;
  53319. private _options;
  53320. private _downSamplePostprocess;
  53321. private _horizontalBlurPostprocess;
  53322. private _verticalBlurPostprocess;
  53323. private _blurTexture;
  53324. private _meshes;
  53325. private _excludedMeshes;
  53326. /**
  53327. * Instantiates a new highlight Layer and references it to the scene..
  53328. * @param name The name of the layer
  53329. * @param scene The scene to use the layer in
  53330. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53331. */
  53332. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53333. /**
  53334. * Get the effect name of the layer.
  53335. * @return The effect name
  53336. */
  53337. getEffectName(): string;
  53338. /**
  53339. * Create the merge effect. This is the shader use to blit the information back
  53340. * to the main canvas at the end of the scene rendering.
  53341. */
  53342. protected _createMergeEffect(): Effect;
  53343. /**
  53344. * Creates the render target textures and post processes used in the highlight layer.
  53345. */
  53346. protected _createTextureAndPostProcesses(): void;
  53347. /**
  53348. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53349. */
  53350. needStencil(): boolean;
  53351. /**
  53352. * Checks for the readiness of the element composing the layer.
  53353. * @param subMesh the mesh to check for
  53354. * @param useInstances specify wether or not to use instances to render the mesh
  53355. * @param emissiveTexture the associated emissive texture used to generate the glow
  53356. * @return true if ready otherwise, false
  53357. */
  53358. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53359. /**
  53360. * Implementation specific of rendering the generating effect on the main canvas.
  53361. * @param effect The effect used to render through
  53362. */
  53363. protected _internalRender(effect: Effect): void;
  53364. /**
  53365. * Returns true if the layer contains information to display, otherwise false.
  53366. */
  53367. shouldRender(): boolean;
  53368. /**
  53369. * Returns true if the mesh should render, otherwise false.
  53370. * @param mesh The mesh to render
  53371. * @returns true if it should render otherwise false
  53372. */
  53373. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53374. /**
  53375. * Sets the required values for both the emissive texture and and the main color.
  53376. */
  53377. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53378. /**
  53379. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53380. * @param mesh The mesh to exclude from the highlight layer
  53381. */
  53382. addExcludedMesh(mesh: Mesh): void;
  53383. /**
  53384. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53385. * @param mesh The mesh to highlight
  53386. */
  53387. removeExcludedMesh(mesh: Mesh): void;
  53388. /**
  53389. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53390. * @param mesh mesh to test
  53391. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53392. */
  53393. hasMesh(mesh: AbstractMesh): boolean;
  53394. /**
  53395. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53396. * @param mesh The mesh to highlight
  53397. * @param color The color of the highlight
  53398. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53399. */
  53400. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53401. /**
  53402. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53403. * @param mesh The mesh to highlight
  53404. */
  53405. removeMesh(mesh: Mesh): void;
  53406. /**
  53407. * Force the stencil to the normal expected value for none glowing parts
  53408. */
  53409. private _defaultStencilReference;
  53410. /**
  53411. * Free any resources and references associated to a mesh.
  53412. * Internal use
  53413. * @param mesh The mesh to free.
  53414. * @hidden
  53415. */
  53416. _disposeMesh(mesh: Mesh): void;
  53417. /**
  53418. * Dispose the highlight layer and free resources.
  53419. */
  53420. dispose(): void;
  53421. /**
  53422. * Gets the class name of the effect layer
  53423. * @returns the string with the class name of the effect layer
  53424. */
  53425. getClassName(): string;
  53426. /**
  53427. * Serializes this Highlight layer
  53428. * @returns a serialized Highlight layer object
  53429. */
  53430. serialize(): any;
  53431. /**
  53432. * Creates a Highlight layer from parsed Highlight layer data
  53433. * @param parsedHightlightLayer defines the Highlight layer data
  53434. * @param scene defines the current scene
  53435. * @param rootUrl defines the root URL containing the Highlight layer information
  53436. * @returns a parsed Highlight layer
  53437. */
  53438. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53439. }
  53440. }
  53441. declare module "babylonjs/Layers/layerSceneComponent" {
  53442. import { Scene } from "babylonjs/scene";
  53443. import { ISceneComponent } from "babylonjs/sceneComponent";
  53444. import { Layer } from "babylonjs/Layers/layer";
  53445. import { AbstractScene } from "babylonjs/abstractScene";
  53446. module "babylonjs/abstractScene" {
  53447. interface AbstractScene {
  53448. /**
  53449. * The list of layers (background and foreground) of the scene
  53450. */
  53451. layers: Array<Layer>;
  53452. }
  53453. }
  53454. /**
  53455. * Defines the layer scene component responsible to manage any layers
  53456. * in a given scene.
  53457. */
  53458. export class LayerSceneComponent implements ISceneComponent {
  53459. /**
  53460. * The component name helpfull to identify the component in the list of scene components.
  53461. */
  53462. readonly name: string;
  53463. /**
  53464. * The scene the component belongs to.
  53465. */
  53466. scene: Scene;
  53467. private _engine;
  53468. /**
  53469. * Creates a new instance of the component for the given scene
  53470. * @param scene Defines the scene to register the component in
  53471. */
  53472. constructor(scene: Scene);
  53473. /**
  53474. * Registers the component in a given scene
  53475. */
  53476. register(): void;
  53477. /**
  53478. * Rebuilds the elements related to this component in case of
  53479. * context lost for instance.
  53480. */
  53481. rebuild(): void;
  53482. /**
  53483. * Disposes the component and the associated ressources.
  53484. */
  53485. dispose(): void;
  53486. private _draw;
  53487. private _drawCameraPredicate;
  53488. private _drawCameraBackground;
  53489. private _drawCameraForeground;
  53490. private _drawRenderTargetPredicate;
  53491. private _drawRenderTargetBackground;
  53492. private _drawRenderTargetForeground;
  53493. /**
  53494. * Adds all the elements from the container to the scene
  53495. * @param container the container holding the elements
  53496. */
  53497. addFromContainer(container: AbstractScene): void;
  53498. /**
  53499. * Removes all the elements in the container from the scene
  53500. * @param container contains the elements to remove
  53501. * @param dispose if the removed element should be disposed (default: false)
  53502. */
  53503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53504. }
  53505. }
  53506. declare module "babylonjs/Shaders/layer.fragment" {
  53507. /** @hidden */
  53508. export var layerPixelShader: {
  53509. name: string;
  53510. shader: string;
  53511. };
  53512. }
  53513. declare module "babylonjs/Shaders/layer.vertex" {
  53514. /** @hidden */
  53515. export var layerVertexShader: {
  53516. name: string;
  53517. shader: string;
  53518. };
  53519. }
  53520. declare module "babylonjs/Layers/layer" {
  53521. import { Observable } from "babylonjs/Misc/observable";
  53522. import { Nullable } from "babylonjs/types";
  53523. import { Scene } from "babylonjs/scene";
  53524. import { Vector2 } from "babylonjs/Maths/math.vector";
  53525. import { Color4 } from "babylonjs/Maths/math.color";
  53526. import { Texture } from "babylonjs/Materials/Textures/texture";
  53527. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53528. import "babylonjs/Shaders/layer.fragment";
  53529. import "babylonjs/Shaders/layer.vertex";
  53530. /**
  53531. * This represents a full screen 2d layer.
  53532. * This can be useful to display a picture in the background of your scene for instance.
  53533. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53534. */
  53535. export class Layer {
  53536. /**
  53537. * Define the name of the layer.
  53538. */
  53539. name: string;
  53540. /**
  53541. * Define the texture the layer should display.
  53542. */
  53543. texture: Nullable<Texture>;
  53544. /**
  53545. * Is the layer in background or foreground.
  53546. */
  53547. isBackground: boolean;
  53548. /**
  53549. * Define the color of the layer (instead of texture).
  53550. */
  53551. color: Color4;
  53552. /**
  53553. * Define the scale of the layer in order to zoom in out of the texture.
  53554. */
  53555. scale: Vector2;
  53556. /**
  53557. * Define an offset for the layer in order to shift the texture.
  53558. */
  53559. offset: Vector2;
  53560. /**
  53561. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53562. */
  53563. alphaBlendingMode: number;
  53564. /**
  53565. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53566. * Alpha test will not mix with the background color in case of transparency.
  53567. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53568. */
  53569. alphaTest: boolean;
  53570. /**
  53571. * Define a mask to restrict the layer to only some of the scene cameras.
  53572. */
  53573. layerMask: number;
  53574. /**
  53575. * Define the list of render target the layer is visible into.
  53576. */
  53577. renderTargetTextures: RenderTargetTexture[];
  53578. /**
  53579. * Define if the layer is only used in renderTarget or if it also
  53580. * renders in the main frame buffer of the canvas.
  53581. */
  53582. renderOnlyInRenderTargetTextures: boolean;
  53583. private _scene;
  53584. private _vertexBuffers;
  53585. private _indexBuffer;
  53586. private _effect;
  53587. private _alphaTestEffect;
  53588. /**
  53589. * An event triggered when the layer is disposed.
  53590. */
  53591. onDisposeObservable: Observable<Layer>;
  53592. private _onDisposeObserver;
  53593. /**
  53594. * Back compatibility with callback before the onDisposeObservable existed.
  53595. * The set callback will be triggered when the layer has been disposed.
  53596. */
  53597. onDispose: () => void;
  53598. /**
  53599. * An event triggered before rendering the scene
  53600. */
  53601. onBeforeRenderObservable: Observable<Layer>;
  53602. private _onBeforeRenderObserver;
  53603. /**
  53604. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53605. * The set callback will be triggered just before rendering the layer.
  53606. */
  53607. onBeforeRender: () => void;
  53608. /**
  53609. * An event triggered after rendering the scene
  53610. */
  53611. onAfterRenderObservable: Observable<Layer>;
  53612. private _onAfterRenderObserver;
  53613. /**
  53614. * Back compatibility with callback before the onAfterRenderObservable existed.
  53615. * The set callback will be triggered just after rendering the layer.
  53616. */
  53617. onAfterRender: () => void;
  53618. /**
  53619. * Instantiates a new layer.
  53620. * This represents a full screen 2d layer.
  53621. * This can be useful to display a picture in the background of your scene for instance.
  53622. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53623. * @param name Define the name of the layer in the scene
  53624. * @param imgUrl Define the url of the texture to display in the layer
  53625. * @param scene Define the scene the layer belongs to
  53626. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53627. * @param color Defines a color for the layer
  53628. */
  53629. constructor(
  53630. /**
  53631. * Define the name of the layer.
  53632. */
  53633. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53634. private _createIndexBuffer;
  53635. /** @hidden */
  53636. _rebuild(): void;
  53637. /**
  53638. * Renders the layer in the scene.
  53639. */
  53640. render(): void;
  53641. /**
  53642. * Disposes and releases the associated ressources.
  53643. */
  53644. dispose(): void;
  53645. }
  53646. }
  53647. declare module "babylonjs/Layers/index" {
  53648. export * from "babylonjs/Layers/effectLayer";
  53649. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53650. export * from "babylonjs/Layers/glowLayer";
  53651. export * from "babylonjs/Layers/highlightLayer";
  53652. export * from "babylonjs/Layers/layer";
  53653. export * from "babylonjs/Layers/layerSceneComponent";
  53654. }
  53655. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53656. /** @hidden */
  53657. export var lensFlarePixelShader: {
  53658. name: string;
  53659. shader: string;
  53660. };
  53661. }
  53662. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53663. /** @hidden */
  53664. export var lensFlareVertexShader: {
  53665. name: string;
  53666. shader: string;
  53667. };
  53668. }
  53669. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53670. import { Scene } from "babylonjs/scene";
  53671. import { Vector3 } from "babylonjs/Maths/math.vector";
  53672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53673. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53674. import "babylonjs/Shaders/lensFlare.fragment";
  53675. import "babylonjs/Shaders/lensFlare.vertex";
  53676. import { Viewport } from "babylonjs/Maths/math.viewport";
  53677. /**
  53678. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53679. * It is usually composed of several `lensFlare`.
  53680. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53681. */
  53682. export class LensFlareSystem {
  53683. /**
  53684. * Define the name of the lens flare system
  53685. */
  53686. name: string;
  53687. /**
  53688. * List of lens flares used in this system.
  53689. */
  53690. lensFlares: LensFlare[];
  53691. /**
  53692. * Define a limit from the border the lens flare can be visible.
  53693. */
  53694. borderLimit: number;
  53695. /**
  53696. * Define a viewport border we do not want to see the lens flare in.
  53697. */
  53698. viewportBorder: number;
  53699. /**
  53700. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53701. */
  53702. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53703. /**
  53704. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53705. */
  53706. layerMask: number;
  53707. /**
  53708. * Define the id of the lens flare system in the scene.
  53709. * (equal to name by default)
  53710. */
  53711. id: string;
  53712. private _scene;
  53713. private _emitter;
  53714. private _vertexBuffers;
  53715. private _indexBuffer;
  53716. private _effect;
  53717. private _positionX;
  53718. private _positionY;
  53719. private _isEnabled;
  53720. /** @hidden */
  53721. static _SceneComponentInitialization: (scene: Scene) => void;
  53722. /**
  53723. * Instantiates a lens flare system.
  53724. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53725. * It is usually composed of several `lensFlare`.
  53726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53727. * @param name Define the name of the lens flare system in the scene
  53728. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53729. * @param scene Define the scene the lens flare system belongs to
  53730. */
  53731. constructor(
  53732. /**
  53733. * Define the name of the lens flare system
  53734. */
  53735. name: string, emitter: any, scene: Scene);
  53736. /**
  53737. * Define if the lens flare system is enabled.
  53738. */
  53739. isEnabled: boolean;
  53740. /**
  53741. * Get the scene the effects belongs to.
  53742. * @returns the scene holding the lens flare system
  53743. */
  53744. getScene(): Scene;
  53745. /**
  53746. * Get the emitter of the lens flare system.
  53747. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53748. * @returns the emitter of the lens flare system
  53749. */
  53750. getEmitter(): any;
  53751. /**
  53752. * Set the emitter of the lens flare system.
  53753. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53754. * @param newEmitter Define the new emitter of the system
  53755. */
  53756. setEmitter(newEmitter: any): void;
  53757. /**
  53758. * Get the lens flare system emitter position.
  53759. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53760. * @returns the position
  53761. */
  53762. getEmitterPosition(): Vector3;
  53763. /**
  53764. * @hidden
  53765. */
  53766. computeEffectivePosition(globalViewport: Viewport): boolean;
  53767. /** @hidden */
  53768. _isVisible(): boolean;
  53769. /**
  53770. * @hidden
  53771. */
  53772. render(): boolean;
  53773. /**
  53774. * Dispose and release the lens flare with its associated resources.
  53775. */
  53776. dispose(): void;
  53777. /**
  53778. * Parse a lens flare system from a JSON repressentation
  53779. * @param parsedLensFlareSystem Define the JSON to parse
  53780. * @param scene Define the scene the parsed system should be instantiated in
  53781. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53782. * @returns the parsed system
  53783. */
  53784. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53785. /**
  53786. * Serialize the current Lens Flare System into a JSON representation.
  53787. * @returns the serialized JSON
  53788. */
  53789. serialize(): any;
  53790. }
  53791. }
  53792. declare module "babylonjs/LensFlares/lensFlare" {
  53793. import { Nullable } from "babylonjs/types";
  53794. import { Color3 } from "babylonjs/Maths/math.color";
  53795. import { Texture } from "babylonjs/Materials/Textures/texture";
  53796. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53797. /**
  53798. * This represents one of the lens effect in a `lensFlareSystem`.
  53799. * It controls one of the indiviual texture used in the effect.
  53800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53801. */
  53802. export class LensFlare {
  53803. /**
  53804. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53805. */
  53806. size: number;
  53807. /**
  53808. * 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.
  53809. */
  53810. position: number;
  53811. /**
  53812. * Define the lens color.
  53813. */
  53814. color: Color3;
  53815. /**
  53816. * Define the lens texture.
  53817. */
  53818. texture: Nullable<Texture>;
  53819. /**
  53820. * Define the alpha mode to render this particular lens.
  53821. */
  53822. alphaMode: number;
  53823. private _system;
  53824. /**
  53825. * Creates a new Lens Flare.
  53826. * This represents one of the lens effect in a `lensFlareSystem`.
  53827. * It controls one of the indiviual texture used in the effect.
  53828. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53829. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53830. * @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.
  53831. * @param color Define the lens color
  53832. * @param imgUrl Define the lens texture url
  53833. * @param system Define the `lensFlareSystem` this flare is part of
  53834. * @returns The newly created Lens Flare
  53835. */
  53836. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53837. /**
  53838. * Instantiates a new Lens Flare.
  53839. * This represents one of the lens effect in a `lensFlareSystem`.
  53840. * It controls one of the indiviual texture used in the effect.
  53841. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53842. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53843. * @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.
  53844. * @param color Define the lens color
  53845. * @param imgUrl Define the lens texture url
  53846. * @param system Define the `lensFlareSystem` this flare is part of
  53847. */
  53848. constructor(
  53849. /**
  53850. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53851. */
  53852. size: number,
  53853. /**
  53854. * 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.
  53855. */
  53856. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53857. /**
  53858. * Dispose and release the lens flare with its associated resources.
  53859. */
  53860. dispose(): void;
  53861. }
  53862. }
  53863. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53864. import { Nullable } from "babylonjs/types";
  53865. import { Scene } from "babylonjs/scene";
  53866. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53867. import { AbstractScene } from "babylonjs/abstractScene";
  53868. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53869. module "babylonjs/abstractScene" {
  53870. interface AbstractScene {
  53871. /**
  53872. * The list of lens flare system added to the scene
  53873. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53874. */
  53875. lensFlareSystems: Array<LensFlareSystem>;
  53876. /**
  53877. * Removes the given lens flare system from this scene.
  53878. * @param toRemove The lens flare system to remove
  53879. * @returns The index of the removed lens flare system
  53880. */
  53881. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53882. /**
  53883. * Adds the given lens flare system to this scene
  53884. * @param newLensFlareSystem The lens flare system to add
  53885. */
  53886. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53887. /**
  53888. * Gets a lens flare system using its name
  53889. * @param name defines the name to look for
  53890. * @returns the lens flare system or null if not found
  53891. */
  53892. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53893. /**
  53894. * Gets a lens flare system using its id
  53895. * @param id defines the id to look for
  53896. * @returns the lens flare system or null if not found
  53897. */
  53898. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53899. }
  53900. }
  53901. /**
  53902. * Defines the lens flare scene component responsible to manage any lens flares
  53903. * in a given scene.
  53904. */
  53905. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53906. /**
  53907. * The component name helpfull to identify the component in the list of scene components.
  53908. */
  53909. readonly name: string;
  53910. /**
  53911. * The scene the component belongs to.
  53912. */
  53913. scene: Scene;
  53914. /**
  53915. * Creates a new instance of the component for the given scene
  53916. * @param scene Defines the scene to register the component in
  53917. */
  53918. constructor(scene: Scene);
  53919. /**
  53920. * Registers the component in a given scene
  53921. */
  53922. register(): void;
  53923. /**
  53924. * Rebuilds the elements related to this component in case of
  53925. * context lost for instance.
  53926. */
  53927. rebuild(): void;
  53928. /**
  53929. * Adds all the elements from the container to the scene
  53930. * @param container the container holding the elements
  53931. */
  53932. addFromContainer(container: AbstractScene): void;
  53933. /**
  53934. * Removes all the elements in the container from the scene
  53935. * @param container contains the elements to remove
  53936. * @param dispose if the removed element should be disposed (default: false)
  53937. */
  53938. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53939. /**
  53940. * Serializes the component data to the specified json object
  53941. * @param serializationObject The object to serialize to
  53942. */
  53943. serialize(serializationObject: any): void;
  53944. /**
  53945. * Disposes the component and the associated ressources.
  53946. */
  53947. dispose(): void;
  53948. private _draw;
  53949. }
  53950. }
  53951. declare module "babylonjs/LensFlares/index" {
  53952. export * from "babylonjs/LensFlares/lensFlare";
  53953. export * from "babylonjs/LensFlares/lensFlareSystem";
  53954. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53955. }
  53956. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53957. import { Scene } from "babylonjs/scene";
  53958. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53959. import { AbstractScene } from "babylonjs/abstractScene";
  53960. /**
  53961. * Defines the shadow generator component responsible to manage any shadow generators
  53962. * in a given scene.
  53963. */
  53964. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53965. /**
  53966. * The component name helpfull to identify the component in the list of scene components.
  53967. */
  53968. readonly name: string;
  53969. /**
  53970. * The scene the component belongs to.
  53971. */
  53972. scene: Scene;
  53973. /**
  53974. * Creates a new instance of the component for the given scene
  53975. * @param scene Defines the scene to register the component in
  53976. */
  53977. constructor(scene: Scene);
  53978. /**
  53979. * Registers the component in a given scene
  53980. */
  53981. register(): void;
  53982. /**
  53983. * Rebuilds the elements related to this component in case of
  53984. * context lost for instance.
  53985. */
  53986. rebuild(): void;
  53987. /**
  53988. * Serializes the component data to the specified json object
  53989. * @param serializationObject The object to serialize to
  53990. */
  53991. serialize(serializationObject: any): void;
  53992. /**
  53993. * Adds all the elements from the container to the scene
  53994. * @param container the container holding the elements
  53995. */
  53996. addFromContainer(container: AbstractScene): void;
  53997. /**
  53998. * Removes all the elements in the container from the scene
  53999. * @param container contains the elements to remove
  54000. * @param dispose if the removed element should be disposed (default: false)
  54001. */
  54002. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54003. /**
  54004. * Rebuilds the elements related to this component in case of
  54005. * context lost for instance.
  54006. */
  54007. dispose(): void;
  54008. private _gatherRenderTargets;
  54009. }
  54010. }
  54011. declare module "babylonjs/Lights/Shadows/index" {
  54012. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54013. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54014. }
  54015. declare module "babylonjs/Lights/pointLight" {
  54016. import { Scene } from "babylonjs/scene";
  54017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54019. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54020. import { Effect } from "babylonjs/Materials/effect";
  54021. /**
  54022. * A point light is a light defined by an unique point in world space.
  54023. * The light is emitted in every direction from this point.
  54024. * A good example of a point light is a standard light bulb.
  54025. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54026. */
  54027. export class PointLight extends ShadowLight {
  54028. private _shadowAngle;
  54029. /**
  54030. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54031. * This specifies what angle the shadow will use to be created.
  54032. *
  54033. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54034. */
  54035. /**
  54036. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54037. * This specifies what angle the shadow will use to be created.
  54038. *
  54039. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54040. */
  54041. shadowAngle: number;
  54042. /**
  54043. * Gets the direction if it has been set.
  54044. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54045. */
  54046. /**
  54047. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54048. */
  54049. direction: Vector3;
  54050. /**
  54051. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54052. * A PointLight emits the light in every direction.
  54053. * It can cast shadows.
  54054. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54055. * ```javascript
  54056. * var pointLight = new PointLight("pl", camera.position, scene);
  54057. * ```
  54058. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54059. * @param name The light friendly name
  54060. * @param position The position of the point light in the scene
  54061. * @param scene The scene the lights belongs to
  54062. */
  54063. constructor(name: string, position: Vector3, scene: Scene);
  54064. /**
  54065. * Returns the string "PointLight"
  54066. * @returns the class name
  54067. */
  54068. getClassName(): string;
  54069. /**
  54070. * Returns the integer 0.
  54071. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54072. */
  54073. getTypeID(): number;
  54074. /**
  54075. * Specifies wether or not the shadowmap should be a cube texture.
  54076. * @returns true if the shadowmap needs to be a cube texture.
  54077. */
  54078. needCube(): boolean;
  54079. /**
  54080. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54081. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54082. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54083. */
  54084. getShadowDirection(faceIndex?: number): Vector3;
  54085. /**
  54086. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54087. * - fov = PI / 2
  54088. * - aspect ratio : 1.0
  54089. * - z-near and far equal to the active camera minZ and maxZ.
  54090. * Returns the PointLight.
  54091. */
  54092. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54093. protected _buildUniformLayout(): void;
  54094. /**
  54095. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54096. * @param effect The effect to update
  54097. * @param lightIndex The index of the light in the effect to update
  54098. * @returns The point light
  54099. */
  54100. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54101. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54102. /**
  54103. * Prepares the list of defines specific to the light type.
  54104. * @param defines the list of defines
  54105. * @param lightIndex defines the index of the light for the effect
  54106. */
  54107. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54108. }
  54109. }
  54110. declare module "babylonjs/Lights/index" {
  54111. export * from "babylonjs/Lights/light";
  54112. export * from "babylonjs/Lights/shadowLight";
  54113. export * from "babylonjs/Lights/Shadows/index";
  54114. export * from "babylonjs/Lights/directionalLight";
  54115. export * from "babylonjs/Lights/hemisphericLight";
  54116. export * from "babylonjs/Lights/pointLight";
  54117. export * from "babylonjs/Lights/spotLight";
  54118. }
  54119. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54120. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54121. /**
  54122. * Header information of HDR texture files.
  54123. */
  54124. export interface HDRInfo {
  54125. /**
  54126. * The height of the texture in pixels.
  54127. */
  54128. height: number;
  54129. /**
  54130. * The width of the texture in pixels.
  54131. */
  54132. width: number;
  54133. /**
  54134. * The index of the beginning of the data in the binary file.
  54135. */
  54136. dataPosition: number;
  54137. }
  54138. /**
  54139. * This groups tools to convert HDR texture to native colors array.
  54140. */
  54141. export class HDRTools {
  54142. private static Ldexp;
  54143. private static Rgbe2float;
  54144. private static readStringLine;
  54145. /**
  54146. * Reads header information from an RGBE texture stored in a native array.
  54147. * More information on this format are available here:
  54148. * https://en.wikipedia.org/wiki/RGBE_image_format
  54149. *
  54150. * @param uint8array The binary file stored in native array.
  54151. * @return The header information.
  54152. */
  54153. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54154. /**
  54155. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54156. * This RGBE texture needs to store the information as a panorama.
  54157. *
  54158. * More information on this format are available here:
  54159. * https://en.wikipedia.org/wiki/RGBE_image_format
  54160. *
  54161. * @param buffer The binary file stored in an array buffer.
  54162. * @param size The expected size of the extracted cubemap.
  54163. * @return The Cube Map information.
  54164. */
  54165. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54166. /**
  54167. * Returns the pixels data extracted from an RGBE texture.
  54168. * This pixels will be stored left to right up to down in the R G B order in one array.
  54169. *
  54170. * More information on this format are available here:
  54171. * https://en.wikipedia.org/wiki/RGBE_image_format
  54172. *
  54173. * @param uint8array The binary file stored in an array buffer.
  54174. * @param hdrInfo The header information of the file.
  54175. * @return The pixels data in RGB right to left up to down order.
  54176. */
  54177. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54178. private static RGBE_ReadPixels_RLE;
  54179. }
  54180. }
  54181. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54182. import { Nullable } from "babylonjs/types";
  54183. import { Scene } from "babylonjs/scene";
  54184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54186. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54187. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54188. /**
  54189. * This represents a texture coming from an HDR input.
  54190. *
  54191. * The only supported format is currently panorama picture stored in RGBE format.
  54192. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54193. */
  54194. export class HDRCubeTexture extends BaseTexture {
  54195. private static _facesMapping;
  54196. private _generateHarmonics;
  54197. private _noMipmap;
  54198. private _textureMatrix;
  54199. private _size;
  54200. private _onLoad;
  54201. private _onError;
  54202. /**
  54203. * The texture URL.
  54204. */
  54205. url: string;
  54206. /**
  54207. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54208. */
  54209. coordinatesMode: number;
  54210. protected _isBlocking: boolean;
  54211. /**
  54212. * Sets wether or not the texture is blocking during loading.
  54213. */
  54214. /**
  54215. * Gets wether or not the texture is blocking during loading.
  54216. */
  54217. isBlocking: boolean;
  54218. protected _rotationY: number;
  54219. /**
  54220. * Sets texture matrix rotation angle around Y axis in radians.
  54221. */
  54222. /**
  54223. * Gets texture matrix rotation angle around Y axis radians.
  54224. */
  54225. rotationY: number;
  54226. /**
  54227. * Gets or sets the center of the bounding box associated with the cube texture
  54228. * It must define where the camera used to render the texture was set
  54229. */
  54230. boundingBoxPosition: Vector3;
  54231. private _boundingBoxSize;
  54232. /**
  54233. * Gets or sets the size of the bounding box associated with the cube texture
  54234. * When defined, the cubemap will switch to local mode
  54235. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54236. * @example https://www.babylonjs-playground.com/#RNASML
  54237. */
  54238. boundingBoxSize: Vector3;
  54239. /**
  54240. * Instantiates an HDRTexture from the following parameters.
  54241. *
  54242. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54243. * @param scene The scene the texture will be used in
  54244. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54245. * @param noMipmap Forces to not generate the mipmap if true
  54246. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54247. * @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)
  54248. * @param reserved Reserved flag for internal use.
  54249. */
  54250. 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>);
  54251. /**
  54252. * Get the current class name of the texture useful for serialization or dynamic coding.
  54253. * @returns "HDRCubeTexture"
  54254. */
  54255. getClassName(): string;
  54256. /**
  54257. * Occurs when the file is raw .hdr file.
  54258. */
  54259. private loadTexture;
  54260. clone(): HDRCubeTexture;
  54261. delayLoad(): void;
  54262. /**
  54263. * Get the texture reflection matrix used to rotate/transform the reflection.
  54264. * @returns the reflection matrix
  54265. */
  54266. getReflectionTextureMatrix(): Matrix;
  54267. /**
  54268. * Set the texture reflection matrix used to rotate/transform the reflection.
  54269. * @param value Define the reflection matrix to set
  54270. */
  54271. setReflectionTextureMatrix(value: Matrix): void;
  54272. /**
  54273. * Parses a JSON representation of an HDR Texture in order to create the texture
  54274. * @param parsedTexture Define the JSON representation
  54275. * @param scene Define the scene the texture should be created in
  54276. * @param rootUrl Define the root url in case we need to load relative dependencies
  54277. * @returns the newly created texture after parsing
  54278. */
  54279. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54280. serialize(): any;
  54281. }
  54282. }
  54283. declare module "babylonjs/Physics/physicsEngine" {
  54284. import { Nullable } from "babylonjs/types";
  54285. import { Vector3 } from "babylonjs/Maths/math.vector";
  54286. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54287. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54288. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54289. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54290. /**
  54291. * Class used to control physics engine
  54292. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54293. */
  54294. export class PhysicsEngine implements IPhysicsEngine {
  54295. private _physicsPlugin;
  54296. /**
  54297. * Global value used to control the smallest number supported by the simulation
  54298. */
  54299. static Epsilon: number;
  54300. private _impostors;
  54301. private _joints;
  54302. private _subTimeStep;
  54303. /**
  54304. * Gets the gravity vector used by the simulation
  54305. */
  54306. gravity: Vector3;
  54307. /**
  54308. * Factory used to create the default physics plugin.
  54309. * @returns The default physics plugin
  54310. */
  54311. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54312. /**
  54313. * Creates a new Physics Engine
  54314. * @param gravity defines the gravity vector used by the simulation
  54315. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54316. */
  54317. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54318. /**
  54319. * Sets the gravity vector used by the simulation
  54320. * @param gravity defines the gravity vector to use
  54321. */
  54322. setGravity(gravity: Vector3): void;
  54323. /**
  54324. * Set the time step of the physics engine.
  54325. * Default is 1/60.
  54326. * To slow it down, enter 1/600 for example.
  54327. * To speed it up, 1/30
  54328. * @param newTimeStep defines the new timestep to apply to this world.
  54329. */
  54330. setTimeStep(newTimeStep?: number): void;
  54331. /**
  54332. * Get the time step of the physics engine.
  54333. * @returns the current time step
  54334. */
  54335. getTimeStep(): number;
  54336. /**
  54337. * Set the sub time step of the physics engine.
  54338. * Default is 0 meaning there is no sub steps
  54339. * To increase physics resolution precision, set a small value (like 1 ms)
  54340. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54341. */
  54342. setSubTimeStep(subTimeStep?: number): void;
  54343. /**
  54344. * Get the sub time step of the physics engine.
  54345. * @returns the current sub time step
  54346. */
  54347. getSubTimeStep(): number;
  54348. /**
  54349. * Release all resources
  54350. */
  54351. dispose(): void;
  54352. /**
  54353. * Gets the name of the current physics plugin
  54354. * @returns the name of the plugin
  54355. */
  54356. getPhysicsPluginName(): string;
  54357. /**
  54358. * Adding a new impostor for the impostor tracking.
  54359. * This will be done by the impostor itself.
  54360. * @param impostor the impostor to add
  54361. */
  54362. addImpostor(impostor: PhysicsImpostor): void;
  54363. /**
  54364. * Remove an impostor from the engine.
  54365. * This impostor and its mesh will not longer be updated by the physics engine.
  54366. * @param impostor the impostor to remove
  54367. */
  54368. removeImpostor(impostor: PhysicsImpostor): void;
  54369. /**
  54370. * Add a joint to the physics engine
  54371. * @param mainImpostor defines the main impostor to which the joint is added.
  54372. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54373. * @param joint defines the joint that will connect both impostors.
  54374. */
  54375. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54376. /**
  54377. * Removes a joint from the simulation
  54378. * @param mainImpostor defines the impostor used with the joint
  54379. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54380. * @param joint defines the joint to remove
  54381. */
  54382. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54383. /**
  54384. * Called by the scene. No need to call it.
  54385. * @param delta defines the timespam between frames
  54386. */
  54387. _step(delta: number): void;
  54388. /**
  54389. * Gets the current plugin used to run the simulation
  54390. * @returns current plugin
  54391. */
  54392. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54393. /**
  54394. * Gets the list of physic impostors
  54395. * @returns an array of PhysicsImpostor
  54396. */
  54397. getImpostors(): Array<PhysicsImpostor>;
  54398. /**
  54399. * Gets the impostor for a physics enabled object
  54400. * @param object defines the object impersonated by the impostor
  54401. * @returns the PhysicsImpostor or null if not found
  54402. */
  54403. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54404. /**
  54405. * Gets the impostor for a physics body object
  54406. * @param body defines physics body used by the impostor
  54407. * @returns the PhysicsImpostor or null if not found
  54408. */
  54409. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54410. /**
  54411. * Does a raycast in the physics world
  54412. * @param from when should the ray start?
  54413. * @param to when should the ray end?
  54414. * @returns PhysicsRaycastResult
  54415. */
  54416. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54417. }
  54418. }
  54419. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54420. import { Nullable } from "babylonjs/types";
  54421. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54423. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54424. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54425. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54426. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54427. /** @hidden */
  54428. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54429. private _useDeltaForWorldStep;
  54430. world: any;
  54431. name: string;
  54432. private _physicsMaterials;
  54433. private _fixedTimeStep;
  54434. private _cannonRaycastResult;
  54435. private _raycastResult;
  54436. private _physicsBodysToRemoveAfterStep;
  54437. BJSCANNON: any;
  54438. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54439. setGravity(gravity: Vector3): void;
  54440. setTimeStep(timeStep: number): void;
  54441. getTimeStep(): number;
  54442. executeStep(delta: number): void;
  54443. private _removeMarkedPhysicsBodiesFromWorld;
  54444. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54445. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54446. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54447. private _processChildMeshes;
  54448. removePhysicsBody(impostor: PhysicsImpostor): void;
  54449. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54450. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54451. private _addMaterial;
  54452. private _checkWithEpsilon;
  54453. private _createShape;
  54454. private _createHeightmap;
  54455. private _minus90X;
  54456. private _plus90X;
  54457. private _tmpPosition;
  54458. private _tmpDeltaPosition;
  54459. private _tmpUnityRotation;
  54460. private _updatePhysicsBodyTransformation;
  54461. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54462. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54463. isSupported(): boolean;
  54464. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54465. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54466. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54467. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54468. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54469. getBodyMass(impostor: PhysicsImpostor): number;
  54470. getBodyFriction(impostor: PhysicsImpostor): number;
  54471. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54472. getBodyRestitution(impostor: PhysicsImpostor): number;
  54473. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54474. sleepBody(impostor: PhysicsImpostor): void;
  54475. wakeUpBody(impostor: PhysicsImpostor): void;
  54476. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54477. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54478. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54479. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54480. getRadius(impostor: PhysicsImpostor): number;
  54481. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54482. dispose(): void;
  54483. private _extendNamespace;
  54484. /**
  54485. * Does a raycast in the physics world
  54486. * @param from when should the ray start?
  54487. * @param to when should the ray end?
  54488. * @returns PhysicsRaycastResult
  54489. */
  54490. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54491. }
  54492. }
  54493. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54494. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54495. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54496. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54498. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54499. import { Nullable } from "babylonjs/types";
  54500. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54501. /** @hidden */
  54502. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54503. world: any;
  54504. name: string;
  54505. BJSOIMO: any;
  54506. private _raycastResult;
  54507. constructor(iterations?: number, oimoInjection?: any);
  54508. setGravity(gravity: Vector3): void;
  54509. setTimeStep(timeStep: number): void;
  54510. getTimeStep(): number;
  54511. private _tmpImpostorsArray;
  54512. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54513. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54514. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54515. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54516. private _tmpPositionVector;
  54517. removePhysicsBody(impostor: PhysicsImpostor): void;
  54518. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54519. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54520. isSupported(): boolean;
  54521. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54522. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54523. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54524. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54525. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54526. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54527. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54528. getBodyMass(impostor: PhysicsImpostor): number;
  54529. getBodyFriction(impostor: PhysicsImpostor): number;
  54530. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54531. getBodyRestitution(impostor: PhysicsImpostor): number;
  54532. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54533. sleepBody(impostor: PhysicsImpostor): void;
  54534. wakeUpBody(impostor: PhysicsImpostor): void;
  54535. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54536. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54537. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54538. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54539. getRadius(impostor: PhysicsImpostor): number;
  54540. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54541. dispose(): void;
  54542. /**
  54543. * Does a raycast in the physics world
  54544. * @param from when should the ray start?
  54545. * @param to when should the ray end?
  54546. * @returns PhysicsRaycastResult
  54547. */
  54548. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54549. }
  54550. }
  54551. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54552. import { Nullable } from "babylonjs/types";
  54553. import { Scene } from "babylonjs/scene";
  54554. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54555. import { Color4 } from "babylonjs/Maths/math.color";
  54556. import { Mesh } from "babylonjs/Meshes/mesh";
  54557. /**
  54558. * Class containing static functions to help procedurally build meshes
  54559. */
  54560. export class RibbonBuilder {
  54561. /**
  54562. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54563. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54564. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54565. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54566. * * 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
  54567. * * 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
  54568. * * 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
  54569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54571. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54572. * * 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
  54573. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54574. * * 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
  54575. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54577. * @param name defines the name of the mesh
  54578. * @param options defines the options used to create the mesh
  54579. * @param scene defines the hosting scene
  54580. * @returns the ribbon mesh
  54581. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54582. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54583. */
  54584. static CreateRibbon(name: string, options: {
  54585. pathArray: Vector3[][];
  54586. closeArray?: boolean;
  54587. closePath?: boolean;
  54588. offset?: number;
  54589. updatable?: boolean;
  54590. sideOrientation?: number;
  54591. frontUVs?: Vector4;
  54592. backUVs?: Vector4;
  54593. instance?: Mesh;
  54594. invertUV?: boolean;
  54595. uvs?: Vector2[];
  54596. colors?: Color4[];
  54597. }, scene?: Nullable<Scene>): Mesh;
  54598. }
  54599. }
  54600. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54601. import { Nullable } from "babylonjs/types";
  54602. import { Scene } from "babylonjs/scene";
  54603. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54604. import { Mesh } from "babylonjs/Meshes/mesh";
  54605. /**
  54606. * Class containing static functions to help procedurally build meshes
  54607. */
  54608. export class ShapeBuilder {
  54609. /**
  54610. * 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.
  54611. * * 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.
  54612. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54613. * * 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.
  54614. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54615. * * 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
  54616. * * 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
  54617. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54622. * @param name defines the name of the mesh
  54623. * @param options defines the options used to create the mesh
  54624. * @param scene defines the hosting scene
  54625. * @returns the extruded shape mesh
  54626. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54628. */
  54629. static ExtrudeShape(name: string, options: {
  54630. shape: Vector3[];
  54631. path: Vector3[];
  54632. scale?: number;
  54633. rotation?: number;
  54634. cap?: number;
  54635. updatable?: boolean;
  54636. sideOrientation?: number;
  54637. frontUVs?: Vector4;
  54638. backUVs?: Vector4;
  54639. instance?: Mesh;
  54640. invertUV?: boolean;
  54641. }, scene?: Nullable<Scene>): Mesh;
  54642. /**
  54643. * Creates an custom extruded shape mesh.
  54644. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54645. * * 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.
  54646. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54647. * * 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
  54648. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54649. * * 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
  54650. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54651. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54652. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54653. * * 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
  54654. * * 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
  54655. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54660. * @param name defines the name of the mesh
  54661. * @param options defines the options used to create the mesh
  54662. * @param scene defines the hosting scene
  54663. * @returns the custom extruded shape mesh
  54664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54665. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54666. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54667. */
  54668. static ExtrudeShapeCustom(name: string, options: {
  54669. shape: Vector3[];
  54670. path: Vector3[];
  54671. scaleFunction?: any;
  54672. rotationFunction?: any;
  54673. ribbonCloseArray?: boolean;
  54674. ribbonClosePath?: boolean;
  54675. cap?: number;
  54676. updatable?: boolean;
  54677. sideOrientation?: number;
  54678. frontUVs?: Vector4;
  54679. backUVs?: Vector4;
  54680. instance?: Mesh;
  54681. invertUV?: boolean;
  54682. }, scene?: Nullable<Scene>): Mesh;
  54683. private static _ExtrudeShapeGeneric;
  54684. }
  54685. }
  54686. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54687. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54688. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54689. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54690. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54691. import { Nullable } from "babylonjs/types";
  54692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54693. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54694. /**
  54695. * AmmoJS Physics plugin
  54696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54697. * @see https://github.com/kripken/ammo.js/
  54698. */
  54699. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54700. private _useDeltaForWorldStep;
  54701. /**
  54702. * Reference to the Ammo library
  54703. */
  54704. bjsAMMO: any;
  54705. /**
  54706. * Created ammoJS world which physics bodies are added to
  54707. */
  54708. world: any;
  54709. /**
  54710. * Name of the plugin
  54711. */
  54712. name: string;
  54713. private _timeStep;
  54714. private _fixedTimeStep;
  54715. private _maxSteps;
  54716. private _tmpQuaternion;
  54717. private _tmpAmmoTransform;
  54718. private _tmpAmmoQuaternion;
  54719. private _tmpAmmoConcreteContactResultCallback;
  54720. private _collisionConfiguration;
  54721. private _dispatcher;
  54722. private _overlappingPairCache;
  54723. private _solver;
  54724. private _softBodySolver;
  54725. private _tmpAmmoVectorA;
  54726. private _tmpAmmoVectorB;
  54727. private _tmpAmmoVectorC;
  54728. private _tmpAmmoVectorD;
  54729. private _tmpContactCallbackResult;
  54730. private _tmpAmmoVectorRCA;
  54731. private _tmpAmmoVectorRCB;
  54732. private _raycastResult;
  54733. private static readonly DISABLE_COLLISION_FLAG;
  54734. private static readonly KINEMATIC_FLAG;
  54735. private static readonly DISABLE_DEACTIVATION_FLAG;
  54736. /**
  54737. * Initializes the ammoJS plugin
  54738. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54739. * @param ammoInjection can be used to inject your own ammo reference
  54740. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54741. */
  54742. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54743. /**
  54744. * Sets the gravity of the physics world (m/(s^2))
  54745. * @param gravity Gravity to set
  54746. */
  54747. setGravity(gravity: Vector3): void;
  54748. /**
  54749. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54750. * @param timeStep timestep to use in seconds
  54751. */
  54752. setTimeStep(timeStep: number): void;
  54753. /**
  54754. * 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)
  54755. * @param fixedTimeStep fixedTimeStep to use in seconds
  54756. */
  54757. setFixedTimeStep(fixedTimeStep: number): void;
  54758. /**
  54759. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54760. * @param maxSteps the maximum number of steps by the physics engine per frame
  54761. */
  54762. setMaxSteps(maxSteps: number): void;
  54763. /**
  54764. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54765. * @returns the current timestep in seconds
  54766. */
  54767. getTimeStep(): number;
  54768. /**
  54769. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54770. */
  54771. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54772. private _isImpostorInContact;
  54773. private _isImpostorPairInContact;
  54774. private _stepSimulation;
  54775. /**
  54776. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54777. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54778. * After the step the babylon meshes are set to the position of the physics imposters
  54779. * @param delta amount of time to step forward
  54780. * @param impostors array of imposters to update before/after the step
  54781. */
  54782. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54783. /**
  54784. * Update babylon mesh to match physics world object
  54785. * @param impostor imposter to match
  54786. */
  54787. private _afterSoftStep;
  54788. /**
  54789. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54790. * @param impostor imposter to match
  54791. */
  54792. private _ropeStep;
  54793. /**
  54794. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54795. * @param impostor imposter to match
  54796. */
  54797. private _softbodyOrClothStep;
  54798. private _tmpVector;
  54799. private _tmpMatrix;
  54800. /**
  54801. * Applies an impulse on the imposter
  54802. * @param impostor imposter to apply impulse to
  54803. * @param force amount of force to be applied to the imposter
  54804. * @param contactPoint the location to apply the impulse on the imposter
  54805. */
  54806. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54807. /**
  54808. * Applies a force on the imposter
  54809. * @param impostor imposter to apply force
  54810. * @param force amount of force to be applied to the imposter
  54811. * @param contactPoint the location to apply the force on the imposter
  54812. */
  54813. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54814. /**
  54815. * Creates a physics body using the plugin
  54816. * @param impostor the imposter to create the physics body on
  54817. */
  54818. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54819. /**
  54820. * Removes the physics body from the imposter and disposes of the body's memory
  54821. * @param impostor imposter to remove the physics body from
  54822. */
  54823. removePhysicsBody(impostor: PhysicsImpostor): void;
  54824. /**
  54825. * Generates a joint
  54826. * @param impostorJoint the imposter joint to create the joint with
  54827. */
  54828. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54829. /**
  54830. * Removes a joint
  54831. * @param impostorJoint the imposter joint to remove the joint from
  54832. */
  54833. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54834. private _addMeshVerts;
  54835. /**
  54836. * Initialise the soft body vertices to match its object's (mesh) vertices
  54837. * Softbody vertices (nodes) are in world space and to match this
  54838. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54839. * @param impostor to create the softbody for
  54840. */
  54841. private _softVertexData;
  54842. /**
  54843. * Create an impostor's soft body
  54844. * @param impostor to create the softbody for
  54845. */
  54846. private _createSoftbody;
  54847. /**
  54848. * Create cloth for an impostor
  54849. * @param impostor to create the softbody for
  54850. */
  54851. private _createCloth;
  54852. /**
  54853. * Create rope for an impostor
  54854. * @param impostor to create the softbody for
  54855. */
  54856. private _createRope;
  54857. /**
  54858. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54859. * @param impostor to create the custom physics shape for
  54860. */
  54861. private _createCustom;
  54862. private _addHullVerts;
  54863. private _createShape;
  54864. /**
  54865. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54866. * @param impostor imposter containing the physics body and babylon object
  54867. */
  54868. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54869. /**
  54870. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54871. * @param impostor imposter containing the physics body and babylon object
  54872. * @param newPosition new position
  54873. * @param newRotation new rotation
  54874. */
  54875. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54876. /**
  54877. * If this plugin is supported
  54878. * @returns true if its supported
  54879. */
  54880. isSupported(): boolean;
  54881. /**
  54882. * Sets the linear velocity of the physics body
  54883. * @param impostor imposter to set the velocity on
  54884. * @param velocity velocity to set
  54885. */
  54886. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54887. /**
  54888. * Sets the angular velocity of the physics body
  54889. * @param impostor imposter to set the velocity on
  54890. * @param velocity velocity to set
  54891. */
  54892. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54893. /**
  54894. * gets the linear velocity
  54895. * @param impostor imposter to get linear velocity from
  54896. * @returns linear velocity
  54897. */
  54898. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54899. /**
  54900. * gets the angular velocity
  54901. * @param impostor imposter to get angular velocity from
  54902. * @returns angular velocity
  54903. */
  54904. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54905. /**
  54906. * Sets the mass of physics body
  54907. * @param impostor imposter to set the mass on
  54908. * @param mass mass to set
  54909. */
  54910. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54911. /**
  54912. * Gets the mass of the physics body
  54913. * @param impostor imposter to get the mass from
  54914. * @returns mass
  54915. */
  54916. getBodyMass(impostor: PhysicsImpostor): number;
  54917. /**
  54918. * Gets friction of the impostor
  54919. * @param impostor impostor to get friction from
  54920. * @returns friction value
  54921. */
  54922. getBodyFriction(impostor: PhysicsImpostor): number;
  54923. /**
  54924. * Sets friction of the impostor
  54925. * @param impostor impostor to set friction on
  54926. * @param friction friction value
  54927. */
  54928. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54929. /**
  54930. * Gets restitution of the impostor
  54931. * @param impostor impostor to get restitution from
  54932. * @returns restitution value
  54933. */
  54934. getBodyRestitution(impostor: PhysicsImpostor): number;
  54935. /**
  54936. * Sets resitution of the impostor
  54937. * @param impostor impostor to set resitution on
  54938. * @param restitution resitution value
  54939. */
  54940. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54941. /**
  54942. * Gets pressure inside the impostor
  54943. * @param impostor impostor to get pressure from
  54944. * @returns pressure value
  54945. */
  54946. getBodyPressure(impostor: PhysicsImpostor): number;
  54947. /**
  54948. * Sets pressure inside a soft body impostor
  54949. * Cloth and rope must remain 0 pressure
  54950. * @param impostor impostor to set pressure on
  54951. * @param pressure pressure value
  54952. */
  54953. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54954. /**
  54955. * Gets stiffness of the impostor
  54956. * @param impostor impostor to get stiffness from
  54957. * @returns pressure value
  54958. */
  54959. getBodyStiffness(impostor: PhysicsImpostor): number;
  54960. /**
  54961. * Sets stiffness of the impostor
  54962. * @param impostor impostor to set stiffness on
  54963. * @param stiffness stiffness value from 0 to 1
  54964. */
  54965. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54966. /**
  54967. * Gets velocityIterations of the impostor
  54968. * @param impostor impostor to get velocity iterations from
  54969. * @returns velocityIterations value
  54970. */
  54971. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54972. /**
  54973. * Sets velocityIterations of the impostor
  54974. * @param impostor impostor to set velocity iterations on
  54975. * @param velocityIterations velocityIterations value
  54976. */
  54977. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54978. /**
  54979. * Gets positionIterations of the impostor
  54980. * @param impostor impostor to get position iterations from
  54981. * @returns positionIterations value
  54982. */
  54983. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54984. /**
  54985. * Sets positionIterations of the impostor
  54986. * @param impostor impostor to set position on
  54987. * @param positionIterations positionIterations value
  54988. */
  54989. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54990. /**
  54991. * Append an anchor to a cloth object
  54992. * @param impostor is the cloth impostor to add anchor to
  54993. * @param otherImpostor is the rigid impostor to anchor to
  54994. * @param width ratio across width from 0 to 1
  54995. * @param height ratio up height from 0 to 1
  54996. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54997. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54998. */
  54999. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55000. /**
  55001. * Append an hook to a rope object
  55002. * @param impostor is the rope impostor to add hook to
  55003. * @param otherImpostor is the rigid impostor to hook to
  55004. * @param length ratio along the rope from 0 to 1
  55005. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55006. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55007. */
  55008. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55009. /**
  55010. * Sleeps the physics body and stops it from being active
  55011. * @param impostor impostor to sleep
  55012. */
  55013. sleepBody(impostor: PhysicsImpostor): void;
  55014. /**
  55015. * Activates the physics body
  55016. * @param impostor impostor to activate
  55017. */
  55018. wakeUpBody(impostor: PhysicsImpostor): void;
  55019. /**
  55020. * Updates the distance parameters of the joint
  55021. * @param joint joint to update
  55022. * @param maxDistance maximum distance of the joint
  55023. * @param minDistance minimum distance of the joint
  55024. */
  55025. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55026. /**
  55027. * Sets a motor on the joint
  55028. * @param joint joint to set motor on
  55029. * @param speed speed of the motor
  55030. * @param maxForce maximum force of the motor
  55031. * @param motorIndex index of the motor
  55032. */
  55033. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55034. /**
  55035. * Sets the motors limit
  55036. * @param joint joint to set limit on
  55037. * @param upperLimit upper limit
  55038. * @param lowerLimit lower limit
  55039. */
  55040. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55041. /**
  55042. * Syncs the position and rotation of a mesh with the impostor
  55043. * @param mesh mesh to sync
  55044. * @param impostor impostor to update the mesh with
  55045. */
  55046. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55047. /**
  55048. * Gets the radius of the impostor
  55049. * @param impostor impostor to get radius from
  55050. * @returns the radius
  55051. */
  55052. getRadius(impostor: PhysicsImpostor): number;
  55053. /**
  55054. * Gets the box size of the impostor
  55055. * @param impostor impostor to get box size from
  55056. * @param result the resulting box size
  55057. */
  55058. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55059. /**
  55060. * Disposes of the impostor
  55061. */
  55062. dispose(): void;
  55063. /**
  55064. * Does a raycast in the physics world
  55065. * @param from when should the ray start?
  55066. * @param to when should the ray end?
  55067. * @returns PhysicsRaycastResult
  55068. */
  55069. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55070. }
  55071. }
  55072. declare module "babylonjs/Probes/reflectionProbe" {
  55073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55074. import { Vector3 } from "babylonjs/Maths/math.vector";
  55075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55076. import { Nullable } from "babylonjs/types";
  55077. import { Scene } from "babylonjs/scene";
  55078. module "babylonjs/abstractScene" {
  55079. interface AbstractScene {
  55080. /**
  55081. * The list of reflection probes added to the scene
  55082. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55083. */
  55084. reflectionProbes: Array<ReflectionProbe>;
  55085. /**
  55086. * Removes the given reflection probe from this scene.
  55087. * @param toRemove The reflection probe to remove
  55088. * @returns The index of the removed reflection probe
  55089. */
  55090. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55091. /**
  55092. * Adds the given reflection probe to this scene.
  55093. * @param newReflectionProbe The reflection probe to add
  55094. */
  55095. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55096. }
  55097. }
  55098. /**
  55099. * Class used to generate realtime reflection / refraction cube textures
  55100. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55101. */
  55102. export class ReflectionProbe {
  55103. /** defines the name of the probe */
  55104. name: string;
  55105. private _scene;
  55106. private _renderTargetTexture;
  55107. private _projectionMatrix;
  55108. private _viewMatrix;
  55109. private _target;
  55110. private _add;
  55111. private _attachedMesh;
  55112. private _invertYAxis;
  55113. /** Gets or sets probe position (center of the cube map) */
  55114. position: Vector3;
  55115. /**
  55116. * Creates a new reflection probe
  55117. * @param name defines the name of the probe
  55118. * @param size defines the texture resolution (for each face)
  55119. * @param scene defines the hosting scene
  55120. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55121. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55122. */
  55123. constructor(
  55124. /** defines the name of the probe */
  55125. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55126. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55127. samples: number;
  55128. /** Gets or sets the refresh rate to use (on every frame by default) */
  55129. refreshRate: number;
  55130. /**
  55131. * Gets the hosting scene
  55132. * @returns a Scene
  55133. */
  55134. getScene(): Scene;
  55135. /** Gets the internal CubeTexture used to render to */
  55136. readonly cubeTexture: RenderTargetTexture;
  55137. /** Gets the list of meshes to render */
  55138. readonly renderList: Nullable<AbstractMesh[]>;
  55139. /**
  55140. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55141. * @param mesh defines the mesh to attach to
  55142. */
  55143. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55144. /**
  55145. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55146. * @param renderingGroupId The rendering group id corresponding to its index
  55147. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55148. */
  55149. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55150. /**
  55151. * Clean all associated resources
  55152. */
  55153. dispose(): void;
  55154. /**
  55155. * Converts the reflection probe information to a readable string for debug purpose.
  55156. * @param fullDetails Supports for multiple levels of logging within scene loading
  55157. * @returns the human readable reflection probe info
  55158. */
  55159. toString(fullDetails?: boolean): string;
  55160. /**
  55161. * Get the class name of the relfection probe.
  55162. * @returns "ReflectionProbe"
  55163. */
  55164. getClassName(): string;
  55165. /**
  55166. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55167. * @returns The JSON representation of the texture
  55168. */
  55169. serialize(): any;
  55170. /**
  55171. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55172. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55173. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55174. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55175. * @returns The parsed reflection probe if successful
  55176. */
  55177. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55178. }
  55179. }
  55180. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55181. /** @hidden */
  55182. export var _BabylonLoaderRegistered: boolean;
  55183. /**
  55184. * Helps setting up some configuration for the babylon file loader.
  55185. */
  55186. export class BabylonFileLoaderConfiguration {
  55187. /**
  55188. * The loader does not allow injecting custom physix engine into the plugins.
  55189. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55190. * So you could set this variable to your engine import to make it work.
  55191. */
  55192. static LoaderInjectedPhysicsEngine: any;
  55193. }
  55194. }
  55195. declare module "babylonjs/Loading/Plugins/index" {
  55196. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55197. }
  55198. declare module "babylonjs/Loading/index" {
  55199. export * from "babylonjs/Loading/loadingScreen";
  55200. export * from "babylonjs/Loading/Plugins/index";
  55201. export * from "babylonjs/Loading/sceneLoader";
  55202. export * from "babylonjs/Loading/sceneLoaderFlags";
  55203. }
  55204. declare module "babylonjs/Materials/Background/index" {
  55205. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55206. }
  55207. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55208. import { Scene } from "babylonjs/scene";
  55209. import { Color3 } from "babylonjs/Maths/math.color";
  55210. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55212. /**
  55213. * The Physically based simple base material of BJS.
  55214. *
  55215. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55216. * It is used as the base class for both the specGloss and metalRough conventions.
  55217. */
  55218. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55219. /**
  55220. * Number of Simultaneous lights allowed on the material.
  55221. */
  55222. maxSimultaneousLights: number;
  55223. /**
  55224. * If sets to true, disables all the lights affecting the material.
  55225. */
  55226. disableLighting: boolean;
  55227. /**
  55228. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55229. */
  55230. environmentTexture: BaseTexture;
  55231. /**
  55232. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55233. */
  55234. invertNormalMapX: boolean;
  55235. /**
  55236. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55237. */
  55238. invertNormalMapY: boolean;
  55239. /**
  55240. * Normal map used in the model.
  55241. */
  55242. normalTexture: BaseTexture;
  55243. /**
  55244. * Emissivie color used to self-illuminate the model.
  55245. */
  55246. emissiveColor: Color3;
  55247. /**
  55248. * Emissivie texture used to self-illuminate the model.
  55249. */
  55250. emissiveTexture: BaseTexture;
  55251. /**
  55252. * Occlusion Channel Strenght.
  55253. */
  55254. occlusionStrength: number;
  55255. /**
  55256. * Occlusion Texture of the material (adding extra occlusion effects).
  55257. */
  55258. occlusionTexture: BaseTexture;
  55259. /**
  55260. * Defines the alpha limits in alpha test mode.
  55261. */
  55262. alphaCutOff: number;
  55263. /**
  55264. * Gets the current double sided mode.
  55265. */
  55266. /**
  55267. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55268. */
  55269. doubleSided: boolean;
  55270. /**
  55271. * Stores the pre-calculated light information of a mesh in a texture.
  55272. */
  55273. lightmapTexture: BaseTexture;
  55274. /**
  55275. * If true, the light map contains occlusion information instead of lighting info.
  55276. */
  55277. useLightmapAsShadowmap: boolean;
  55278. /**
  55279. * Instantiates a new PBRMaterial instance.
  55280. *
  55281. * @param name The material name
  55282. * @param scene The scene the material will be use in.
  55283. */
  55284. constructor(name: string, scene: Scene);
  55285. getClassName(): string;
  55286. }
  55287. }
  55288. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55289. import { Scene } from "babylonjs/scene";
  55290. import { Color3 } from "babylonjs/Maths/math.color";
  55291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55292. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55293. /**
  55294. * The PBR material of BJS following the metal roughness convention.
  55295. *
  55296. * This fits to the PBR convention in the GLTF definition:
  55297. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55298. */
  55299. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55300. /**
  55301. * The base color has two different interpretations depending on the value of metalness.
  55302. * When the material is a metal, the base color is the specific measured reflectance value
  55303. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55304. * of the material.
  55305. */
  55306. baseColor: Color3;
  55307. /**
  55308. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55309. * well as opacity information in the alpha channel.
  55310. */
  55311. baseTexture: BaseTexture;
  55312. /**
  55313. * Specifies the metallic scalar value of the material.
  55314. * Can also be used to scale the metalness values of the metallic texture.
  55315. */
  55316. metallic: number;
  55317. /**
  55318. * Specifies the roughness scalar value of the material.
  55319. * Can also be used to scale the roughness values of the metallic texture.
  55320. */
  55321. roughness: number;
  55322. /**
  55323. * Texture containing both the metallic value in the B channel and the
  55324. * roughness value in the G channel to keep better precision.
  55325. */
  55326. metallicRoughnessTexture: BaseTexture;
  55327. /**
  55328. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55329. *
  55330. * @param name The material name
  55331. * @param scene The scene the material will be use in.
  55332. */
  55333. constructor(name: string, scene: Scene);
  55334. /**
  55335. * Return the currrent class name of the material.
  55336. */
  55337. getClassName(): string;
  55338. /**
  55339. * Makes a duplicate of the current material.
  55340. * @param name - name to use for the new material.
  55341. */
  55342. clone(name: string): PBRMetallicRoughnessMaterial;
  55343. /**
  55344. * Serialize the material to a parsable JSON object.
  55345. */
  55346. serialize(): any;
  55347. /**
  55348. * Parses a JSON object correponding to the serialize function.
  55349. */
  55350. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55351. }
  55352. }
  55353. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55354. import { Scene } from "babylonjs/scene";
  55355. import { Color3 } from "babylonjs/Maths/math.color";
  55356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55357. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55358. /**
  55359. * The PBR material of BJS following the specular glossiness convention.
  55360. *
  55361. * This fits to the PBR convention in the GLTF definition:
  55362. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55363. */
  55364. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55365. /**
  55366. * Specifies the diffuse color of the material.
  55367. */
  55368. diffuseColor: Color3;
  55369. /**
  55370. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55371. * channel.
  55372. */
  55373. diffuseTexture: BaseTexture;
  55374. /**
  55375. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55376. */
  55377. specularColor: Color3;
  55378. /**
  55379. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55380. */
  55381. glossiness: number;
  55382. /**
  55383. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55384. */
  55385. specularGlossinessTexture: BaseTexture;
  55386. /**
  55387. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55388. *
  55389. * @param name The material name
  55390. * @param scene The scene the material will be use in.
  55391. */
  55392. constructor(name: string, scene: Scene);
  55393. /**
  55394. * Return the currrent class name of the material.
  55395. */
  55396. getClassName(): string;
  55397. /**
  55398. * Makes a duplicate of the current material.
  55399. * @param name - name to use for the new material.
  55400. */
  55401. clone(name: string): PBRSpecularGlossinessMaterial;
  55402. /**
  55403. * Serialize the material to a parsable JSON object.
  55404. */
  55405. serialize(): any;
  55406. /**
  55407. * Parses a JSON object correponding to the serialize function.
  55408. */
  55409. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55410. }
  55411. }
  55412. declare module "babylonjs/Materials/PBR/index" {
  55413. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55414. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55415. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55416. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55417. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55418. }
  55419. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55420. import { Nullable } from "babylonjs/types";
  55421. import { Scene } from "babylonjs/scene";
  55422. import { Matrix } from "babylonjs/Maths/math.vector";
  55423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55424. /**
  55425. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55426. * It can help converting any input color in a desired output one. This can then be used to create effects
  55427. * from sepia, black and white to sixties or futuristic rendering...
  55428. *
  55429. * The only supported format is currently 3dl.
  55430. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55431. */
  55432. export class ColorGradingTexture extends BaseTexture {
  55433. /**
  55434. * The current texture matrix. (will always be identity in color grading texture)
  55435. */
  55436. private _textureMatrix;
  55437. /**
  55438. * The texture URL.
  55439. */
  55440. url: string;
  55441. /**
  55442. * Empty line regex stored for GC.
  55443. */
  55444. private static _noneEmptyLineRegex;
  55445. private _engine;
  55446. /**
  55447. * Instantiates a ColorGradingTexture from the following parameters.
  55448. *
  55449. * @param url The location of the color gradind data (currently only supporting 3dl)
  55450. * @param scene The scene the texture will be used in
  55451. */
  55452. constructor(url: string, scene: Scene);
  55453. /**
  55454. * Returns the texture matrix used in most of the material.
  55455. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55456. */
  55457. getTextureMatrix(): Matrix;
  55458. /**
  55459. * Occurs when the file being loaded is a .3dl LUT file.
  55460. */
  55461. private load3dlTexture;
  55462. /**
  55463. * Starts the loading process of the texture.
  55464. */
  55465. private loadTexture;
  55466. /**
  55467. * Clones the color gradind texture.
  55468. */
  55469. clone(): ColorGradingTexture;
  55470. /**
  55471. * Called during delayed load for textures.
  55472. */
  55473. delayLoad(): void;
  55474. /**
  55475. * Parses a color grading texture serialized by Babylon.
  55476. * @param parsedTexture The texture information being parsedTexture
  55477. * @param scene The scene to load the texture in
  55478. * @param rootUrl The root url of the data assets to load
  55479. * @return A color gradind texture
  55480. */
  55481. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55482. /**
  55483. * Serializes the LUT texture to json format.
  55484. */
  55485. serialize(): any;
  55486. }
  55487. }
  55488. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55490. import { Scene } from "babylonjs/scene";
  55491. import { Nullable } from "babylonjs/types";
  55492. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55493. /**
  55494. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55495. */
  55496. export class EquiRectangularCubeTexture extends BaseTexture {
  55497. /** The six faces of the cube. */
  55498. private static _FacesMapping;
  55499. private _noMipmap;
  55500. private _onLoad;
  55501. private _onError;
  55502. /** The size of the cubemap. */
  55503. private _size;
  55504. /** The buffer of the image. */
  55505. private _buffer;
  55506. /** The width of the input image. */
  55507. private _width;
  55508. /** The height of the input image. */
  55509. private _height;
  55510. /** The URL to the image. */
  55511. url: string;
  55512. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55513. coordinatesMode: number;
  55514. /**
  55515. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55516. * @param url The location of the image
  55517. * @param scene The scene the texture will be used in
  55518. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55519. * @param noMipmap Forces to not generate the mipmap if true
  55520. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55521. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55522. * @param onLoad — defines a callback called when texture is loaded
  55523. * @param onError — defines a callback called if there is an error
  55524. */
  55525. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55526. /**
  55527. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55528. */
  55529. private loadImage;
  55530. /**
  55531. * Convert the image buffer into a cubemap and create a CubeTexture.
  55532. */
  55533. private loadTexture;
  55534. /**
  55535. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55536. * @param buffer The ArrayBuffer that should be converted.
  55537. * @returns The buffer as Float32Array.
  55538. */
  55539. private getFloat32ArrayFromArrayBuffer;
  55540. /**
  55541. * Get the current class name of the texture useful for serialization or dynamic coding.
  55542. * @returns "EquiRectangularCubeTexture"
  55543. */
  55544. getClassName(): string;
  55545. /**
  55546. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55547. * @returns A clone of the current EquiRectangularCubeTexture.
  55548. */
  55549. clone(): EquiRectangularCubeTexture;
  55550. }
  55551. }
  55552. declare module "babylonjs/Misc/tga" {
  55553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55554. /**
  55555. * Based on jsTGALoader - Javascript loader for TGA file
  55556. * By Vincent Thibault
  55557. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55558. */
  55559. export class TGATools {
  55560. private static _TYPE_INDEXED;
  55561. private static _TYPE_RGB;
  55562. private static _TYPE_GREY;
  55563. private static _TYPE_RLE_INDEXED;
  55564. private static _TYPE_RLE_RGB;
  55565. private static _TYPE_RLE_GREY;
  55566. private static _ORIGIN_MASK;
  55567. private static _ORIGIN_SHIFT;
  55568. private static _ORIGIN_BL;
  55569. private static _ORIGIN_BR;
  55570. private static _ORIGIN_UL;
  55571. private static _ORIGIN_UR;
  55572. /**
  55573. * Gets the header of a TGA file
  55574. * @param data defines the TGA data
  55575. * @returns the header
  55576. */
  55577. static GetTGAHeader(data: Uint8Array): any;
  55578. /**
  55579. * Uploads TGA content to a Babylon Texture
  55580. * @hidden
  55581. */
  55582. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55583. /** @hidden */
  55584. 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;
  55585. /** @hidden */
  55586. 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;
  55587. /** @hidden */
  55588. 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;
  55589. /** @hidden */
  55590. 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;
  55591. /** @hidden */
  55592. 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;
  55593. /** @hidden */
  55594. 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;
  55595. }
  55596. }
  55597. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55598. import { Nullable } from "babylonjs/types";
  55599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55600. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55601. /**
  55602. * Implementation of the TGA Texture Loader.
  55603. * @hidden
  55604. */
  55605. export class _TGATextureLoader implements IInternalTextureLoader {
  55606. /**
  55607. * Defines wether the loader supports cascade loading the different faces.
  55608. */
  55609. readonly supportCascades: boolean;
  55610. /**
  55611. * This returns if the loader support the current file information.
  55612. * @param extension defines the file extension of the file being loaded
  55613. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55614. * @param fallback defines the fallback internal texture if any
  55615. * @param isBase64 defines whether the texture is encoded as a base64
  55616. * @param isBuffer defines whether the texture data are stored as a buffer
  55617. * @returns true if the loader can load the specified file
  55618. */
  55619. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55620. /**
  55621. * Transform the url before loading if required.
  55622. * @param rootUrl the url of the texture
  55623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55624. * @returns the transformed texture
  55625. */
  55626. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55627. /**
  55628. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55629. * @param rootUrl the url of the texture
  55630. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55631. * @returns the fallback texture
  55632. */
  55633. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55634. /**
  55635. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55636. * @param data contains the texture data
  55637. * @param texture defines the BabylonJS internal texture
  55638. * @param createPolynomials will be true if polynomials have been requested
  55639. * @param onLoad defines the callback to trigger once the texture is ready
  55640. * @param onError defines the callback to trigger in case of error
  55641. */
  55642. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55643. /**
  55644. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55645. * @param data contains the texture data
  55646. * @param texture defines the BabylonJS internal texture
  55647. * @param callback defines the method to call once ready to upload
  55648. */
  55649. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55650. }
  55651. }
  55652. declare module "babylonjs/Misc/basis" {
  55653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55654. /**
  55655. * Info about the .basis files
  55656. */
  55657. class BasisFileInfo {
  55658. /**
  55659. * If the file has alpha
  55660. */
  55661. hasAlpha: boolean;
  55662. /**
  55663. * Info about each image of the basis file
  55664. */
  55665. images: Array<{
  55666. levels: Array<{
  55667. width: number;
  55668. height: number;
  55669. transcodedPixels: ArrayBufferView;
  55670. }>;
  55671. }>;
  55672. }
  55673. /**
  55674. * Result of transcoding a basis file
  55675. */
  55676. class TranscodeResult {
  55677. /**
  55678. * Info about the .basis file
  55679. */
  55680. fileInfo: BasisFileInfo;
  55681. /**
  55682. * Format to use when loading the file
  55683. */
  55684. format: number;
  55685. }
  55686. /**
  55687. * Configuration options for the Basis transcoder
  55688. */
  55689. export class BasisTranscodeConfiguration {
  55690. /**
  55691. * Supported compression formats used to determine the supported output format of the transcoder
  55692. */
  55693. supportedCompressionFormats?: {
  55694. /**
  55695. * etc1 compression format
  55696. */
  55697. etc1?: boolean;
  55698. /**
  55699. * s3tc compression format
  55700. */
  55701. s3tc?: boolean;
  55702. /**
  55703. * pvrtc compression format
  55704. */
  55705. pvrtc?: boolean;
  55706. /**
  55707. * etc2 compression format
  55708. */
  55709. etc2?: boolean;
  55710. };
  55711. /**
  55712. * If mipmap levels should be loaded for transcoded images (Default: true)
  55713. */
  55714. loadMipmapLevels?: boolean;
  55715. /**
  55716. * Index of a single image to load (Default: all images)
  55717. */
  55718. loadSingleImage?: number;
  55719. }
  55720. /**
  55721. * Used to load .Basis files
  55722. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55723. */
  55724. export class BasisTools {
  55725. private static _IgnoreSupportedFormats;
  55726. /**
  55727. * URL to use when loading the basis transcoder
  55728. */
  55729. static JSModuleURL: string;
  55730. /**
  55731. * URL to use when loading the wasm module for the transcoder
  55732. */
  55733. static WasmModuleURL: string;
  55734. /**
  55735. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55736. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55737. * @returns internal format corresponding to the Basis format
  55738. */
  55739. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55740. private static _WorkerPromise;
  55741. private static _Worker;
  55742. private static _actionId;
  55743. private static _CreateWorkerAsync;
  55744. /**
  55745. * Transcodes a loaded image file to compressed pixel data
  55746. * @param imageData image data to transcode
  55747. * @param config configuration options for the transcoding
  55748. * @returns a promise resulting in the transcoded image
  55749. */
  55750. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55751. /**
  55752. * Loads a texture from the transcode result
  55753. * @param texture texture load to
  55754. * @param transcodeResult the result of transcoding the basis file to load from
  55755. */
  55756. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55757. }
  55758. }
  55759. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55760. import { Nullable } from "babylonjs/types";
  55761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55762. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55763. /**
  55764. * Loader for .basis file format
  55765. */
  55766. export class _BasisTextureLoader implements IInternalTextureLoader {
  55767. /**
  55768. * Defines whether the loader supports cascade loading the different faces.
  55769. */
  55770. readonly supportCascades: boolean;
  55771. /**
  55772. * This returns if the loader support the current file information.
  55773. * @param extension defines the file extension of the file being loaded
  55774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55775. * @param fallback defines the fallback internal texture if any
  55776. * @param isBase64 defines whether the texture is encoded as a base64
  55777. * @param isBuffer defines whether the texture data are stored as a buffer
  55778. * @returns true if the loader can load the specified file
  55779. */
  55780. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55781. /**
  55782. * Transform the url before loading if required.
  55783. * @param rootUrl the url of the texture
  55784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55785. * @returns the transformed texture
  55786. */
  55787. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55788. /**
  55789. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55790. * @param rootUrl the url of the texture
  55791. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55792. * @returns the fallback texture
  55793. */
  55794. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55795. /**
  55796. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55797. * @param data contains the texture data
  55798. * @param texture defines the BabylonJS internal texture
  55799. * @param createPolynomials will be true if polynomials have been requested
  55800. * @param onLoad defines the callback to trigger once the texture is ready
  55801. * @param onError defines the callback to trigger in case of error
  55802. */
  55803. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55804. /**
  55805. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55806. * @param data contains the texture data
  55807. * @param texture defines the BabylonJS internal texture
  55808. * @param callback defines the method to call once ready to upload
  55809. */
  55810. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55811. }
  55812. }
  55813. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55814. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55815. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55816. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55817. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55818. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55819. }
  55820. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55821. import { Scene } from "babylonjs/scene";
  55822. import { Texture } from "babylonjs/Materials/Textures/texture";
  55823. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55824. /**
  55825. * 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.
  55826. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55827. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55828. */
  55829. export class CustomProceduralTexture extends ProceduralTexture {
  55830. private _animate;
  55831. private _time;
  55832. private _config;
  55833. private _texturePath;
  55834. /**
  55835. * Instantiates a new Custom Procedural Texture.
  55836. * 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.
  55837. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55838. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55839. * @param name Define the name of the texture
  55840. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55841. * @param size Define the size of the texture to create
  55842. * @param scene Define the scene the texture belongs to
  55843. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55844. * @param generateMipMaps Define if the texture should creates mip maps or not
  55845. */
  55846. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55847. private _loadJson;
  55848. /**
  55849. * Is the texture ready to be used ? (rendered at least once)
  55850. * @returns true if ready, otherwise, false.
  55851. */
  55852. isReady(): boolean;
  55853. /**
  55854. * Render the texture to its associated render target.
  55855. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55856. */
  55857. render(useCameraPostProcess?: boolean): void;
  55858. /**
  55859. * Update the list of dependant textures samplers in the shader.
  55860. */
  55861. updateTextures(): void;
  55862. /**
  55863. * Update the uniform values of the procedural texture in the shader.
  55864. */
  55865. updateShaderUniforms(): void;
  55866. /**
  55867. * Define if the texture animates or not.
  55868. */
  55869. animate: boolean;
  55870. }
  55871. }
  55872. declare module "babylonjs/Shaders/noise.fragment" {
  55873. /** @hidden */
  55874. export var noisePixelShader: {
  55875. name: string;
  55876. shader: string;
  55877. };
  55878. }
  55879. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55880. import { Nullable } from "babylonjs/types";
  55881. import { Scene } from "babylonjs/scene";
  55882. import { Texture } from "babylonjs/Materials/Textures/texture";
  55883. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55884. import "babylonjs/Shaders/noise.fragment";
  55885. /**
  55886. * Class used to generate noise procedural textures
  55887. */
  55888. export class NoiseProceduralTexture extends ProceduralTexture {
  55889. private _time;
  55890. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55891. brightness: number;
  55892. /** Defines the number of octaves to process */
  55893. octaves: number;
  55894. /** Defines the level of persistence (0.8 by default) */
  55895. persistence: number;
  55896. /** Gets or sets animation speed factor (default is 1) */
  55897. animationSpeedFactor: number;
  55898. /**
  55899. * Creates a new NoiseProceduralTexture
  55900. * @param name defines the name fo the texture
  55901. * @param size defines the size of the texture (default is 256)
  55902. * @param scene defines the hosting scene
  55903. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55904. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55905. */
  55906. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55907. private _updateShaderUniforms;
  55908. protected _getDefines(): string;
  55909. /** Generate the current state of the procedural texture */
  55910. render(useCameraPostProcess?: boolean): void;
  55911. /**
  55912. * Serializes this noise procedural texture
  55913. * @returns a serialized noise procedural texture object
  55914. */
  55915. serialize(): any;
  55916. /**
  55917. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55918. * @param parsedTexture defines parsed texture data
  55919. * @param scene defines the current scene
  55920. * @param rootUrl defines the root URL containing noise procedural texture information
  55921. * @returns a parsed NoiseProceduralTexture
  55922. */
  55923. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55924. }
  55925. }
  55926. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55927. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55928. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55929. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55930. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55931. }
  55932. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55933. import { Nullable } from "babylonjs/types";
  55934. import { Scene } from "babylonjs/scene";
  55935. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55936. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55937. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55938. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55939. /**
  55940. * Raw cube texture where the raw buffers are passed in
  55941. */
  55942. export class RawCubeTexture extends CubeTexture {
  55943. /**
  55944. * Creates a cube texture where the raw buffers are passed in.
  55945. * @param scene defines the scene the texture is attached to
  55946. * @param data defines the array of data to use to create each face
  55947. * @param size defines the size of the textures
  55948. * @param format defines the format of the data
  55949. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55950. * @param generateMipMaps defines if the engine should generate the mip levels
  55951. * @param invertY defines if data must be stored with Y axis inverted
  55952. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55953. * @param compression defines the compression used (null by default)
  55954. */
  55955. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55956. /**
  55957. * Updates the raw cube texture.
  55958. * @param data defines the data to store
  55959. * @param format defines the data format
  55960. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55961. * @param invertY defines if data must be stored with Y axis inverted
  55962. * @param compression defines the compression used (null by default)
  55963. * @param level defines which level of the texture to update
  55964. */
  55965. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55966. /**
  55967. * Updates a raw cube texture with RGBD encoded data.
  55968. * @param data defines the array of data [mipmap][face] to use to create each face
  55969. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55970. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55971. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55972. * @returns a promsie that resolves when the operation is complete
  55973. */
  55974. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55975. /**
  55976. * Clones the raw cube texture.
  55977. * @return a new cube texture
  55978. */
  55979. clone(): CubeTexture;
  55980. /** @hidden */
  55981. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55982. }
  55983. }
  55984. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55985. import { Scene } from "babylonjs/scene";
  55986. import { Texture } from "babylonjs/Materials/Textures/texture";
  55987. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55988. /**
  55989. * Class used to store 3D textures containing user data
  55990. */
  55991. export class RawTexture3D extends Texture {
  55992. /** Gets or sets the texture format to use */
  55993. format: number;
  55994. private _engine;
  55995. /**
  55996. * Create a new RawTexture3D
  55997. * @param data defines the data of the texture
  55998. * @param width defines the width of the texture
  55999. * @param height defines the height of the texture
  56000. * @param depth defines the depth of the texture
  56001. * @param format defines the texture format to use
  56002. * @param scene defines the hosting scene
  56003. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56004. * @param invertY defines if texture must be stored with Y axis inverted
  56005. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56006. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56007. */
  56008. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56009. /** Gets or sets the texture format to use */
  56010. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56011. /**
  56012. * Update the texture with new data
  56013. * @param data defines the data to store in the texture
  56014. */
  56015. update(data: ArrayBufferView): void;
  56016. }
  56017. }
  56018. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56019. import { Scene } from "babylonjs/scene";
  56020. import { Texture } from "babylonjs/Materials/Textures/texture";
  56021. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56022. /**
  56023. * Class used to store 2D array textures containing user data
  56024. */
  56025. export class RawTexture2DArray extends Texture {
  56026. /** Gets or sets the texture format to use */
  56027. format: number;
  56028. private _engine;
  56029. /**
  56030. * Create a new RawTexture2DArray
  56031. * @param data defines the data of the texture
  56032. * @param width defines the width of the texture
  56033. * @param height defines the height of the texture
  56034. * @param depth defines the number of layers of the texture
  56035. * @param format defines the texture format to use
  56036. * @param scene defines the hosting scene
  56037. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56038. * @param invertY defines if texture must be stored with Y axis inverted
  56039. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56040. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56041. */
  56042. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56043. /** Gets or sets the texture format to use */
  56044. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56045. /**
  56046. * Update the texture with new data
  56047. * @param data defines the data to store in the texture
  56048. */
  56049. update(data: ArrayBufferView): void;
  56050. }
  56051. }
  56052. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56053. import { Scene } from "babylonjs/scene";
  56054. import { Plane } from "babylonjs/Maths/math.plane";
  56055. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56056. /**
  56057. * Creates a refraction texture used by refraction channel of the standard material.
  56058. * It is like a mirror but to see through a material.
  56059. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56060. */
  56061. export class RefractionTexture extends RenderTargetTexture {
  56062. /**
  56063. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56064. * 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.
  56065. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56066. */
  56067. refractionPlane: Plane;
  56068. /**
  56069. * Define how deep under the surface we should see.
  56070. */
  56071. depth: number;
  56072. /**
  56073. * Creates a refraction texture used by refraction channel of the standard material.
  56074. * It is like a mirror but to see through a material.
  56075. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56076. * @param name Define the texture name
  56077. * @param size Define the size of the underlying texture
  56078. * @param scene Define the scene the refraction belongs to
  56079. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56080. */
  56081. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56082. /**
  56083. * Clone the refraction texture.
  56084. * @returns the cloned texture
  56085. */
  56086. clone(): RefractionTexture;
  56087. /**
  56088. * Serialize the texture to a JSON representation you could use in Parse later on
  56089. * @returns the serialized JSON representation
  56090. */
  56091. serialize(): any;
  56092. }
  56093. }
  56094. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56095. import { Nullable } from "babylonjs/types";
  56096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56097. import { Matrix } from "babylonjs/Maths/math.vector";
  56098. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56099. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56100. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56101. import { Scene } from "babylonjs/scene";
  56102. /**
  56103. * Defines the options related to the creation of an HtmlElementTexture
  56104. */
  56105. export interface IHtmlElementTextureOptions {
  56106. /**
  56107. * Defines wether mip maps should be created or not.
  56108. */
  56109. generateMipMaps?: boolean;
  56110. /**
  56111. * Defines the sampling mode of the texture.
  56112. */
  56113. samplingMode?: number;
  56114. /**
  56115. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56116. */
  56117. engine: Nullable<ThinEngine>;
  56118. /**
  56119. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56120. */
  56121. scene: Nullable<Scene>;
  56122. }
  56123. /**
  56124. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56125. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56126. * is automatically managed.
  56127. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56128. * in your application.
  56129. *
  56130. * As the update is not automatic, you need to call them manually.
  56131. */
  56132. export class HtmlElementTexture extends BaseTexture {
  56133. /**
  56134. * The texture URL.
  56135. */
  56136. element: HTMLVideoElement | HTMLCanvasElement;
  56137. private static readonly DefaultOptions;
  56138. private _textureMatrix;
  56139. private _engine;
  56140. private _isVideo;
  56141. private _generateMipMaps;
  56142. private _samplingMode;
  56143. /**
  56144. * Instantiates a HtmlElementTexture from the following parameters.
  56145. *
  56146. * @param name Defines the name of the texture
  56147. * @param element Defines the video or canvas the texture is filled with
  56148. * @param options Defines the other none mandatory texture creation options
  56149. */
  56150. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56151. private _createInternalTexture;
  56152. /**
  56153. * Returns the texture matrix used in most of the material.
  56154. */
  56155. getTextureMatrix(): Matrix;
  56156. /**
  56157. * Updates the content of the texture.
  56158. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56159. */
  56160. update(invertY?: Nullable<boolean>): void;
  56161. }
  56162. }
  56163. declare module "babylonjs/Materials/Textures/index" {
  56164. export * from "babylonjs/Materials/Textures/baseTexture";
  56165. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56166. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56167. export * from "babylonjs/Materials/Textures/cubeTexture";
  56168. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56169. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56170. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56171. export * from "babylonjs/Materials/Textures/internalTexture";
  56172. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56173. export * from "babylonjs/Materials/Textures/Loaders/index";
  56174. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56175. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56176. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56177. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56178. export * from "babylonjs/Materials/Textures/rawTexture";
  56179. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56180. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56181. export * from "babylonjs/Materials/Textures/refractionTexture";
  56182. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56183. export * from "babylonjs/Materials/Textures/texture";
  56184. export * from "babylonjs/Materials/Textures/videoTexture";
  56185. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56186. }
  56187. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56188. /**
  56189. * Enum used to define the target of a block
  56190. */
  56191. export enum NodeMaterialBlockTargets {
  56192. /** Vertex shader */
  56193. Vertex = 1,
  56194. /** Fragment shader */
  56195. Fragment = 2,
  56196. /** Neutral */
  56197. Neutral = 4,
  56198. /** Vertex and Fragment */
  56199. VertexAndFragment = 3
  56200. }
  56201. }
  56202. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56203. /**
  56204. * Defines the kind of connection point for node based material
  56205. */
  56206. export enum NodeMaterialBlockConnectionPointTypes {
  56207. /** Float */
  56208. Float = 1,
  56209. /** Int */
  56210. Int = 2,
  56211. /** Vector2 */
  56212. Vector2 = 4,
  56213. /** Vector3 */
  56214. Vector3 = 8,
  56215. /** Vector4 */
  56216. Vector4 = 16,
  56217. /** Color3 */
  56218. Color3 = 32,
  56219. /** Color4 */
  56220. Color4 = 64,
  56221. /** Matrix */
  56222. Matrix = 128,
  56223. /** Detect type based on connection */
  56224. AutoDetect = 1024,
  56225. /** Output type that will be defined by input type */
  56226. BasedOnInput = 2048
  56227. }
  56228. }
  56229. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56230. /**
  56231. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56232. */
  56233. export enum NodeMaterialBlockConnectionPointMode {
  56234. /** Value is an uniform */
  56235. Uniform = 0,
  56236. /** Value is a mesh attribute */
  56237. Attribute = 1,
  56238. /** Value is a varying between vertex and fragment shaders */
  56239. Varying = 2,
  56240. /** Mode is undefined */
  56241. Undefined = 3
  56242. }
  56243. }
  56244. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56245. /**
  56246. * Enum used to define system values e.g. values automatically provided by the system
  56247. */
  56248. export enum NodeMaterialSystemValues {
  56249. /** World */
  56250. World = 1,
  56251. /** View */
  56252. View = 2,
  56253. /** Projection */
  56254. Projection = 3,
  56255. /** ViewProjection */
  56256. ViewProjection = 4,
  56257. /** WorldView */
  56258. WorldView = 5,
  56259. /** WorldViewProjection */
  56260. WorldViewProjection = 6,
  56261. /** CameraPosition */
  56262. CameraPosition = 7,
  56263. /** Fog Color */
  56264. FogColor = 8,
  56265. /** Delta time */
  56266. DeltaTime = 9
  56267. }
  56268. }
  56269. declare module "babylonjs/Materials/Node/Enums/index" {
  56270. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56271. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56272. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56273. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56274. }
  56275. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56277. /**
  56278. * Root class for all node material optimizers
  56279. */
  56280. export class NodeMaterialOptimizer {
  56281. /**
  56282. * Function used to optimize a NodeMaterial graph
  56283. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56284. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56285. */
  56286. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56287. }
  56288. }
  56289. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56293. import { Scene } from "babylonjs/scene";
  56294. /**
  56295. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56296. */
  56297. export class TransformBlock extends NodeMaterialBlock {
  56298. /**
  56299. * Defines the value to use to complement W value to transform it to a Vector4
  56300. */
  56301. complementW: number;
  56302. /**
  56303. * Defines the value to use to complement z value to transform it to a Vector4
  56304. */
  56305. complementZ: number;
  56306. /**
  56307. * Creates a new TransformBlock
  56308. * @param name defines the block name
  56309. */
  56310. constructor(name: string);
  56311. /**
  56312. * Gets the current class name
  56313. * @returns the class name
  56314. */
  56315. getClassName(): string;
  56316. /**
  56317. * Gets the vector input
  56318. */
  56319. readonly vector: NodeMaterialConnectionPoint;
  56320. /**
  56321. * Gets the output component
  56322. */
  56323. readonly output: NodeMaterialConnectionPoint;
  56324. /**
  56325. * Gets the matrix transform input
  56326. */
  56327. readonly transform: NodeMaterialConnectionPoint;
  56328. protected _buildBlock(state: NodeMaterialBuildState): this;
  56329. serialize(): any;
  56330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56331. protected _dumpPropertiesCode(): string;
  56332. }
  56333. }
  56334. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56338. /**
  56339. * Block used to output the vertex position
  56340. */
  56341. export class VertexOutputBlock extends NodeMaterialBlock {
  56342. /**
  56343. * Creates a new VertexOutputBlock
  56344. * @param name defines the block name
  56345. */
  56346. constructor(name: string);
  56347. /**
  56348. * Gets the current class name
  56349. * @returns the class name
  56350. */
  56351. getClassName(): string;
  56352. /**
  56353. * Gets the vector input component
  56354. */
  56355. readonly vector: NodeMaterialConnectionPoint;
  56356. protected _buildBlock(state: NodeMaterialBuildState): this;
  56357. }
  56358. }
  56359. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56361. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56362. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56363. /**
  56364. * Block used to output the final color
  56365. */
  56366. export class FragmentOutputBlock extends NodeMaterialBlock {
  56367. /**
  56368. * Create a new FragmentOutputBlock
  56369. * @param name defines the block name
  56370. */
  56371. constructor(name: string);
  56372. /**
  56373. * Gets the current class name
  56374. * @returns the class name
  56375. */
  56376. getClassName(): string;
  56377. /**
  56378. * Gets the rgba input component
  56379. */
  56380. readonly rgba: NodeMaterialConnectionPoint;
  56381. /**
  56382. * Gets the rgb input component
  56383. */
  56384. readonly rgb: NodeMaterialConnectionPoint;
  56385. /**
  56386. * Gets the a input component
  56387. */
  56388. readonly a: NodeMaterialConnectionPoint;
  56389. protected _buildBlock(state: NodeMaterialBuildState): this;
  56390. }
  56391. }
  56392. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56398. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56399. import { Effect } from "babylonjs/Materials/effect";
  56400. import { Mesh } from "babylonjs/Meshes/mesh";
  56401. import { Nullable } from "babylonjs/types";
  56402. import { Scene } from "babylonjs/scene";
  56403. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56404. /**
  56405. * Block used to read a reflection texture from a sampler
  56406. */
  56407. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56408. private _define3DName;
  56409. private _defineCubicName;
  56410. private _defineExplicitName;
  56411. private _defineProjectionName;
  56412. private _defineLocalCubicName;
  56413. private _defineSphericalName;
  56414. private _definePlanarName;
  56415. private _defineEquirectangularName;
  56416. private _defineMirroredEquirectangularFixedName;
  56417. private _defineEquirectangularFixedName;
  56418. private _defineSkyboxName;
  56419. private _cubeSamplerName;
  56420. private _2DSamplerName;
  56421. private _positionUVWName;
  56422. private _directionWName;
  56423. private _reflectionCoordsName;
  56424. private _reflection2DCoordsName;
  56425. private _reflectionColorName;
  56426. private _reflectionMatrixName;
  56427. /**
  56428. * Gets or sets the texture associated with the node
  56429. */
  56430. texture: Nullable<BaseTexture>;
  56431. /**
  56432. * Create a new TextureBlock
  56433. * @param name defines the block name
  56434. */
  56435. constructor(name: string);
  56436. /**
  56437. * Gets the current class name
  56438. * @returns the class name
  56439. */
  56440. getClassName(): string;
  56441. /**
  56442. * Gets the world position input component
  56443. */
  56444. readonly position: NodeMaterialConnectionPoint;
  56445. /**
  56446. * Gets the world position input component
  56447. */
  56448. readonly worldPosition: NodeMaterialConnectionPoint;
  56449. /**
  56450. * Gets the world normal input component
  56451. */
  56452. readonly worldNormal: NodeMaterialConnectionPoint;
  56453. /**
  56454. * Gets the world input component
  56455. */
  56456. readonly world: NodeMaterialConnectionPoint;
  56457. /**
  56458. * Gets the camera (or eye) position component
  56459. */
  56460. readonly cameraPosition: NodeMaterialConnectionPoint;
  56461. /**
  56462. * Gets the view input component
  56463. */
  56464. readonly view: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the rgb output component
  56467. */
  56468. readonly rgb: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the r output component
  56471. */
  56472. readonly r: NodeMaterialConnectionPoint;
  56473. /**
  56474. * Gets the g output component
  56475. */
  56476. readonly g: NodeMaterialConnectionPoint;
  56477. /**
  56478. * Gets the b output component
  56479. */
  56480. readonly b: NodeMaterialConnectionPoint;
  56481. autoConfigure(material: NodeMaterial): void;
  56482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56483. isReady(): boolean;
  56484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56485. private _injectVertexCode;
  56486. private _writeOutput;
  56487. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56488. protected _dumpPropertiesCode(): string;
  56489. serialize(): any;
  56490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56491. }
  56492. }
  56493. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56495. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56496. import { Scene } from "babylonjs/scene";
  56497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56498. import { Matrix } from "babylonjs/Maths/math.vector";
  56499. import { Mesh } from "babylonjs/Meshes/mesh";
  56500. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56501. import { Observable } from "babylonjs/Misc/observable";
  56502. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56503. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56504. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56505. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56506. import { Nullable } from "babylonjs/types";
  56507. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56508. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56509. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56510. /**
  56511. * Interface used to configure the node material editor
  56512. */
  56513. export interface INodeMaterialEditorOptions {
  56514. /** Define the URl to load node editor script */
  56515. editorURL?: string;
  56516. }
  56517. /** @hidden */
  56518. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56519. /** BONES */
  56520. NUM_BONE_INFLUENCERS: number;
  56521. BonesPerMesh: number;
  56522. BONETEXTURE: boolean;
  56523. /** MORPH TARGETS */
  56524. MORPHTARGETS: boolean;
  56525. MORPHTARGETS_NORMAL: boolean;
  56526. MORPHTARGETS_TANGENT: boolean;
  56527. MORPHTARGETS_UV: boolean;
  56528. NUM_MORPH_INFLUENCERS: number;
  56529. /** IMAGE PROCESSING */
  56530. IMAGEPROCESSING: boolean;
  56531. VIGNETTE: boolean;
  56532. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56533. VIGNETTEBLENDMODEOPAQUE: boolean;
  56534. TONEMAPPING: boolean;
  56535. TONEMAPPING_ACES: boolean;
  56536. CONTRAST: boolean;
  56537. EXPOSURE: boolean;
  56538. COLORCURVES: boolean;
  56539. COLORGRADING: boolean;
  56540. COLORGRADING3D: boolean;
  56541. SAMPLER3DGREENDEPTH: boolean;
  56542. SAMPLER3DBGRMAP: boolean;
  56543. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56544. /** MISC. */
  56545. BUMPDIRECTUV: number;
  56546. constructor();
  56547. setValue(name: string, value: boolean): void;
  56548. }
  56549. /**
  56550. * Class used to configure NodeMaterial
  56551. */
  56552. export interface INodeMaterialOptions {
  56553. /**
  56554. * Defines if blocks should emit comments
  56555. */
  56556. emitComments: boolean;
  56557. }
  56558. /**
  56559. * Class used to create a node based material built by assembling shader blocks
  56560. */
  56561. export class NodeMaterial extends PushMaterial {
  56562. private static _BuildIdGenerator;
  56563. private _options;
  56564. private _vertexCompilationState;
  56565. private _fragmentCompilationState;
  56566. private _sharedData;
  56567. private _buildId;
  56568. private _buildWasSuccessful;
  56569. private _cachedWorldViewMatrix;
  56570. private _cachedWorldViewProjectionMatrix;
  56571. private _optimizers;
  56572. private _animationFrame;
  56573. /** Define the URl to load node editor script */
  56574. static EditorURL: string;
  56575. private BJSNODEMATERIALEDITOR;
  56576. /** Get the inspector from bundle or global */
  56577. private _getGlobalNodeMaterialEditor;
  56578. /**
  56579. * Gets or sets data used by visual editor
  56580. * @see https://nme.babylonjs.com
  56581. */
  56582. editorData: any;
  56583. /**
  56584. * 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)
  56585. */
  56586. ignoreAlpha: boolean;
  56587. /**
  56588. * Defines the maximum number of lights that can be used in the material
  56589. */
  56590. maxSimultaneousLights: number;
  56591. /**
  56592. * Observable raised when the material is built
  56593. */
  56594. onBuildObservable: Observable<NodeMaterial>;
  56595. /**
  56596. * Gets or sets the root nodes of the material vertex shader
  56597. */
  56598. _vertexOutputNodes: NodeMaterialBlock[];
  56599. /**
  56600. * Gets or sets the root nodes of the material fragment (pixel) shader
  56601. */
  56602. _fragmentOutputNodes: NodeMaterialBlock[];
  56603. /** Gets or sets options to control the node material overall behavior */
  56604. options: INodeMaterialOptions;
  56605. /**
  56606. * Default configuration related to image processing available in the standard Material.
  56607. */
  56608. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56609. /**
  56610. * Gets the image processing configuration used either in this material.
  56611. */
  56612. /**
  56613. * Sets the Default image processing configuration used either in the this material.
  56614. *
  56615. * If sets to null, the scene one is in use.
  56616. */
  56617. imageProcessingConfiguration: ImageProcessingConfiguration;
  56618. /**
  56619. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56620. */
  56621. attachedBlocks: NodeMaterialBlock[];
  56622. /**
  56623. * Create a new node based material
  56624. * @param name defines the material name
  56625. * @param scene defines the hosting scene
  56626. * @param options defines creation option
  56627. */
  56628. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56629. /**
  56630. * Gets the current class name of the material e.g. "NodeMaterial"
  56631. * @returns the class name
  56632. */
  56633. getClassName(): string;
  56634. /**
  56635. * Keep track of the image processing observer to allow dispose and replace.
  56636. */
  56637. private _imageProcessingObserver;
  56638. /**
  56639. * Attaches a new image processing configuration to the Standard Material.
  56640. * @param configuration
  56641. */
  56642. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56643. /**
  56644. * Get a block by its name
  56645. * @param name defines the name of the block to retrieve
  56646. * @returns the required block or null if not found
  56647. */
  56648. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56649. /**
  56650. * Get a block by its name
  56651. * @param predicate defines the predicate used to find the good candidate
  56652. * @returns the required block or null if not found
  56653. */
  56654. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56655. /**
  56656. * Get an input block by its name
  56657. * @param predicate defines the predicate used to find the good candidate
  56658. * @returns the required input block or null if not found
  56659. */
  56660. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56661. /**
  56662. * Gets the list of input blocks attached to this material
  56663. * @returns an array of InputBlocks
  56664. */
  56665. getInputBlocks(): InputBlock[];
  56666. /**
  56667. * Adds a new optimizer to the list of optimizers
  56668. * @param optimizer defines the optimizers to add
  56669. * @returns the current material
  56670. */
  56671. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56672. /**
  56673. * Remove an optimizer from the list of optimizers
  56674. * @param optimizer defines the optimizers to remove
  56675. * @returns the current material
  56676. */
  56677. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56678. /**
  56679. * Add a new block to the list of output nodes
  56680. * @param node defines the node to add
  56681. * @returns the current material
  56682. */
  56683. addOutputNode(node: NodeMaterialBlock): this;
  56684. /**
  56685. * Remove a block from the list of root nodes
  56686. * @param node defines the node to remove
  56687. * @returns the current material
  56688. */
  56689. removeOutputNode(node: NodeMaterialBlock): this;
  56690. private _addVertexOutputNode;
  56691. private _removeVertexOutputNode;
  56692. private _addFragmentOutputNode;
  56693. private _removeFragmentOutputNode;
  56694. /**
  56695. * Specifies if the material will require alpha blending
  56696. * @returns a boolean specifying if alpha blending is needed
  56697. */
  56698. needAlphaBlending(): boolean;
  56699. /**
  56700. * Specifies if this material should be rendered in alpha test mode
  56701. * @returns a boolean specifying if an alpha test is needed.
  56702. */
  56703. needAlphaTesting(): boolean;
  56704. private _initializeBlock;
  56705. private _resetDualBlocks;
  56706. /**
  56707. * Remove a block from the current node material
  56708. * @param block defines the block to remove
  56709. */
  56710. removeBlock(block: NodeMaterialBlock): void;
  56711. /**
  56712. * Build the material and generates the inner effect
  56713. * @param verbose defines if the build should log activity
  56714. */
  56715. build(verbose?: boolean): void;
  56716. /**
  56717. * Runs an otpimization phase to try to improve the shader code
  56718. */
  56719. optimize(): void;
  56720. private _prepareDefinesForAttributes;
  56721. /**
  56722. * Get if the submesh is ready to be used and all its information available.
  56723. * Child classes can use it to update shaders
  56724. * @param mesh defines the mesh to check
  56725. * @param subMesh defines which submesh to check
  56726. * @param useInstances specifies that instances should be used
  56727. * @returns a boolean indicating that the submesh is ready or not
  56728. */
  56729. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56730. /**
  56731. * Get a string representing the shaders built by the current node graph
  56732. */
  56733. readonly compiledShaders: string;
  56734. /**
  56735. * Binds the world matrix to the material
  56736. * @param world defines the world transformation matrix
  56737. */
  56738. bindOnlyWorldMatrix(world: Matrix): void;
  56739. /**
  56740. * Binds the submesh to this material by preparing the effect and shader to draw
  56741. * @param world defines the world transformation matrix
  56742. * @param mesh defines the mesh containing the submesh
  56743. * @param subMesh defines the submesh to bind the material to
  56744. */
  56745. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56746. /**
  56747. * Gets the active textures from the material
  56748. * @returns an array of textures
  56749. */
  56750. getActiveTextures(): BaseTexture[];
  56751. /**
  56752. * Gets the list of texture blocks
  56753. * @returns an array of texture blocks
  56754. */
  56755. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56756. /**
  56757. * Specifies if the material uses a texture
  56758. * @param texture defines the texture to check against the material
  56759. * @returns a boolean specifying if the material uses the texture
  56760. */
  56761. hasTexture(texture: BaseTexture): boolean;
  56762. /**
  56763. * Disposes the material
  56764. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56765. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56766. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56767. */
  56768. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56769. /** Creates the node editor window. */
  56770. private _createNodeEditor;
  56771. /**
  56772. * Launch the node material editor
  56773. * @param config Define the configuration of the editor
  56774. * @return a promise fulfilled when the node editor is visible
  56775. */
  56776. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56777. /**
  56778. * Clear the current material
  56779. */
  56780. clear(): void;
  56781. /**
  56782. * Clear the current material and set it to a default state
  56783. */
  56784. setToDefault(): void;
  56785. /**
  56786. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56787. * @param url defines the url to load from
  56788. * @returns a promise that will fullfil when the material is fully loaded
  56789. */
  56790. loadAsync(url: string): Promise<void>;
  56791. private _gatherBlocks;
  56792. /**
  56793. * Generate a string containing the code declaration required to create an equivalent of this material
  56794. * @returns a string
  56795. */
  56796. generateCode(): string;
  56797. /**
  56798. * Serializes this material in a JSON representation
  56799. * @returns the serialized material object
  56800. */
  56801. serialize(): any;
  56802. private _restoreConnections;
  56803. /**
  56804. * Clear the current graph and load a new one from a serialization object
  56805. * @param source defines the JSON representation of the material
  56806. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56807. */
  56808. loadFromSerialization(source: any, rootUrl?: string): void;
  56809. /**
  56810. * Creates a node material from parsed material data
  56811. * @param source defines the JSON representation of the material
  56812. * @param scene defines the hosting scene
  56813. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56814. * @returns a new node material
  56815. */
  56816. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56817. /**
  56818. * Creates a new node material set to default basic configuration
  56819. * @param name defines the name of the material
  56820. * @param scene defines the hosting scene
  56821. * @returns a new NodeMaterial
  56822. */
  56823. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56824. }
  56825. }
  56826. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56829. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56832. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56833. import { Effect } from "babylonjs/Materials/effect";
  56834. import { Mesh } from "babylonjs/Meshes/mesh";
  56835. import { Nullable } from "babylonjs/types";
  56836. import { Texture } from "babylonjs/Materials/Textures/texture";
  56837. import { Scene } from "babylonjs/scene";
  56838. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56839. /**
  56840. * Block used to read a texture from a sampler
  56841. */
  56842. export class TextureBlock extends NodeMaterialBlock {
  56843. private _defineName;
  56844. private _linearDefineName;
  56845. private _tempTextureRead;
  56846. private _samplerName;
  56847. private _transformedUVName;
  56848. private _textureTransformName;
  56849. private _textureInfoName;
  56850. private _mainUVName;
  56851. private _mainUVDefineName;
  56852. /**
  56853. * Gets or sets the texture associated with the node
  56854. */
  56855. texture: Nullable<Texture>;
  56856. /**
  56857. * Create a new TextureBlock
  56858. * @param name defines the block name
  56859. */
  56860. constructor(name: string);
  56861. /**
  56862. * Gets the current class name
  56863. * @returns the class name
  56864. */
  56865. getClassName(): string;
  56866. /**
  56867. * Gets the uv input component
  56868. */
  56869. readonly uv: NodeMaterialConnectionPoint;
  56870. /**
  56871. * Gets the rgba output component
  56872. */
  56873. readonly rgba: NodeMaterialConnectionPoint;
  56874. /**
  56875. * Gets the rgb output component
  56876. */
  56877. readonly rgb: NodeMaterialConnectionPoint;
  56878. /**
  56879. * Gets the r output component
  56880. */
  56881. readonly r: NodeMaterialConnectionPoint;
  56882. /**
  56883. * Gets the g output component
  56884. */
  56885. readonly g: NodeMaterialConnectionPoint;
  56886. /**
  56887. * Gets the b output component
  56888. */
  56889. readonly b: NodeMaterialConnectionPoint;
  56890. /**
  56891. * Gets the a output component
  56892. */
  56893. readonly a: NodeMaterialConnectionPoint;
  56894. readonly target: NodeMaterialBlockTargets;
  56895. autoConfigure(material: NodeMaterial): void;
  56896. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56898. private _getTextureBase;
  56899. isReady(): boolean;
  56900. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56901. private readonly _isMixed;
  56902. private _injectVertexCode;
  56903. private _writeTextureRead;
  56904. private _writeOutput;
  56905. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56906. protected _dumpPropertiesCode(): string;
  56907. serialize(): any;
  56908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56909. }
  56910. }
  56911. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56914. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56915. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56916. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56917. import { Scene } from "babylonjs/scene";
  56918. /**
  56919. * Class used to store shared data between 2 NodeMaterialBuildState
  56920. */
  56921. export class NodeMaterialBuildStateSharedData {
  56922. /**
  56923. * Gets the list of emitted varyings
  56924. */
  56925. temps: string[];
  56926. /**
  56927. * Gets the list of emitted varyings
  56928. */
  56929. varyings: string[];
  56930. /**
  56931. * Gets the varying declaration string
  56932. */
  56933. varyingDeclaration: string;
  56934. /**
  56935. * Input blocks
  56936. */
  56937. inputBlocks: InputBlock[];
  56938. /**
  56939. * Input blocks
  56940. */
  56941. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56942. /**
  56943. * Bindable blocks (Blocks that need to set data to the effect)
  56944. */
  56945. bindableBlocks: NodeMaterialBlock[];
  56946. /**
  56947. * List of blocks that can provide a compilation fallback
  56948. */
  56949. blocksWithFallbacks: NodeMaterialBlock[];
  56950. /**
  56951. * List of blocks that can provide a define update
  56952. */
  56953. blocksWithDefines: NodeMaterialBlock[];
  56954. /**
  56955. * List of blocks that can provide a repeatable content
  56956. */
  56957. repeatableContentBlocks: NodeMaterialBlock[];
  56958. /**
  56959. * List of blocks that can provide a dynamic list of uniforms
  56960. */
  56961. dynamicUniformBlocks: NodeMaterialBlock[];
  56962. /**
  56963. * List of blocks that can block the isReady function for the material
  56964. */
  56965. blockingBlocks: NodeMaterialBlock[];
  56966. /**
  56967. * Gets the list of animated inputs
  56968. */
  56969. animatedInputs: InputBlock[];
  56970. /**
  56971. * Build Id used to avoid multiple recompilations
  56972. */
  56973. buildId: number;
  56974. /** List of emitted variables */
  56975. variableNames: {
  56976. [key: string]: number;
  56977. };
  56978. /** List of emitted defines */
  56979. defineNames: {
  56980. [key: string]: number;
  56981. };
  56982. /** Should emit comments? */
  56983. emitComments: boolean;
  56984. /** Emit build activity */
  56985. verbose: boolean;
  56986. /** Gets or sets the hosting scene */
  56987. scene: Scene;
  56988. /**
  56989. * Gets the compilation hints emitted at compilation time
  56990. */
  56991. hints: {
  56992. needWorldViewMatrix: boolean;
  56993. needWorldViewProjectionMatrix: boolean;
  56994. needAlphaBlending: boolean;
  56995. needAlphaTesting: boolean;
  56996. };
  56997. /**
  56998. * List of compilation checks
  56999. */
  57000. checks: {
  57001. emitVertex: boolean;
  57002. emitFragment: boolean;
  57003. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57004. };
  57005. /** Creates a new shared data */
  57006. constructor();
  57007. /**
  57008. * Emits console errors and exceptions if there is a failing check
  57009. */
  57010. emitErrors(): void;
  57011. }
  57012. }
  57013. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57014. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57015. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57016. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57017. /**
  57018. * Class used to store node based material build state
  57019. */
  57020. export class NodeMaterialBuildState {
  57021. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57022. supportUniformBuffers: boolean;
  57023. /**
  57024. * Gets the list of emitted attributes
  57025. */
  57026. attributes: string[];
  57027. /**
  57028. * Gets the list of emitted uniforms
  57029. */
  57030. uniforms: string[];
  57031. /**
  57032. * Gets the list of emitted constants
  57033. */
  57034. constants: string[];
  57035. /**
  57036. * Gets the list of emitted samplers
  57037. */
  57038. samplers: string[];
  57039. /**
  57040. * Gets the list of emitted functions
  57041. */
  57042. functions: {
  57043. [key: string]: string;
  57044. };
  57045. /**
  57046. * Gets the list of emitted extensions
  57047. */
  57048. extensions: {
  57049. [key: string]: string;
  57050. };
  57051. /**
  57052. * Gets the target of the compilation state
  57053. */
  57054. target: NodeMaterialBlockTargets;
  57055. /**
  57056. * Gets the list of emitted counters
  57057. */
  57058. counters: {
  57059. [key: string]: number;
  57060. };
  57061. /**
  57062. * Shared data between multiple NodeMaterialBuildState instances
  57063. */
  57064. sharedData: NodeMaterialBuildStateSharedData;
  57065. /** @hidden */
  57066. _vertexState: NodeMaterialBuildState;
  57067. /** @hidden */
  57068. _attributeDeclaration: string;
  57069. /** @hidden */
  57070. _uniformDeclaration: string;
  57071. /** @hidden */
  57072. _constantDeclaration: string;
  57073. /** @hidden */
  57074. _samplerDeclaration: string;
  57075. /** @hidden */
  57076. _varyingTransfer: string;
  57077. private _repeatableContentAnchorIndex;
  57078. /** @hidden */
  57079. _builtCompilationString: string;
  57080. /**
  57081. * Gets the emitted compilation strings
  57082. */
  57083. compilationString: string;
  57084. /**
  57085. * Finalize the compilation strings
  57086. * @param state defines the current compilation state
  57087. */
  57088. finalize(state: NodeMaterialBuildState): void;
  57089. /** @hidden */
  57090. readonly _repeatableContentAnchor: string;
  57091. /** @hidden */
  57092. _getFreeVariableName(prefix: string): string;
  57093. /** @hidden */
  57094. _getFreeDefineName(prefix: string): string;
  57095. /** @hidden */
  57096. _excludeVariableName(name: string): void;
  57097. /** @hidden */
  57098. _emit2DSampler(name: string): void;
  57099. /** @hidden */
  57100. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57101. /** @hidden */
  57102. _emitExtension(name: string, extension: string): void;
  57103. /** @hidden */
  57104. _emitFunction(name: string, code: string, comments: string): void;
  57105. /** @hidden */
  57106. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57107. replaceStrings?: {
  57108. search: RegExp;
  57109. replace: string;
  57110. }[];
  57111. repeatKey?: string;
  57112. }): string;
  57113. /** @hidden */
  57114. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57115. repeatKey?: string;
  57116. removeAttributes?: boolean;
  57117. removeUniforms?: boolean;
  57118. removeVaryings?: boolean;
  57119. removeIfDef?: boolean;
  57120. replaceStrings?: {
  57121. search: RegExp;
  57122. replace: string;
  57123. }[];
  57124. }, storeKey?: string): void;
  57125. /** @hidden */
  57126. _registerTempVariable(name: string): boolean;
  57127. /** @hidden */
  57128. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57129. /** @hidden */
  57130. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57131. /** @hidden */
  57132. _emitFloat(value: number): string;
  57133. }
  57134. }
  57135. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57136. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57138. import { Nullable } from "babylonjs/types";
  57139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57140. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57141. import { Effect } from "babylonjs/Materials/effect";
  57142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57143. import { Mesh } from "babylonjs/Meshes/mesh";
  57144. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57145. import { Scene } from "babylonjs/scene";
  57146. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57147. /**
  57148. * Defines a block that can be used inside a node based material
  57149. */
  57150. export class NodeMaterialBlock {
  57151. private _buildId;
  57152. private _buildTarget;
  57153. private _target;
  57154. private _isFinalMerger;
  57155. private _isInput;
  57156. protected _isUnique: boolean;
  57157. /** @hidden */
  57158. _codeVariableName: string;
  57159. /** @hidden */
  57160. _inputs: NodeMaterialConnectionPoint[];
  57161. /** @hidden */
  57162. _outputs: NodeMaterialConnectionPoint[];
  57163. /** @hidden */
  57164. _preparationId: number;
  57165. /**
  57166. * Gets or sets the name of the block
  57167. */
  57168. name: string;
  57169. /**
  57170. * Gets or sets the unique id of the node
  57171. */
  57172. uniqueId: number;
  57173. /**
  57174. * Gets or sets the comments associated with this block
  57175. */
  57176. comments: string;
  57177. /**
  57178. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57179. */
  57180. readonly isUnique: boolean;
  57181. /**
  57182. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57183. */
  57184. readonly isFinalMerger: boolean;
  57185. /**
  57186. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57187. */
  57188. readonly isInput: boolean;
  57189. /**
  57190. * Gets or sets the build Id
  57191. */
  57192. buildId: number;
  57193. /**
  57194. * Gets or sets the target of the block
  57195. */
  57196. target: NodeMaterialBlockTargets;
  57197. /**
  57198. * Gets the list of input points
  57199. */
  57200. readonly inputs: NodeMaterialConnectionPoint[];
  57201. /** Gets the list of output points */
  57202. readonly outputs: NodeMaterialConnectionPoint[];
  57203. /**
  57204. * Find an input by its name
  57205. * @param name defines the name of the input to look for
  57206. * @returns the input or null if not found
  57207. */
  57208. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57209. /**
  57210. * Find an output by its name
  57211. * @param name defines the name of the outputto look for
  57212. * @returns the output or null if not found
  57213. */
  57214. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57215. /**
  57216. * Creates a new NodeMaterialBlock
  57217. * @param name defines the block name
  57218. * @param target defines the target of that block (Vertex by default)
  57219. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57220. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57221. */
  57222. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57223. /**
  57224. * Initialize the block and prepare the context for build
  57225. * @param state defines the state that will be used for the build
  57226. */
  57227. initialize(state: NodeMaterialBuildState): void;
  57228. /**
  57229. * Bind data to effect. Will only be called for blocks with isBindable === true
  57230. * @param effect defines the effect to bind data to
  57231. * @param nodeMaterial defines the hosting NodeMaterial
  57232. * @param mesh defines the mesh that will be rendered
  57233. */
  57234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57235. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57236. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57237. protected _writeFloat(value: number): string;
  57238. /**
  57239. * Gets the current class name e.g. "NodeMaterialBlock"
  57240. * @returns the class name
  57241. */
  57242. getClassName(): string;
  57243. /**
  57244. * Register a new input. Must be called inside a block constructor
  57245. * @param name defines the connection point name
  57246. * @param type defines the connection point type
  57247. * @param isOptional defines a boolean indicating that this input can be omitted
  57248. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57249. * @returns the current block
  57250. */
  57251. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57252. /**
  57253. * Register a new output. Must be called inside a block constructor
  57254. * @param name defines the connection point name
  57255. * @param type defines the connection point type
  57256. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57257. * @returns the current block
  57258. */
  57259. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57260. /**
  57261. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57262. * @param forOutput defines an optional connection point to check compatibility with
  57263. * @returns the first available input or null
  57264. */
  57265. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57266. /**
  57267. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57268. * @param forBlock defines an optional block to check compatibility with
  57269. * @returns the first available input or null
  57270. */
  57271. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57272. /**
  57273. * Gets the sibling of the given output
  57274. * @param current defines the current output
  57275. * @returns the next output in the list or null
  57276. */
  57277. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57278. /**
  57279. * Connect current block with another block
  57280. * @param other defines the block to connect with
  57281. * @param options define the various options to help pick the right connections
  57282. * @returns the current block
  57283. */
  57284. connectTo(other: NodeMaterialBlock, options?: {
  57285. input?: string;
  57286. output?: string;
  57287. outputSwizzle?: string;
  57288. }): this | undefined;
  57289. protected _buildBlock(state: NodeMaterialBuildState): void;
  57290. /**
  57291. * Add uniforms, samplers and uniform buffers at compilation time
  57292. * @param state defines the state to update
  57293. * @param nodeMaterial defines the node material requesting the update
  57294. * @param defines defines the material defines to update
  57295. * @param uniformBuffers defines the list of uniform buffer names
  57296. */
  57297. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57298. /**
  57299. * Add potential fallbacks if shader compilation fails
  57300. * @param mesh defines the mesh to be rendered
  57301. * @param fallbacks defines the current prioritized list of fallbacks
  57302. */
  57303. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57304. /**
  57305. * Initialize defines for shader compilation
  57306. * @param mesh defines the mesh to be rendered
  57307. * @param nodeMaterial defines the node material requesting the update
  57308. * @param defines defines the material defines to update
  57309. * @param useInstances specifies that instances should be used
  57310. */
  57311. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57312. /**
  57313. * Update defines for shader compilation
  57314. * @param mesh defines the mesh to be rendered
  57315. * @param nodeMaterial defines the node material requesting the update
  57316. * @param defines defines the material defines to update
  57317. * @param useInstances specifies that instances should be used
  57318. */
  57319. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57320. /**
  57321. * Lets the block try to connect some inputs automatically
  57322. * @param material defines the hosting NodeMaterial
  57323. */
  57324. autoConfigure(material: NodeMaterial): void;
  57325. /**
  57326. * Function called when a block is declared as repeatable content generator
  57327. * @param vertexShaderState defines the current compilation state for the vertex shader
  57328. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57329. * @param mesh defines the mesh to be rendered
  57330. * @param defines defines the material defines to update
  57331. */
  57332. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57333. /**
  57334. * Checks if the block is ready
  57335. * @param mesh defines the mesh to be rendered
  57336. * @param nodeMaterial defines the node material requesting the update
  57337. * @param defines defines the material defines to update
  57338. * @param useInstances specifies that instances should be used
  57339. * @returns true if the block is ready
  57340. */
  57341. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57342. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57343. private _processBuild;
  57344. /**
  57345. * Compile the current node and generate the shader code
  57346. * @param state defines the current compilation state (uniforms, samplers, current string)
  57347. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57348. * @returns true if already built
  57349. */
  57350. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57351. protected _inputRename(name: string): string;
  57352. protected _outputRename(name: string): string;
  57353. protected _dumpPropertiesCode(): string;
  57354. /** @hidden */
  57355. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57356. /** @hidden */
  57357. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57358. /**
  57359. * Clone the current block to a new identical block
  57360. * @param scene defines the hosting scene
  57361. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57362. * @returns a copy of the current block
  57363. */
  57364. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57365. /**
  57366. * Serializes this block in a JSON representation
  57367. * @returns the serialized block object
  57368. */
  57369. serialize(): any;
  57370. /** @hidden */
  57371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57372. /**
  57373. * Release resources
  57374. */
  57375. dispose(): void;
  57376. }
  57377. }
  57378. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57379. /**
  57380. * Enum defining the type of animations supported by InputBlock
  57381. */
  57382. export enum AnimatedInputBlockTypes {
  57383. /** No animation */
  57384. None = 0,
  57385. /** Time based animation. Will only work for floats */
  57386. Time = 1
  57387. }
  57388. }
  57389. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57391. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57392. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57393. import { Nullable } from "babylonjs/types";
  57394. import { Effect } from "babylonjs/Materials/effect";
  57395. import { Matrix } from "babylonjs/Maths/math.vector";
  57396. import { Scene } from "babylonjs/scene";
  57397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57399. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57400. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57401. /**
  57402. * Block used to expose an input value
  57403. */
  57404. export class InputBlock extends NodeMaterialBlock {
  57405. private _mode;
  57406. private _associatedVariableName;
  57407. private _storedValue;
  57408. private _valueCallback;
  57409. private _type;
  57410. private _animationType;
  57411. /** Gets or set a value used to limit the range of float values */
  57412. min: number;
  57413. /** Gets or set a value used to limit the range of float values */
  57414. max: number;
  57415. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57416. matrixMode: number;
  57417. /** @hidden */
  57418. _systemValue: Nullable<NodeMaterialSystemValues>;
  57419. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57420. visibleInInspector: boolean;
  57421. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57422. isConstant: boolean;
  57423. /**
  57424. * Gets or sets the connection point type (default is float)
  57425. */
  57426. readonly type: NodeMaterialBlockConnectionPointTypes;
  57427. /**
  57428. * Creates a new InputBlock
  57429. * @param name defines the block name
  57430. * @param target defines the target of that block (Vertex by default)
  57431. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57432. */
  57433. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57434. /**
  57435. * Gets the output component
  57436. */
  57437. readonly output: NodeMaterialConnectionPoint;
  57438. /**
  57439. * Set the source of this connection point to a vertex attribute
  57440. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57441. * @returns the current connection point
  57442. */
  57443. setAsAttribute(attributeName?: string): InputBlock;
  57444. /**
  57445. * Set the source of this connection point to a system value
  57446. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57447. * @returns the current connection point
  57448. */
  57449. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57450. /**
  57451. * Gets or sets the value of that point.
  57452. * Please note that this value will be ignored if valueCallback is defined
  57453. */
  57454. value: any;
  57455. /**
  57456. * Gets or sets a callback used to get the value of that point.
  57457. * Please note that setting this value will force the connection point to ignore the value property
  57458. */
  57459. valueCallback: () => any;
  57460. /**
  57461. * Gets or sets the associated variable name in the shader
  57462. */
  57463. associatedVariableName: string;
  57464. /** Gets or sets the type of animation applied to the input */
  57465. animationType: AnimatedInputBlockTypes;
  57466. /**
  57467. * Gets a boolean indicating that this connection point not defined yet
  57468. */
  57469. readonly isUndefined: boolean;
  57470. /**
  57471. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57472. * In this case the connection point name must be the name of the uniform to use.
  57473. * Can only be set on inputs
  57474. */
  57475. isUniform: boolean;
  57476. /**
  57477. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57478. * In this case the connection point name must be the name of the attribute to use
  57479. * Can only be set on inputs
  57480. */
  57481. isAttribute: boolean;
  57482. /**
  57483. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57484. * Can only be set on exit points
  57485. */
  57486. isVarying: boolean;
  57487. /**
  57488. * Gets a boolean indicating that the current connection point is a system value
  57489. */
  57490. readonly isSystemValue: boolean;
  57491. /**
  57492. * Gets or sets the current well known value or null if not defined as a system value
  57493. */
  57494. systemValue: Nullable<NodeMaterialSystemValues>;
  57495. /**
  57496. * Gets the current class name
  57497. * @returns the class name
  57498. */
  57499. getClassName(): string;
  57500. /**
  57501. * Animate the input if animationType !== None
  57502. * @param scene defines the rendering scene
  57503. */
  57504. animate(scene: Scene): void;
  57505. private _emitDefine;
  57506. initialize(state: NodeMaterialBuildState): void;
  57507. /**
  57508. * Set the input block to its default value (based on its type)
  57509. */
  57510. setDefaultValue(): void;
  57511. private _emitConstant;
  57512. private _emit;
  57513. /** @hidden */
  57514. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57515. /** @hidden */
  57516. _transmit(effect: Effect, scene: Scene): void;
  57517. protected _buildBlock(state: NodeMaterialBuildState): void;
  57518. protected _dumpPropertiesCode(): string;
  57519. serialize(): any;
  57520. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57521. }
  57522. }
  57523. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57524. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57525. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57526. import { Nullable } from "babylonjs/types";
  57527. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57528. import { Observable } from "babylonjs/Misc/observable";
  57529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57530. /**
  57531. * Enum used to define the compatibility state between two connection points
  57532. */
  57533. export enum NodeMaterialConnectionPointCompatibilityStates {
  57534. /** Points are compatibles */
  57535. Compatible = 0,
  57536. /** Points are incompatible because of their types */
  57537. TypeIncompatible = 1,
  57538. /** Points are incompatible because of their targets (vertex vs fragment) */
  57539. TargetIncompatible = 2
  57540. }
  57541. /**
  57542. * Defines the direction of a connection point
  57543. */
  57544. export enum NodeMaterialConnectionPointDirection {
  57545. /** Input */
  57546. Input = 0,
  57547. /** Output */
  57548. Output = 1
  57549. }
  57550. /**
  57551. * Defines a connection point for a block
  57552. */
  57553. export class NodeMaterialConnectionPoint {
  57554. /** @hidden */
  57555. _ownerBlock: NodeMaterialBlock;
  57556. /** @hidden */
  57557. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57558. private _endpoints;
  57559. private _associatedVariableName;
  57560. private _direction;
  57561. /** @hidden */
  57562. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57563. /** @hidden */
  57564. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57565. private _type;
  57566. /** @hidden */
  57567. _enforceAssociatedVariableName: boolean;
  57568. /** Gets the direction of the point */
  57569. readonly direction: NodeMaterialConnectionPointDirection;
  57570. /**
  57571. * Gets or sets the additional types supported by this connection point
  57572. */
  57573. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57574. /**
  57575. * Gets or sets the additional types excluded by this connection point
  57576. */
  57577. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57578. /**
  57579. * Observable triggered when this point is connected
  57580. */
  57581. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57582. /**
  57583. * Gets or sets the associated variable name in the shader
  57584. */
  57585. associatedVariableName: string;
  57586. /**
  57587. * Gets or sets the connection point type (default is float)
  57588. */
  57589. type: NodeMaterialBlockConnectionPointTypes;
  57590. /**
  57591. * Gets or sets the connection point name
  57592. */
  57593. name: string;
  57594. /**
  57595. * Gets or sets a boolean indicating that this connection point can be omitted
  57596. */
  57597. isOptional: boolean;
  57598. /**
  57599. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57600. */
  57601. define: string;
  57602. /** @hidden */
  57603. _prioritizeVertex: boolean;
  57604. private _target;
  57605. /** Gets or sets the target of that connection point */
  57606. target: NodeMaterialBlockTargets;
  57607. /**
  57608. * Gets a boolean indicating that the current point is connected
  57609. */
  57610. readonly isConnected: boolean;
  57611. /**
  57612. * Gets a boolean indicating that the current point is connected to an input block
  57613. */
  57614. readonly isConnectedToInputBlock: boolean;
  57615. /**
  57616. * Gets a the connected input block (if any)
  57617. */
  57618. readonly connectInputBlock: Nullable<InputBlock>;
  57619. /** Get the other side of the connection (if any) */
  57620. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57621. /** Get the block that owns this connection point */
  57622. readonly ownerBlock: NodeMaterialBlock;
  57623. /** Get the block connected on the other side of this connection (if any) */
  57624. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57625. /** Get the block connected on the endpoints of this connection (if any) */
  57626. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57627. /** Gets the list of connected endpoints */
  57628. readonly endpoints: NodeMaterialConnectionPoint[];
  57629. /** Gets a boolean indicating if that output point is connected to at least one input */
  57630. readonly hasEndpoints: boolean;
  57631. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57632. readonly isConnectedInVertexShader: boolean;
  57633. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57634. readonly isConnectedInFragmentShader: boolean;
  57635. /**
  57636. * Creates a new connection point
  57637. * @param name defines the connection point name
  57638. * @param ownerBlock defines the block hosting this connection point
  57639. * @param direction defines the direction of the connection point
  57640. */
  57641. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57642. /**
  57643. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57644. * @returns the class name
  57645. */
  57646. getClassName(): string;
  57647. /**
  57648. * Gets a boolean indicating if the current point can be connected to another point
  57649. * @param connectionPoint defines the other connection point
  57650. * @returns a boolean
  57651. */
  57652. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57653. /**
  57654. * Gets a number indicating if the current point can be connected to another point
  57655. * @param connectionPoint defines the other connection point
  57656. * @returns a number defining the compatibility state
  57657. */
  57658. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57659. /**
  57660. * Connect this point to another connection point
  57661. * @param connectionPoint defines the other connection point
  57662. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57663. * @returns the current connection point
  57664. */
  57665. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57666. /**
  57667. * Disconnect this point from one of his endpoint
  57668. * @param endpoint defines the other connection point
  57669. * @returns the current connection point
  57670. */
  57671. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57672. /**
  57673. * Serializes this point in a JSON representation
  57674. * @returns the serialized point object
  57675. */
  57676. serialize(): any;
  57677. /**
  57678. * Release resources
  57679. */
  57680. dispose(): void;
  57681. }
  57682. }
  57683. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57684. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57685. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57687. import { Mesh } from "babylonjs/Meshes/mesh";
  57688. import { Effect } from "babylonjs/Materials/effect";
  57689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57690. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57691. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57692. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57693. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57694. /**
  57695. * Block used to add support for vertex skinning (bones)
  57696. */
  57697. export class BonesBlock extends NodeMaterialBlock {
  57698. /**
  57699. * Creates a new BonesBlock
  57700. * @param name defines the block name
  57701. */
  57702. constructor(name: string);
  57703. /**
  57704. * Initialize the block and prepare the context for build
  57705. * @param state defines the state that will be used for the build
  57706. */
  57707. initialize(state: NodeMaterialBuildState): void;
  57708. /**
  57709. * Gets the current class name
  57710. * @returns the class name
  57711. */
  57712. getClassName(): string;
  57713. /**
  57714. * Gets the matrix indices input component
  57715. */
  57716. readonly matricesIndices: NodeMaterialConnectionPoint;
  57717. /**
  57718. * Gets the matrix weights input component
  57719. */
  57720. readonly matricesWeights: NodeMaterialConnectionPoint;
  57721. /**
  57722. * Gets the extra matrix indices input component
  57723. */
  57724. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57725. /**
  57726. * Gets the extra matrix weights input component
  57727. */
  57728. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57729. /**
  57730. * Gets the world input component
  57731. */
  57732. readonly world: NodeMaterialConnectionPoint;
  57733. /**
  57734. * Gets the output component
  57735. */
  57736. readonly output: NodeMaterialConnectionPoint;
  57737. autoConfigure(material: NodeMaterial): void;
  57738. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57741. protected _buildBlock(state: NodeMaterialBuildState): this;
  57742. }
  57743. }
  57744. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57749. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57750. /**
  57751. * Block used to add support for instances
  57752. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57753. */
  57754. export class InstancesBlock extends NodeMaterialBlock {
  57755. /**
  57756. * Creates a new InstancesBlock
  57757. * @param name defines the block name
  57758. */
  57759. constructor(name: string);
  57760. /**
  57761. * Gets the current class name
  57762. * @returns the class name
  57763. */
  57764. getClassName(): string;
  57765. /**
  57766. * Gets the first world row input component
  57767. */
  57768. readonly world0: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the second world row input component
  57771. */
  57772. readonly world1: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the third world row input component
  57775. */
  57776. readonly world2: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the forth world row input component
  57779. */
  57780. readonly world3: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the world input component
  57783. */
  57784. readonly world: NodeMaterialConnectionPoint;
  57785. /**
  57786. * Gets the output component
  57787. */
  57788. readonly output: NodeMaterialConnectionPoint;
  57789. autoConfigure(material: NodeMaterial): void;
  57790. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57791. protected _buildBlock(state: NodeMaterialBuildState): this;
  57792. }
  57793. }
  57794. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57799. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57800. import { Effect } from "babylonjs/Materials/effect";
  57801. import { Mesh } from "babylonjs/Meshes/mesh";
  57802. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57803. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57804. /**
  57805. * Block used to add morph targets support to vertex shader
  57806. */
  57807. export class MorphTargetsBlock extends NodeMaterialBlock {
  57808. private _repeatableContentAnchor;
  57809. private _repeatebleContentGenerated;
  57810. /**
  57811. * Create a new MorphTargetsBlock
  57812. * @param name defines the block name
  57813. */
  57814. constructor(name: string);
  57815. /**
  57816. * Gets the current class name
  57817. * @returns the class name
  57818. */
  57819. getClassName(): string;
  57820. /**
  57821. * Gets the position input component
  57822. */
  57823. readonly position: NodeMaterialConnectionPoint;
  57824. /**
  57825. * Gets the normal input component
  57826. */
  57827. readonly normal: NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the tangent input component
  57830. */
  57831. readonly tangent: NodeMaterialConnectionPoint;
  57832. /**
  57833. * Gets the tangent input component
  57834. */
  57835. readonly uv: NodeMaterialConnectionPoint;
  57836. /**
  57837. * Gets the position output component
  57838. */
  57839. readonly positionOutput: NodeMaterialConnectionPoint;
  57840. /**
  57841. * Gets the normal output component
  57842. */
  57843. readonly normalOutput: NodeMaterialConnectionPoint;
  57844. /**
  57845. * Gets the tangent output component
  57846. */
  57847. readonly tangentOutput: NodeMaterialConnectionPoint;
  57848. /**
  57849. * Gets the tangent output component
  57850. */
  57851. readonly uvOutput: NodeMaterialConnectionPoint;
  57852. initialize(state: NodeMaterialBuildState): void;
  57853. autoConfigure(material: NodeMaterial): void;
  57854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57855. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57856. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57857. protected _buildBlock(state: NodeMaterialBuildState): this;
  57858. }
  57859. }
  57860. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57864. import { Nullable } from "babylonjs/types";
  57865. import { Scene } from "babylonjs/scene";
  57866. import { Effect } from "babylonjs/Materials/effect";
  57867. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57868. import { Mesh } from "babylonjs/Meshes/mesh";
  57869. import { Light } from "babylonjs/Lights/light";
  57870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57871. /**
  57872. * Block used to get data information from a light
  57873. */
  57874. export class LightInformationBlock extends NodeMaterialBlock {
  57875. private _lightDataUniformName;
  57876. private _lightColorUniformName;
  57877. private _lightTypeDefineName;
  57878. /**
  57879. * Gets or sets the light associated with this block
  57880. */
  57881. light: Nullable<Light>;
  57882. /**
  57883. * Creates a new LightInformationBlock
  57884. * @param name defines the block name
  57885. */
  57886. constructor(name: string);
  57887. /**
  57888. * Gets the current class name
  57889. * @returns the class name
  57890. */
  57891. getClassName(): string;
  57892. /**
  57893. * Gets the world position input component
  57894. */
  57895. readonly worldPosition: NodeMaterialConnectionPoint;
  57896. /**
  57897. * Gets the direction output component
  57898. */
  57899. readonly direction: NodeMaterialConnectionPoint;
  57900. /**
  57901. * Gets the direction output component
  57902. */
  57903. readonly color: NodeMaterialConnectionPoint;
  57904. /**
  57905. * Gets the direction output component
  57906. */
  57907. readonly intensity: NodeMaterialConnectionPoint;
  57908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57910. protected _buildBlock(state: NodeMaterialBuildState): this;
  57911. serialize(): any;
  57912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57913. }
  57914. }
  57915. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57916. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57917. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57918. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57919. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57920. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57921. }
  57922. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57923. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57925. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57927. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57928. import { Effect } from "babylonjs/Materials/effect";
  57929. import { Mesh } from "babylonjs/Meshes/mesh";
  57930. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57931. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57932. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57933. /**
  57934. * Block used to add image processing support to fragment shader
  57935. */
  57936. export class ImageProcessingBlock extends NodeMaterialBlock {
  57937. /**
  57938. * Create a new ImageProcessingBlock
  57939. * @param name defines the block name
  57940. */
  57941. constructor(name: string);
  57942. /**
  57943. * Gets the current class name
  57944. * @returns the class name
  57945. */
  57946. getClassName(): string;
  57947. /**
  57948. * Gets the color input component
  57949. */
  57950. readonly color: NodeMaterialConnectionPoint;
  57951. /**
  57952. * Gets the output component
  57953. */
  57954. readonly output: NodeMaterialConnectionPoint;
  57955. /**
  57956. * Initialize the block and prepare the context for build
  57957. * @param state defines the state that will be used for the build
  57958. */
  57959. initialize(state: NodeMaterialBuildState): void;
  57960. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57963. protected _buildBlock(state: NodeMaterialBuildState): this;
  57964. }
  57965. }
  57966. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57970. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57972. import { Effect } from "babylonjs/Materials/effect";
  57973. import { Mesh } from "babylonjs/Meshes/mesh";
  57974. import { Scene } from "babylonjs/scene";
  57975. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57976. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57977. /**
  57978. * Block used to pertub normals based on a normal map
  57979. */
  57980. export class PerturbNormalBlock extends NodeMaterialBlock {
  57981. private _tangentSpaceParameterName;
  57982. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57983. invertX: boolean;
  57984. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57985. invertY: boolean;
  57986. /**
  57987. * Create a new PerturbNormalBlock
  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 world position input component
  57998. */
  57999. readonly worldPosition: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the world normal input component
  58002. */
  58003. readonly worldNormal: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the uv input component
  58006. */
  58007. readonly uv: NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the normal map color input component
  58010. */
  58011. readonly normalMapColor: NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the strength input component
  58014. */
  58015. readonly strength: NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the output component
  58018. */
  58019. readonly output: NodeMaterialConnectionPoint;
  58020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58022. autoConfigure(material: NodeMaterial): void;
  58023. protected _buildBlock(state: NodeMaterialBuildState): this;
  58024. protected _dumpPropertiesCode(): string;
  58025. serialize(): any;
  58026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58027. }
  58028. }
  58029. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58033. /**
  58034. * Block used to discard a pixel if a value is smaller than a cutoff
  58035. */
  58036. export class DiscardBlock extends NodeMaterialBlock {
  58037. /**
  58038. * Create a new DiscardBlock
  58039. * @param name defines the block name
  58040. */
  58041. constructor(name: string);
  58042. /**
  58043. * Gets the current class name
  58044. * @returns the class name
  58045. */
  58046. getClassName(): string;
  58047. /**
  58048. * Gets the color input component
  58049. */
  58050. readonly value: NodeMaterialConnectionPoint;
  58051. /**
  58052. * Gets the cutoff input component
  58053. */
  58054. readonly cutoff: NodeMaterialConnectionPoint;
  58055. protected _buildBlock(state: NodeMaterialBuildState): this;
  58056. }
  58057. }
  58058. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58062. /**
  58063. * Block used to test if the fragment shader is front facing
  58064. */
  58065. export class FrontFacingBlock extends NodeMaterialBlock {
  58066. /**
  58067. * Creates a new FrontFacingBlock
  58068. * @param name defines the block name
  58069. */
  58070. constructor(name: string);
  58071. /**
  58072. * Gets the current class name
  58073. * @returns the class name
  58074. */
  58075. getClassName(): string;
  58076. /**
  58077. * Gets the output component
  58078. */
  58079. readonly output: NodeMaterialConnectionPoint;
  58080. protected _buildBlock(state: NodeMaterialBuildState): this;
  58081. }
  58082. }
  58083. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58087. /**
  58088. * Block used to get the derivative value on x and y of a given input
  58089. */
  58090. export class DerivativeBlock extends NodeMaterialBlock {
  58091. /**
  58092. * Create a new DerivativeBlock
  58093. * @param name defines the block name
  58094. */
  58095. constructor(name: string);
  58096. /**
  58097. * Gets the current class name
  58098. * @returns the class name
  58099. */
  58100. getClassName(): string;
  58101. /**
  58102. * Gets the input component
  58103. */
  58104. readonly input: NodeMaterialConnectionPoint;
  58105. /**
  58106. * Gets the derivative output on x
  58107. */
  58108. readonly dx: NodeMaterialConnectionPoint;
  58109. /**
  58110. * Gets the derivative output on y
  58111. */
  58112. readonly dy: NodeMaterialConnectionPoint;
  58113. protected _buildBlock(state: NodeMaterialBuildState): this;
  58114. }
  58115. }
  58116. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58117. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58118. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58119. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58120. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58121. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58122. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58123. }
  58124. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58127. import { Mesh } from "babylonjs/Meshes/mesh";
  58128. import { Effect } from "babylonjs/Materials/effect";
  58129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58131. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58132. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58133. /**
  58134. * Block used to add support for scene fog
  58135. */
  58136. export class FogBlock extends NodeMaterialBlock {
  58137. private _fogDistanceName;
  58138. private _fogParameters;
  58139. /**
  58140. * Create a new FogBlock
  58141. * @param name defines the block name
  58142. */
  58143. constructor(name: string);
  58144. /**
  58145. * Gets the current class name
  58146. * @returns the class name
  58147. */
  58148. getClassName(): string;
  58149. /**
  58150. * Gets the world position input component
  58151. */
  58152. readonly worldPosition: NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the view input component
  58155. */
  58156. readonly view: NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the color input component
  58159. */
  58160. readonly input: NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the fog color input component
  58163. */
  58164. readonly fogColor: NodeMaterialConnectionPoint;
  58165. /**
  58166. * Gets the output component
  58167. */
  58168. readonly output: NodeMaterialConnectionPoint;
  58169. autoConfigure(material: NodeMaterial): void;
  58170. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58172. protected _buildBlock(state: NodeMaterialBuildState): this;
  58173. }
  58174. }
  58175. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58176. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58180. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58181. import { Effect } from "babylonjs/Materials/effect";
  58182. import { Mesh } from "babylonjs/Meshes/mesh";
  58183. import { Light } from "babylonjs/Lights/light";
  58184. import { Nullable } from "babylonjs/types";
  58185. import { Scene } from "babylonjs/scene";
  58186. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58187. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58188. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58189. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58190. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58191. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58192. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58193. /**
  58194. * Block used to add light in the fragment shader
  58195. */
  58196. export class LightBlock extends NodeMaterialBlock {
  58197. private _lightId;
  58198. /**
  58199. * Gets or sets the light associated with this block
  58200. */
  58201. light: Nullable<Light>;
  58202. /**
  58203. * Create a new LightBlock
  58204. * @param name defines the block name
  58205. */
  58206. constructor(name: string);
  58207. /**
  58208. * Gets the current class name
  58209. * @returns the class name
  58210. */
  58211. getClassName(): string;
  58212. /**
  58213. * Gets the world position input component
  58214. */
  58215. readonly worldPosition: NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the world normal input component
  58218. */
  58219. readonly worldNormal: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the camera (or eye) position component
  58222. */
  58223. readonly cameraPosition: NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the glossiness component
  58226. */
  58227. readonly glossiness: NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the glossinness power component
  58230. */
  58231. readonly glossPower: NodeMaterialConnectionPoint;
  58232. /**
  58233. * Gets the diffuse color component
  58234. */
  58235. readonly diffuseColor: NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the specular color component
  58238. */
  58239. readonly specularColor: NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the diffuse output component
  58242. */
  58243. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the specular output component
  58246. */
  58247. readonly specularOutput: NodeMaterialConnectionPoint;
  58248. autoConfigure(material: NodeMaterial): void;
  58249. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58250. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58251. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58252. private _injectVertexCode;
  58253. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58254. serialize(): any;
  58255. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58256. }
  58257. }
  58258. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58259. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58260. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58261. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58262. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58263. }
  58264. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58265. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58266. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58267. }
  58268. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58272. /**
  58273. * Block used to multiply 2 values
  58274. */
  58275. export class MultiplyBlock extends NodeMaterialBlock {
  58276. /**
  58277. * Creates a new MultiplyBlock
  58278. * @param name defines the block name
  58279. */
  58280. constructor(name: string);
  58281. /**
  58282. * Gets the current class name
  58283. * @returns the class name
  58284. */
  58285. getClassName(): string;
  58286. /**
  58287. * Gets the left operand input component
  58288. */
  58289. readonly left: NodeMaterialConnectionPoint;
  58290. /**
  58291. * Gets the right operand input component
  58292. */
  58293. readonly right: NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the output component
  58296. */
  58297. readonly output: NodeMaterialConnectionPoint;
  58298. protected _buildBlock(state: NodeMaterialBuildState): this;
  58299. }
  58300. }
  58301. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58305. /**
  58306. * Block used to add 2 vectors
  58307. */
  58308. export class AddBlock extends NodeMaterialBlock {
  58309. /**
  58310. * Creates a new AddBlock
  58311. * @param name defines the block name
  58312. */
  58313. constructor(name: string);
  58314. /**
  58315. * Gets the current class name
  58316. * @returns the class name
  58317. */
  58318. getClassName(): string;
  58319. /**
  58320. * Gets the left operand input component
  58321. */
  58322. readonly left: NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the right operand input component
  58325. */
  58326. readonly right: NodeMaterialConnectionPoint;
  58327. /**
  58328. * Gets the output component
  58329. */
  58330. readonly output: NodeMaterialConnectionPoint;
  58331. protected _buildBlock(state: NodeMaterialBuildState): this;
  58332. }
  58333. }
  58334. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58338. /**
  58339. * Block used to scale a vector by a float
  58340. */
  58341. export class ScaleBlock extends NodeMaterialBlock {
  58342. /**
  58343. * Creates a new ScaleBlock
  58344. * @param name defines the block name
  58345. */
  58346. constructor(name: string);
  58347. /**
  58348. * Gets the current class name
  58349. * @returns the class name
  58350. */
  58351. getClassName(): string;
  58352. /**
  58353. * Gets the input component
  58354. */
  58355. readonly input: NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the factor input component
  58358. */
  58359. readonly factor: NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the output component
  58362. */
  58363. readonly output: NodeMaterialConnectionPoint;
  58364. protected _buildBlock(state: NodeMaterialBuildState): this;
  58365. }
  58366. }
  58367. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58371. import { Scene } from "babylonjs/scene";
  58372. /**
  58373. * Block used to clamp a float
  58374. */
  58375. export class ClampBlock extends NodeMaterialBlock {
  58376. /** Gets or sets the minimum range */
  58377. minimum: number;
  58378. /** Gets or sets the maximum range */
  58379. maximum: number;
  58380. /**
  58381. * Creates a new ClampBlock
  58382. * @param name defines the block name
  58383. */
  58384. constructor(name: string);
  58385. /**
  58386. * Gets the current class name
  58387. * @returns the class name
  58388. */
  58389. getClassName(): string;
  58390. /**
  58391. * Gets the value input component
  58392. */
  58393. readonly value: NodeMaterialConnectionPoint;
  58394. /**
  58395. * Gets the output component
  58396. */
  58397. readonly output: NodeMaterialConnectionPoint;
  58398. protected _buildBlock(state: NodeMaterialBuildState): this;
  58399. protected _dumpPropertiesCode(): string;
  58400. serialize(): any;
  58401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58402. }
  58403. }
  58404. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58408. /**
  58409. * Block used to apply a cross product between 2 vectors
  58410. */
  58411. export class CrossBlock extends NodeMaterialBlock {
  58412. /**
  58413. * Creates a new CrossBlock
  58414. * @param name defines the block name
  58415. */
  58416. constructor(name: string);
  58417. /**
  58418. * Gets the current class name
  58419. * @returns the class name
  58420. */
  58421. getClassName(): string;
  58422. /**
  58423. * Gets the left operand input component
  58424. */
  58425. readonly left: NodeMaterialConnectionPoint;
  58426. /**
  58427. * Gets the right operand input component
  58428. */
  58429. readonly right: NodeMaterialConnectionPoint;
  58430. /**
  58431. * Gets the output component
  58432. */
  58433. readonly output: NodeMaterialConnectionPoint;
  58434. protected _buildBlock(state: NodeMaterialBuildState): this;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58441. /**
  58442. * Block used to apply a dot product between 2 vectors
  58443. */
  58444. export class DotBlock extends NodeMaterialBlock {
  58445. /**
  58446. * Creates a new DotBlock
  58447. * @param name defines the block name
  58448. */
  58449. constructor(name: string);
  58450. /**
  58451. * Gets the current class name
  58452. * @returns the class name
  58453. */
  58454. getClassName(): string;
  58455. /**
  58456. * Gets the left operand input component
  58457. */
  58458. readonly left: NodeMaterialConnectionPoint;
  58459. /**
  58460. * Gets the right operand input component
  58461. */
  58462. readonly right: NodeMaterialConnectionPoint;
  58463. /**
  58464. * Gets the output component
  58465. */
  58466. readonly output: NodeMaterialConnectionPoint;
  58467. protected _buildBlock(state: NodeMaterialBuildState): this;
  58468. }
  58469. }
  58470. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58474. import { Vector2 } from "babylonjs/Maths/math.vector";
  58475. import { Scene } from "babylonjs/scene";
  58476. /**
  58477. * Block used to remap a float from a range to a new one
  58478. */
  58479. export class RemapBlock extends NodeMaterialBlock {
  58480. /**
  58481. * Gets or sets the source range
  58482. */
  58483. sourceRange: Vector2;
  58484. /**
  58485. * Gets or sets the target range
  58486. */
  58487. targetRange: Vector2;
  58488. /**
  58489. * Creates a new RemapBlock
  58490. * @param name defines the block name
  58491. */
  58492. constructor(name: string);
  58493. /**
  58494. * Gets the current class name
  58495. * @returns the class name
  58496. */
  58497. getClassName(): string;
  58498. /**
  58499. * Gets the input component
  58500. */
  58501. readonly input: NodeMaterialConnectionPoint;
  58502. /**
  58503. * Gets the source min input component
  58504. */
  58505. readonly sourceMin: NodeMaterialConnectionPoint;
  58506. /**
  58507. * Gets the source max input component
  58508. */
  58509. readonly sourceMax: NodeMaterialConnectionPoint;
  58510. /**
  58511. * Gets the target min input component
  58512. */
  58513. readonly targetMin: NodeMaterialConnectionPoint;
  58514. /**
  58515. * Gets the target max input component
  58516. */
  58517. readonly targetMax: NodeMaterialConnectionPoint;
  58518. /**
  58519. * Gets the output component
  58520. */
  58521. readonly output: NodeMaterialConnectionPoint;
  58522. protected _buildBlock(state: NodeMaterialBuildState): this;
  58523. protected _dumpPropertiesCode(): string;
  58524. serialize(): any;
  58525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58526. }
  58527. }
  58528. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58532. /**
  58533. * Block used to normalize a vector
  58534. */
  58535. export class NormalizeBlock extends NodeMaterialBlock {
  58536. /**
  58537. * Creates a new NormalizeBlock
  58538. * @param name defines the block name
  58539. */
  58540. constructor(name: string);
  58541. /**
  58542. * Gets the current class name
  58543. * @returns the class name
  58544. */
  58545. getClassName(): string;
  58546. /**
  58547. * Gets the input component
  58548. */
  58549. readonly input: NodeMaterialConnectionPoint;
  58550. /**
  58551. * Gets the output component
  58552. */
  58553. readonly output: NodeMaterialConnectionPoint;
  58554. protected _buildBlock(state: NodeMaterialBuildState): this;
  58555. }
  58556. }
  58557. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58561. import { Scene } from "babylonjs/scene";
  58562. /**
  58563. * Operations supported by the Trigonometry block
  58564. */
  58565. export enum TrigonometryBlockOperations {
  58566. /** Cos */
  58567. Cos = 0,
  58568. /** Sin */
  58569. Sin = 1,
  58570. /** Abs */
  58571. Abs = 2,
  58572. /** Exp */
  58573. Exp = 3,
  58574. /** Exp2 */
  58575. Exp2 = 4,
  58576. /** Round */
  58577. Round = 5,
  58578. /** Floor */
  58579. Floor = 6,
  58580. /** Ceiling */
  58581. Ceiling = 7,
  58582. /** Square root */
  58583. Sqrt = 8,
  58584. /** Log */
  58585. Log = 9,
  58586. /** Tangent */
  58587. Tan = 10,
  58588. /** Arc tangent */
  58589. ArcTan = 11,
  58590. /** Arc cosinus */
  58591. ArcCos = 12,
  58592. /** Arc sinus */
  58593. ArcSin = 13,
  58594. /** Fraction */
  58595. Fract = 14,
  58596. /** Sign */
  58597. Sign = 15,
  58598. /** To radians (from degrees) */
  58599. Radians = 16,
  58600. /** To degrees (from radians) */
  58601. Degrees = 17
  58602. }
  58603. /**
  58604. * Block used to apply trigonometry operation to floats
  58605. */
  58606. export class TrigonometryBlock extends NodeMaterialBlock {
  58607. /**
  58608. * Gets or sets the operation applied by the block
  58609. */
  58610. operation: TrigonometryBlockOperations;
  58611. /**
  58612. * Creates a new TrigonometryBlock
  58613. * @param name defines the block name
  58614. */
  58615. constructor(name: string);
  58616. /**
  58617. * Gets the current class name
  58618. * @returns the class name
  58619. */
  58620. getClassName(): string;
  58621. /**
  58622. * Gets the input component
  58623. */
  58624. readonly input: NodeMaterialConnectionPoint;
  58625. /**
  58626. * Gets the output component
  58627. */
  58628. readonly output: NodeMaterialConnectionPoint;
  58629. protected _buildBlock(state: NodeMaterialBuildState): this;
  58630. serialize(): any;
  58631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58632. protected _dumpPropertiesCode(): string;
  58633. }
  58634. }
  58635. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58639. /**
  58640. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58641. */
  58642. export class ColorMergerBlock extends NodeMaterialBlock {
  58643. /**
  58644. * Create a new ColorMergerBlock
  58645. * @param name defines the block name
  58646. */
  58647. constructor(name: string);
  58648. /**
  58649. * Gets the current class name
  58650. * @returns the class name
  58651. */
  58652. getClassName(): string;
  58653. /**
  58654. * Gets the rgb component (input)
  58655. */
  58656. readonly rgbIn: NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the r component (input)
  58659. */
  58660. readonly r: NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the g component (input)
  58663. */
  58664. readonly g: NodeMaterialConnectionPoint;
  58665. /**
  58666. * Gets the b component (input)
  58667. */
  58668. readonly b: NodeMaterialConnectionPoint;
  58669. /**
  58670. * Gets the a component (input)
  58671. */
  58672. readonly a: NodeMaterialConnectionPoint;
  58673. /**
  58674. * Gets the rgba component (output)
  58675. */
  58676. readonly rgba: NodeMaterialConnectionPoint;
  58677. /**
  58678. * Gets the rgb component (output)
  58679. */
  58680. readonly rgbOut: NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the rgb component (output)
  58683. * @deprecated Please use rgbOut instead.
  58684. */
  58685. readonly rgb: NodeMaterialConnectionPoint;
  58686. protected _buildBlock(state: NodeMaterialBuildState): this;
  58687. }
  58688. }
  58689. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58693. /**
  58694. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58695. */
  58696. export class VectorMergerBlock extends NodeMaterialBlock {
  58697. /**
  58698. * Create a new VectorMergerBlock
  58699. * @param name defines the block name
  58700. */
  58701. constructor(name: string);
  58702. /**
  58703. * Gets the current class name
  58704. * @returns the class name
  58705. */
  58706. getClassName(): string;
  58707. /**
  58708. * Gets the xyz component (input)
  58709. */
  58710. readonly xyzIn: NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the xy component (input)
  58713. */
  58714. readonly xyIn: NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the x component (input)
  58717. */
  58718. readonly x: NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the y component (input)
  58721. */
  58722. readonly y: NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the z component (input)
  58725. */
  58726. readonly z: NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the w component (input)
  58729. */
  58730. readonly w: NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the xyzw component (output)
  58733. */
  58734. readonly xyzw: NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the xyz component (output)
  58737. */
  58738. readonly xyzOut: NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the xy component (output)
  58741. */
  58742. readonly xyOut: NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the xy component (output)
  58745. * @deprecated Please use xyOut instead.
  58746. */
  58747. readonly xy: NodeMaterialConnectionPoint;
  58748. /**
  58749. * Gets the xyz component (output)
  58750. * @deprecated Please use xyzOut instead.
  58751. */
  58752. readonly xyz: NodeMaterialConnectionPoint;
  58753. protected _buildBlock(state: NodeMaterialBuildState): this;
  58754. }
  58755. }
  58756. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58760. /**
  58761. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58762. */
  58763. export class ColorSplitterBlock extends NodeMaterialBlock {
  58764. /**
  58765. * Create a new ColorSplitterBlock
  58766. * @param name defines the block name
  58767. */
  58768. constructor(name: string);
  58769. /**
  58770. * Gets the current class name
  58771. * @returns the class name
  58772. */
  58773. getClassName(): string;
  58774. /**
  58775. * Gets the rgba component (input)
  58776. */
  58777. readonly rgba: NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the rgb component (input)
  58780. */
  58781. readonly rgbIn: NodeMaterialConnectionPoint;
  58782. /**
  58783. * Gets the rgb component (output)
  58784. */
  58785. readonly rgbOut: NodeMaterialConnectionPoint;
  58786. /**
  58787. * Gets the r component (output)
  58788. */
  58789. readonly r: NodeMaterialConnectionPoint;
  58790. /**
  58791. * Gets the g component (output)
  58792. */
  58793. readonly g: NodeMaterialConnectionPoint;
  58794. /**
  58795. * Gets the b component (output)
  58796. */
  58797. readonly b: NodeMaterialConnectionPoint;
  58798. /**
  58799. * Gets the a component (output)
  58800. */
  58801. readonly a: NodeMaterialConnectionPoint;
  58802. protected _inputRename(name: string): string;
  58803. protected _outputRename(name: string): string;
  58804. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58805. }
  58806. }
  58807. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58811. /**
  58812. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58813. */
  58814. export class VectorSplitterBlock extends NodeMaterialBlock {
  58815. /**
  58816. * Create a new VectorSplitterBlock
  58817. * @param name defines the block name
  58818. */
  58819. constructor(name: string);
  58820. /**
  58821. * Gets the current class name
  58822. * @returns the class name
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Gets the xyzw component (input)
  58827. */
  58828. readonly xyzw: NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the xyz component (input)
  58831. */
  58832. readonly xyzIn: NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the xy component (input)
  58835. */
  58836. readonly xyIn: NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the xyz component (output)
  58839. */
  58840. readonly xyzOut: NodeMaterialConnectionPoint;
  58841. /**
  58842. * Gets the xy component (output)
  58843. */
  58844. readonly xyOut: NodeMaterialConnectionPoint;
  58845. /**
  58846. * Gets the x component (output)
  58847. */
  58848. readonly x: NodeMaterialConnectionPoint;
  58849. /**
  58850. * Gets the y component (output)
  58851. */
  58852. readonly y: NodeMaterialConnectionPoint;
  58853. /**
  58854. * Gets the z component (output)
  58855. */
  58856. readonly z: NodeMaterialConnectionPoint;
  58857. /**
  58858. * Gets the w component (output)
  58859. */
  58860. readonly w: NodeMaterialConnectionPoint;
  58861. protected _inputRename(name: string): string;
  58862. protected _outputRename(name: string): string;
  58863. protected _buildBlock(state: NodeMaterialBuildState): this;
  58864. }
  58865. }
  58866. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58870. /**
  58871. * Block used to lerp between 2 values
  58872. */
  58873. export class LerpBlock extends NodeMaterialBlock {
  58874. /**
  58875. * Creates a new LerpBlock
  58876. * @param name defines the block name
  58877. */
  58878. constructor(name: string);
  58879. /**
  58880. * Gets the current class name
  58881. * @returns the class name
  58882. */
  58883. getClassName(): string;
  58884. /**
  58885. * Gets the left operand input component
  58886. */
  58887. readonly left: NodeMaterialConnectionPoint;
  58888. /**
  58889. * Gets the right operand input component
  58890. */
  58891. readonly right: NodeMaterialConnectionPoint;
  58892. /**
  58893. * Gets the gradient operand input component
  58894. */
  58895. readonly gradient: NodeMaterialConnectionPoint;
  58896. /**
  58897. * Gets the output component
  58898. */
  58899. readonly output: NodeMaterialConnectionPoint;
  58900. protected _buildBlock(state: NodeMaterialBuildState): this;
  58901. }
  58902. }
  58903. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58907. /**
  58908. * Block used to divide 2 vectors
  58909. */
  58910. export class DivideBlock extends NodeMaterialBlock {
  58911. /**
  58912. * Creates a new DivideBlock
  58913. * @param name defines the block name
  58914. */
  58915. constructor(name: string);
  58916. /**
  58917. * Gets the current class name
  58918. * @returns the class name
  58919. */
  58920. getClassName(): string;
  58921. /**
  58922. * Gets the left operand input component
  58923. */
  58924. readonly left: NodeMaterialConnectionPoint;
  58925. /**
  58926. * Gets the right operand input component
  58927. */
  58928. readonly right: NodeMaterialConnectionPoint;
  58929. /**
  58930. * Gets the output component
  58931. */
  58932. readonly output: NodeMaterialConnectionPoint;
  58933. protected _buildBlock(state: NodeMaterialBuildState): this;
  58934. }
  58935. }
  58936. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58940. /**
  58941. * Block used to subtract 2 vectors
  58942. */
  58943. export class SubtractBlock extends NodeMaterialBlock {
  58944. /**
  58945. * Creates a new SubtractBlock
  58946. * @param name defines the block name
  58947. */
  58948. constructor(name: string);
  58949. /**
  58950. * Gets the current class name
  58951. * @returns the class name
  58952. */
  58953. getClassName(): string;
  58954. /**
  58955. * Gets the left operand input component
  58956. */
  58957. readonly left: NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the right operand input component
  58960. */
  58961. readonly right: NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the output component
  58964. */
  58965. readonly output: NodeMaterialConnectionPoint;
  58966. protected _buildBlock(state: NodeMaterialBuildState): this;
  58967. }
  58968. }
  58969. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58970. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58971. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58972. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58973. /**
  58974. * Block used to step a value
  58975. */
  58976. export class StepBlock extends NodeMaterialBlock {
  58977. /**
  58978. * Creates a new StepBlock
  58979. * @param name defines the block name
  58980. */
  58981. constructor(name: string);
  58982. /**
  58983. * Gets the current class name
  58984. * @returns the class name
  58985. */
  58986. getClassName(): string;
  58987. /**
  58988. * Gets the value operand input component
  58989. */
  58990. readonly value: NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the edge operand input component
  58993. */
  58994. readonly edge: NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the output component
  58997. */
  58998. readonly output: NodeMaterialConnectionPoint;
  58999. protected _buildBlock(state: NodeMaterialBuildState): this;
  59000. }
  59001. }
  59002. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59006. /**
  59007. * Block used to get the opposite (1 - x) of a value
  59008. */
  59009. export class OneMinusBlock extends NodeMaterialBlock {
  59010. /**
  59011. * Creates a new OneMinusBlock
  59012. * @param name defines the block name
  59013. */
  59014. constructor(name: string);
  59015. /**
  59016. * Gets the current class name
  59017. * @returns the class name
  59018. */
  59019. getClassName(): string;
  59020. /**
  59021. * Gets the input component
  59022. */
  59023. readonly input: NodeMaterialConnectionPoint;
  59024. /**
  59025. * Gets the output component
  59026. */
  59027. readonly output: NodeMaterialConnectionPoint;
  59028. protected _buildBlock(state: NodeMaterialBuildState): this;
  59029. }
  59030. }
  59031. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59032. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59034. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59035. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59036. /**
  59037. * Block used to get the view direction
  59038. */
  59039. export class ViewDirectionBlock extends NodeMaterialBlock {
  59040. /**
  59041. * Creates a new ViewDirectionBlock
  59042. * @param name defines the block name
  59043. */
  59044. constructor(name: string);
  59045. /**
  59046. * Gets the current class name
  59047. * @returns the class name
  59048. */
  59049. getClassName(): string;
  59050. /**
  59051. * Gets the world position component
  59052. */
  59053. readonly worldPosition: NodeMaterialConnectionPoint;
  59054. /**
  59055. * Gets the camera position component
  59056. */
  59057. readonly cameraPosition: NodeMaterialConnectionPoint;
  59058. /**
  59059. * Gets the output component
  59060. */
  59061. readonly output: NodeMaterialConnectionPoint;
  59062. autoConfigure(material: NodeMaterial): void;
  59063. protected _buildBlock(state: NodeMaterialBuildState): this;
  59064. }
  59065. }
  59066. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59070. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59071. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59072. /**
  59073. * Block used to compute fresnel value
  59074. */
  59075. export class FresnelBlock extends NodeMaterialBlock {
  59076. /**
  59077. * Create a new FresnelBlock
  59078. * @param name defines the block name
  59079. */
  59080. constructor(name: string);
  59081. /**
  59082. * Gets the current class name
  59083. * @returns the class name
  59084. */
  59085. getClassName(): string;
  59086. /**
  59087. * Gets the world normal input component
  59088. */
  59089. readonly worldNormal: NodeMaterialConnectionPoint;
  59090. /**
  59091. * Gets the view direction input component
  59092. */
  59093. readonly viewDirection: NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the bias input component
  59096. */
  59097. readonly bias: NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the camera (or eye) position component
  59100. */
  59101. readonly power: NodeMaterialConnectionPoint;
  59102. /**
  59103. * Gets the fresnel output component
  59104. */
  59105. readonly fresnel: NodeMaterialConnectionPoint;
  59106. autoConfigure(material: NodeMaterial): void;
  59107. protected _buildBlock(state: NodeMaterialBuildState): this;
  59108. }
  59109. }
  59110. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59114. /**
  59115. * Block used to get the max of 2 values
  59116. */
  59117. export class MaxBlock extends NodeMaterialBlock {
  59118. /**
  59119. * Creates a new MaxBlock
  59120. * @param name defines the block name
  59121. */
  59122. constructor(name: string);
  59123. /**
  59124. * Gets the current class name
  59125. * @returns the class name
  59126. */
  59127. getClassName(): string;
  59128. /**
  59129. * Gets the left operand input component
  59130. */
  59131. readonly left: NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the right operand input component
  59134. */
  59135. readonly right: NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the output component
  59138. */
  59139. readonly output: NodeMaterialConnectionPoint;
  59140. protected _buildBlock(state: NodeMaterialBuildState): this;
  59141. }
  59142. }
  59143. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59147. /**
  59148. * Block used to get the min of 2 values
  59149. */
  59150. export class MinBlock extends NodeMaterialBlock {
  59151. /**
  59152. * Creates a new MinBlock
  59153. * @param name defines the block name
  59154. */
  59155. constructor(name: string);
  59156. /**
  59157. * Gets the current class name
  59158. * @returns the class name
  59159. */
  59160. getClassName(): string;
  59161. /**
  59162. * Gets the left operand input component
  59163. */
  59164. readonly left: NodeMaterialConnectionPoint;
  59165. /**
  59166. * Gets the right operand input component
  59167. */
  59168. readonly right: NodeMaterialConnectionPoint;
  59169. /**
  59170. * Gets the output component
  59171. */
  59172. readonly output: NodeMaterialConnectionPoint;
  59173. protected _buildBlock(state: NodeMaterialBuildState): this;
  59174. }
  59175. }
  59176. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59180. /**
  59181. * Block used to get the distance between 2 values
  59182. */
  59183. export class DistanceBlock extends NodeMaterialBlock {
  59184. /**
  59185. * Creates a new DistanceBlock
  59186. * @param name defines the block name
  59187. */
  59188. constructor(name: string);
  59189. /**
  59190. * Gets the current class name
  59191. * @returns the class name
  59192. */
  59193. getClassName(): string;
  59194. /**
  59195. * Gets the left operand input component
  59196. */
  59197. readonly left: NodeMaterialConnectionPoint;
  59198. /**
  59199. * Gets the right operand input component
  59200. */
  59201. readonly right: NodeMaterialConnectionPoint;
  59202. /**
  59203. * Gets the output component
  59204. */
  59205. readonly output: NodeMaterialConnectionPoint;
  59206. protected _buildBlock(state: NodeMaterialBuildState): this;
  59207. }
  59208. }
  59209. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59213. /**
  59214. * Block used to get the length of a vector
  59215. */
  59216. export class LengthBlock extends NodeMaterialBlock {
  59217. /**
  59218. * Creates a new LengthBlock
  59219. * @param name defines the block name
  59220. */
  59221. constructor(name: string);
  59222. /**
  59223. * Gets the current class name
  59224. * @returns the class name
  59225. */
  59226. getClassName(): string;
  59227. /**
  59228. * Gets the value input component
  59229. */
  59230. readonly value: NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the output component
  59233. */
  59234. readonly output: NodeMaterialConnectionPoint;
  59235. protected _buildBlock(state: NodeMaterialBuildState): this;
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59242. /**
  59243. * Block used to get negative version of a value (i.e. x * -1)
  59244. */
  59245. export class NegateBlock extends NodeMaterialBlock {
  59246. /**
  59247. * Creates a new NegateBlock
  59248. * @param name defines the block name
  59249. */
  59250. constructor(name: string);
  59251. /**
  59252. * Gets the current class name
  59253. * @returns the class name
  59254. */
  59255. getClassName(): string;
  59256. /**
  59257. * Gets the value input component
  59258. */
  59259. readonly value: NodeMaterialConnectionPoint;
  59260. /**
  59261. * Gets the output component
  59262. */
  59263. readonly output: NodeMaterialConnectionPoint;
  59264. protected _buildBlock(state: NodeMaterialBuildState): this;
  59265. }
  59266. }
  59267. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59271. /**
  59272. * Block used to get the value of the first parameter raised to the power of the second
  59273. */
  59274. export class PowBlock extends NodeMaterialBlock {
  59275. /**
  59276. * Creates a new PowBlock
  59277. * @param name defines the block name
  59278. */
  59279. constructor(name: string);
  59280. /**
  59281. * Gets the current class name
  59282. * @returns the class name
  59283. */
  59284. getClassName(): string;
  59285. /**
  59286. * Gets the value operand input component
  59287. */
  59288. readonly value: NodeMaterialConnectionPoint;
  59289. /**
  59290. * Gets the power operand input component
  59291. */
  59292. readonly power: NodeMaterialConnectionPoint;
  59293. /**
  59294. * Gets the output component
  59295. */
  59296. readonly output: NodeMaterialConnectionPoint;
  59297. protected _buildBlock(state: NodeMaterialBuildState): this;
  59298. }
  59299. }
  59300. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59304. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59305. /**
  59306. * Block used to get a random number
  59307. */
  59308. export class RandomNumberBlock extends NodeMaterialBlock {
  59309. /**
  59310. * Creates a new RandomNumberBlock
  59311. * @param name defines the block name
  59312. */
  59313. constructor(name: string);
  59314. /**
  59315. * Gets the current class name
  59316. * @returns the class name
  59317. */
  59318. getClassName(): string;
  59319. /**
  59320. * Gets the seed input component
  59321. */
  59322. readonly seed: NodeMaterialConnectionPoint;
  59323. /**
  59324. * Gets the output component
  59325. */
  59326. readonly output: NodeMaterialConnectionPoint;
  59327. protected _buildBlock(state: NodeMaterialBuildState): this;
  59328. }
  59329. }
  59330. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59334. /**
  59335. * Block used to compute arc tangent of 2 values
  59336. */
  59337. export class ArcTan2Block extends NodeMaterialBlock {
  59338. /**
  59339. * Creates a new ArcTan2Block
  59340. * @param name defines the block name
  59341. */
  59342. constructor(name: string);
  59343. /**
  59344. * Gets the current class name
  59345. * @returns the class name
  59346. */
  59347. getClassName(): string;
  59348. /**
  59349. * Gets the x operand input component
  59350. */
  59351. readonly x: NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the y operand input component
  59354. */
  59355. readonly y: NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. readonly output: NodeMaterialConnectionPoint;
  59360. protected _buildBlock(state: NodeMaterialBuildState): this;
  59361. }
  59362. }
  59363. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59367. /**
  59368. * Block used to smooth step a value
  59369. */
  59370. export class SmoothStepBlock extends NodeMaterialBlock {
  59371. /**
  59372. * Creates a new SmoothStepBlock
  59373. * @param name defines the block name
  59374. */
  59375. constructor(name: string);
  59376. /**
  59377. * Gets the current class name
  59378. * @returns the class name
  59379. */
  59380. getClassName(): string;
  59381. /**
  59382. * Gets the value operand input component
  59383. */
  59384. readonly value: NodeMaterialConnectionPoint;
  59385. /**
  59386. * Gets the first edge operand input component
  59387. */
  59388. readonly edge0: NodeMaterialConnectionPoint;
  59389. /**
  59390. * Gets the second edge operand input component
  59391. */
  59392. readonly edge1: NodeMaterialConnectionPoint;
  59393. /**
  59394. * Gets the output component
  59395. */
  59396. readonly output: NodeMaterialConnectionPoint;
  59397. protected _buildBlock(state: NodeMaterialBuildState): this;
  59398. }
  59399. }
  59400. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59404. /**
  59405. * Block used to get the reciprocal (1 / x) of a value
  59406. */
  59407. export class ReciprocalBlock extends NodeMaterialBlock {
  59408. /**
  59409. * Creates a new ReciprocalBlock
  59410. * @param name defines the block name
  59411. */
  59412. constructor(name: string);
  59413. /**
  59414. * Gets the current class name
  59415. * @returns the class name
  59416. */
  59417. getClassName(): string;
  59418. /**
  59419. * Gets the input component
  59420. */
  59421. readonly input: NodeMaterialConnectionPoint;
  59422. /**
  59423. * Gets the output component
  59424. */
  59425. readonly output: NodeMaterialConnectionPoint;
  59426. protected _buildBlock(state: NodeMaterialBuildState): this;
  59427. }
  59428. }
  59429. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59433. /**
  59434. * Block used to replace a color by another one
  59435. */
  59436. export class ReplaceColorBlock extends NodeMaterialBlock {
  59437. /**
  59438. * Creates a new ReplaceColorBlock
  59439. * @param name defines the block name
  59440. */
  59441. constructor(name: string);
  59442. /**
  59443. * Gets the current class name
  59444. * @returns the class name
  59445. */
  59446. getClassName(): string;
  59447. /**
  59448. * Gets the value input component
  59449. */
  59450. readonly value: NodeMaterialConnectionPoint;
  59451. /**
  59452. * Gets the reference input component
  59453. */
  59454. readonly reference: NodeMaterialConnectionPoint;
  59455. /**
  59456. * Gets the distance input component
  59457. */
  59458. readonly distance: NodeMaterialConnectionPoint;
  59459. /**
  59460. * Gets the replacement input component
  59461. */
  59462. readonly replacement: NodeMaterialConnectionPoint;
  59463. /**
  59464. * Gets the output component
  59465. */
  59466. readonly output: NodeMaterialConnectionPoint;
  59467. protected _buildBlock(state: NodeMaterialBuildState): this;
  59468. }
  59469. }
  59470. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59471. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59474. /**
  59475. * Block used to posterize a value
  59476. * @see https://en.wikipedia.org/wiki/Posterization
  59477. */
  59478. export class PosterizeBlock extends NodeMaterialBlock {
  59479. /**
  59480. * Creates a new PosterizeBlock
  59481. * @param name defines the block name
  59482. */
  59483. constructor(name: string);
  59484. /**
  59485. * Gets the current class name
  59486. * @returns the class name
  59487. */
  59488. getClassName(): string;
  59489. /**
  59490. * Gets the value input component
  59491. */
  59492. readonly value: NodeMaterialConnectionPoint;
  59493. /**
  59494. * Gets the steps input component
  59495. */
  59496. readonly steps: NodeMaterialConnectionPoint;
  59497. /**
  59498. * Gets the output component
  59499. */
  59500. readonly output: NodeMaterialConnectionPoint;
  59501. protected _buildBlock(state: NodeMaterialBuildState): this;
  59502. }
  59503. }
  59504. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59508. import { Scene } from "babylonjs/scene";
  59509. /**
  59510. * Operations supported by the Wave block
  59511. */
  59512. export enum WaveBlockKind {
  59513. /** SawTooth */
  59514. SawTooth = 0,
  59515. /** Square */
  59516. Square = 1,
  59517. /** Triangle */
  59518. Triangle = 2
  59519. }
  59520. /**
  59521. * Block used to apply wave operation to floats
  59522. */
  59523. export class WaveBlock extends NodeMaterialBlock {
  59524. /**
  59525. * Gets or sets the kibnd of wave to be applied by the block
  59526. */
  59527. kind: WaveBlockKind;
  59528. /**
  59529. * Creates a new WaveBlock
  59530. * @param name defines the block name
  59531. */
  59532. constructor(name: string);
  59533. /**
  59534. * Gets the current class name
  59535. * @returns the class name
  59536. */
  59537. getClassName(): string;
  59538. /**
  59539. * Gets the input component
  59540. */
  59541. readonly input: NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the output component
  59544. */
  59545. readonly output: NodeMaterialConnectionPoint;
  59546. protected _buildBlock(state: NodeMaterialBuildState): this;
  59547. serialize(): any;
  59548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59549. }
  59550. }
  59551. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59555. import { Color3 } from "babylonjs/Maths/math.color";
  59556. import { Scene } from "babylonjs/scene";
  59557. /**
  59558. * Class used to store a color step for the GradientBlock
  59559. */
  59560. export class GradientBlockColorStep {
  59561. /**
  59562. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59563. */
  59564. step: number;
  59565. /**
  59566. * Gets or sets the color associated with this step
  59567. */
  59568. color: Color3;
  59569. /**
  59570. * Creates a new GradientBlockColorStep
  59571. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59572. * @param color defines the color associated with this step
  59573. */
  59574. constructor(
  59575. /**
  59576. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59577. */
  59578. step: number,
  59579. /**
  59580. * Gets or sets the color associated with this step
  59581. */
  59582. color: Color3);
  59583. }
  59584. /**
  59585. * Block used to return a color from a gradient based on an input value between 0 and 1
  59586. */
  59587. export class GradientBlock extends NodeMaterialBlock {
  59588. /**
  59589. * Gets or sets the list of color steps
  59590. */
  59591. colorSteps: GradientBlockColorStep[];
  59592. /**
  59593. * Creates a new GradientBlock
  59594. * @param name defines the block name
  59595. */
  59596. constructor(name: string);
  59597. /**
  59598. * Gets the current class name
  59599. * @returns the class name
  59600. */
  59601. getClassName(): string;
  59602. /**
  59603. * Gets the gradient input component
  59604. */
  59605. readonly gradient: NodeMaterialConnectionPoint;
  59606. /**
  59607. * Gets the output component
  59608. */
  59609. readonly output: NodeMaterialConnectionPoint;
  59610. private _writeColorConstant;
  59611. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59612. serialize(): any;
  59613. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59614. protected _dumpPropertiesCode(): string;
  59615. }
  59616. }
  59617. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59621. /**
  59622. * Block used to normalize lerp between 2 values
  59623. */
  59624. export class NLerpBlock extends NodeMaterialBlock {
  59625. /**
  59626. * Creates a new NLerpBlock
  59627. * @param name defines the block name
  59628. */
  59629. constructor(name: string);
  59630. /**
  59631. * Gets the current class name
  59632. * @returns the class name
  59633. */
  59634. getClassName(): string;
  59635. /**
  59636. * Gets the left operand input component
  59637. */
  59638. readonly left: NodeMaterialConnectionPoint;
  59639. /**
  59640. * Gets the right operand input component
  59641. */
  59642. readonly right: NodeMaterialConnectionPoint;
  59643. /**
  59644. * Gets the gradient operand input component
  59645. */
  59646. readonly gradient: NodeMaterialConnectionPoint;
  59647. /**
  59648. * Gets the output component
  59649. */
  59650. readonly output: NodeMaterialConnectionPoint;
  59651. protected _buildBlock(state: NodeMaterialBuildState): this;
  59652. }
  59653. }
  59654. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59658. import { Scene } from "babylonjs/scene";
  59659. /**
  59660. * block used to Generate a Worley Noise 3D Noise Pattern
  59661. */
  59662. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59663. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59664. manhattanDistance: boolean;
  59665. /**
  59666. * Creates a new WorleyNoise3DBlock
  59667. * @param name defines the block name
  59668. */
  59669. constructor(name: string);
  59670. /**
  59671. * Gets the current class name
  59672. * @returns the class name
  59673. */
  59674. getClassName(): string;
  59675. /**
  59676. * Gets the seed input component
  59677. */
  59678. readonly seed: NodeMaterialConnectionPoint;
  59679. /**
  59680. * Gets the jitter input component
  59681. */
  59682. readonly jitter: NodeMaterialConnectionPoint;
  59683. /**
  59684. * Gets the output component
  59685. */
  59686. readonly output: NodeMaterialConnectionPoint;
  59687. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59688. /**
  59689. * Exposes the properties to the UI?
  59690. */
  59691. protected _dumpPropertiesCode(): string;
  59692. /**
  59693. * Exposes the properties to the Seralize?
  59694. */
  59695. serialize(): any;
  59696. /**
  59697. * Exposes the properties to the deseralize?
  59698. */
  59699. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59700. }
  59701. }
  59702. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59706. /**
  59707. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59708. */
  59709. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59710. /**
  59711. * Creates a new SimplexPerlin3DBlock
  59712. * @param name defines the block name
  59713. */
  59714. constructor(name: string);
  59715. /**
  59716. * Gets the current class name
  59717. * @returns the class name
  59718. */
  59719. getClassName(): string;
  59720. /**
  59721. * Gets the seed operand input component
  59722. */
  59723. readonly seed: NodeMaterialConnectionPoint;
  59724. /**
  59725. * Gets the output component
  59726. */
  59727. readonly output: NodeMaterialConnectionPoint;
  59728. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59729. }
  59730. }
  59731. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59735. /**
  59736. * Block used to blend normals
  59737. */
  59738. export class NormalBlendBlock extends NodeMaterialBlock {
  59739. /**
  59740. * Creates a new NormalBlendBlock
  59741. * @param name defines the block name
  59742. */
  59743. constructor(name: string);
  59744. /**
  59745. * Gets the current class name
  59746. * @returns the class name
  59747. */
  59748. getClassName(): string;
  59749. /**
  59750. * Gets the first input component
  59751. */
  59752. readonly normalMap0: NodeMaterialConnectionPoint;
  59753. /**
  59754. * Gets the second input component
  59755. */
  59756. readonly normalMap1: NodeMaterialConnectionPoint;
  59757. /**
  59758. * Gets the output component
  59759. */
  59760. readonly output: NodeMaterialConnectionPoint;
  59761. protected _buildBlock(state: NodeMaterialBuildState): this;
  59762. }
  59763. }
  59764. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59765. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59766. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59767. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59768. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59769. /**
  59770. * Block used to rotate a 2d vector by a given angle
  59771. */
  59772. export class Rotate2dBlock extends NodeMaterialBlock {
  59773. /**
  59774. * Creates a new Rotate2dBlock
  59775. * @param name defines the block name
  59776. */
  59777. constructor(name: string);
  59778. /**
  59779. * Gets the current class name
  59780. * @returns the class name
  59781. */
  59782. getClassName(): string;
  59783. /**
  59784. * Gets the input vector
  59785. */
  59786. readonly input: NodeMaterialConnectionPoint;
  59787. /**
  59788. * Gets the input angle
  59789. */
  59790. readonly angle: NodeMaterialConnectionPoint;
  59791. /**
  59792. * Gets the output component
  59793. */
  59794. readonly output: NodeMaterialConnectionPoint;
  59795. autoConfigure(material: NodeMaterial): void;
  59796. protected _buildBlock(state: NodeMaterialBuildState): this;
  59797. }
  59798. }
  59799. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59803. /**
  59804. * Block used to get the reflected vector from a direction and a normal
  59805. */
  59806. export class ReflectBlock extends NodeMaterialBlock {
  59807. /**
  59808. * Creates a new ReflectBlock
  59809. * @param name defines the block name
  59810. */
  59811. constructor(name: string);
  59812. /**
  59813. * Gets the current class name
  59814. * @returns the class name
  59815. */
  59816. getClassName(): string;
  59817. /**
  59818. * Gets the incident component
  59819. */
  59820. readonly incident: NodeMaterialConnectionPoint;
  59821. /**
  59822. * Gets the normal component
  59823. */
  59824. readonly normal: NodeMaterialConnectionPoint;
  59825. /**
  59826. * Gets the output component
  59827. */
  59828. readonly output: NodeMaterialConnectionPoint;
  59829. protected _buildBlock(state: NodeMaterialBuildState): this;
  59830. }
  59831. }
  59832. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59836. /**
  59837. * Block used to get the refracted vector from a direction and a normal
  59838. */
  59839. export class RefractBlock extends NodeMaterialBlock {
  59840. /**
  59841. * Creates a new RefractBlock
  59842. * @param name defines the block name
  59843. */
  59844. constructor(name: string);
  59845. /**
  59846. * Gets the current class name
  59847. * @returns the class name
  59848. */
  59849. getClassName(): string;
  59850. /**
  59851. * Gets the incident component
  59852. */
  59853. readonly incident: NodeMaterialConnectionPoint;
  59854. /**
  59855. * Gets the normal component
  59856. */
  59857. readonly normal: NodeMaterialConnectionPoint;
  59858. /**
  59859. * Gets the index of refraction component
  59860. */
  59861. readonly ior: NodeMaterialConnectionPoint;
  59862. /**
  59863. * Gets the output component
  59864. */
  59865. readonly output: NodeMaterialConnectionPoint;
  59866. protected _buildBlock(state: NodeMaterialBuildState): this;
  59867. }
  59868. }
  59869. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59873. /**
  59874. * Block used to desaturate a color
  59875. */
  59876. export class DesaturateBlock extends NodeMaterialBlock {
  59877. /**
  59878. * Creates a new DesaturateBlock
  59879. * @param name defines the block name
  59880. */
  59881. constructor(name: string);
  59882. /**
  59883. * Gets the current class name
  59884. * @returns the class name
  59885. */
  59886. getClassName(): string;
  59887. /**
  59888. * Gets the color operand input component
  59889. */
  59890. readonly color: NodeMaterialConnectionPoint;
  59891. /**
  59892. * Gets the level operand input component
  59893. */
  59894. readonly level: NodeMaterialConnectionPoint;
  59895. /**
  59896. * Gets the output component
  59897. */
  59898. readonly output: NodeMaterialConnectionPoint;
  59899. protected _buildBlock(state: NodeMaterialBuildState): this;
  59900. }
  59901. }
  59902. declare module "babylonjs/Materials/Node/Blocks/index" {
  59903. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59904. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59905. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59906. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59907. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59908. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59909. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59910. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59911. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59912. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59913. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59914. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59915. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59916. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59917. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59918. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59919. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59920. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59921. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59922. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59923. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59924. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59925. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59926. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59927. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59928. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59929. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59930. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59931. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59932. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59933. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59934. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59935. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59936. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59937. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59938. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59939. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59940. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59941. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59942. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59943. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59944. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59945. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59946. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59947. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  59948. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  59949. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  59950. }
  59951. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59952. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59953. }
  59954. declare module "babylonjs/Materials/Node/index" {
  59955. export * from "babylonjs/Materials/Node/Enums/index";
  59956. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59957. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59958. export * from "babylonjs/Materials/Node/nodeMaterial";
  59959. export * from "babylonjs/Materials/Node/Blocks/index";
  59960. export * from "babylonjs/Materials/Node/Optimizers/index";
  59961. }
  59962. declare module "babylonjs/Materials/effectRenderer" {
  59963. import { Nullable } from "babylonjs/types";
  59964. import { Texture } from "babylonjs/Materials/Textures/texture";
  59965. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59966. import { Viewport } from "babylonjs/Maths/math.viewport";
  59967. import { Observable } from "babylonjs/Misc/observable";
  59968. import { Effect } from "babylonjs/Materials/effect";
  59969. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59970. import "babylonjs/Shaders/postprocess.vertex";
  59971. /**
  59972. * Effect Render Options
  59973. */
  59974. export interface IEffectRendererOptions {
  59975. /**
  59976. * Defines the vertices positions.
  59977. */
  59978. positions?: number[];
  59979. /**
  59980. * Defines the indices.
  59981. */
  59982. indices?: number[];
  59983. }
  59984. /**
  59985. * Helper class to render one or more effects
  59986. */
  59987. export class EffectRenderer {
  59988. private engine;
  59989. private static _DefaultOptions;
  59990. private _vertexBuffers;
  59991. private _indexBuffer;
  59992. private _ringBufferIndex;
  59993. private _ringScreenBuffer;
  59994. private _fullscreenViewport;
  59995. private _getNextFrameBuffer;
  59996. /**
  59997. * Creates an effect renderer
  59998. * @param engine the engine to use for rendering
  59999. * @param options defines the options of the effect renderer
  60000. */
  60001. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60002. /**
  60003. * Sets the current viewport in normalized coordinates 0-1
  60004. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60005. */
  60006. setViewport(viewport?: Viewport): void;
  60007. /**
  60008. * Binds the embedded attributes buffer to the effect.
  60009. * @param effect Defines the effect to bind the attributes for
  60010. */
  60011. bindBuffers(effect: Effect): void;
  60012. /**
  60013. * Sets the current effect wrapper to use during draw.
  60014. * The effect needs to be ready before calling this api.
  60015. * This also sets the default full screen position attribute.
  60016. * @param effectWrapper Defines the effect to draw with
  60017. */
  60018. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60019. /**
  60020. * Draws a full screen quad.
  60021. */
  60022. draw(): void;
  60023. /**
  60024. * renders one or more effects to a specified texture
  60025. * @param effectWrappers list of effects to renderer
  60026. * @param outputTexture texture to draw to, if null it will render to the screen
  60027. */
  60028. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60029. /**
  60030. * Disposes of the effect renderer
  60031. */
  60032. dispose(): void;
  60033. }
  60034. /**
  60035. * Options to create an EffectWrapper
  60036. */
  60037. interface EffectWrapperCreationOptions {
  60038. /**
  60039. * Engine to use to create the effect
  60040. */
  60041. engine: ThinEngine;
  60042. /**
  60043. * Fragment shader for the effect
  60044. */
  60045. fragmentShader: string;
  60046. /**
  60047. * Vertex shader for the effect
  60048. */
  60049. vertexShader?: string;
  60050. /**
  60051. * Attributes to use in the shader
  60052. */
  60053. attributeNames?: Array<string>;
  60054. /**
  60055. * Uniforms to use in the shader
  60056. */
  60057. uniformNames?: Array<string>;
  60058. /**
  60059. * Texture sampler names to use in the shader
  60060. */
  60061. samplerNames?: Array<string>;
  60062. /**
  60063. * The friendly name of the effect displayed in Spector.
  60064. */
  60065. name?: string;
  60066. }
  60067. /**
  60068. * Wraps an effect to be used for rendering
  60069. */
  60070. export class EffectWrapper {
  60071. /**
  60072. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60073. */
  60074. onApplyObservable: Observable<{}>;
  60075. /**
  60076. * The underlying effect
  60077. */
  60078. effect: Effect;
  60079. /**
  60080. * Creates an effect to be renderer
  60081. * @param creationOptions options to create the effect
  60082. */
  60083. constructor(creationOptions: EffectWrapperCreationOptions);
  60084. /**
  60085. * Disposes of the effect wrapper
  60086. */
  60087. dispose(): void;
  60088. }
  60089. }
  60090. declare module "babylonjs/Materials/index" {
  60091. export * from "babylonjs/Materials/Background/index";
  60092. export * from "babylonjs/Materials/colorCurves";
  60093. export * from "babylonjs/Materials/iEffectFallbacks";
  60094. export * from "babylonjs/Materials/effectFallbacks";
  60095. export * from "babylonjs/Materials/effect";
  60096. export * from "babylonjs/Materials/fresnelParameters";
  60097. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60098. export * from "babylonjs/Materials/material";
  60099. export * from "babylonjs/Materials/materialDefines";
  60100. export * from "babylonjs/Materials/materialHelper";
  60101. export * from "babylonjs/Materials/multiMaterial";
  60102. export * from "babylonjs/Materials/PBR/index";
  60103. export * from "babylonjs/Materials/pushMaterial";
  60104. export * from "babylonjs/Materials/shaderMaterial";
  60105. export * from "babylonjs/Materials/standardMaterial";
  60106. export * from "babylonjs/Materials/Textures/index";
  60107. export * from "babylonjs/Materials/uniformBuffer";
  60108. export * from "babylonjs/Materials/materialFlags";
  60109. export * from "babylonjs/Materials/Node/index";
  60110. export * from "babylonjs/Materials/effectRenderer";
  60111. }
  60112. declare module "babylonjs/Maths/index" {
  60113. export * from "babylonjs/Maths/math.scalar";
  60114. export * from "babylonjs/Maths/math";
  60115. export * from "babylonjs/Maths/sphericalPolynomial";
  60116. }
  60117. declare module "babylonjs/Misc/workerPool" {
  60118. import { IDisposable } from "babylonjs/scene";
  60119. /**
  60120. * Helper class to push actions to a pool of workers.
  60121. */
  60122. export class WorkerPool implements IDisposable {
  60123. private _workerInfos;
  60124. private _pendingActions;
  60125. /**
  60126. * Constructor
  60127. * @param workers Array of workers to use for actions
  60128. */
  60129. constructor(workers: Array<Worker>);
  60130. /**
  60131. * Terminates all workers and clears any pending actions.
  60132. */
  60133. dispose(): void;
  60134. /**
  60135. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60136. * pended until a worker has completed its action.
  60137. * @param action The action to perform. Call onComplete when the action is complete.
  60138. */
  60139. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60140. private _execute;
  60141. }
  60142. }
  60143. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60144. import { IDisposable } from "babylonjs/scene";
  60145. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60146. /**
  60147. * Configuration for Draco compression
  60148. */
  60149. export interface IDracoCompressionConfiguration {
  60150. /**
  60151. * Configuration for the decoder.
  60152. */
  60153. decoder: {
  60154. /**
  60155. * The url to the WebAssembly module.
  60156. */
  60157. wasmUrl?: string;
  60158. /**
  60159. * The url to the WebAssembly binary.
  60160. */
  60161. wasmBinaryUrl?: string;
  60162. /**
  60163. * The url to the fallback JavaScript module.
  60164. */
  60165. fallbackUrl?: string;
  60166. };
  60167. }
  60168. /**
  60169. * Draco compression (https://google.github.io/draco/)
  60170. *
  60171. * This class wraps the Draco module.
  60172. *
  60173. * **Encoder**
  60174. *
  60175. * The encoder is not currently implemented.
  60176. *
  60177. * **Decoder**
  60178. *
  60179. * 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.
  60180. *
  60181. * To update the configuration, use the following code:
  60182. * ```javascript
  60183. * DracoCompression.Configuration = {
  60184. * decoder: {
  60185. * wasmUrl: "<url to the WebAssembly library>",
  60186. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60187. * fallbackUrl: "<url to the fallback JavaScript library>",
  60188. * }
  60189. * };
  60190. * ```
  60191. *
  60192. * 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.
  60193. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60194. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60195. *
  60196. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60197. * ```javascript
  60198. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60199. * ```
  60200. *
  60201. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60202. */
  60203. export class DracoCompression implements IDisposable {
  60204. private _workerPoolPromise?;
  60205. private _decoderModulePromise?;
  60206. /**
  60207. * The configuration. Defaults to the following urls:
  60208. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60209. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60210. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60211. */
  60212. static Configuration: IDracoCompressionConfiguration;
  60213. /**
  60214. * Returns true if the decoder configuration is available.
  60215. */
  60216. static readonly DecoderAvailable: boolean;
  60217. /**
  60218. * Default number of workers to create when creating the draco compression object.
  60219. */
  60220. static DefaultNumWorkers: number;
  60221. private static GetDefaultNumWorkers;
  60222. private static _Default;
  60223. /**
  60224. * Default instance for the draco compression object.
  60225. */
  60226. static readonly Default: DracoCompression;
  60227. /**
  60228. * Constructor
  60229. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60230. */
  60231. constructor(numWorkers?: number);
  60232. /**
  60233. * Stop all async operations and release resources.
  60234. */
  60235. dispose(): void;
  60236. /**
  60237. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60238. * @returns a promise that resolves when ready
  60239. */
  60240. whenReadyAsync(): Promise<void>;
  60241. /**
  60242. * Decode Draco compressed mesh data to vertex data.
  60243. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60244. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60245. * @returns A promise that resolves with the decoded vertex data
  60246. */
  60247. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60248. [kind: string]: number;
  60249. }): Promise<VertexData>;
  60250. }
  60251. }
  60252. declare module "babylonjs/Meshes/Compression/index" {
  60253. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60254. }
  60255. declare module "babylonjs/Meshes/csg" {
  60256. import { Nullable } from "babylonjs/types";
  60257. import { Scene } from "babylonjs/scene";
  60258. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60259. import { Mesh } from "babylonjs/Meshes/mesh";
  60260. import { Material } from "babylonjs/Materials/material";
  60261. /**
  60262. * Class for building Constructive Solid Geometry
  60263. */
  60264. export class CSG {
  60265. private polygons;
  60266. /**
  60267. * The world matrix
  60268. */
  60269. matrix: Matrix;
  60270. /**
  60271. * Stores the position
  60272. */
  60273. position: Vector3;
  60274. /**
  60275. * Stores the rotation
  60276. */
  60277. rotation: Vector3;
  60278. /**
  60279. * Stores the rotation quaternion
  60280. */
  60281. rotationQuaternion: Nullable<Quaternion>;
  60282. /**
  60283. * Stores the scaling vector
  60284. */
  60285. scaling: Vector3;
  60286. /**
  60287. * Convert the Mesh to CSG
  60288. * @param mesh The Mesh to convert to CSG
  60289. * @returns A new CSG from the Mesh
  60290. */
  60291. static FromMesh(mesh: Mesh): CSG;
  60292. /**
  60293. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60294. * @param polygons Polygons used to construct a CSG solid
  60295. */
  60296. private static FromPolygons;
  60297. /**
  60298. * Clones, or makes a deep copy, of the CSG
  60299. * @returns A new CSG
  60300. */
  60301. clone(): CSG;
  60302. /**
  60303. * Unions this CSG with another CSG
  60304. * @param csg The CSG to union against this CSG
  60305. * @returns The unioned CSG
  60306. */
  60307. union(csg: CSG): CSG;
  60308. /**
  60309. * Unions this CSG with another CSG in place
  60310. * @param csg The CSG to union against this CSG
  60311. */
  60312. unionInPlace(csg: CSG): void;
  60313. /**
  60314. * Subtracts this CSG with another CSG
  60315. * @param csg The CSG to subtract against this CSG
  60316. * @returns A new CSG
  60317. */
  60318. subtract(csg: CSG): CSG;
  60319. /**
  60320. * Subtracts this CSG with another CSG in place
  60321. * @param csg The CSG to subtact against this CSG
  60322. */
  60323. subtractInPlace(csg: CSG): void;
  60324. /**
  60325. * Intersect this CSG with another CSG
  60326. * @param csg The CSG to intersect against this CSG
  60327. * @returns A new CSG
  60328. */
  60329. intersect(csg: CSG): CSG;
  60330. /**
  60331. * Intersects this CSG with another CSG in place
  60332. * @param csg The CSG to intersect against this CSG
  60333. */
  60334. intersectInPlace(csg: CSG): void;
  60335. /**
  60336. * Return a new CSG solid with solid and empty space switched. This solid is
  60337. * not modified.
  60338. * @returns A new CSG solid with solid and empty space switched
  60339. */
  60340. inverse(): CSG;
  60341. /**
  60342. * Inverses the CSG in place
  60343. */
  60344. inverseInPlace(): void;
  60345. /**
  60346. * This is used to keep meshes transformations so they can be restored
  60347. * when we build back a Babylon Mesh
  60348. * NB : All CSG operations are performed in world coordinates
  60349. * @param csg The CSG to copy the transform attributes from
  60350. * @returns This CSG
  60351. */
  60352. copyTransformAttributes(csg: CSG): CSG;
  60353. /**
  60354. * Build Raw mesh from CSG
  60355. * Coordinates here are in world space
  60356. * @param name The name of the mesh geometry
  60357. * @param scene The Scene
  60358. * @param keepSubMeshes Specifies if the submeshes should be kept
  60359. * @returns A new Mesh
  60360. */
  60361. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60362. /**
  60363. * Build Mesh from CSG taking material and transforms into account
  60364. * @param name The name of the Mesh
  60365. * @param material The material of the Mesh
  60366. * @param scene The Scene
  60367. * @param keepSubMeshes Specifies if submeshes should be kept
  60368. * @returns The new Mesh
  60369. */
  60370. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60371. }
  60372. }
  60373. declare module "babylonjs/Meshes/trailMesh" {
  60374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60375. import { Mesh } from "babylonjs/Meshes/mesh";
  60376. import { Scene } from "babylonjs/scene";
  60377. /**
  60378. * Class used to create a trail following a mesh
  60379. */
  60380. export class TrailMesh extends Mesh {
  60381. private _generator;
  60382. private _autoStart;
  60383. private _running;
  60384. private _diameter;
  60385. private _length;
  60386. private _sectionPolygonPointsCount;
  60387. private _sectionVectors;
  60388. private _sectionNormalVectors;
  60389. private _beforeRenderObserver;
  60390. /**
  60391. * @constructor
  60392. * @param name The value used by scene.getMeshByName() to do a lookup.
  60393. * @param generator The mesh to generate a trail.
  60394. * @param scene The scene to add this mesh to.
  60395. * @param diameter Diameter of trailing mesh. Default is 1.
  60396. * @param length Length of trailing mesh. Default is 60.
  60397. * @param autoStart Automatically start trailing mesh. Default true.
  60398. */
  60399. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60400. /**
  60401. * "TrailMesh"
  60402. * @returns "TrailMesh"
  60403. */
  60404. getClassName(): string;
  60405. private _createMesh;
  60406. /**
  60407. * Start trailing mesh.
  60408. */
  60409. start(): void;
  60410. /**
  60411. * Stop trailing mesh.
  60412. */
  60413. stop(): void;
  60414. /**
  60415. * Update trailing mesh geometry.
  60416. */
  60417. update(): void;
  60418. /**
  60419. * Returns a new TrailMesh object.
  60420. * @param name is a string, the name given to the new mesh
  60421. * @param newGenerator use new generator object for cloned trail mesh
  60422. * @returns a new mesh
  60423. */
  60424. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60425. /**
  60426. * Serializes this trail mesh
  60427. * @param serializationObject object to write serialization to
  60428. */
  60429. serialize(serializationObject: any): void;
  60430. /**
  60431. * Parses a serialized trail mesh
  60432. * @param parsedMesh the serialized mesh
  60433. * @param scene the scene to create the trail mesh in
  60434. * @returns the created trail mesh
  60435. */
  60436. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60437. }
  60438. }
  60439. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60440. import { Nullable } from "babylonjs/types";
  60441. import { Scene } from "babylonjs/scene";
  60442. import { Vector4 } from "babylonjs/Maths/math.vector";
  60443. import { Color4 } from "babylonjs/Maths/math.color";
  60444. import { Mesh } from "babylonjs/Meshes/mesh";
  60445. /**
  60446. * Class containing static functions to help procedurally build meshes
  60447. */
  60448. export class TiledBoxBuilder {
  60449. /**
  60450. * Creates a box mesh
  60451. * 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)
  60452. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60456. * @param name defines the name of the mesh
  60457. * @param options defines the options used to create the mesh
  60458. * @param scene defines the hosting scene
  60459. * @returns the box mesh
  60460. */
  60461. static CreateTiledBox(name: string, options: {
  60462. pattern?: number;
  60463. width?: number;
  60464. height?: number;
  60465. depth?: number;
  60466. tileSize?: number;
  60467. tileWidth?: number;
  60468. tileHeight?: number;
  60469. alignHorizontal?: number;
  60470. alignVertical?: number;
  60471. faceUV?: Vector4[];
  60472. faceColors?: Color4[];
  60473. sideOrientation?: number;
  60474. updatable?: boolean;
  60475. }, scene?: Nullable<Scene>): Mesh;
  60476. }
  60477. }
  60478. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60479. import { Vector4 } from "babylonjs/Maths/math.vector";
  60480. import { Mesh } from "babylonjs/Meshes/mesh";
  60481. /**
  60482. * Class containing static functions to help procedurally build meshes
  60483. */
  60484. export class TorusKnotBuilder {
  60485. /**
  60486. * Creates a torus knot mesh
  60487. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60488. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60489. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60490. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60494. * @param name defines the name of the mesh
  60495. * @param options defines the options used to create the mesh
  60496. * @param scene defines the hosting scene
  60497. * @returns the torus knot mesh
  60498. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60499. */
  60500. static CreateTorusKnot(name: string, options: {
  60501. radius?: number;
  60502. tube?: number;
  60503. radialSegments?: number;
  60504. tubularSegments?: number;
  60505. p?: number;
  60506. q?: number;
  60507. updatable?: boolean;
  60508. sideOrientation?: number;
  60509. frontUVs?: Vector4;
  60510. backUVs?: Vector4;
  60511. }, scene: any): Mesh;
  60512. }
  60513. }
  60514. declare module "babylonjs/Meshes/polygonMesh" {
  60515. import { Scene } from "babylonjs/scene";
  60516. import { Vector2 } from "babylonjs/Maths/math.vector";
  60517. import { Mesh } from "babylonjs/Meshes/mesh";
  60518. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60519. import { Path2 } from "babylonjs/Maths/math.path";
  60520. /**
  60521. * Polygon
  60522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60523. */
  60524. export class Polygon {
  60525. /**
  60526. * Creates a rectangle
  60527. * @param xmin bottom X coord
  60528. * @param ymin bottom Y coord
  60529. * @param xmax top X coord
  60530. * @param ymax top Y coord
  60531. * @returns points that make the resulting rectation
  60532. */
  60533. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60534. /**
  60535. * Creates a circle
  60536. * @param radius radius of circle
  60537. * @param cx scale in x
  60538. * @param cy scale in y
  60539. * @param numberOfSides number of sides that make up the circle
  60540. * @returns points that make the resulting circle
  60541. */
  60542. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60543. /**
  60544. * Creates a polygon from input string
  60545. * @param input Input polygon data
  60546. * @returns the parsed points
  60547. */
  60548. static Parse(input: string): Vector2[];
  60549. /**
  60550. * Starts building a polygon from x and y coordinates
  60551. * @param x x coordinate
  60552. * @param y y coordinate
  60553. * @returns the started path2
  60554. */
  60555. static StartingAt(x: number, y: number): Path2;
  60556. }
  60557. /**
  60558. * Builds a polygon
  60559. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60560. */
  60561. export class PolygonMeshBuilder {
  60562. private _points;
  60563. private _outlinepoints;
  60564. private _holes;
  60565. private _name;
  60566. private _scene;
  60567. private _epoints;
  60568. private _eholes;
  60569. private _addToepoint;
  60570. /**
  60571. * Babylon reference to the earcut plugin.
  60572. */
  60573. bjsEarcut: any;
  60574. /**
  60575. * Creates a PolygonMeshBuilder
  60576. * @param name name of the builder
  60577. * @param contours Path of the polygon
  60578. * @param scene scene to add to when creating the mesh
  60579. * @param earcutInjection can be used to inject your own earcut reference
  60580. */
  60581. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60582. /**
  60583. * Adds a whole within the polygon
  60584. * @param hole Array of points defining the hole
  60585. * @returns this
  60586. */
  60587. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60588. /**
  60589. * Creates the polygon
  60590. * @param updatable If the mesh should be updatable
  60591. * @param depth The depth of the mesh created
  60592. * @returns the created mesh
  60593. */
  60594. build(updatable?: boolean, depth?: number): Mesh;
  60595. /**
  60596. * Creates the polygon
  60597. * @param depth The depth of the mesh created
  60598. * @returns the created VertexData
  60599. */
  60600. buildVertexData(depth?: number): VertexData;
  60601. /**
  60602. * Adds a side to the polygon
  60603. * @param positions points that make the polygon
  60604. * @param normals normals of the polygon
  60605. * @param uvs uvs of the polygon
  60606. * @param indices indices of the polygon
  60607. * @param bounds bounds of the polygon
  60608. * @param points points of the polygon
  60609. * @param depth depth of the polygon
  60610. * @param flip flip of the polygon
  60611. */
  60612. private addSide;
  60613. }
  60614. }
  60615. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60616. import { Scene } from "babylonjs/scene";
  60617. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60618. import { Color4 } from "babylonjs/Maths/math.color";
  60619. import { Mesh } from "babylonjs/Meshes/mesh";
  60620. import { Nullable } from "babylonjs/types";
  60621. /**
  60622. * Class containing static functions to help procedurally build meshes
  60623. */
  60624. export class PolygonBuilder {
  60625. /**
  60626. * Creates a polygon mesh
  60627. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60628. * * 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
  60629. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60632. * * Remember you can only change the shape positions, not their number when updating a polygon
  60633. * @param name defines the name of the mesh
  60634. * @param options defines the options used to create the mesh
  60635. * @param scene defines the hosting scene
  60636. * @param earcutInjection can be used to inject your own earcut reference
  60637. * @returns the polygon mesh
  60638. */
  60639. static CreatePolygon(name: string, options: {
  60640. shape: Vector3[];
  60641. holes?: Vector3[][];
  60642. depth?: number;
  60643. faceUV?: Vector4[];
  60644. faceColors?: Color4[];
  60645. updatable?: boolean;
  60646. sideOrientation?: number;
  60647. frontUVs?: Vector4;
  60648. backUVs?: Vector4;
  60649. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60650. /**
  60651. * Creates an extruded polygon mesh, with depth in the Y direction.
  60652. * * 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)
  60653. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60654. * @param name defines the name of the mesh
  60655. * @param options defines the options used to create the mesh
  60656. * @param scene defines the hosting scene
  60657. * @param earcutInjection can be used to inject your own earcut reference
  60658. * @returns the polygon mesh
  60659. */
  60660. static ExtrudePolygon(name: string, options: {
  60661. shape: Vector3[];
  60662. holes?: Vector3[][];
  60663. depth?: number;
  60664. faceUV?: Vector4[];
  60665. faceColors?: Color4[];
  60666. updatable?: boolean;
  60667. sideOrientation?: number;
  60668. frontUVs?: Vector4;
  60669. backUVs?: Vector4;
  60670. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60671. }
  60672. }
  60673. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60674. import { Scene } from "babylonjs/scene";
  60675. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60676. import { Mesh } from "babylonjs/Meshes/mesh";
  60677. import { Nullable } from "babylonjs/types";
  60678. /**
  60679. * Class containing static functions to help procedurally build meshes
  60680. */
  60681. export class LatheBuilder {
  60682. /**
  60683. * Creates lathe mesh.
  60684. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60685. * * 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
  60686. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60687. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60688. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60689. * * 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
  60690. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60691. * * 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
  60692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60696. * @param name defines the name of the mesh
  60697. * @param options defines the options used to create the mesh
  60698. * @param scene defines the hosting scene
  60699. * @returns the lathe mesh
  60700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60701. */
  60702. static CreateLathe(name: string, options: {
  60703. shape: Vector3[];
  60704. radius?: number;
  60705. tessellation?: number;
  60706. clip?: number;
  60707. arc?: number;
  60708. closed?: boolean;
  60709. updatable?: boolean;
  60710. sideOrientation?: number;
  60711. frontUVs?: Vector4;
  60712. backUVs?: Vector4;
  60713. cap?: number;
  60714. invertUV?: boolean;
  60715. }, scene?: Nullable<Scene>): Mesh;
  60716. }
  60717. }
  60718. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60719. import { Nullable } from "babylonjs/types";
  60720. import { Scene } from "babylonjs/scene";
  60721. import { Vector4 } from "babylonjs/Maths/math.vector";
  60722. import { Mesh } from "babylonjs/Meshes/mesh";
  60723. /**
  60724. * Class containing static functions to help procedurally build meshes
  60725. */
  60726. export class TiledPlaneBuilder {
  60727. /**
  60728. * Creates a tiled plane mesh
  60729. * * The parameter `pattern` will, depending on value, do nothing or
  60730. * * * flip (reflect about central vertical) alternate tiles across and up
  60731. * * * flip every tile on alternate rows
  60732. * * * rotate (180 degs) alternate tiles across and up
  60733. * * * rotate every tile on alternate rows
  60734. * * * flip and rotate alternate tiles across and up
  60735. * * * flip and rotate every tile on alternate rows
  60736. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60737. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60739. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60740. * * 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)
  60741. * * 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)
  60742. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60743. * @param name defines the name of the mesh
  60744. * @param options defines the options used to create the mesh
  60745. * @param scene defines the hosting scene
  60746. * @returns the box mesh
  60747. */
  60748. static CreateTiledPlane(name: string, options: {
  60749. pattern?: number;
  60750. tileSize?: number;
  60751. tileWidth?: number;
  60752. tileHeight?: number;
  60753. size?: number;
  60754. width?: number;
  60755. height?: number;
  60756. alignHorizontal?: number;
  60757. alignVertical?: number;
  60758. sideOrientation?: number;
  60759. frontUVs?: Vector4;
  60760. backUVs?: Vector4;
  60761. updatable?: boolean;
  60762. }, scene?: Nullable<Scene>): Mesh;
  60763. }
  60764. }
  60765. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60766. import { Nullable } from "babylonjs/types";
  60767. import { Scene } from "babylonjs/scene";
  60768. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60769. import { Mesh } from "babylonjs/Meshes/mesh";
  60770. /**
  60771. * Class containing static functions to help procedurally build meshes
  60772. */
  60773. export class TubeBuilder {
  60774. /**
  60775. * Creates a tube mesh.
  60776. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60777. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60778. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60779. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60780. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60781. * * 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)
  60782. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60783. * * 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
  60784. * * 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
  60785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60789. * @param name defines the name of the mesh
  60790. * @param options defines the options used to create the mesh
  60791. * @param scene defines the hosting scene
  60792. * @returns the tube mesh
  60793. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60794. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60795. */
  60796. static CreateTube(name: string, options: {
  60797. path: Vector3[];
  60798. radius?: number;
  60799. tessellation?: number;
  60800. radiusFunction?: {
  60801. (i: number, distance: number): number;
  60802. };
  60803. cap?: number;
  60804. arc?: number;
  60805. updatable?: boolean;
  60806. sideOrientation?: number;
  60807. frontUVs?: Vector4;
  60808. backUVs?: Vector4;
  60809. instance?: Mesh;
  60810. invertUV?: boolean;
  60811. }, scene?: Nullable<Scene>): Mesh;
  60812. }
  60813. }
  60814. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60815. import { Scene } from "babylonjs/scene";
  60816. import { Vector4 } from "babylonjs/Maths/math.vector";
  60817. import { Mesh } from "babylonjs/Meshes/mesh";
  60818. import { Nullable } from "babylonjs/types";
  60819. /**
  60820. * Class containing static functions to help procedurally build meshes
  60821. */
  60822. export class IcoSphereBuilder {
  60823. /**
  60824. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60825. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60826. * * 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`)
  60827. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60828. * * 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
  60829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60832. * @param name defines the name of the mesh
  60833. * @param options defines the options used to create the mesh
  60834. * @param scene defines the hosting scene
  60835. * @returns the icosahedron mesh
  60836. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60837. */
  60838. static CreateIcoSphere(name: string, options: {
  60839. radius?: number;
  60840. radiusX?: number;
  60841. radiusY?: number;
  60842. radiusZ?: number;
  60843. flat?: boolean;
  60844. subdivisions?: number;
  60845. sideOrientation?: number;
  60846. frontUVs?: Vector4;
  60847. backUVs?: Vector4;
  60848. updatable?: boolean;
  60849. }, scene?: Nullable<Scene>): Mesh;
  60850. }
  60851. }
  60852. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60853. import { Vector3 } from "babylonjs/Maths/math.vector";
  60854. import { Mesh } from "babylonjs/Meshes/mesh";
  60855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60856. /**
  60857. * Class containing static functions to help procedurally build meshes
  60858. */
  60859. export class DecalBuilder {
  60860. /**
  60861. * Creates a decal mesh.
  60862. * 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
  60863. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60864. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60865. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60866. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60867. * @param name defines the name of the mesh
  60868. * @param sourceMesh defines the mesh where the decal must be applied
  60869. * @param options defines the options used to create the mesh
  60870. * @param scene defines the hosting scene
  60871. * @returns the decal mesh
  60872. * @see https://doc.babylonjs.com/how_to/decals
  60873. */
  60874. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60875. position?: Vector3;
  60876. normal?: Vector3;
  60877. size?: Vector3;
  60878. angle?: number;
  60879. }): Mesh;
  60880. }
  60881. }
  60882. declare module "babylonjs/Meshes/meshBuilder" {
  60883. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60884. import { Nullable } from "babylonjs/types";
  60885. import { Scene } from "babylonjs/scene";
  60886. import { Mesh } from "babylonjs/Meshes/mesh";
  60887. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60888. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60890. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60891. import { Plane } from "babylonjs/Maths/math.plane";
  60892. /**
  60893. * Class containing static functions to help procedurally build meshes
  60894. */
  60895. export class MeshBuilder {
  60896. /**
  60897. * Creates a box mesh
  60898. * * The parameter `size` sets the size (float) of each box side (default 1)
  60899. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60900. * * 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)
  60901. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60905. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60906. * @param name defines the name of the mesh
  60907. * @param options defines the options used to create the mesh
  60908. * @param scene defines the hosting scene
  60909. * @returns the box mesh
  60910. */
  60911. static CreateBox(name: string, options: {
  60912. size?: number;
  60913. width?: number;
  60914. height?: number;
  60915. depth?: number;
  60916. faceUV?: Vector4[];
  60917. faceColors?: Color4[];
  60918. sideOrientation?: number;
  60919. frontUVs?: Vector4;
  60920. backUVs?: Vector4;
  60921. updatable?: boolean;
  60922. }, scene?: Nullable<Scene>): Mesh;
  60923. /**
  60924. * Creates a tiled box mesh
  60925. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60927. * @param name defines the name of the mesh
  60928. * @param options defines the options used to create the mesh
  60929. * @param scene defines the hosting scene
  60930. * @returns the tiled box mesh
  60931. */
  60932. static CreateTiledBox(name: string, options: {
  60933. pattern?: number;
  60934. size?: number;
  60935. width?: number;
  60936. height?: number;
  60937. depth: number;
  60938. tileSize?: number;
  60939. tileWidth?: number;
  60940. tileHeight?: number;
  60941. faceUV?: Vector4[];
  60942. faceColors?: Color4[];
  60943. alignHorizontal?: number;
  60944. alignVertical?: number;
  60945. sideOrientation?: number;
  60946. updatable?: boolean;
  60947. }, scene?: Nullable<Scene>): Mesh;
  60948. /**
  60949. * Creates a sphere mesh
  60950. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60951. * * 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`)
  60952. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60953. * * 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
  60954. * * 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)
  60955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60958. * @param name defines the name of the mesh
  60959. * @param options defines the options used to create the mesh
  60960. * @param scene defines the hosting scene
  60961. * @returns the sphere mesh
  60962. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60963. */
  60964. static CreateSphere(name: string, options: {
  60965. segments?: number;
  60966. diameter?: number;
  60967. diameterX?: number;
  60968. diameterY?: number;
  60969. diameterZ?: number;
  60970. arc?: number;
  60971. slice?: number;
  60972. sideOrientation?: number;
  60973. frontUVs?: Vector4;
  60974. backUVs?: Vector4;
  60975. updatable?: boolean;
  60976. }, scene?: Nullable<Scene>): Mesh;
  60977. /**
  60978. * Creates a plane polygonal mesh. By default, this is a disc
  60979. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60980. * * 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
  60981. * * 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
  60982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60985. * @param name defines the name of the mesh
  60986. * @param options defines the options used to create the mesh
  60987. * @param scene defines the hosting scene
  60988. * @returns the plane polygonal mesh
  60989. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60990. */
  60991. static CreateDisc(name: string, options: {
  60992. radius?: number;
  60993. tessellation?: number;
  60994. arc?: number;
  60995. updatable?: boolean;
  60996. sideOrientation?: number;
  60997. frontUVs?: Vector4;
  60998. backUVs?: Vector4;
  60999. }, scene?: Nullable<Scene>): Mesh;
  61000. /**
  61001. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61002. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61003. * * 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`)
  61004. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61005. * * 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
  61006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61009. * @param name defines the name of the mesh
  61010. * @param options defines the options used to create the mesh
  61011. * @param scene defines the hosting scene
  61012. * @returns the icosahedron mesh
  61013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61014. */
  61015. static CreateIcoSphere(name: string, options: {
  61016. radius?: number;
  61017. radiusX?: number;
  61018. radiusY?: number;
  61019. radiusZ?: number;
  61020. flat?: boolean;
  61021. subdivisions?: number;
  61022. sideOrientation?: number;
  61023. frontUVs?: Vector4;
  61024. backUVs?: Vector4;
  61025. updatable?: boolean;
  61026. }, scene?: Nullable<Scene>): Mesh;
  61027. /**
  61028. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61029. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61030. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61031. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61032. * * 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
  61033. * * 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
  61034. * * 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
  61035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61037. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61038. * * 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
  61039. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61040. * * 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
  61041. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61043. * @param name defines the name of the mesh
  61044. * @param options defines the options used to create the mesh
  61045. * @param scene defines the hosting scene
  61046. * @returns the ribbon mesh
  61047. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61048. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61049. */
  61050. static CreateRibbon(name: string, options: {
  61051. pathArray: Vector3[][];
  61052. closeArray?: boolean;
  61053. closePath?: boolean;
  61054. offset?: number;
  61055. updatable?: boolean;
  61056. sideOrientation?: number;
  61057. frontUVs?: Vector4;
  61058. backUVs?: Vector4;
  61059. instance?: Mesh;
  61060. invertUV?: boolean;
  61061. uvs?: Vector2[];
  61062. colors?: Color4[];
  61063. }, scene?: Nullable<Scene>): Mesh;
  61064. /**
  61065. * Creates a cylinder or a cone mesh
  61066. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61067. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61068. * * 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.
  61069. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61070. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61071. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61072. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61073. * * 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).
  61074. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61075. * * 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).
  61076. * * 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
  61077. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61078. * * 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
  61079. * * 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.
  61080. * * If `enclose` is false, a ring surface is one element.
  61081. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61082. * * 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
  61083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61086. * @param name defines the name of the mesh
  61087. * @param options defines the options used to create the mesh
  61088. * @param scene defines the hosting scene
  61089. * @returns the cylinder mesh
  61090. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61091. */
  61092. static CreateCylinder(name: string, options: {
  61093. height?: number;
  61094. diameterTop?: number;
  61095. diameterBottom?: number;
  61096. diameter?: number;
  61097. tessellation?: number;
  61098. subdivisions?: number;
  61099. arc?: number;
  61100. faceColors?: Color4[];
  61101. faceUV?: Vector4[];
  61102. updatable?: boolean;
  61103. hasRings?: boolean;
  61104. enclose?: boolean;
  61105. cap?: number;
  61106. sideOrientation?: number;
  61107. frontUVs?: Vector4;
  61108. backUVs?: Vector4;
  61109. }, scene?: Nullable<Scene>): Mesh;
  61110. /**
  61111. * Creates a torus mesh
  61112. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61113. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61114. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61118. * @param name defines the name of the mesh
  61119. * @param options defines the options used to create the mesh
  61120. * @param scene defines the hosting scene
  61121. * @returns the torus mesh
  61122. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61123. */
  61124. static CreateTorus(name: string, options: {
  61125. diameter?: number;
  61126. thickness?: number;
  61127. tessellation?: number;
  61128. updatable?: boolean;
  61129. sideOrientation?: number;
  61130. frontUVs?: Vector4;
  61131. backUVs?: Vector4;
  61132. }, scene?: Nullable<Scene>): Mesh;
  61133. /**
  61134. * Creates a torus knot mesh
  61135. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61136. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61137. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61138. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61142. * @param name defines the name of the mesh
  61143. * @param options defines the options used to create the mesh
  61144. * @param scene defines the hosting scene
  61145. * @returns the torus knot mesh
  61146. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61147. */
  61148. static CreateTorusKnot(name: string, options: {
  61149. radius?: number;
  61150. tube?: number;
  61151. radialSegments?: number;
  61152. tubularSegments?: number;
  61153. p?: number;
  61154. q?: number;
  61155. updatable?: boolean;
  61156. sideOrientation?: number;
  61157. frontUVs?: Vector4;
  61158. backUVs?: Vector4;
  61159. }, scene?: Nullable<Scene>): Mesh;
  61160. /**
  61161. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61162. * * 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
  61163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61164. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61165. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61166. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61167. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61168. * * 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
  61169. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61172. * @param name defines the name of the new line system
  61173. * @param options defines the options used to create the line system
  61174. * @param scene defines the hosting scene
  61175. * @returns a new line system mesh
  61176. */
  61177. static CreateLineSystem(name: string, options: {
  61178. lines: Vector3[][];
  61179. updatable?: boolean;
  61180. instance?: Nullable<LinesMesh>;
  61181. colors?: Nullable<Color4[][]>;
  61182. useVertexAlpha?: boolean;
  61183. }, scene: Nullable<Scene>): LinesMesh;
  61184. /**
  61185. * Creates a line mesh
  61186. * 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
  61187. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61188. * * The parameter `points` is an array successive Vector3
  61189. * * 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
  61190. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61191. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61192. * * When updating an instance, remember that only point positions can change, not the number of points
  61193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61195. * @param name defines the name of the new line system
  61196. * @param options defines the options used to create the line system
  61197. * @param scene defines the hosting scene
  61198. * @returns a new line mesh
  61199. */
  61200. static CreateLines(name: string, options: {
  61201. points: Vector3[];
  61202. updatable?: boolean;
  61203. instance?: Nullable<LinesMesh>;
  61204. colors?: Color4[];
  61205. useVertexAlpha?: boolean;
  61206. }, scene?: Nullable<Scene>): LinesMesh;
  61207. /**
  61208. * Creates a dashed line mesh
  61209. * * 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
  61210. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61211. * * The parameter `points` is an array successive Vector3
  61212. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61213. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61214. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61215. * * 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
  61216. * * When updating an instance, remember that only point positions can change, not the number of points
  61217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61218. * @param name defines the name of the mesh
  61219. * @param options defines the options used to create the mesh
  61220. * @param scene defines the hosting scene
  61221. * @returns the dashed line mesh
  61222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61223. */
  61224. static CreateDashedLines(name: string, options: {
  61225. points: Vector3[];
  61226. dashSize?: number;
  61227. gapSize?: number;
  61228. dashNb?: number;
  61229. updatable?: boolean;
  61230. instance?: LinesMesh;
  61231. }, scene?: Nullable<Scene>): LinesMesh;
  61232. /**
  61233. * 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.
  61234. * * 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.
  61235. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61236. * * 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.
  61237. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61238. * * 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
  61239. * * 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
  61240. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61245. * @param name defines the name of the mesh
  61246. * @param options defines the options used to create the mesh
  61247. * @param scene defines the hosting scene
  61248. * @returns the extruded shape mesh
  61249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61251. */
  61252. static ExtrudeShape(name: string, options: {
  61253. shape: Vector3[];
  61254. path: Vector3[];
  61255. scale?: number;
  61256. rotation?: number;
  61257. cap?: number;
  61258. updatable?: boolean;
  61259. sideOrientation?: number;
  61260. frontUVs?: Vector4;
  61261. backUVs?: Vector4;
  61262. instance?: Mesh;
  61263. invertUV?: boolean;
  61264. }, scene?: Nullable<Scene>): Mesh;
  61265. /**
  61266. * Creates an custom extruded shape mesh.
  61267. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61268. * * 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.
  61269. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61270. * * 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
  61271. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61272. * * 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
  61273. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61274. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61275. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61276. * * 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
  61277. * * 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
  61278. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61281. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61283. * @param name defines the name of the mesh
  61284. * @param options defines the options used to create the mesh
  61285. * @param scene defines the hosting scene
  61286. * @returns the custom extruded shape mesh
  61287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61290. */
  61291. static ExtrudeShapeCustom(name: string, options: {
  61292. shape: Vector3[];
  61293. path: Vector3[];
  61294. scaleFunction?: any;
  61295. rotationFunction?: any;
  61296. ribbonCloseArray?: boolean;
  61297. ribbonClosePath?: boolean;
  61298. cap?: number;
  61299. updatable?: boolean;
  61300. sideOrientation?: number;
  61301. frontUVs?: Vector4;
  61302. backUVs?: Vector4;
  61303. instance?: Mesh;
  61304. invertUV?: boolean;
  61305. }, scene?: Nullable<Scene>): Mesh;
  61306. /**
  61307. * Creates lathe mesh.
  61308. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61309. * * 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
  61310. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61311. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61312. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61313. * * 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
  61314. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61315. * * 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
  61316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61318. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61320. * @param name defines the name of the mesh
  61321. * @param options defines the options used to create the mesh
  61322. * @param scene defines the hosting scene
  61323. * @returns the lathe mesh
  61324. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61325. */
  61326. static CreateLathe(name: string, options: {
  61327. shape: Vector3[];
  61328. radius?: number;
  61329. tessellation?: number;
  61330. clip?: number;
  61331. arc?: number;
  61332. closed?: boolean;
  61333. updatable?: boolean;
  61334. sideOrientation?: number;
  61335. frontUVs?: Vector4;
  61336. backUVs?: Vector4;
  61337. cap?: number;
  61338. invertUV?: boolean;
  61339. }, scene?: Nullable<Scene>): Mesh;
  61340. /**
  61341. * Creates a tiled plane mesh
  61342. * * You can set a limited pattern arrangement with the tiles
  61343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61346. * @param name defines the name of the mesh
  61347. * @param options defines the options used to create the mesh
  61348. * @param scene defines the hosting scene
  61349. * @returns the plane mesh
  61350. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61351. */
  61352. static CreateTiledPlane(name: string, options: {
  61353. pattern?: number;
  61354. tileSize?: number;
  61355. tileWidth?: number;
  61356. tileHeight?: number;
  61357. size?: number;
  61358. width?: number;
  61359. height?: number;
  61360. alignHorizontal?: number;
  61361. alignVertical?: number;
  61362. sideOrientation?: number;
  61363. frontUVs?: Vector4;
  61364. backUVs?: Vector4;
  61365. updatable?: boolean;
  61366. }, scene?: Nullable<Scene>): Mesh;
  61367. /**
  61368. * Creates a plane mesh
  61369. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61370. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61371. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61375. * @param name defines the name of the mesh
  61376. * @param options defines the options used to create the mesh
  61377. * @param scene defines the hosting scene
  61378. * @returns the plane mesh
  61379. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61380. */
  61381. static CreatePlane(name: string, options: {
  61382. size?: number;
  61383. width?: number;
  61384. height?: number;
  61385. sideOrientation?: number;
  61386. frontUVs?: Vector4;
  61387. backUVs?: Vector4;
  61388. updatable?: boolean;
  61389. sourcePlane?: Plane;
  61390. }, scene?: Nullable<Scene>): Mesh;
  61391. /**
  61392. * Creates a ground mesh
  61393. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61394. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61396. * @param name defines the name of the mesh
  61397. * @param options defines the options used to create the mesh
  61398. * @param scene defines the hosting scene
  61399. * @returns the ground mesh
  61400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61401. */
  61402. static CreateGround(name: string, options: {
  61403. width?: number;
  61404. height?: number;
  61405. subdivisions?: number;
  61406. subdivisionsX?: number;
  61407. subdivisionsY?: number;
  61408. updatable?: boolean;
  61409. }, scene?: Nullable<Scene>): Mesh;
  61410. /**
  61411. * Creates a tiled ground mesh
  61412. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61413. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61414. * * 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
  61415. * * 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
  61416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61417. * @param name defines the name of the mesh
  61418. * @param options defines the options used to create the mesh
  61419. * @param scene defines the hosting scene
  61420. * @returns the tiled ground mesh
  61421. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61422. */
  61423. static CreateTiledGround(name: string, options: {
  61424. xmin: number;
  61425. zmin: number;
  61426. xmax: number;
  61427. zmax: number;
  61428. subdivisions?: {
  61429. w: number;
  61430. h: number;
  61431. };
  61432. precision?: {
  61433. w: number;
  61434. h: number;
  61435. };
  61436. updatable?: boolean;
  61437. }, scene?: Nullable<Scene>): Mesh;
  61438. /**
  61439. * Creates a ground mesh from a height map
  61440. * * The parameter `url` sets the URL of the height map image resource.
  61441. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61442. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61443. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61444. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61445. * * 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.
  61446. * * 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).
  61447. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61449. * @param name defines the name of the mesh
  61450. * @param url defines the url to the height map
  61451. * @param options defines the options used to create the mesh
  61452. * @param scene defines the hosting scene
  61453. * @returns the ground mesh
  61454. * @see https://doc.babylonjs.com/babylon101/height_map
  61455. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61456. */
  61457. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61458. width?: number;
  61459. height?: number;
  61460. subdivisions?: number;
  61461. minHeight?: number;
  61462. maxHeight?: number;
  61463. colorFilter?: Color3;
  61464. alphaFilter?: number;
  61465. updatable?: boolean;
  61466. onReady?: (mesh: GroundMesh) => void;
  61467. }, scene?: Nullable<Scene>): GroundMesh;
  61468. /**
  61469. * Creates a polygon mesh
  61470. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61471. * * 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
  61472. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61475. * * Remember you can only change the shape positions, not their number when updating a polygon
  61476. * @param name defines the name of the mesh
  61477. * @param options defines the options used to create the mesh
  61478. * @param scene defines the hosting scene
  61479. * @param earcutInjection can be used to inject your own earcut reference
  61480. * @returns the polygon mesh
  61481. */
  61482. static CreatePolygon(name: string, options: {
  61483. shape: Vector3[];
  61484. holes?: Vector3[][];
  61485. depth?: number;
  61486. faceUV?: Vector4[];
  61487. faceColors?: Color4[];
  61488. updatable?: boolean;
  61489. sideOrientation?: number;
  61490. frontUVs?: Vector4;
  61491. backUVs?: Vector4;
  61492. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61493. /**
  61494. * Creates an extruded polygon mesh, with depth in the Y direction.
  61495. * * 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)
  61496. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61497. * @param name defines the name of the mesh
  61498. * @param options defines the options used to create the mesh
  61499. * @param scene defines the hosting scene
  61500. * @param earcutInjection can be used to inject your own earcut reference
  61501. * @returns the polygon mesh
  61502. */
  61503. static ExtrudePolygon(name: string, options: {
  61504. shape: Vector3[];
  61505. holes?: Vector3[][];
  61506. depth?: number;
  61507. faceUV?: Vector4[];
  61508. faceColors?: Color4[];
  61509. updatable?: boolean;
  61510. sideOrientation?: number;
  61511. frontUVs?: Vector4;
  61512. backUVs?: Vector4;
  61513. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61514. /**
  61515. * Creates a tube mesh.
  61516. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61517. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61518. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61519. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61520. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61521. * * 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)
  61522. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61523. * * 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
  61524. * * 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
  61525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61527. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61529. * @param name defines the name of the mesh
  61530. * @param options defines the options used to create the mesh
  61531. * @param scene defines the hosting scene
  61532. * @returns the tube mesh
  61533. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61534. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61535. */
  61536. static CreateTube(name: string, options: {
  61537. path: Vector3[];
  61538. radius?: number;
  61539. tessellation?: number;
  61540. radiusFunction?: {
  61541. (i: number, distance: number): number;
  61542. };
  61543. cap?: number;
  61544. arc?: number;
  61545. updatable?: boolean;
  61546. sideOrientation?: number;
  61547. frontUVs?: Vector4;
  61548. backUVs?: Vector4;
  61549. instance?: Mesh;
  61550. invertUV?: boolean;
  61551. }, scene?: Nullable<Scene>): Mesh;
  61552. /**
  61553. * Creates a polyhedron mesh
  61554. * * 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
  61555. * * The parameter `size` (positive float, default 1) sets the polygon size
  61556. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61557. * * 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`
  61558. * * 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
  61559. * * 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)`)
  61560. * * 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
  61561. * * 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
  61562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61565. * @param name defines the name of the mesh
  61566. * @param options defines the options used to create the mesh
  61567. * @param scene defines the hosting scene
  61568. * @returns the polyhedron mesh
  61569. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61570. */
  61571. static CreatePolyhedron(name: string, options: {
  61572. type?: number;
  61573. size?: number;
  61574. sizeX?: number;
  61575. sizeY?: number;
  61576. sizeZ?: number;
  61577. custom?: any;
  61578. faceUV?: Vector4[];
  61579. faceColors?: Color4[];
  61580. flat?: boolean;
  61581. updatable?: boolean;
  61582. sideOrientation?: number;
  61583. frontUVs?: Vector4;
  61584. backUVs?: Vector4;
  61585. }, scene?: Nullable<Scene>): Mesh;
  61586. /**
  61587. * Creates a decal mesh.
  61588. * 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
  61589. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61590. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61591. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61592. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61593. * @param name defines the name of the mesh
  61594. * @param sourceMesh defines the mesh where the decal must be applied
  61595. * @param options defines the options used to create the mesh
  61596. * @param scene defines the hosting scene
  61597. * @returns the decal mesh
  61598. * @see https://doc.babylonjs.com/how_to/decals
  61599. */
  61600. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61601. position?: Vector3;
  61602. normal?: Vector3;
  61603. size?: Vector3;
  61604. angle?: number;
  61605. }): Mesh;
  61606. }
  61607. }
  61608. declare module "babylonjs/Meshes/meshSimplification" {
  61609. import { Mesh } from "babylonjs/Meshes/mesh";
  61610. /**
  61611. * A simplifier interface for future simplification implementations
  61612. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61613. */
  61614. export interface ISimplifier {
  61615. /**
  61616. * Simplification of a given mesh according to the given settings.
  61617. * Since this requires computation, it is assumed that the function runs async.
  61618. * @param settings The settings of the simplification, including quality and distance
  61619. * @param successCallback A callback that will be called after the mesh was simplified.
  61620. * @param errorCallback in case of an error, this callback will be called. optional.
  61621. */
  61622. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61623. }
  61624. /**
  61625. * Expected simplification settings.
  61626. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61627. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61628. */
  61629. export interface ISimplificationSettings {
  61630. /**
  61631. * Gets or sets the expected quality
  61632. */
  61633. quality: number;
  61634. /**
  61635. * Gets or sets the distance when this optimized version should be used
  61636. */
  61637. distance: number;
  61638. /**
  61639. * Gets an already optimized mesh
  61640. */
  61641. optimizeMesh?: boolean;
  61642. }
  61643. /**
  61644. * Class used to specify simplification options
  61645. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61646. */
  61647. export class SimplificationSettings implements ISimplificationSettings {
  61648. /** expected quality */
  61649. quality: number;
  61650. /** distance when this optimized version should be used */
  61651. distance: number;
  61652. /** already optimized mesh */
  61653. optimizeMesh?: boolean | undefined;
  61654. /**
  61655. * Creates a SimplificationSettings
  61656. * @param quality expected quality
  61657. * @param distance distance when this optimized version should be used
  61658. * @param optimizeMesh already optimized mesh
  61659. */
  61660. constructor(
  61661. /** expected quality */
  61662. quality: number,
  61663. /** distance when this optimized version should be used */
  61664. distance: number,
  61665. /** already optimized mesh */
  61666. optimizeMesh?: boolean | undefined);
  61667. }
  61668. /**
  61669. * Interface used to define a simplification task
  61670. */
  61671. export interface ISimplificationTask {
  61672. /**
  61673. * Array of settings
  61674. */
  61675. settings: Array<ISimplificationSettings>;
  61676. /**
  61677. * Simplification type
  61678. */
  61679. simplificationType: SimplificationType;
  61680. /**
  61681. * Mesh to simplify
  61682. */
  61683. mesh: Mesh;
  61684. /**
  61685. * Callback called on success
  61686. */
  61687. successCallback?: () => void;
  61688. /**
  61689. * Defines if parallel processing can be used
  61690. */
  61691. parallelProcessing: boolean;
  61692. }
  61693. /**
  61694. * Queue used to order the simplification tasks
  61695. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61696. */
  61697. export class SimplificationQueue {
  61698. private _simplificationArray;
  61699. /**
  61700. * Gets a boolean indicating that the process is still running
  61701. */
  61702. running: boolean;
  61703. /**
  61704. * Creates a new queue
  61705. */
  61706. constructor();
  61707. /**
  61708. * Adds a new simplification task
  61709. * @param task defines a task to add
  61710. */
  61711. addTask(task: ISimplificationTask): void;
  61712. /**
  61713. * Execute next task
  61714. */
  61715. executeNext(): void;
  61716. /**
  61717. * Execute a simplification task
  61718. * @param task defines the task to run
  61719. */
  61720. runSimplification(task: ISimplificationTask): void;
  61721. private getSimplifier;
  61722. }
  61723. /**
  61724. * The implemented types of simplification
  61725. * At the moment only Quadratic Error Decimation is implemented
  61726. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61727. */
  61728. export enum SimplificationType {
  61729. /** Quadratic error decimation */
  61730. QUADRATIC = 0
  61731. }
  61732. }
  61733. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61734. import { Scene } from "babylonjs/scene";
  61735. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61736. import { ISceneComponent } from "babylonjs/sceneComponent";
  61737. module "babylonjs/scene" {
  61738. interface Scene {
  61739. /** @hidden (Backing field) */
  61740. _simplificationQueue: SimplificationQueue;
  61741. /**
  61742. * Gets or sets the simplification queue attached to the scene
  61743. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61744. */
  61745. simplificationQueue: SimplificationQueue;
  61746. }
  61747. }
  61748. module "babylonjs/Meshes/mesh" {
  61749. interface Mesh {
  61750. /**
  61751. * Simplify the mesh according to the given array of settings.
  61752. * Function will return immediately and will simplify async
  61753. * @param settings a collection of simplification settings
  61754. * @param parallelProcessing should all levels calculate parallel or one after the other
  61755. * @param simplificationType the type of simplification to run
  61756. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61757. * @returns the current mesh
  61758. */
  61759. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61760. }
  61761. }
  61762. /**
  61763. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61764. * created in a scene
  61765. */
  61766. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61767. /**
  61768. * The component name helpfull to identify the component in the list of scene components.
  61769. */
  61770. readonly name: string;
  61771. /**
  61772. * The scene the component belongs to.
  61773. */
  61774. scene: Scene;
  61775. /**
  61776. * Creates a new instance of the component for the given scene
  61777. * @param scene Defines the scene to register the component in
  61778. */
  61779. constructor(scene: Scene);
  61780. /**
  61781. * Registers the component in a given scene
  61782. */
  61783. register(): void;
  61784. /**
  61785. * Rebuilds the elements related to this component in case of
  61786. * context lost for instance.
  61787. */
  61788. rebuild(): void;
  61789. /**
  61790. * Disposes the component and the associated ressources
  61791. */
  61792. dispose(): void;
  61793. private _beforeCameraUpdate;
  61794. }
  61795. }
  61796. declare module "babylonjs/Meshes/Builders/index" {
  61797. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61798. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61799. export * from "babylonjs/Meshes/Builders/discBuilder";
  61800. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61801. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61802. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61803. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61804. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61805. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61806. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61807. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61808. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61809. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61810. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61811. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61812. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61813. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61814. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61815. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61816. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61817. }
  61818. declare module "babylonjs/Meshes/index" {
  61819. export * from "babylonjs/Meshes/abstractMesh";
  61820. export * from "babylonjs/Meshes/buffer";
  61821. export * from "babylonjs/Meshes/Compression/index";
  61822. export * from "babylonjs/Meshes/csg";
  61823. export * from "babylonjs/Meshes/geometry";
  61824. export * from "babylonjs/Meshes/groundMesh";
  61825. export * from "babylonjs/Meshes/trailMesh";
  61826. export * from "babylonjs/Meshes/instancedMesh";
  61827. export * from "babylonjs/Meshes/linesMesh";
  61828. export * from "babylonjs/Meshes/mesh";
  61829. export * from "babylonjs/Meshes/mesh.vertexData";
  61830. export * from "babylonjs/Meshes/meshBuilder";
  61831. export * from "babylonjs/Meshes/meshSimplification";
  61832. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61833. export * from "babylonjs/Meshes/polygonMesh";
  61834. export * from "babylonjs/Meshes/subMesh";
  61835. export * from "babylonjs/Meshes/meshLODLevel";
  61836. export * from "babylonjs/Meshes/transformNode";
  61837. export * from "babylonjs/Meshes/Builders/index";
  61838. export * from "babylonjs/Meshes/dataBuffer";
  61839. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61840. }
  61841. declare module "babylonjs/Morph/index" {
  61842. export * from "babylonjs/Morph/morphTarget";
  61843. export * from "babylonjs/Morph/morphTargetManager";
  61844. }
  61845. declare module "babylonjs/Navigation/INavigationEngine" {
  61846. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61847. import { Vector3 } from "babylonjs/Maths/math";
  61848. import { Mesh } from "babylonjs/Meshes/mesh";
  61849. import { Scene } from "babylonjs/scene";
  61850. /**
  61851. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61852. */
  61853. export interface INavigationEnginePlugin {
  61854. /**
  61855. * plugin name
  61856. */
  61857. name: string;
  61858. /**
  61859. * Creates a navigation mesh
  61860. * @param meshes array of all the geometry used to compute the navigatio mesh
  61861. * @param parameters bunch of parameters used to filter geometry
  61862. */
  61863. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61864. /**
  61865. * Create a navigation mesh debug mesh
  61866. * @param scene is where the mesh will be added
  61867. * @returns debug display mesh
  61868. */
  61869. createDebugNavMesh(scene: Scene): Mesh;
  61870. /**
  61871. * Get a navigation mesh constrained position, closest to the parameter position
  61872. * @param position world position
  61873. * @returns the closest point to position constrained by the navigation mesh
  61874. */
  61875. getClosestPoint(position: Vector3): Vector3;
  61876. /**
  61877. * Get a navigation mesh constrained position, within a particular radius
  61878. * @param position world position
  61879. * @param maxRadius the maximum distance to the constrained world position
  61880. * @returns the closest point to position constrained by the navigation mesh
  61881. */
  61882. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61883. /**
  61884. * Compute the final position from a segment made of destination-position
  61885. * @param position world position
  61886. * @param destination world position
  61887. * @returns the resulting point along the navmesh
  61888. */
  61889. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61890. /**
  61891. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61892. * @param start world position
  61893. * @param end world position
  61894. * @returns array containing world position composing the path
  61895. */
  61896. computePath(start: Vector3, end: Vector3): Vector3[];
  61897. /**
  61898. * If this plugin is supported
  61899. * @returns true if plugin is supported
  61900. */
  61901. isSupported(): boolean;
  61902. /**
  61903. * Create a new Crowd so you can add agents
  61904. * @param maxAgents the maximum agent count in the crowd
  61905. * @param maxAgentRadius the maximum radius an agent can have
  61906. * @param scene to attach the crowd to
  61907. * @returns the crowd you can add agents to
  61908. */
  61909. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61910. /**
  61911. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61912. * The queries will try to find a solution within those bounds
  61913. * default is (1,1,1)
  61914. * @param extent x,y,z value that define the extent around the queries point of reference
  61915. */
  61916. setDefaultQueryExtent(extent: Vector3): void;
  61917. /**
  61918. * Get the Bounding box extent specified by setDefaultQueryExtent
  61919. * @returns the box extent values
  61920. */
  61921. getDefaultQueryExtent(): Vector3;
  61922. /**
  61923. * Release all resources
  61924. */
  61925. dispose(): void;
  61926. }
  61927. /**
  61928. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61929. */
  61930. export interface ICrowd {
  61931. /**
  61932. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61933. * You can attach anything to that node. The node position is updated in the scene update tick.
  61934. * @param pos world position that will be constrained by the navigation mesh
  61935. * @param parameters agent parameters
  61936. * @param transform hooked to the agent that will be update by the scene
  61937. * @returns agent index
  61938. */
  61939. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61940. /**
  61941. * Returns the agent position in world space
  61942. * @param index agent index returned by addAgent
  61943. * @returns world space position
  61944. */
  61945. getAgentPosition(index: number): Vector3;
  61946. /**
  61947. * Gets the agent velocity in world space
  61948. * @param index agent index returned by addAgent
  61949. * @returns world space velocity
  61950. */
  61951. getAgentVelocity(index: number): Vector3;
  61952. /**
  61953. * remove a particular agent previously created
  61954. * @param index agent index returned by addAgent
  61955. */
  61956. removeAgent(index: number): void;
  61957. /**
  61958. * get the list of all agents attached to this crowd
  61959. * @returns list of agent indices
  61960. */
  61961. getAgents(): number[];
  61962. /**
  61963. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61964. * @param deltaTime in seconds
  61965. */
  61966. update(deltaTime: number): void;
  61967. /**
  61968. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61969. * @param index agent index returned by addAgent
  61970. * @param destination targeted world position
  61971. */
  61972. agentGoto(index: number, destination: Vector3): void;
  61973. /**
  61974. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61975. * The queries will try to find a solution within those bounds
  61976. * default is (1,1,1)
  61977. * @param extent x,y,z value that define the extent around the queries point of reference
  61978. */
  61979. setDefaultQueryExtent(extent: Vector3): void;
  61980. /**
  61981. * Get the Bounding box extent specified by setDefaultQueryExtent
  61982. * @returns the box extent values
  61983. */
  61984. getDefaultQueryExtent(): Vector3;
  61985. /**
  61986. * Release all resources
  61987. */
  61988. dispose(): void;
  61989. }
  61990. /**
  61991. * Configures an agent
  61992. */
  61993. export interface IAgentParameters {
  61994. /**
  61995. * Agent radius. [Limit: >= 0]
  61996. */
  61997. radius: number;
  61998. /**
  61999. * Agent height. [Limit: > 0]
  62000. */
  62001. height: number;
  62002. /**
  62003. * Maximum allowed acceleration. [Limit: >= 0]
  62004. */
  62005. maxAcceleration: number;
  62006. /**
  62007. * Maximum allowed speed. [Limit: >= 0]
  62008. */
  62009. maxSpeed: number;
  62010. /**
  62011. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62012. */
  62013. collisionQueryRange: number;
  62014. /**
  62015. * The path visibility optimization range. [Limit: > 0]
  62016. */
  62017. pathOptimizationRange: number;
  62018. /**
  62019. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62020. */
  62021. separationWeight: number;
  62022. }
  62023. /**
  62024. * Configures the navigation mesh creation
  62025. */
  62026. export interface INavMeshParameters {
  62027. /**
  62028. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62029. */
  62030. cs: number;
  62031. /**
  62032. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62033. */
  62034. ch: number;
  62035. /**
  62036. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62037. */
  62038. walkableSlopeAngle: number;
  62039. /**
  62040. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62041. * be considered walkable. [Limit: >= 3] [Units: vx]
  62042. */
  62043. walkableHeight: number;
  62044. /**
  62045. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62046. */
  62047. walkableClimb: number;
  62048. /**
  62049. * The distance to erode/shrink the walkable area of the heightfield away from
  62050. * obstructions. [Limit: >=0] [Units: vx]
  62051. */
  62052. walkableRadius: number;
  62053. /**
  62054. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62055. */
  62056. maxEdgeLen: number;
  62057. /**
  62058. * The maximum distance a simplfied contour's border edges should deviate
  62059. * the original raw contour. [Limit: >=0] [Units: vx]
  62060. */
  62061. maxSimplificationError: number;
  62062. /**
  62063. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62064. */
  62065. minRegionArea: number;
  62066. /**
  62067. * Any regions with a span count smaller than this value will, if possible,
  62068. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62069. */
  62070. mergeRegionArea: number;
  62071. /**
  62072. * The maximum number of vertices allowed for polygons generated during the
  62073. * contour to polygon conversion process. [Limit: >= 3]
  62074. */
  62075. maxVertsPerPoly: number;
  62076. /**
  62077. * Sets the sampling distance to use when generating the detail mesh.
  62078. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62079. */
  62080. detailSampleDist: number;
  62081. /**
  62082. * The maximum distance the detail mesh surface should deviate from heightfield
  62083. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62084. */
  62085. detailSampleMaxError: number;
  62086. }
  62087. }
  62088. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62089. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62090. import { Mesh } from "babylonjs/Meshes/mesh";
  62091. import { Scene } from "babylonjs/scene";
  62092. import { Vector3 } from "babylonjs/Maths/math";
  62093. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62094. /**
  62095. * RecastJS navigation plugin
  62096. */
  62097. export class RecastJSPlugin implements INavigationEnginePlugin {
  62098. /**
  62099. * Reference to the Recast library
  62100. */
  62101. bjsRECAST: any;
  62102. /**
  62103. * plugin name
  62104. */
  62105. name: string;
  62106. /**
  62107. * the first navmesh created. We might extend this to support multiple navmeshes
  62108. */
  62109. navMesh: any;
  62110. /**
  62111. * Initializes the recastJS plugin
  62112. * @param recastInjection can be used to inject your own recast reference
  62113. */
  62114. constructor(recastInjection?: any);
  62115. /**
  62116. * Creates a navigation mesh
  62117. * @param meshes array of all the geometry used to compute the navigatio mesh
  62118. * @param parameters bunch of parameters used to filter geometry
  62119. */
  62120. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62121. /**
  62122. * Create a navigation mesh debug mesh
  62123. * @param scene is where the mesh will be added
  62124. * @returns debug display mesh
  62125. */
  62126. createDebugNavMesh(scene: Scene): Mesh;
  62127. /**
  62128. * Get a navigation mesh constrained position, closest to the parameter position
  62129. * @param position world position
  62130. * @returns the closest point to position constrained by the navigation mesh
  62131. */
  62132. getClosestPoint(position: Vector3): Vector3;
  62133. /**
  62134. * Get a navigation mesh constrained position, within a particular radius
  62135. * @param position world position
  62136. * @param maxRadius the maximum distance to the constrained world position
  62137. * @returns the closest point to position constrained by the navigation mesh
  62138. */
  62139. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62140. /**
  62141. * Compute the final position from a segment made of destination-position
  62142. * @param position world position
  62143. * @param destination world position
  62144. * @returns the resulting point along the navmesh
  62145. */
  62146. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62147. /**
  62148. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62149. * @param start world position
  62150. * @param end world position
  62151. * @returns array containing world position composing the path
  62152. */
  62153. computePath(start: Vector3, end: Vector3): Vector3[];
  62154. /**
  62155. * Create a new Crowd so you can add agents
  62156. * @param maxAgents the maximum agent count in the crowd
  62157. * @param maxAgentRadius the maximum radius an agent can have
  62158. * @param scene to attach the crowd to
  62159. * @returns the crowd you can add agents to
  62160. */
  62161. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62162. /**
  62163. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62164. * The queries will try to find a solution within those bounds
  62165. * default is (1,1,1)
  62166. * @param extent x,y,z value that define the extent around the queries point of reference
  62167. */
  62168. setDefaultQueryExtent(extent: Vector3): void;
  62169. /**
  62170. * Get the Bounding box extent specified by setDefaultQueryExtent
  62171. * @returns the box extent values
  62172. */
  62173. getDefaultQueryExtent(): Vector3;
  62174. /**
  62175. * Disposes
  62176. */
  62177. dispose(): void;
  62178. /**
  62179. * If this plugin is supported
  62180. * @returns true if plugin is supported
  62181. */
  62182. isSupported(): boolean;
  62183. }
  62184. /**
  62185. * Recast detour crowd implementation
  62186. */
  62187. export class RecastJSCrowd implements ICrowd {
  62188. /**
  62189. * Recast/detour plugin
  62190. */
  62191. bjsRECASTPlugin: RecastJSPlugin;
  62192. /**
  62193. * Link to the detour crowd
  62194. */
  62195. recastCrowd: any;
  62196. /**
  62197. * One transform per agent
  62198. */
  62199. transforms: TransformNode[];
  62200. /**
  62201. * All agents created
  62202. */
  62203. agents: number[];
  62204. /**
  62205. * Link to the scene is kept to unregister the crowd from the scene
  62206. */
  62207. private _scene;
  62208. /**
  62209. * Observer for crowd updates
  62210. */
  62211. private _onBeforeAnimationsObserver;
  62212. /**
  62213. * Constructor
  62214. * @param plugin recastJS plugin
  62215. * @param maxAgents the maximum agent count in the crowd
  62216. * @param maxAgentRadius the maximum radius an agent can have
  62217. * @param scene to attach the crowd to
  62218. * @returns the crowd you can add agents to
  62219. */
  62220. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62221. /**
  62222. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62223. * You can attach anything to that node. The node position is updated in the scene update tick.
  62224. * @param pos world position that will be constrained by the navigation mesh
  62225. * @param parameters agent parameters
  62226. * @param transform hooked to the agent that will be update by the scene
  62227. * @returns agent index
  62228. */
  62229. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62230. /**
  62231. * Returns the agent position in world space
  62232. * @param index agent index returned by addAgent
  62233. * @returns world space position
  62234. */
  62235. getAgentPosition(index: number): Vector3;
  62236. /**
  62237. * Returns the agent velocity in world space
  62238. * @param index agent index returned by addAgent
  62239. * @returns world space velocity
  62240. */
  62241. getAgentVelocity(index: number): Vector3;
  62242. /**
  62243. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62244. * @param index agent index returned by addAgent
  62245. * @param destination targeted world position
  62246. */
  62247. agentGoto(index: number, destination: Vector3): void;
  62248. /**
  62249. * remove a particular agent previously created
  62250. * @param index agent index returned by addAgent
  62251. */
  62252. removeAgent(index: number): void;
  62253. /**
  62254. * get the list of all agents attached to this crowd
  62255. * @returns list of agent indices
  62256. */
  62257. getAgents(): number[];
  62258. /**
  62259. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62260. * @param deltaTime in seconds
  62261. */
  62262. update(deltaTime: number): void;
  62263. /**
  62264. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62265. * The queries will try to find a solution within those bounds
  62266. * default is (1,1,1)
  62267. * @param extent x,y,z value that define the extent around the queries point of reference
  62268. */
  62269. setDefaultQueryExtent(extent: Vector3): void;
  62270. /**
  62271. * Get the Bounding box extent specified by setDefaultQueryExtent
  62272. * @returns the box extent values
  62273. */
  62274. getDefaultQueryExtent(): Vector3;
  62275. /**
  62276. * Release all resources
  62277. */
  62278. dispose(): void;
  62279. }
  62280. }
  62281. declare module "babylonjs/Navigation/Plugins/index" {
  62282. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62283. }
  62284. declare module "babylonjs/Navigation/index" {
  62285. export * from "babylonjs/Navigation/INavigationEngine";
  62286. export * from "babylonjs/Navigation/Plugins/index";
  62287. }
  62288. declare module "babylonjs/Offline/database" {
  62289. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62290. /**
  62291. * Class used to enable access to IndexedDB
  62292. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62293. */
  62294. export class Database implements IOfflineProvider {
  62295. private _callbackManifestChecked;
  62296. private _currentSceneUrl;
  62297. private _db;
  62298. private _enableSceneOffline;
  62299. private _enableTexturesOffline;
  62300. private _manifestVersionFound;
  62301. private _mustUpdateRessources;
  62302. private _hasReachedQuota;
  62303. private _isSupported;
  62304. private _idbFactory;
  62305. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62306. private static IsUASupportingBlobStorage;
  62307. /**
  62308. * Gets a boolean indicating if Database storate is enabled (off by default)
  62309. */
  62310. static IDBStorageEnabled: boolean;
  62311. /**
  62312. * Gets a boolean indicating if scene must be saved in the database
  62313. */
  62314. readonly enableSceneOffline: boolean;
  62315. /**
  62316. * Gets a boolean indicating if textures must be saved in the database
  62317. */
  62318. readonly enableTexturesOffline: boolean;
  62319. /**
  62320. * Creates a new Database
  62321. * @param urlToScene defines the url to load the scene
  62322. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62323. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62324. */
  62325. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62326. private static _ParseURL;
  62327. private static _ReturnFullUrlLocation;
  62328. private _checkManifestFile;
  62329. /**
  62330. * Open the database and make it available
  62331. * @param successCallback defines the callback to call on success
  62332. * @param errorCallback defines the callback to call on error
  62333. */
  62334. open(successCallback: () => void, errorCallback: () => void): void;
  62335. /**
  62336. * Loads an image from the database
  62337. * @param url defines the url to load from
  62338. * @param image defines the target DOM image
  62339. */
  62340. loadImage(url: string, image: HTMLImageElement): void;
  62341. private _loadImageFromDBAsync;
  62342. private _saveImageIntoDBAsync;
  62343. private _checkVersionFromDB;
  62344. private _loadVersionFromDBAsync;
  62345. private _saveVersionIntoDBAsync;
  62346. /**
  62347. * Loads a file from database
  62348. * @param url defines the URL to load from
  62349. * @param sceneLoaded defines a callback to call on success
  62350. * @param progressCallBack defines a callback to call when progress changed
  62351. * @param errorCallback defines a callback to call on error
  62352. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62353. */
  62354. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62355. private _loadFileAsync;
  62356. private _saveFileAsync;
  62357. /**
  62358. * Validates if xhr data is correct
  62359. * @param xhr defines the request to validate
  62360. * @param dataType defines the expected data type
  62361. * @returns true if data is correct
  62362. */
  62363. private static _ValidateXHRData;
  62364. }
  62365. }
  62366. declare module "babylonjs/Offline/index" {
  62367. export * from "babylonjs/Offline/database";
  62368. export * from "babylonjs/Offline/IOfflineProvider";
  62369. }
  62370. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62371. /** @hidden */
  62372. export var gpuUpdateParticlesPixelShader: {
  62373. name: string;
  62374. shader: string;
  62375. };
  62376. }
  62377. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62378. /** @hidden */
  62379. export var gpuUpdateParticlesVertexShader: {
  62380. name: string;
  62381. shader: string;
  62382. };
  62383. }
  62384. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62385. /** @hidden */
  62386. export var clipPlaneFragmentDeclaration2: {
  62387. name: string;
  62388. shader: string;
  62389. };
  62390. }
  62391. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62392. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62393. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62394. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62395. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62396. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62397. /** @hidden */
  62398. export var gpuRenderParticlesPixelShader: {
  62399. name: string;
  62400. shader: string;
  62401. };
  62402. }
  62403. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62404. /** @hidden */
  62405. export var clipPlaneVertexDeclaration2: {
  62406. name: string;
  62407. shader: string;
  62408. };
  62409. }
  62410. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62411. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62412. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62413. /** @hidden */
  62414. export var gpuRenderParticlesVertexShader: {
  62415. name: string;
  62416. shader: string;
  62417. };
  62418. }
  62419. declare module "babylonjs/Particles/gpuParticleSystem" {
  62420. import { Nullable } from "babylonjs/types";
  62421. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62422. import { Observable } from "babylonjs/Misc/observable";
  62423. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62424. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62425. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62426. import { Scene, IDisposable } from "babylonjs/scene";
  62427. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62428. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62429. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62430. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62431. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62432. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62433. /**
  62434. * This represents a GPU particle system in Babylon
  62435. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62436. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62437. */
  62438. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62439. /**
  62440. * The layer mask we are rendering the particles through.
  62441. */
  62442. layerMask: number;
  62443. private _capacity;
  62444. private _activeCount;
  62445. private _currentActiveCount;
  62446. private _accumulatedCount;
  62447. private _renderEffect;
  62448. private _updateEffect;
  62449. private _buffer0;
  62450. private _buffer1;
  62451. private _spriteBuffer;
  62452. private _updateVAO;
  62453. private _renderVAO;
  62454. private _targetIndex;
  62455. private _sourceBuffer;
  62456. private _targetBuffer;
  62457. private _engine;
  62458. private _currentRenderId;
  62459. private _started;
  62460. private _stopped;
  62461. private _timeDelta;
  62462. private _randomTexture;
  62463. private _randomTexture2;
  62464. private _attributesStrideSize;
  62465. private _updateEffectOptions;
  62466. private _randomTextureSize;
  62467. private _actualFrame;
  62468. private readonly _rawTextureWidth;
  62469. /**
  62470. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62471. */
  62472. static readonly IsSupported: boolean;
  62473. /**
  62474. * An event triggered when the system is disposed.
  62475. */
  62476. onDisposeObservable: Observable<GPUParticleSystem>;
  62477. /**
  62478. * Gets the maximum number of particles active at the same time.
  62479. * @returns The max number of active particles.
  62480. */
  62481. getCapacity(): number;
  62482. /**
  62483. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62484. * to override the particles.
  62485. */
  62486. forceDepthWrite: boolean;
  62487. /**
  62488. * Gets or set the number of active particles
  62489. */
  62490. activeParticleCount: number;
  62491. private _preWarmDone;
  62492. /**
  62493. * Is this system ready to be used/rendered
  62494. * @return true if the system is ready
  62495. */
  62496. isReady(): boolean;
  62497. /**
  62498. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62499. * @returns True if it has been started, otherwise false.
  62500. */
  62501. isStarted(): boolean;
  62502. /**
  62503. * Starts the particle system and begins to emit
  62504. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62505. */
  62506. start(delay?: number): void;
  62507. /**
  62508. * Stops the particle system.
  62509. */
  62510. stop(): void;
  62511. /**
  62512. * Remove all active particles
  62513. */
  62514. reset(): void;
  62515. /**
  62516. * Returns the string "GPUParticleSystem"
  62517. * @returns a string containing the class name
  62518. */
  62519. getClassName(): string;
  62520. private _colorGradientsTexture;
  62521. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62522. /**
  62523. * Adds a new color gradient
  62524. * @param gradient defines the gradient to use (between 0 and 1)
  62525. * @param color1 defines the color to affect to the specified gradient
  62526. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62527. * @returns the current particle system
  62528. */
  62529. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62530. /**
  62531. * Remove a specific color gradient
  62532. * @param gradient defines the gradient to remove
  62533. * @returns the current particle system
  62534. */
  62535. removeColorGradient(gradient: number): GPUParticleSystem;
  62536. private _angularSpeedGradientsTexture;
  62537. private _sizeGradientsTexture;
  62538. private _velocityGradientsTexture;
  62539. private _limitVelocityGradientsTexture;
  62540. private _dragGradientsTexture;
  62541. private _addFactorGradient;
  62542. /**
  62543. * Adds a new size gradient
  62544. * @param gradient defines the gradient to use (between 0 and 1)
  62545. * @param factor defines the size factor to affect to the specified gradient
  62546. * @returns the current particle system
  62547. */
  62548. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62549. /**
  62550. * Remove a specific size gradient
  62551. * @param gradient defines the gradient to remove
  62552. * @returns the current particle system
  62553. */
  62554. removeSizeGradient(gradient: number): GPUParticleSystem;
  62555. /**
  62556. * Adds a new angular speed gradient
  62557. * @param gradient defines the gradient to use (between 0 and 1)
  62558. * @param factor defines the angular speed to affect to the specified gradient
  62559. * @returns the current particle system
  62560. */
  62561. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62562. /**
  62563. * Remove a specific angular speed gradient
  62564. * @param gradient defines the gradient to remove
  62565. * @returns the current particle system
  62566. */
  62567. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62568. /**
  62569. * Adds a new velocity gradient
  62570. * @param gradient defines the gradient to use (between 0 and 1)
  62571. * @param factor defines the velocity to affect to the specified gradient
  62572. * @returns the current particle system
  62573. */
  62574. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62575. /**
  62576. * Remove a specific velocity gradient
  62577. * @param gradient defines the gradient to remove
  62578. * @returns the current particle system
  62579. */
  62580. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62581. /**
  62582. * Adds a new limit velocity gradient
  62583. * @param gradient defines the gradient to use (between 0 and 1)
  62584. * @param factor defines the limit velocity value to affect to the specified gradient
  62585. * @returns the current particle system
  62586. */
  62587. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62588. /**
  62589. * Remove a specific limit velocity gradient
  62590. * @param gradient defines the gradient to remove
  62591. * @returns the current particle system
  62592. */
  62593. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62594. /**
  62595. * Adds a new drag gradient
  62596. * @param gradient defines the gradient to use (between 0 and 1)
  62597. * @param factor defines the drag value to affect to the specified gradient
  62598. * @returns the current particle system
  62599. */
  62600. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62601. /**
  62602. * Remove a specific drag gradient
  62603. * @param gradient defines the gradient to remove
  62604. * @returns the current particle system
  62605. */
  62606. removeDragGradient(gradient: number): GPUParticleSystem;
  62607. /**
  62608. * Not supported by GPUParticleSystem
  62609. * @param gradient defines the gradient to use (between 0 and 1)
  62610. * @param factor defines the emit rate value to affect to the specified gradient
  62611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62612. * @returns the current particle system
  62613. */
  62614. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62615. /**
  62616. * Not supported by GPUParticleSystem
  62617. * @param gradient defines the gradient to remove
  62618. * @returns the current particle system
  62619. */
  62620. removeEmitRateGradient(gradient: number): IParticleSystem;
  62621. /**
  62622. * Not supported by GPUParticleSystem
  62623. * @param gradient defines the gradient to use (between 0 and 1)
  62624. * @param factor defines the start size value to affect to the specified gradient
  62625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62626. * @returns the current particle system
  62627. */
  62628. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62629. /**
  62630. * Not supported by GPUParticleSystem
  62631. * @param gradient defines the gradient to remove
  62632. * @returns the current particle system
  62633. */
  62634. removeStartSizeGradient(gradient: number): IParticleSystem;
  62635. /**
  62636. * Not supported by GPUParticleSystem
  62637. * @param gradient defines the gradient to use (between 0 and 1)
  62638. * @param min defines the color remap minimal range
  62639. * @param max defines the color remap maximal range
  62640. * @returns the current particle system
  62641. */
  62642. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62643. /**
  62644. * Not supported by GPUParticleSystem
  62645. * @param gradient defines the gradient to remove
  62646. * @returns the current particle system
  62647. */
  62648. removeColorRemapGradient(): IParticleSystem;
  62649. /**
  62650. * Not supported by GPUParticleSystem
  62651. * @param gradient defines the gradient to use (between 0 and 1)
  62652. * @param min defines the alpha remap minimal range
  62653. * @param max defines the alpha remap maximal range
  62654. * @returns the current particle system
  62655. */
  62656. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62657. /**
  62658. * Not supported by GPUParticleSystem
  62659. * @param gradient defines the gradient to remove
  62660. * @returns the current particle system
  62661. */
  62662. removeAlphaRemapGradient(): IParticleSystem;
  62663. /**
  62664. * Not supported by GPUParticleSystem
  62665. * @param gradient defines the gradient to use (between 0 and 1)
  62666. * @param color defines the color to affect to the specified gradient
  62667. * @returns the current particle system
  62668. */
  62669. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62670. /**
  62671. * Not supported by GPUParticleSystem
  62672. * @param gradient defines the gradient to remove
  62673. * @returns the current particle system
  62674. */
  62675. removeRampGradient(): IParticleSystem;
  62676. /**
  62677. * Not supported by GPUParticleSystem
  62678. * @returns the list of ramp gradients
  62679. */
  62680. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62681. /**
  62682. * Not supported by GPUParticleSystem
  62683. * Gets or sets a boolean indicating that ramp gradients must be used
  62684. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62685. */
  62686. useRampGradients: boolean;
  62687. /**
  62688. * Not supported by GPUParticleSystem
  62689. * @param gradient defines the gradient to use (between 0 and 1)
  62690. * @param factor defines the life time factor to affect to the specified gradient
  62691. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62692. * @returns the current particle system
  62693. */
  62694. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62695. /**
  62696. * Not supported by GPUParticleSystem
  62697. * @param gradient defines the gradient to remove
  62698. * @returns the current particle system
  62699. */
  62700. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62701. /**
  62702. * Instantiates a GPU particle system.
  62703. * 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.
  62704. * @param name The name of the particle system
  62705. * @param options The options used to create the system
  62706. * @param scene The scene the particle system belongs to
  62707. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62708. */
  62709. constructor(name: string, options: Partial<{
  62710. capacity: number;
  62711. randomTextureSize: number;
  62712. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62713. protected _reset(): void;
  62714. private _createUpdateVAO;
  62715. private _createRenderVAO;
  62716. private _initialize;
  62717. /** @hidden */
  62718. _recreateUpdateEffect(): void;
  62719. /** @hidden */
  62720. _recreateRenderEffect(): void;
  62721. /**
  62722. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62723. * @param preWarm defines if we are in the pre-warmimg phase
  62724. */
  62725. animate(preWarm?: boolean): void;
  62726. private _createFactorGradientTexture;
  62727. private _createSizeGradientTexture;
  62728. private _createAngularSpeedGradientTexture;
  62729. private _createVelocityGradientTexture;
  62730. private _createLimitVelocityGradientTexture;
  62731. private _createDragGradientTexture;
  62732. private _createColorGradientTexture;
  62733. /**
  62734. * Renders the particle system in its current state
  62735. * @param preWarm defines if the system should only update the particles but not render them
  62736. * @returns the current number of particles
  62737. */
  62738. render(preWarm?: boolean): number;
  62739. /**
  62740. * Rebuilds the particle system
  62741. */
  62742. rebuild(): void;
  62743. private _releaseBuffers;
  62744. private _releaseVAOs;
  62745. /**
  62746. * Disposes the particle system and free the associated resources
  62747. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62748. */
  62749. dispose(disposeTexture?: boolean): void;
  62750. /**
  62751. * Clones the particle system.
  62752. * @param name The name of the cloned object
  62753. * @param newEmitter The new emitter to use
  62754. * @returns the cloned particle system
  62755. */
  62756. clone(name: string, newEmitter: any): GPUParticleSystem;
  62757. /**
  62758. * Serializes the particle system to a JSON object.
  62759. * @returns the JSON object
  62760. */
  62761. serialize(): any;
  62762. /**
  62763. * Parses a JSON object to create a GPU particle system.
  62764. * @param parsedParticleSystem The JSON object to parse
  62765. * @param scene The scene to create the particle system in
  62766. * @param rootUrl The root url to use to load external dependencies like texture
  62767. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62768. * @returns the parsed GPU particle system
  62769. */
  62770. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62771. }
  62772. }
  62773. declare module "babylonjs/Particles/particleSystemSet" {
  62774. import { Nullable } from "babylonjs/types";
  62775. import { Color3 } from "babylonjs/Maths/math.color";
  62776. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62778. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62779. import { Scene, IDisposable } from "babylonjs/scene";
  62780. /**
  62781. * Represents a set of particle systems working together to create a specific effect
  62782. */
  62783. export class ParticleSystemSet implements IDisposable {
  62784. /**
  62785. * Gets or sets base Assets URL
  62786. */
  62787. static BaseAssetsUrl: string;
  62788. private _emitterCreationOptions;
  62789. private _emitterNode;
  62790. /**
  62791. * Gets the particle system list
  62792. */
  62793. systems: IParticleSystem[];
  62794. /**
  62795. * Gets the emitter node used with this set
  62796. */
  62797. readonly emitterNode: Nullable<TransformNode>;
  62798. /**
  62799. * Creates a new emitter mesh as a sphere
  62800. * @param options defines the options used to create the sphere
  62801. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62802. * @param scene defines the hosting scene
  62803. */
  62804. setEmitterAsSphere(options: {
  62805. diameter: number;
  62806. segments: number;
  62807. color: Color3;
  62808. }, renderingGroupId: number, scene: Scene): void;
  62809. /**
  62810. * Starts all particle systems of the set
  62811. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62812. */
  62813. start(emitter?: AbstractMesh): void;
  62814. /**
  62815. * Release all associated resources
  62816. */
  62817. dispose(): void;
  62818. /**
  62819. * Serialize the set into a JSON compatible object
  62820. * @returns a JSON compatible representation of the set
  62821. */
  62822. serialize(): any;
  62823. /**
  62824. * Parse a new ParticleSystemSet from a serialized source
  62825. * @param data defines a JSON compatible representation of the set
  62826. * @param scene defines the hosting scene
  62827. * @param gpu defines if we want GPU particles or CPU particles
  62828. * @returns a new ParticleSystemSet
  62829. */
  62830. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62831. }
  62832. }
  62833. declare module "babylonjs/Particles/particleHelper" {
  62834. import { Nullable } from "babylonjs/types";
  62835. import { Scene } from "babylonjs/scene";
  62836. import { Vector3 } from "babylonjs/Maths/math.vector";
  62837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62838. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62839. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62840. /**
  62841. * This class is made for on one-liner static method to help creating particle system set.
  62842. */
  62843. export class ParticleHelper {
  62844. /**
  62845. * Gets or sets base Assets URL
  62846. */
  62847. static BaseAssetsUrl: string;
  62848. /**
  62849. * Create a default particle system that you can tweak
  62850. * @param emitter defines the emitter to use
  62851. * @param capacity defines the system capacity (default is 500 particles)
  62852. * @param scene defines the hosting scene
  62853. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62854. * @returns the new Particle system
  62855. */
  62856. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62857. /**
  62858. * This is the main static method (one-liner) of this helper to create different particle systems
  62859. * @param type This string represents the type to the particle system to create
  62860. * @param scene The scene where the particle system should live
  62861. * @param gpu If the system will use gpu
  62862. * @returns the ParticleSystemSet created
  62863. */
  62864. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62865. /**
  62866. * Static function used to export a particle system to a ParticleSystemSet variable.
  62867. * Please note that the emitter shape is not exported
  62868. * @param systems defines the particle systems to export
  62869. * @returns the created particle system set
  62870. */
  62871. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62872. }
  62873. }
  62874. declare module "babylonjs/Particles/particleSystemComponent" {
  62875. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62876. import { Effect } from "babylonjs/Materials/effect";
  62877. import "babylonjs/Shaders/particles.vertex";
  62878. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62879. module "babylonjs/Engines/engine" {
  62880. interface Engine {
  62881. /**
  62882. * Create an effect to use with particle systems.
  62883. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62884. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62885. * @param uniformsNames defines a list of attribute names
  62886. * @param samplers defines an array of string used to represent textures
  62887. * @param defines defines the string containing the defines to use to compile the shaders
  62888. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62889. * @param onCompiled defines a function to call when the effect creation is successful
  62890. * @param onError defines a function to call when the effect creation has failed
  62891. * @returns the new Effect
  62892. */
  62893. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62894. }
  62895. }
  62896. module "babylonjs/Meshes/mesh" {
  62897. interface Mesh {
  62898. /**
  62899. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62900. * @returns an array of IParticleSystem
  62901. */
  62902. getEmittedParticleSystems(): IParticleSystem[];
  62903. /**
  62904. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62905. * @returns an array of IParticleSystem
  62906. */
  62907. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62908. }
  62909. }
  62910. /**
  62911. * @hidden
  62912. */
  62913. export var _IDoNeedToBeInTheBuild: number;
  62914. }
  62915. declare module "babylonjs/Particles/pointsCloudSystem" {
  62916. import { Color4 } from "babylonjs/Maths/math";
  62917. import { Mesh } from "babylonjs/Meshes/mesh";
  62918. import { Scene, IDisposable } from "babylonjs/scene";
  62919. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62920. /** Defines the 4 color options */
  62921. export enum PointColor {
  62922. /** color value */
  62923. Color = 2,
  62924. /** uv value */
  62925. UV = 1,
  62926. /** random value */
  62927. Random = 0,
  62928. /** stated value */
  62929. Stated = 3
  62930. }
  62931. /**
  62932. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62933. * 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.
  62934. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62935. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62936. *
  62937. * Full documentation here : TO BE ENTERED
  62938. */
  62939. export class PointsCloudSystem implements IDisposable {
  62940. /**
  62941. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62942. * Example : var p = SPS.particles[i];
  62943. */
  62944. particles: CloudPoint[];
  62945. /**
  62946. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62947. */
  62948. nbParticles: number;
  62949. /**
  62950. * This a counter for your own usage. It's not set by any SPS functions.
  62951. */
  62952. counter: number;
  62953. /**
  62954. * The PCS name. This name is also given to the underlying mesh.
  62955. */
  62956. name: string;
  62957. /**
  62958. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62959. */
  62960. mesh: Mesh;
  62961. /**
  62962. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62963. * Please read :
  62964. */
  62965. vars: any;
  62966. /**
  62967. * @hidden
  62968. */
  62969. _size: number;
  62970. private _scene;
  62971. private _promises;
  62972. private _positions;
  62973. private _indices;
  62974. private _normals;
  62975. private _colors;
  62976. private _uvs;
  62977. private _indices32;
  62978. private _positions32;
  62979. private _colors32;
  62980. private _uvs32;
  62981. private _updatable;
  62982. private _isVisibilityBoxLocked;
  62983. private _alwaysVisible;
  62984. private _groups;
  62985. private _groupCounter;
  62986. private _computeParticleColor;
  62987. private _computeParticleTexture;
  62988. private _computeParticleRotation;
  62989. private _computeBoundingBox;
  62990. private _isReady;
  62991. /**
  62992. * Creates a PCS (Points Cloud System) object
  62993. * @param name (String) is the PCS name, this will be the underlying mesh name
  62994. * @param pointSize (number) is the size for each point
  62995. * @param scene (Scene) is the scene in which the PCS is added
  62996. * @param options defines the options of the PCS e.g.
  62997. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62998. */
  62999. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63000. updatable?: boolean;
  63001. });
  63002. /**
  63003. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63004. * If no points were added to the PCS, the returned mesh is just a single point.
  63005. * @returns a promise for the created mesh
  63006. */
  63007. buildMeshAsync(): Promise<Mesh>;
  63008. /**
  63009. * @hidden
  63010. */
  63011. private _buildMesh;
  63012. private _addParticle;
  63013. private _randomUnitVector;
  63014. private _getColorIndicesForCoord;
  63015. private _setPointsColorOrUV;
  63016. private _colorFromTexture;
  63017. private _calculateDensity;
  63018. /**
  63019. * Adds points to the PCS in random positions within a unit sphere
  63020. * @param nb (positive integer) the number of particles to be created from this model
  63021. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63022. * @returns the number of groups in the system
  63023. */
  63024. addPoints(nb: number, pointFunction?: any): number;
  63025. /**
  63026. * Adds points to the PCS from the surface of the model shape
  63027. * @param mesh is any Mesh object that will be used as a surface model for the points
  63028. * @param nb (positive integer) the number of particles to be created from this model
  63029. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63030. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63031. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63032. * @returns the number of groups in the system
  63033. */
  63034. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63035. /**
  63036. * Adds points to the PCS inside the model shape
  63037. * @param mesh is any Mesh object that will be used as a surface model for the points
  63038. * @param nb (positive integer) the number of particles to be created from this model
  63039. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63040. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63041. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63042. * @returns the number of groups in the system
  63043. */
  63044. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63045. /**
  63046. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63047. * This method calls `updateParticle()` for each particle of the SPS.
  63048. * For an animated SPS, it is usually called within the render loop.
  63049. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63050. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63051. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63052. * @returns the PCS.
  63053. */
  63054. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63055. /**
  63056. * Disposes the PCS.
  63057. */
  63058. dispose(): void;
  63059. /**
  63060. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63061. * doc :
  63062. * @returns the PCS.
  63063. */
  63064. refreshVisibleSize(): PointsCloudSystem;
  63065. /**
  63066. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63067. * @param size the size (float) of the visibility box
  63068. * note : this doesn't lock the PCS mesh bounding box.
  63069. * doc :
  63070. */
  63071. setVisibilityBox(size: number): void;
  63072. /**
  63073. * Gets whether the PCS is always visible or not
  63074. * doc :
  63075. */
  63076. /**
  63077. * Sets the PCS as always visible or not
  63078. * doc :
  63079. */
  63080. isAlwaysVisible: boolean;
  63081. /**
  63082. * Tells to `setParticles()` to compute the particle rotations or not
  63083. * Default value : false. The PCS is faster when it's set to false
  63084. * Note : particle rotations are only applied to parent particles
  63085. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63086. */
  63087. computeParticleRotation: boolean;
  63088. /**
  63089. * Tells to `setParticles()` to compute the particle colors or not.
  63090. * Default value : true. The PCS is faster when it's set to false.
  63091. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63092. */
  63093. /**
  63094. * Gets if `setParticles()` computes the particle colors or not.
  63095. * Default value : false. The PCS is faster when it's set to false.
  63096. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63097. */
  63098. computeParticleColor: boolean;
  63099. /**
  63100. * Gets if `setParticles()` computes the particle textures or not.
  63101. * Default value : false. The PCS is faster when it's set to false.
  63102. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63103. */
  63104. computeParticleTexture: boolean;
  63105. /**
  63106. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63107. */
  63108. /**
  63109. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63110. */
  63111. computeBoundingBox: boolean;
  63112. /**
  63113. * This function does nothing. It may be overwritten to set all the particle first values.
  63114. * The PCS doesn't call this function, you may have to call it by your own.
  63115. * doc :
  63116. */
  63117. initParticles(): void;
  63118. /**
  63119. * This function does nothing. It may be overwritten to recycle a particle
  63120. * The PCS doesn't call this function, you can to call it
  63121. * doc :
  63122. * @param particle The particle to recycle
  63123. * @returns the recycled particle
  63124. */
  63125. recycleParticle(particle: CloudPoint): CloudPoint;
  63126. /**
  63127. * Updates a particle : this function should be overwritten by the user.
  63128. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63129. * doc :
  63130. * @example : just set a particle position or velocity and recycle conditions
  63131. * @param particle The particle to update
  63132. * @returns the updated particle
  63133. */
  63134. updateParticle(particle: CloudPoint): CloudPoint;
  63135. /**
  63136. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63137. * This does nothing and may be overwritten by the user.
  63138. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63139. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63140. * @param update the boolean update value actually passed to setParticles()
  63141. */
  63142. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63143. /**
  63144. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63145. * This will be passed three parameters.
  63146. * This does nothing and may be overwritten by the user.
  63147. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63148. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63149. * @param update the boolean update value actually passed to setParticles()
  63150. */
  63151. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63152. }
  63153. }
  63154. declare module "babylonjs/Particles/cloudPoint" {
  63155. import { Nullable } from "babylonjs/types";
  63156. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63157. import { Mesh } from "babylonjs/Meshes/mesh";
  63158. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63159. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63160. /**
  63161. * Represents one particle of a points cloud system.
  63162. */
  63163. export class CloudPoint {
  63164. /**
  63165. * particle global index
  63166. */
  63167. idx: number;
  63168. /**
  63169. * The color of the particle
  63170. */
  63171. color: Nullable<Color4>;
  63172. /**
  63173. * The world space position of the particle.
  63174. */
  63175. position: Vector3;
  63176. /**
  63177. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63178. */
  63179. rotation: Vector3;
  63180. /**
  63181. * The world space rotation quaternion of the particle.
  63182. */
  63183. rotationQuaternion: Nullable<Quaternion>;
  63184. /**
  63185. * The uv of the particle.
  63186. */
  63187. uv: Nullable<Vector2>;
  63188. /**
  63189. * The current speed of the particle.
  63190. */
  63191. velocity: Vector3;
  63192. /**
  63193. * The pivot point in the particle local space.
  63194. */
  63195. pivot: Vector3;
  63196. /**
  63197. * Must the particle be translated from its pivot point in its local space ?
  63198. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63199. * Default : false
  63200. */
  63201. translateFromPivot: boolean;
  63202. /**
  63203. * Index of this particle in the global "positions" array (Internal use)
  63204. * @hidden
  63205. */
  63206. _pos: number;
  63207. /**
  63208. * @hidden Index of this particle in the global "indices" array (Internal use)
  63209. */
  63210. _ind: number;
  63211. /**
  63212. * Group this particle belongs to
  63213. */
  63214. _group: PointsGroup;
  63215. /**
  63216. * Group id of this particle
  63217. */
  63218. groupId: number;
  63219. /**
  63220. * Index of the particle in its group id (Internal use)
  63221. */
  63222. idxInGroup: number;
  63223. /**
  63224. * @hidden Particle BoundingInfo object (Internal use)
  63225. */
  63226. _boundingInfo: BoundingInfo;
  63227. /**
  63228. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63229. */
  63230. _pcs: PointsCloudSystem;
  63231. /**
  63232. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63233. */
  63234. _stillInvisible: boolean;
  63235. /**
  63236. * @hidden Last computed particle rotation matrix
  63237. */
  63238. _rotationMatrix: number[];
  63239. /**
  63240. * Parent particle Id, if any.
  63241. * Default null.
  63242. */
  63243. parentId: Nullable<number>;
  63244. /**
  63245. * @hidden Internal global position in the PCS.
  63246. */
  63247. _globalPosition: Vector3;
  63248. /**
  63249. * Creates a Point Cloud object.
  63250. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63251. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63252. * @param group (PointsGroup) is the group the particle belongs to
  63253. * @param groupId (integer) is the group identifier in the PCS.
  63254. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63255. * @param pcs defines the PCS it is associated to
  63256. */
  63257. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63258. /**
  63259. * get point size
  63260. */
  63261. /**
  63262. * Set point size
  63263. */
  63264. size: Vector3;
  63265. /**
  63266. * Legacy support, changed quaternion to rotationQuaternion
  63267. */
  63268. /**
  63269. * Legacy support, changed quaternion to rotationQuaternion
  63270. */
  63271. quaternion: Nullable<Quaternion>;
  63272. /**
  63273. * Returns a boolean. True if the particle intersects a mesh, else false
  63274. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63275. * @param target is the object (point or mesh) what the intersection is computed against
  63276. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63277. * @returns true if it intersects
  63278. */
  63279. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63280. /**
  63281. * get the rotation matrix of the particle
  63282. * @hidden
  63283. */
  63284. getRotationMatrix(m: Matrix): void;
  63285. }
  63286. /**
  63287. * Represents a group of points in a points cloud system
  63288. * * PCS internal tool, don't use it manually.
  63289. */
  63290. export class PointsGroup {
  63291. /**
  63292. * The group id
  63293. * @hidden
  63294. */
  63295. groupID: number;
  63296. /**
  63297. * image data for group (internal use)
  63298. * @hidden
  63299. */
  63300. _groupImageData: Nullable<ArrayBufferView>;
  63301. /**
  63302. * Image Width (internal use)
  63303. * @hidden
  63304. */
  63305. _groupImgWidth: number;
  63306. /**
  63307. * Image Height (internal use)
  63308. * @hidden
  63309. */
  63310. _groupImgHeight: number;
  63311. /**
  63312. * Custom position function (internal use)
  63313. * @hidden
  63314. */
  63315. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63316. /**
  63317. * density per facet for surface points
  63318. * @hidden
  63319. */
  63320. _groupDensity: number[];
  63321. /**
  63322. * Only when points are colored by texture carries pointer to texture list array
  63323. * @hidden
  63324. */
  63325. _textureNb: number;
  63326. /**
  63327. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63328. * PCS internal tool, don't use it manually.
  63329. * @hidden
  63330. */
  63331. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63332. }
  63333. }
  63334. declare module "babylonjs/Particles/index" {
  63335. export * from "babylonjs/Particles/baseParticleSystem";
  63336. export * from "babylonjs/Particles/EmitterTypes/index";
  63337. export * from "babylonjs/Particles/gpuParticleSystem";
  63338. export * from "babylonjs/Particles/IParticleSystem";
  63339. export * from "babylonjs/Particles/particle";
  63340. export * from "babylonjs/Particles/particleHelper";
  63341. export * from "babylonjs/Particles/particleSystem";
  63342. export * from "babylonjs/Particles/particleSystemComponent";
  63343. export * from "babylonjs/Particles/particleSystemSet";
  63344. export * from "babylonjs/Particles/solidParticle";
  63345. export * from "babylonjs/Particles/solidParticleSystem";
  63346. export * from "babylonjs/Particles/cloudPoint";
  63347. export * from "babylonjs/Particles/pointsCloudSystem";
  63348. export * from "babylonjs/Particles/subEmitter";
  63349. }
  63350. declare module "babylonjs/Physics/physicsEngineComponent" {
  63351. import { Nullable } from "babylonjs/types";
  63352. import { Observable, Observer } from "babylonjs/Misc/observable";
  63353. import { Vector3 } from "babylonjs/Maths/math.vector";
  63354. import { Mesh } from "babylonjs/Meshes/mesh";
  63355. import { ISceneComponent } from "babylonjs/sceneComponent";
  63356. import { Scene } from "babylonjs/scene";
  63357. import { Node } from "babylonjs/node";
  63358. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63360. module "babylonjs/scene" {
  63361. interface Scene {
  63362. /** @hidden (Backing field) */
  63363. _physicsEngine: Nullable<IPhysicsEngine>;
  63364. /** @hidden */
  63365. _physicsTimeAccumulator: number;
  63366. /**
  63367. * Gets the current physics engine
  63368. * @returns a IPhysicsEngine or null if none attached
  63369. */
  63370. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63371. /**
  63372. * Enables physics to the current scene
  63373. * @param gravity defines the scene's gravity for the physics engine
  63374. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63375. * @return a boolean indicating if the physics engine was initialized
  63376. */
  63377. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63378. /**
  63379. * Disables and disposes the physics engine associated with the scene
  63380. */
  63381. disablePhysicsEngine(): void;
  63382. /**
  63383. * Gets a boolean indicating if there is an active physics engine
  63384. * @returns a boolean indicating if there is an active physics engine
  63385. */
  63386. isPhysicsEnabled(): boolean;
  63387. /**
  63388. * Deletes a physics compound impostor
  63389. * @param compound defines the compound to delete
  63390. */
  63391. deleteCompoundImpostor(compound: any): void;
  63392. /**
  63393. * An event triggered when physic simulation is about to be run
  63394. */
  63395. onBeforePhysicsObservable: Observable<Scene>;
  63396. /**
  63397. * An event triggered when physic simulation has been done
  63398. */
  63399. onAfterPhysicsObservable: Observable<Scene>;
  63400. }
  63401. }
  63402. module "babylonjs/Meshes/abstractMesh" {
  63403. interface AbstractMesh {
  63404. /** @hidden */
  63405. _physicsImpostor: Nullable<PhysicsImpostor>;
  63406. /**
  63407. * Gets or sets impostor used for physic simulation
  63408. * @see http://doc.babylonjs.com/features/physics_engine
  63409. */
  63410. physicsImpostor: Nullable<PhysicsImpostor>;
  63411. /**
  63412. * Gets the current physics impostor
  63413. * @see http://doc.babylonjs.com/features/physics_engine
  63414. * @returns a physics impostor or null
  63415. */
  63416. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63417. /** Apply a physic impulse to the mesh
  63418. * @param force defines the force to apply
  63419. * @param contactPoint defines where to apply the force
  63420. * @returns the current mesh
  63421. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63422. */
  63423. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63424. /**
  63425. * Creates a physic joint between two meshes
  63426. * @param otherMesh defines the other mesh to use
  63427. * @param pivot1 defines the pivot to use on this mesh
  63428. * @param pivot2 defines the pivot to use on the other mesh
  63429. * @param options defines additional options (can be plugin dependent)
  63430. * @returns the current mesh
  63431. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63432. */
  63433. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63434. /** @hidden */
  63435. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63436. }
  63437. }
  63438. /**
  63439. * Defines the physics engine scene component responsible to manage a physics engine
  63440. */
  63441. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63442. /**
  63443. * The component name helpful to identify the component in the list of scene components.
  63444. */
  63445. readonly name: string;
  63446. /**
  63447. * The scene the component belongs to.
  63448. */
  63449. scene: Scene;
  63450. /**
  63451. * Creates a new instance of the component for the given scene
  63452. * @param scene Defines the scene to register the component in
  63453. */
  63454. constructor(scene: Scene);
  63455. /**
  63456. * Registers the component in a given scene
  63457. */
  63458. register(): void;
  63459. /**
  63460. * Rebuilds the elements related to this component in case of
  63461. * context lost for instance.
  63462. */
  63463. rebuild(): void;
  63464. /**
  63465. * Disposes the component and the associated ressources
  63466. */
  63467. dispose(): void;
  63468. }
  63469. }
  63470. declare module "babylonjs/Physics/physicsHelper" {
  63471. import { Nullable } from "babylonjs/types";
  63472. import { Vector3 } from "babylonjs/Maths/math.vector";
  63473. import { Mesh } from "babylonjs/Meshes/mesh";
  63474. import { Scene } from "babylonjs/scene";
  63475. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63476. /**
  63477. * A helper for physics simulations
  63478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63479. */
  63480. export class PhysicsHelper {
  63481. private _scene;
  63482. private _physicsEngine;
  63483. /**
  63484. * Initializes the Physics helper
  63485. * @param scene Babylon.js scene
  63486. */
  63487. constructor(scene: Scene);
  63488. /**
  63489. * Applies a radial explosion impulse
  63490. * @param origin the origin of the explosion
  63491. * @param radiusOrEventOptions the radius or the options of radial explosion
  63492. * @param strength the explosion strength
  63493. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63494. * @returns A physics radial explosion event, or null
  63495. */
  63496. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63497. /**
  63498. * Applies a radial explosion force
  63499. * @param origin the origin of the explosion
  63500. * @param radiusOrEventOptions the radius or the options of radial explosion
  63501. * @param strength the explosion strength
  63502. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63503. * @returns A physics radial explosion event, or null
  63504. */
  63505. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63506. /**
  63507. * Creates a gravitational field
  63508. * @param origin the origin of the explosion
  63509. * @param radiusOrEventOptions the radius or the options of radial explosion
  63510. * @param strength the explosion strength
  63511. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63512. * @returns A physics gravitational field event, or null
  63513. */
  63514. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63515. /**
  63516. * Creates a physics updraft event
  63517. * @param origin the origin of the updraft
  63518. * @param radiusOrEventOptions the radius or the options of the updraft
  63519. * @param strength the strength of the updraft
  63520. * @param height the height of the updraft
  63521. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63522. * @returns A physics updraft event, or null
  63523. */
  63524. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63525. /**
  63526. * Creates a physics vortex event
  63527. * @param origin the of the vortex
  63528. * @param radiusOrEventOptions the radius or the options of the vortex
  63529. * @param strength the strength of the vortex
  63530. * @param height the height of the vortex
  63531. * @returns a Physics vortex event, or null
  63532. * A physics vortex event or null
  63533. */
  63534. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63535. }
  63536. /**
  63537. * Represents a physics radial explosion event
  63538. */
  63539. class PhysicsRadialExplosionEvent {
  63540. private _scene;
  63541. private _options;
  63542. private _sphere;
  63543. private _dataFetched;
  63544. /**
  63545. * Initializes a radial explosioin event
  63546. * @param _scene BabylonJS scene
  63547. * @param _options The options for the vortex event
  63548. */
  63549. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63550. /**
  63551. * Returns the data related to the radial explosion event (sphere).
  63552. * @returns The radial explosion event data
  63553. */
  63554. getData(): PhysicsRadialExplosionEventData;
  63555. /**
  63556. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63557. * @param impostor A physics imposter
  63558. * @param origin the origin of the explosion
  63559. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63560. */
  63561. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63562. /**
  63563. * Triggers affecterd impostors callbacks
  63564. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63565. */
  63566. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63567. /**
  63568. * Disposes the sphere.
  63569. * @param force Specifies if the sphere should be disposed by force
  63570. */
  63571. dispose(force?: boolean): void;
  63572. /*** Helpers ***/
  63573. private _prepareSphere;
  63574. private _intersectsWithSphere;
  63575. }
  63576. /**
  63577. * Represents a gravitational field event
  63578. */
  63579. class PhysicsGravitationalFieldEvent {
  63580. private _physicsHelper;
  63581. private _scene;
  63582. private _origin;
  63583. private _options;
  63584. private _tickCallback;
  63585. private _sphere;
  63586. private _dataFetched;
  63587. /**
  63588. * Initializes the physics gravitational field event
  63589. * @param _physicsHelper A physics helper
  63590. * @param _scene BabylonJS scene
  63591. * @param _origin The origin position of the gravitational field event
  63592. * @param _options The options for the vortex event
  63593. */
  63594. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63595. /**
  63596. * Returns the data related to the gravitational field event (sphere).
  63597. * @returns A gravitational field event
  63598. */
  63599. getData(): PhysicsGravitationalFieldEventData;
  63600. /**
  63601. * Enables the gravitational field.
  63602. */
  63603. enable(): void;
  63604. /**
  63605. * Disables the gravitational field.
  63606. */
  63607. disable(): void;
  63608. /**
  63609. * Disposes the sphere.
  63610. * @param force The force to dispose from the gravitational field event
  63611. */
  63612. dispose(force?: boolean): void;
  63613. private _tick;
  63614. }
  63615. /**
  63616. * Represents a physics updraft event
  63617. */
  63618. class PhysicsUpdraftEvent {
  63619. private _scene;
  63620. private _origin;
  63621. private _options;
  63622. private _physicsEngine;
  63623. private _originTop;
  63624. private _originDirection;
  63625. private _tickCallback;
  63626. private _cylinder;
  63627. private _cylinderPosition;
  63628. private _dataFetched;
  63629. /**
  63630. * Initializes the physics updraft event
  63631. * @param _scene BabylonJS scene
  63632. * @param _origin The origin position of the updraft
  63633. * @param _options The options for the updraft event
  63634. */
  63635. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63636. /**
  63637. * Returns the data related to the updraft event (cylinder).
  63638. * @returns A physics updraft event
  63639. */
  63640. getData(): PhysicsUpdraftEventData;
  63641. /**
  63642. * Enables the updraft.
  63643. */
  63644. enable(): void;
  63645. /**
  63646. * Disables the updraft.
  63647. */
  63648. disable(): void;
  63649. /**
  63650. * Disposes the cylinder.
  63651. * @param force Specifies if the updraft should be disposed by force
  63652. */
  63653. dispose(force?: boolean): void;
  63654. private getImpostorHitData;
  63655. private _tick;
  63656. /*** Helpers ***/
  63657. private _prepareCylinder;
  63658. private _intersectsWithCylinder;
  63659. }
  63660. /**
  63661. * Represents a physics vortex event
  63662. */
  63663. class PhysicsVortexEvent {
  63664. private _scene;
  63665. private _origin;
  63666. private _options;
  63667. private _physicsEngine;
  63668. private _originTop;
  63669. private _tickCallback;
  63670. private _cylinder;
  63671. private _cylinderPosition;
  63672. private _dataFetched;
  63673. /**
  63674. * Initializes the physics vortex event
  63675. * @param _scene The BabylonJS scene
  63676. * @param _origin The origin position of the vortex
  63677. * @param _options The options for the vortex event
  63678. */
  63679. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63680. /**
  63681. * Returns the data related to the vortex event (cylinder).
  63682. * @returns The physics vortex event data
  63683. */
  63684. getData(): PhysicsVortexEventData;
  63685. /**
  63686. * Enables the vortex.
  63687. */
  63688. enable(): void;
  63689. /**
  63690. * Disables the cortex.
  63691. */
  63692. disable(): void;
  63693. /**
  63694. * Disposes the sphere.
  63695. * @param force
  63696. */
  63697. dispose(force?: boolean): void;
  63698. private getImpostorHitData;
  63699. private _tick;
  63700. /*** Helpers ***/
  63701. private _prepareCylinder;
  63702. private _intersectsWithCylinder;
  63703. }
  63704. /**
  63705. * Options fot the radial explosion event
  63706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63707. */
  63708. export class PhysicsRadialExplosionEventOptions {
  63709. /**
  63710. * The radius of the sphere for the radial explosion.
  63711. */
  63712. radius: number;
  63713. /**
  63714. * The strenth of the explosion.
  63715. */
  63716. strength: number;
  63717. /**
  63718. * The strenght of the force in correspondence to the distance of the affected object
  63719. */
  63720. falloff: PhysicsRadialImpulseFalloff;
  63721. /**
  63722. * Sphere options for the radial explosion.
  63723. */
  63724. sphere: {
  63725. segments: number;
  63726. diameter: number;
  63727. };
  63728. /**
  63729. * Sphere options for the radial explosion.
  63730. */
  63731. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63732. }
  63733. /**
  63734. * Options fot the updraft event
  63735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63736. */
  63737. export class PhysicsUpdraftEventOptions {
  63738. /**
  63739. * The radius of the cylinder for the vortex
  63740. */
  63741. radius: number;
  63742. /**
  63743. * The strenth of the updraft.
  63744. */
  63745. strength: number;
  63746. /**
  63747. * The height of the cylinder for the updraft.
  63748. */
  63749. height: number;
  63750. /**
  63751. * The mode for the the updraft.
  63752. */
  63753. updraftMode: PhysicsUpdraftMode;
  63754. }
  63755. /**
  63756. * Options fot the vortex event
  63757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63758. */
  63759. export class PhysicsVortexEventOptions {
  63760. /**
  63761. * The radius of the cylinder for the vortex
  63762. */
  63763. radius: number;
  63764. /**
  63765. * The strenth of the vortex.
  63766. */
  63767. strength: number;
  63768. /**
  63769. * The height of the cylinder for the vortex.
  63770. */
  63771. height: number;
  63772. /**
  63773. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63774. */
  63775. centripetalForceThreshold: number;
  63776. /**
  63777. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63778. */
  63779. centripetalForceMultiplier: number;
  63780. /**
  63781. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63782. */
  63783. centrifugalForceMultiplier: number;
  63784. /**
  63785. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63786. */
  63787. updraftForceMultiplier: number;
  63788. }
  63789. /**
  63790. * The strenght of the force in correspondence to the distance of the affected object
  63791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63792. */
  63793. export enum PhysicsRadialImpulseFalloff {
  63794. /** Defines that impulse is constant in strength across it's whole radius */
  63795. Constant = 0,
  63796. /** Defines that impulse gets weaker if it's further from the origin */
  63797. Linear = 1
  63798. }
  63799. /**
  63800. * The strength of the force in correspondence to the distance of the affected object
  63801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63802. */
  63803. export enum PhysicsUpdraftMode {
  63804. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63805. Center = 0,
  63806. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63807. Perpendicular = 1
  63808. }
  63809. /**
  63810. * Interface for a physics hit data
  63811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63812. */
  63813. export interface PhysicsHitData {
  63814. /**
  63815. * The force applied at the contact point
  63816. */
  63817. force: Vector3;
  63818. /**
  63819. * The contact point
  63820. */
  63821. contactPoint: Vector3;
  63822. /**
  63823. * The distance from the origin to the contact point
  63824. */
  63825. distanceFromOrigin: number;
  63826. }
  63827. /**
  63828. * Interface for radial explosion event data
  63829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63830. */
  63831. export interface PhysicsRadialExplosionEventData {
  63832. /**
  63833. * A sphere used for the radial explosion event
  63834. */
  63835. sphere: Mesh;
  63836. }
  63837. /**
  63838. * Interface for gravitational field event data
  63839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63840. */
  63841. export interface PhysicsGravitationalFieldEventData {
  63842. /**
  63843. * A sphere mesh used for the gravitational field event
  63844. */
  63845. sphere: Mesh;
  63846. }
  63847. /**
  63848. * Interface for updraft event data
  63849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63850. */
  63851. export interface PhysicsUpdraftEventData {
  63852. /**
  63853. * A cylinder used for the updraft event
  63854. */
  63855. cylinder: Mesh;
  63856. }
  63857. /**
  63858. * Interface for vortex event data
  63859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63860. */
  63861. export interface PhysicsVortexEventData {
  63862. /**
  63863. * A cylinder used for the vortex event
  63864. */
  63865. cylinder: Mesh;
  63866. }
  63867. /**
  63868. * Interface for an affected physics impostor
  63869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63870. */
  63871. export interface PhysicsAffectedImpostorWithData {
  63872. /**
  63873. * The impostor affected by the effect
  63874. */
  63875. impostor: PhysicsImpostor;
  63876. /**
  63877. * The data about the hit/horce from the explosion
  63878. */
  63879. hitData: PhysicsHitData;
  63880. }
  63881. }
  63882. declare module "babylonjs/Physics/Plugins/index" {
  63883. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63884. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63885. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63886. }
  63887. declare module "babylonjs/Physics/index" {
  63888. export * from "babylonjs/Physics/IPhysicsEngine";
  63889. export * from "babylonjs/Physics/physicsEngine";
  63890. export * from "babylonjs/Physics/physicsEngineComponent";
  63891. export * from "babylonjs/Physics/physicsHelper";
  63892. export * from "babylonjs/Physics/physicsImpostor";
  63893. export * from "babylonjs/Physics/physicsJoint";
  63894. export * from "babylonjs/Physics/Plugins/index";
  63895. }
  63896. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63897. /** @hidden */
  63898. export var blackAndWhitePixelShader: {
  63899. name: string;
  63900. shader: string;
  63901. };
  63902. }
  63903. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63905. import { Camera } from "babylonjs/Cameras/camera";
  63906. import { Engine } from "babylonjs/Engines/engine";
  63907. import "babylonjs/Shaders/blackAndWhite.fragment";
  63908. /**
  63909. * Post process used to render in black and white
  63910. */
  63911. export class BlackAndWhitePostProcess extends PostProcess {
  63912. /**
  63913. * Linear about to convert he result to black and white (default: 1)
  63914. */
  63915. degree: number;
  63916. /**
  63917. * Creates a black and white post process
  63918. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63919. * @param name The name of the effect.
  63920. * @param options The required width/height ratio to downsize to before computing the render pass.
  63921. * @param camera The camera to apply the render pass to.
  63922. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63923. * @param engine The engine which the post process will be applied. (default: current engine)
  63924. * @param reusable If the post process can be reused on the same frame. (default: false)
  63925. */
  63926. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63927. }
  63928. }
  63929. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63930. import { Nullable } from "babylonjs/types";
  63931. import { Camera } from "babylonjs/Cameras/camera";
  63932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63933. import { Engine } from "babylonjs/Engines/engine";
  63934. /**
  63935. * This represents a set of one or more post processes in Babylon.
  63936. * A post process can be used to apply a shader to a texture after it is rendered.
  63937. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63938. */
  63939. export class PostProcessRenderEffect {
  63940. private _postProcesses;
  63941. private _getPostProcesses;
  63942. private _singleInstance;
  63943. private _cameras;
  63944. private _indicesForCamera;
  63945. /**
  63946. * Name of the effect
  63947. * @hidden
  63948. */
  63949. _name: string;
  63950. /**
  63951. * Instantiates a post process render effect.
  63952. * A post process can be used to apply a shader to a texture after it is rendered.
  63953. * @param engine The engine the effect is tied to
  63954. * @param name The name of the effect
  63955. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63956. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63957. */
  63958. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63959. /**
  63960. * Checks if all the post processes in the effect are supported.
  63961. */
  63962. readonly isSupported: boolean;
  63963. /**
  63964. * Updates the current state of the effect
  63965. * @hidden
  63966. */
  63967. _update(): void;
  63968. /**
  63969. * Attaches the effect on cameras
  63970. * @param cameras The camera to attach to.
  63971. * @hidden
  63972. */
  63973. _attachCameras(cameras: Camera): void;
  63974. /**
  63975. * Attaches the effect on cameras
  63976. * @param cameras The camera to attach to.
  63977. * @hidden
  63978. */
  63979. _attachCameras(cameras: Camera[]): void;
  63980. /**
  63981. * Detaches the effect on cameras
  63982. * @param cameras The camera to detatch from.
  63983. * @hidden
  63984. */
  63985. _detachCameras(cameras: Camera): void;
  63986. /**
  63987. * Detatches the effect on cameras
  63988. * @param cameras The camera to detatch from.
  63989. * @hidden
  63990. */
  63991. _detachCameras(cameras: Camera[]): void;
  63992. /**
  63993. * Enables the effect on given cameras
  63994. * @param cameras The camera to enable.
  63995. * @hidden
  63996. */
  63997. _enable(cameras: Camera): void;
  63998. /**
  63999. * Enables the effect on given cameras
  64000. * @param cameras The camera to enable.
  64001. * @hidden
  64002. */
  64003. _enable(cameras: Nullable<Camera[]>): void;
  64004. /**
  64005. * Disables the effect on the given cameras
  64006. * @param cameras The camera to disable.
  64007. * @hidden
  64008. */
  64009. _disable(cameras: Camera): void;
  64010. /**
  64011. * Disables the effect on the given cameras
  64012. * @param cameras The camera to disable.
  64013. * @hidden
  64014. */
  64015. _disable(cameras: Nullable<Camera[]>): void;
  64016. /**
  64017. * Gets a list of the post processes contained in the effect.
  64018. * @param camera The camera to get the post processes on.
  64019. * @returns The list of the post processes in the effect.
  64020. */
  64021. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64022. }
  64023. }
  64024. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64025. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64026. /** @hidden */
  64027. export var extractHighlightsPixelShader: {
  64028. name: string;
  64029. shader: string;
  64030. };
  64031. }
  64032. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64033. import { Nullable } from "babylonjs/types";
  64034. import { Camera } from "babylonjs/Cameras/camera";
  64035. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64036. import { Engine } from "babylonjs/Engines/engine";
  64037. import "babylonjs/Shaders/extractHighlights.fragment";
  64038. /**
  64039. * 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.
  64040. */
  64041. export class ExtractHighlightsPostProcess extends PostProcess {
  64042. /**
  64043. * The luminance threshold, pixels below this value will be set to black.
  64044. */
  64045. threshold: number;
  64046. /** @hidden */
  64047. _exposure: number;
  64048. /**
  64049. * Post process which has the input texture to be used when performing highlight extraction
  64050. * @hidden
  64051. */
  64052. _inputPostProcess: Nullable<PostProcess>;
  64053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64054. }
  64055. }
  64056. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64057. /** @hidden */
  64058. export var bloomMergePixelShader: {
  64059. name: string;
  64060. shader: string;
  64061. };
  64062. }
  64063. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64065. import { Nullable } from "babylonjs/types";
  64066. import { Engine } from "babylonjs/Engines/engine";
  64067. import { Camera } from "babylonjs/Cameras/camera";
  64068. import "babylonjs/Shaders/bloomMerge.fragment";
  64069. /**
  64070. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64071. */
  64072. export class BloomMergePostProcess extends PostProcess {
  64073. /** Weight of the bloom to be added to the original input. */
  64074. weight: number;
  64075. /**
  64076. * Creates a new instance of @see BloomMergePostProcess
  64077. * @param name The name of the effect.
  64078. * @param originalFromInput Post process which's input will be used for the merge.
  64079. * @param blurred Blurred highlights post process which's output will be used.
  64080. * @param weight Weight of the bloom to be added to the original input.
  64081. * @param options The required width/height ratio to downsize to before computing the render pass.
  64082. * @param camera The camera to apply the render pass to.
  64083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64084. * @param engine The engine which the post process will be applied. (default: current engine)
  64085. * @param reusable If the post process can be reused on the same frame. (default: false)
  64086. * @param textureType Type of textures used when performing the post process. (default: 0)
  64087. * @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)
  64088. */
  64089. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64090. /** Weight of the bloom to be added to the original input. */
  64091. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64092. }
  64093. }
  64094. declare module "babylonjs/PostProcesses/bloomEffect" {
  64095. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64096. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64097. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64098. import { Camera } from "babylonjs/Cameras/camera";
  64099. import { Scene } from "babylonjs/scene";
  64100. /**
  64101. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64102. */
  64103. export class BloomEffect extends PostProcessRenderEffect {
  64104. private bloomScale;
  64105. /**
  64106. * @hidden Internal
  64107. */
  64108. _effects: Array<PostProcess>;
  64109. /**
  64110. * @hidden Internal
  64111. */
  64112. _downscale: ExtractHighlightsPostProcess;
  64113. private _blurX;
  64114. private _blurY;
  64115. private _merge;
  64116. /**
  64117. * The luminance threshold to find bright areas of the image to bloom.
  64118. */
  64119. threshold: number;
  64120. /**
  64121. * The strength of the bloom.
  64122. */
  64123. weight: number;
  64124. /**
  64125. * Specifies the size of the bloom blur kernel, relative to the final output size
  64126. */
  64127. kernel: number;
  64128. /**
  64129. * Creates a new instance of @see BloomEffect
  64130. * @param scene The scene the effect belongs to.
  64131. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64132. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64133. * @param bloomWeight The the strength of bloom.
  64134. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64135. * @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)
  64136. */
  64137. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64138. /**
  64139. * Disposes each of the internal effects for a given camera.
  64140. * @param camera The camera to dispose the effect on.
  64141. */
  64142. disposeEffects(camera: Camera): void;
  64143. /**
  64144. * @hidden Internal
  64145. */
  64146. _updateEffects(): void;
  64147. /**
  64148. * Internal
  64149. * @returns if all the contained post processes are ready.
  64150. * @hidden
  64151. */
  64152. _isReady(): boolean;
  64153. }
  64154. }
  64155. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64156. /** @hidden */
  64157. export var chromaticAberrationPixelShader: {
  64158. name: string;
  64159. shader: string;
  64160. };
  64161. }
  64162. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64163. import { Vector2 } from "babylonjs/Maths/math.vector";
  64164. import { Nullable } from "babylonjs/types";
  64165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64166. import { Camera } from "babylonjs/Cameras/camera";
  64167. import { Engine } from "babylonjs/Engines/engine";
  64168. import "babylonjs/Shaders/chromaticAberration.fragment";
  64169. /**
  64170. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64171. */
  64172. export class ChromaticAberrationPostProcess extends PostProcess {
  64173. /**
  64174. * The amount of seperation of rgb channels (default: 30)
  64175. */
  64176. aberrationAmount: number;
  64177. /**
  64178. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64179. */
  64180. radialIntensity: number;
  64181. /**
  64182. * 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))
  64183. */
  64184. direction: Vector2;
  64185. /**
  64186. * 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))
  64187. */
  64188. centerPosition: Vector2;
  64189. /**
  64190. * Creates a new instance ChromaticAberrationPostProcess
  64191. * @param name The name of the effect.
  64192. * @param screenWidth The width of the screen to apply the effect on.
  64193. * @param screenHeight The height of the screen to apply the effect on.
  64194. * @param options The required width/height ratio to downsize to before computing the render pass.
  64195. * @param camera The camera to apply the render pass to.
  64196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64197. * @param engine The engine which the post process will be applied. (default: current engine)
  64198. * @param reusable If the post process can be reused on the same frame. (default: false)
  64199. * @param textureType Type of textures used when performing the post process. (default: 0)
  64200. * @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)
  64201. */
  64202. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64203. }
  64204. }
  64205. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64206. /** @hidden */
  64207. export var circleOfConfusionPixelShader: {
  64208. name: string;
  64209. shader: string;
  64210. };
  64211. }
  64212. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64213. import { Nullable } from "babylonjs/types";
  64214. import { Engine } from "babylonjs/Engines/engine";
  64215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64216. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64217. import { Camera } from "babylonjs/Cameras/camera";
  64218. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64219. /**
  64220. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64221. */
  64222. export class CircleOfConfusionPostProcess extends PostProcess {
  64223. /**
  64224. * 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.
  64225. */
  64226. lensSize: number;
  64227. /**
  64228. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64229. */
  64230. fStop: number;
  64231. /**
  64232. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64233. */
  64234. focusDistance: number;
  64235. /**
  64236. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64237. */
  64238. focalLength: number;
  64239. private _depthTexture;
  64240. /**
  64241. * Creates a new instance CircleOfConfusionPostProcess
  64242. * @param name The name of the effect.
  64243. * @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.
  64244. * @param options The required width/height ratio to downsize to before computing the render pass.
  64245. * @param camera The camera to apply the render pass to.
  64246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64247. * @param engine The engine which the post process will be applied. (default: current engine)
  64248. * @param reusable If the post process can be reused on the same frame. (default: false)
  64249. * @param textureType Type of textures used when performing the post process. (default: 0)
  64250. * @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)
  64251. */
  64252. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64253. /**
  64254. * 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.
  64255. */
  64256. depthTexture: RenderTargetTexture;
  64257. }
  64258. }
  64259. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64260. /** @hidden */
  64261. export var colorCorrectionPixelShader: {
  64262. name: string;
  64263. shader: string;
  64264. };
  64265. }
  64266. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64267. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64268. import { Engine } from "babylonjs/Engines/engine";
  64269. import { Camera } from "babylonjs/Cameras/camera";
  64270. import "babylonjs/Shaders/colorCorrection.fragment";
  64271. /**
  64272. *
  64273. * This post-process allows the modification of rendered colors by using
  64274. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64275. *
  64276. * The object needs to be provided an url to a texture containing the color
  64277. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64278. * Use an image editing software to tweak the LUT to match your needs.
  64279. *
  64280. * For an example of a color LUT, see here:
  64281. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64282. * For explanations on color grading, see here:
  64283. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64284. *
  64285. */
  64286. export class ColorCorrectionPostProcess extends PostProcess {
  64287. private _colorTableTexture;
  64288. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64289. }
  64290. }
  64291. declare module "babylonjs/Shaders/convolution.fragment" {
  64292. /** @hidden */
  64293. export var convolutionPixelShader: {
  64294. name: string;
  64295. shader: string;
  64296. };
  64297. }
  64298. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64300. import { Nullable } from "babylonjs/types";
  64301. import { Camera } from "babylonjs/Cameras/camera";
  64302. import { Engine } from "babylonjs/Engines/engine";
  64303. import "babylonjs/Shaders/convolution.fragment";
  64304. /**
  64305. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64306. * input texture to perform effects such as edge detection or sharpening
  64307. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64308. */
  64309. export class ConvolutionPostProcess extends PostProcess {
  64310. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64311. kernel: number[];
  64312. /**
  64313. * Creates a new instance ConvolutionPostProcess
  64314. * @param name The name of the effect.
  64315. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64316. * @param options The required width/height ratio to downsize to before computing the render pass.
  64317. * @param camera The camera to apply the render pass to.
  64318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64319. * @param engine The engine which the post process will be applied. (default: current engine)
  64320. * @param reusable If the post process can be reused on the same frame. (default: false)
  64321. * @param textureType Type of textures used when performing the post process. (default: 0)
  64322. */
  64323. constructor(name: string,
  64324. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64325. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64326. /**
  64327. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64328. */
  64329. static EdgeDetect0Kernel: number[];
  64330. /**
  64331. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64332. */
  64333. static EdgeDetect1Kernel: number[];
  64334. /**
  64335. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64336. */
  64337. static EdgeDetect2Kernel: number[];
  64338. /**
  64339. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64340. */
  64341. static SharpenKernel: number[];
  64342. /**
  64343. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64344. */
  64345. static EmbossKernel: number[];
  64346. /**
  64347. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64348. */
  64349. static GaussianKernel: number[];
  64350. }
  64351. }
  64352. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64353. import { Nullable } from "babylonjs/types";
  64354. import { Vector2 } from "babylonjs/Maths/math.vector";
  64355. import { Camera } from "babylonjs/Cameras/camera";
  64356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64357. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64358. import { Engine } from "babylonjs/Engines/engine";
  64359. import { Scene } from "babylonjs/scene";
  64360. /**
  64361. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64362. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64363. * based on samples that have a large difference in distance than the center pixel.
  64364. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64365. */
  64366. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64367. direction: Vector2;
  64368. /**
  64369. * Creates a new instance CircleOfConfusionPostProcess
  64370. * @param name The name of the effect.
  64371. * @param scene The scene the effect belongs to.
  64372. * @param direction The direction the blur should be applied.
  64373. * @param kernel The size of the kernel used to blur.
  64374. * @param options The required width/height ratio to downsize to before computing the render pass.
  64375. * @param camera The camera to apply the render pass to.
  64376. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64377. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64379. * @param engine The engine which the post process will be applied. (default: current engine)
  64380. * @param reusable If the post process can be reused on the same frame. (default: false)
  64381. * @param textureType Type of textures used when performing the post process. (default: 0)
  64382. * @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)
  64383. */
  64384. 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);
  64385. }
  64386. }
  64387. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64388. /** @hidden */
  64389. export var depthOfFieldMergePixelShader: {
  64390. name: string;
  64391. shader: string;
  64392. };
  64393. }
  64394. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64395. import { Nullable } from "babylonjs/types";
  64396. import { Camera } from "babylonjs/Cameras/camera";
  64397. import { Effect } from "babylonjs/Materials/effect";
  64398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64399. import { Engine } from "babylonjs/Engines/engine";
  64400. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64401. /**
  64402. * Options to be set when merging outputs from the default pipeline.
  64403. */
  64404. export class DepthOfFieldMergePostProcessOptions {
  64405. /**
  64406. * The original image to merge on top of
  64407. */
  64408. originalFromInput: PostProcess;
  64409. /**
  64410. * Parameters to perform the merge of the depth of field effect
  64411. */
  64412. depthOfField?: {
  64413. circleOfConfusion: PostProcess;
  64414. blurSteps: Array<PostProcess>;
  64415. };
  64416. /**
  64417. * Parameters to perform the merge of bloom effect
  64418. */
  64419. bloom?: {
  64420. blurred: PostProcess;
  64421. weight: number;
  64422. };
  64423. }
  64424. /**
  64425. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64426. */
  64427. export class DepthOfFieldMergePostProcess extends PostProcess {
  64428. private blurSteps;
  64429. /**
  64430. * Creates a new instance of DepthOfFieldMergePostProcess
  64431. * @param name The name of the effect.
  64432. * @param originalFromInput Post process which's input will be used for the merge.
  64433. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64434. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64435. * @param options The required width/height ratio to downsize to before computing the render pass.
  64436. * @param camera The camera to apply the render pass to.
  64437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64438. * @param engine The engine which the post process will be applied. (default: current engine)
  64439. * @param reusable If the post process can be reused on the same frame. (default: false)
  64440. * @param textureType Type of textures used when performing the post process. (default: 0)
  64441. * @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)
  64442. */
  64443. 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);
  64444. /**
  64445. * Updates the effect with the current post process compile time values and recompiles the shader.
  64446. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64447. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64448. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64449. * @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
  64450. * @param onCompiled Called when the shader has been compiled.
  64451. * @param onError Called if there is an error when compiling a shader.
  64452. */
  64453. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64454. }
  64455. }
  64456. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64457. import { Nullable } from "babylonjs/types";
  64458. import { Camera } from "babylonjs/Cameras/camera";
  64459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64460. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64461. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64462. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64463. import { Scene } from "babylonjs/scene";
  64464. /**
  64465. * Specifies the level of max blur that should be applied when using the depth of field effect
  64466. */
  64467. export enum DepthOfFieldEffectBlurLevel {
  64468. /**
  64469. * Subtle blur
  64470. */
  64471. Low = 0,
  64472. /**
  64473. * Medium blur
  64474. */
  64475. Medium = 1,
  64476. /**
  64477. * Large blur
  64478. */
  64479. High = 2
  64480. }
  64481. /**
  64482. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64483. */
  64484. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64485. private _circleOfConfusion;
  64486. /**
  64487. * @hidden Internal, blurs from high to low
  64488. */
  64489. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64490. private _depthOfFieldBlurY;
  64491. private _dofMerge;
  64492. /**
  64493. * @hidden Internal post processes in depth of field effect
  64494. */
  64495. _effects: Array<PostProcess>;
  64496. /**
  64497. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64498. */
  64499. focalLength: number;
  64500. /**
  64501. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64502. */
  64503. fStop: number;
  64504. /**
  64505. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64506. */
  64507. focusDistance: number;
  64508. /**
  64509. * 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.
  64510. */
  64511. lensSize: number;
  64512. /**
  64513. * Creates a new instance DepthOfFieldEffect
  64514. * @param scene The scene the effect belongs to.
  64515. * @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.
  64516. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64517. * @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)
  64518. */
  64519. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64520. /**
  64521. * Get the current class name of the current effet
  64522. * @returns "DepthOfFieldEffect"
  64523. */
  64524. getClassName(): string;
  64525. /**
  64526. * 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.
  64527. */
  64528. depthTexture: RenderTargetTexture;
  64529. /**
  64530. * Disposes each of the internal effects for a given camera.
  64531. * @param camera The camera to dispose the effect on.
  64532. */
  64533. disposeEffects(camera: Camera): void;
  64534. /**
  64535. * @hidden Internal
  64536. */
  64537. _updateEffects(): void;
  64538. /**
  64539. * Internal
  64540. * @returns if all the contained post processes are ready.
  64541. * @hidden
  64542. */
  64543. _isReady(): boolean;
  64544. }
  64545. }
  64546. declare module "babylonjs/Shaders/displayPass.fragment" {
  64547. /** @hidden */
  64548. export var displayPassPixelShader: {
  64549. name: string;
  64550. shader: string;
  64551. };
  64552. }
  64553. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64554. import { Nullable } from "babylonjs/types";
  64555. import { Camera } from "babylonjs/Cameras/camera";
  64556. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64557. import { Engine } from "babylonjs/Engines/engine";
  64558. import "babylonjs/Shaders/displayPass.fragment";
  64559. /**
  64560. * DisplayPassPostProcess which produces an output the same as it's input
  64561. */
  64562. export class DisplayPassPostProcess extends PostProcess {
  64563. /**
  64564. * Creates the DisplayPassPostProcess
  64565. * @param name The name of the effect.
  64566. * @param options The required width/height ratio to downsize to before computing the render pass.
  64567. * @param camera The camera to apply the render pass to.
  64568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64569. * @param engine The engine which the post process will be applied. (default: current engine)
  64570. * @param reusable If the post process can be reused on the same frame. (default: false)
  64571. */
  64572. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64573. }
  64574. }
  64575. declare module "babylonjs/Shaders/filter.fragment" {
  64576. /** @hidden */
  64577. export var filterPixelShader: {
  64578. name: string;
  64579. shader: string;
  64580. };
  64581. }
  64582. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64583. import { Nullable } from "babylonjs/types";
  64584. import { Matrix } from "babylonjs/Maths/math.vector";
  64585. import { Camera } from "babylonjs/Cameras/camera";
  64586. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64587. import { Engine } from "babylonjs/Engines/engine";
  64588. import "babylonjs/Shaders/filter.fragment";
  64589. /**
  64590. * Applies a kernel filter to the image
  64591. */
  64592. export class FilterPostProcess extends PostProcess {
  64593. /** The matrix to be applied to the image */
  64594. kernelMatrix: Matrix;
  64595. /**
  64596. *
  64597. * @param name The name of the effect.
  64598. * @param kernelMatrix The matrix to be applied to the image
  64599. * @param options The required width/height ratio to downsize to before computing the render pass.
  64600. * @param camera The camera to apply the render pass to.
  64601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64602. * @param engine The engine which the post process will be applied. (default: current engine)
  64603. * @param reusable If the post process can be reused on the same frame. (default: false)
  64604. */
  64605. constructor(name: string,
  64606. /** The matrix to be applied to the image */
  64607. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64608. }
  64609. }
  64610. declare module "babylonjs/Shaders/fxaa.fragment" {
  64611. /** @hidden */
  64612. export var fxaaPixelShader: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module "babylonjs/Shaders/fxaa.vertex" {
  64618. /** @hidden */
  64619. export var fxaaVertexShader: {
  64620. name: string;
  64621. shader: string;
  64622. };
  64623. }
  64624. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64625. import { Nullable } from "babylonjs/types";
  64626. import { Camera } from "babylonjs/Cameras/camera";
  64627. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64628. import { Engine } from "babylonjs/Engines/engine";
  64629. import "babylonjs/Shaders/fxaa.fragment";
  64630. import "babylonjs/Shaders/fxaa.vertex";
  64631. /**
  64632. * Fxaa post process
  64633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64634. */
  64635. export class FxaaPostProcess extends PostProcess {
  64636. /** @hidden */
  64637. texelWidth: number;
  64638. /** @hidden */
  64639. texelHeight: number;
  64640. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64641. private _getDefines;
  64642. }
  64643. }
  64644. declare module "babylonjs/Shaders/grain.fragment" {
  64645. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64646. /** @hidden */
  64647. export var grainPixelShader: {
  64648. name: string;
  64649. shader: string;
  64650. };
  64651. }
  64652. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64653. import { Nullable } from "babylonjs/types";
  64654. import { Camera } from "babylonjs/Cameras/camera";
  64655. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64656. import { Engine } from "babylonjs/Engines/engine";
  64657. import "babylonjs/Shaders/grain.fragment";
  64658. /**
  64659. * The GrainPostProcess adds noise to the image at mid luminance levels
  64660. */
  64661. export class GrainPostProcess extends PostProcess {
  64662. /**
  64663. * The intensity of the grain added (default: 30)
  64664. */
  64665. intensity: number;
  64666. /**
  64667. * If the grain should be randomized on every frame
  64668. */
  64669. animated: boolean;
  64670. /**
  64671. * Creates a new instance of @see GrainPostProcess
  64672. * @param name The name of the effect.
  64673. * @param options The required width/height ratio to downsize to before computing the render pass.
  64674. * @param camera The camera to apply the render pass to.
  64675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64676. * @param engine The engine which the post process will be applied. (default: current engine)
  64677. * @param reusable If the post process can be reused on the same frame. (default: false)
  64678. * @param textureType Type of textures used when performing the post process. (default: 0)
  64679. * @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)
  64680. */
  64681. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64682. }
  64683. }
  64684. declare module "babylonjs/Shaders/highlights.fragment" {
  64685. /** @hidden */
  64686. export var highlightsPixelShader: {
  64687. name: string;
  64688. shader: string;
  64689. };
  64690. }
  64691. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64692. import { Nullable } from "babylonjs/types";
  64693. import { Camera } from "babylonjs/Cameras/camera";
  64694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64695. import { Engine } from "babylonjs/Engines/engine";
  64696. import "babylonjs/Shaders/highlights.fragment";
  64697. /**
  64698. * Extracts highlights from the image
  64699. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64700. */
  64701. export class HighlightsPostProcess extends PostProcess {
  64702. /**
  64703. * Extracts highlights from the image
  64704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64705. * @param name The name of the effect.
  64706. * @param options The required width/height ratio to downsize to before computing the render pass.
  64707. * @param camera The camera to apply the render pass to.
  64708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64709. * @param engine The engine which the post process will be applied. (default: current engine)
  64710. * @param reusable If the post process can be reused on the same frame. (default: false)
  64711. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64712. */
  64713. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64714. }
  64715. }
  64716. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64717. /** @hidden */
  64718. export var mrtFragmentDeclaration: {
  64719. name: string;
  64720. shader: string;
  64721. };
  64722. }
  64723. declare module "babylonjs/Shaders/geometry.fragment" {
  64724. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64725. /** @hidden */
  64726. export var geometryPixelShader: {
  64727. name: string;
  64728. shader: string;
  64729. };
  64730. }
  64731. declare module "babylonjs/Shaders/geometry.vertex" {
  64732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64733. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64736. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64739. /** @hidden */
  64740. export var geometryVertexShader: {
  64741. name: string;
  64742. shader: string;
  64743. };
  64744. }
  64745. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64746. import { Matrix } from "babylonjs/Maths/math.vector";
  64747. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64748. import { Mesh } from "babylonjs/Meshes/mesh";
  64749. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64750. import { Effect } from "babylonjs/Materials/effect";
  64751. import { Scene } from "babylonjs/scene";
  64752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64753. import "babylonjs/Shaders/geometry.fragment";
  64754. import "babylonjs/Shaders/geometry.vertex";
  64755. /** @hidden */
  64756. interface ISavedTransformationMatrix {
  64757. world: Matrix;
  64758. viewProjection: Matrix;
  64759. }
  64760. /**
  64761. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64762. */
  64763. export class GeometryBufferRenderer {
  64764. /**
  64765. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64766. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64767. */
  64768. static readonly POSITION_TEXTURE_TYPE: number;
  64769. /**
  64770. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64771. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64772. */
  64773. static readonly VELOCITY_TEXTURE_TYPE: number;
  64774. /**
  64775. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64776. * in order to compute objects velocities when enableVelocity is set to "true"
  64777. * @hidden
  64778. */
  64779. _previousTransformationMatrices: {
  64780. [index: number]: ISavedTransformationMatrix;
  64781. };
  64782. /**
  64783. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64784. * in order to compute objects velocities when enableVelocity is set to "true"
  64785. * @hidden
  64786. */
  64787. _previousBonesTransformationMatrices: {
  64788. [index: number]: Float32Array;
  64789. };
  64790. /**
  64791. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64792. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64793. */
  64794. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64795. private _scene;
  64796. private _multiRenderTarget;
  64797. private _ratio;
  64798. private _enablePosition;
  64799. private _enableVelocity;
  64800. private _positionIndex;
  64801. private _velocityIndex;
  64802. protected _effect: Effect;
  64803. protected _cachedDefines: string;
  64804. /**
  64805. * Set the render list (meshes to be rendered) used in the G buffer.
  64806. */
  64807. renderList: Mesh[];
  64808. /**
  64809. * Gets wether or not G buffer are supported by the running hardware.
  64810. * This requires draw buffer supports
  64811. */
  64812. readonly isSupported: boolean;
  64813. /**
  64814. * Returns the index of the given texture type in the G-Buffer textures array
  64815. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64816. * @returns the index of the given texture type in the G-Buffer textures array
  64817. */
  64818. getTextureIndex(textureType: number): number;
  64819. /**
  64820. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64821. */
  64822. /**
  64823. * Sets whether or not objects positions are enabled for the G buffer.
  64824. */
  64825. enablePosition: boolean;
  64826. /**
  64827. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64828. */
  64829. /**
  64830. * Sets wether or not objects velocities are enabled for the G buffer.
  64831. */
  64832. enableVelocity: boolean;
  64833. /**
  64834. * Gets the scene associated with the buffer.
  64835. */
  64836. readonly scene: Scene;
  64837. /**
  64838. * Gets the ratio used by the buffer during its creation.
  64839. * How big is the buffer related to the main canvas.
  64840. */
  64841. readonly ratio: number;
  64842. /** @hidden */
  64843. static _SceneComponentInitialization: (scene: Scene) => void;
  64844. /**
  64845. * Creates a new G Buffer for the scene
  64846. * @param scene The scene the buffer belongs to
  64847. * @param ratio How big is the buffer related to the main canvas.
  64848. */
  64849. constructor(scene: Scene, ratio?: number);
  64850. /**
  64851. * Checks wether everything is ready to render a submesh to the G buffer.
  64852. * @param subMesh the submesh to check readiness for
  64853. * @param useInstances is the mesh drawn using instance or not
  64854. * @returns true if ready otherwise false
  64855. */
  64856. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64857. /**
  64858. * Gets the current underlying G Buffer.
  64859. * @returns the buffer
  64860. */
  64861. getGBuffer(): MultiRenderTarget;
  64862. /**
  64863. * Gets the number of samples used to render the buffer (anti aliasing).
  64864. */
  64865. /**
  64866. * Sets the number of samples used to render the buffer (anti aliasing).
  64867. */
  64868. samples: number;
  64869. /**
  64870. * Disposes the renderer and frees up associated resources.
  64871. */
  64872. dispose(): void;
  64873. protected _createRenderTargets(): void;
  64874. private _copyBonesTransformationMatrices;
  64875. }
  64876. }
  64877. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64878. import { Nullable } from "babylonjs/types";
  64879. import { Scene } from "babylonjs/scene";
  64880. import { ISceneComponent } from "babylonjs/sceneComponent";
  64881. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64882. module "babylonjs/scene" {
  64883. interface Scene {
  64884. /** @hidden (Backing field) */
  64885. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64886. /**
  64887. * Gets or Sets the current geometry buffer associated to the scene.
  64888. */
  64889. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64890. /**
  64891. * Enables a GeometryBufferRender and associates it with the scene
  64892. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64893. * @returns the GeometryBufferRenderer
  64894. */
  64895. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64896. /**
  64897. * Disables the GeometryBufferRender associated with the scene
  64898. */
  64899. disableGeometryBufferRenderer(): void;
  64900. }
  64901. }
  64902. /**
  64903. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64904. * in several rendering techniques.
  64905. */
  64906. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64907. /**
  64908. * The component name helpful to identify the component in the list of scene components.
  64909. */
  64910. readonly name: string;
  64911. /**
  64912. * The scene the component belongs to.
  64913. */
  64914. scene: Scene;
  64915. /**
  64916. * Creates a new instance of the component for the given scene
  64917. * @param scene Defines the scene to register the component in
  64918. */
  64919. constructor(scene: Scene);
  64920. /**
  64921. * Registers the component in a given scene
  64922. */
  64923. register(): void;
  64924. /**
  64925. * Rebuilds the elements related to this component in case of
  64926. * context lost for instance.
  64927. */
  64928. rebuild(): void;
  64929. /**
  64930. * Disposes the component and the associated ressources
  64931. */
  64932. dispose(): void;
  64933. private _gatherRenderTargets;
  64934. }
  64935. }
  64936. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64937. /** @hidden */
  64938. export var motionBlurPixelShader: {
  64939. name: string;
  64940. shader: string;
  64941. };
  64942. }
  64943. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64944. import { Nullable } from "babylonjs/types";
  64945. import { Camera } from "babylonjs/Cameras/camera";
  64946. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64947. import { Scene } from "babylonjs/scene";
  64948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64949. import "babylonjs/Animations/animatable";
  64950. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64951. import "babylonjs/Shaders/motionBlur.fragment";
  64952. import { Engine } from "babylonjs/Engines/engine";
  64953. /**
  64954. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64955. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64956. * As an example, all you have to do is to create the post-process:
  64957. * var mb = new BABYLON.MotionBlurPostProcess(
  64958. * 'mb', // The name of the effect.
  64959. * scene, // The scene containing the objects to blur according to their velocity.
  64960. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64961. * camera // The camera to apply the render pass to.
  64962. * );
  64963. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64964. */
  64965. export class MotionBlurPostProcess extends PostProcess {
  64966. /**
  64967. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64968. */
  64969. motionStrength: number;
  64970. /**
  64971. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64972. */
  64973. /**
  64974. * Sets the number of iterations to be used for motion blur quality
  64975. */
  64976. motionBlurSamples: number;
  64977. private _motionBlurSamples;
  64978. private _geometryBufferRenderer;
  64979. /**
  64980. * Creates a new instance MotionBlurPostProcess
  64981. * @param name The name of the effect.
  64982. * @param scene The scene containing the objects to blur according to their velocity.
  64983. * @param options The required width/height ratio to downsize to before computing the render pass.
  64984. * @param camera The camera to apply the render pass to.
  64985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64986. * @param engine The engine which the post process will be applied. (default: current engine)
  64987. * @param reusable If the post process can be reused on the same frame. (default: false)
  64988. * @param textureType Type of textures used when performing the post process. (default: 0)
  64989. * @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)
  64990. */
  64991. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64992. /**
  64993. * Excludes the given skinned mesh from computing bones velocities.
  64994. * 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.
  64995. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64996. */
  64997. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64998. /**
  64999. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65000. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65001. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65002. */
  65003. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65004. /**
  65005. * Disposes the post process.
  65006. * @param camera The camera to dispose the post process on.
  65007. */
  65008. dispose(camera?: Camera): void;
  65009. }
  65010. }
  65011. declare module "babylonjs/Shaders/refraction.fragment" {
  65012. /** @hidden */
  65013. export var refractionPixelShader: {
  65014. name: string;
  65015. shader: string;
  65016. };
  65017. }
  65018. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65019. import { Color3 } from "babylonjs/Maths/math.color";
  65020. import { Camera } from "babylonjs/Cameras/camera";
  65021. import { Texture } from "babylonjs/Materials/Textures/texture";
  65022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65023. import { Engine } from "babylonjs/Engines/engine";
  65024. import "babylonjs/Shaders/refraction.fragment";
  65025. /**
  65026. * Post process which applies a refractin texture
  65027. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65028. */
  65029. export class RefractionPostProcess extends PostProcess {
  65030. /** the base color of the refraction (used to taint the rendering) */
  65031. color: Color3;
  65032. /** simulated refraction depth */
  65033. depth: number;
  65034. /** the coefficient of the base color (0 to remove base color tainting) */
  65035. colorLevel: number;
  65036. private _refTexture;
  65037. private _ownRefractionTexture;
  65038. /**
  65039. * Gets or sets the refraction texture
  65040. * Please note that you are responsible for disposing the texture if you set it manually
  65041. */
  65042. refractionTexture: Texture;
  65043. /**
  65044. * Initializes the RefractionPostProcess
  65045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65046. * @param name The name of the effect.
  65047. * @param refractionTextureUrl Url of the refraction texture to use
  65048. * @param color the base color of the refraction (used to taint the rendering)
  65049. * @param depth simulated refraction depth
  65050. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65051. * @param camera The camera to apply the render pass to.
  65052. * @param options The required width/height ratio to downsize to before computing the render pass.
  65053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65054. * @param engine The engine which the post process will be applied. (default: current engine)
  65055. * @param reusable If the post process can be reused on the same frame. (default: false)
  65056. */
  65057. constructor(name: string, refractionTextureUrl: string,
  65058. /** the base color of the refraction (used to taint the rendering) */
  65059. color: Color3,
  65060. /** simulated refraction depth */
  65061. depth: number,
  65062. /** the coefficient of the base color (0 to remove base color tainting) */
  65063. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65064. /**
  65065. * Disposes of the post process
  65066. * @param camera Camera to dispose post process on
  65067. */
  65068. dispose(camera: Camera): void;
  65069. }
  65070. }
  65071. declare module "babylonjs/Shaders/sharpen.fragment" {
  65072. /** @hidden */
  65073. export var sharpenPixelShader: {
  65074. name: string;
  65075. shader: string;
  65076. };
  65077. }
  65078. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65079. import { Nullable } from "babylonjs/types";
  65080. import { Camera } from "babylonjs/Cameras/camera";
  65081. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65082. import "babylonjs/Shaders/sharpen.fragment";
  65083. import { Engine } from "babylonjs/Engines/engine";
  65084. /**
  65085. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65086. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65087. */
  65088. export class SharpenPostProcess extends PostProcess {
  65089. /**
  65090. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65091. */
  65092. colorAmount: number;
  65093. /**
  65094. * How much sharpness should be applied (default: 0.3)
  65095. */
  65096. edgeAmount: number;
  65097. /**
  65098. * Creates a new instance ConvolutionPostProcess
  65099. * @param name The name of the effect.
  65100. * @param options The required width/height ratio to downsize to before computing the render pass.
  65101. * @param camera The camera to apply the render pass to.
  65102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65103. * @param engine The engine which the post process will be applied. (default: current engine)
  65104. * @param reusable If the post process can be reused on the same frame. (default: false)
  65105. * @param textureType Type of textures used when performing the post process. (default: 0)
  65106. * @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)
  65107. */
  65108. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65109. }
  65110. }
  65111. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65112. import { Nullable } from "babylonjs/types";
  65113. import { Camera } from "babylonjs/Cameras/camera";
  65114. import { Engine } from "babylonjs/Engines/engine";
  65115. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65116. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65117. /**
  65118. * PostProcessRenderPipeline
  65119. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65120. */
  65121. export class PostProcessRenderPipeline {
  65122. private engine;
  65123. private _renderEffects;
  65124. private _renderEffectsForIsolatedPass;
  65125. /**
  65126. * List of inspectable custom properties (used by the Inspector)
  65127. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65128. */
  65129. inspectableCustomProperties: IInspectable[];
  65130. /**
  65131. * @hidden
  65132. */
  65133. protected _cameras: Camera[];
  65134. /** @hidden */
  65135. _name: string;
  65136. /**
  65137. * Gets pipeline name
  65138. */
  65139. readonly name: string;
  65140. /** Gets the list of attached cameras */
  65141. readonly cameras: Camera[];
  65142. /**
  65143. * Initializes a PostProcessRenderPipeline
  65144. * @param engine engine to add the pipeline to
  65145. * @param name name of the pipeline
  65146. */
  65147. constructor(engine: Engine, name: string);
  65148. /**
  65149. * Gets the class name
  65150. * @returns "PostProcessRenderPipeline"
  65151. */
  65152. getClassName(): string;
  65153. /**
  65154. * If all the render effects in the pipeline are supported
  65155. */
  65156. readonly isSupported: boolean;
  65157. /**
  65158. * Adds an effect to the pipeline
  65159. * @param renderEffect the effect to add
  65160. */
  65161. addEffect(renderEffect: PostProcessRenderEffect): void;
  65162. /** @hidden */
  65163. _rebuild(): void;
  65164. /** @hidden */
  65165. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65166. /** @hidden */
  65167. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65168. /** @hidden */
  65169. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65170. /** @hidden */
  65171. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65172. /** @hidden */
  65173. _attachCameras(cameras: Camera, unique: boolean): void;
  65174. /** @hidden */
  65175. _attachCameras(cameras: Camera[], unique: boolean): void;
  65176. /** @hidden */
  65177. _detachCameras(cameras: Camera): void;
  65178. /** @hidden */
  65179. _detachCameras(cameras: Nullable<Camera[]>): void;
  65180. /** @hidden */
  65181. _update(): void;
  65182. /** @hidden */
  65183. _reset(): void;
  65184. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65185. /**
  65186. * Disposes of the pipeline
  65187. */
  65188. dispose(): void;
  65189. }
  65190. }
  65191. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65192. import { Camera } from "babylonjs/Cameras/camera";
  65193. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65194. /**
  65195. * PostProcessRenderPipelineManager class
  65196. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65197. */
  65198. export class PostProcessRenderPipelineManager {
  65199. private _renderPipelines;
  65200. /**
  65201. * Initializes a PostProcessRenderPipelineManager
  65202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65203. */
  65204. constructor();
  65205. /**
  65206. * Gets the list of supported render pipelines
  65207. */
  65208. readonly supportedPipelines: PostProcessRenderPipeline[];
  65209. /**
  65210. * Adds a pipeline to the manager
  65211. * @param renderPipeline The pipeline to add
  65212. */
  65213. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65214. /**
  65215. * Attaches a camera to the pipeline
  65216. * @param renderPipelineName The name of the pipeline to attach to
  65217. * @param cameras the camera to attach
  65218. * @param unique if the camera can be attached multiple times to the pipeline
  65219. */
  65220. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65221. /**
  65222. * Detaches a camera from the pipeline
  65223. * @param renderPipelineName The name of the pipeline to detach from
  65224. * @param cameras the camera to detach
  65225. */
  65226. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65227. /**
  65228. * Enables an effect by name on a pipeline
  65229. * @param renderPipelineName the name of the pipeline to enable the effect in
  65230. * @param renderEffectName the name of the effect to enable
  65231. * @param cameras the cameras that the effect should be enabled on
  65232. */
  65233. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65234. /**
  65235. * Disables an effect by name on a pipeline
  65236. * @param renderPipelineName the name of the pipeline to disable the effect in
  65237. * @param renderEffectName the name of the effect to disable
  65238. * @param cameras the cameras that the effect should be disabled on
  65239. */
  65240. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65241. /**
  65242. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65243. */
  65244. update(): void;
  65245. /** @hidden */
  65246. _rebuild(): void;
  65247. /**
  65248. * Disposes of the manager and pipelines
  65249. */
  65250. dispose(): void;
  65251. }
  65252. }
  65253. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65254. import { ISceneComponent } from "babylonjs/sceneComponent";
  65255. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65256. import { Scene } from "babylonjs/scene";
  65257. module "babylonjs/scene" {
  65258. interface Scene {
  65259. /** @hidden (Backing field) */
  65260. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65261. /**
  65262. * Gets the postprocess render pipeline manager
  65263. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65264. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65265. */
  65266. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65267. }
  65268. }
  65269. /**
  65270. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65271. */
  65272. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65273. /**
  65274. * The component name helpfull to identify the component in the list of scene components.
  65275. */
  65276. readonly name: string;
  65277. /**
  65278. * The scene the component belongs to.
  65279. */
  65280. scene: Scene;
  65281. /**
  65282. * Creates a new instance of the component for the given scene
  65283. * @param scene Defines the scene to register the component in
  65284. */
  65285. constructor(scene: Scene);
  65286. /**
  65287. * Registers the component in a given scene
  65288. */
  65289. register(): void;
  65290. /**
  65291. * Rebuilds the elements related to this component in case of
  65292. * context lost for instance.
  65293. */
  65294. rebuild(): void;
  65295. /**
  65296. * Disposes the component and the associated ressources
  65297. */
  65298. dispose(): void;
  65299. private _gatherRenderTargets;
  65300. }
  65301. }
  65302. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65303. import { Nullable } from "babylonjs/types";
  65304. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65305. import { Camera } from "babylonjs/Cameras/camera";
  65306. import { IDisposable } from "babylonjs/scene";
  65307. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65308. import { Scene } from "babylonjs/scene";
  65309. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65310. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65311. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65312. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65313. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65314. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65315. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65316. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65317. import { Animation } from "babylonjs/Animations/animation";
  65318. /**
  65319. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65320. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65321. */
  65322. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65323. private _scene;
  65324. private _camerasToBeAttached;
  65325. /**
  65326. * ID of the sharpen post process,
  65327. */
  65328. private readonly SharpenPostProcessId;
  65329. /**
  65330. * @ignore
  65331. * ID of the image processing post process;
  65332. */
  65333. readonly ImageProcessingPostProcessId: string;
  65334. /**
  65335. * @ignore
  65336. * ID of the Fast Approximate Anti-Aliasing post process;
  65337. */
  65338. readonly FxaaPostProcessId: string;
  65339. /**
  65340. * ID of the chromatic aberration post process,
  65341. */
  65342. private readonly ChromaticAberrationPostProcessId;
  65343. /**
  65344. * ID of the grain post process
  65345. */
  65346. private readonly GrainPostProcessId;
  65347. /**
  65348. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65349. */
  65350. sharpen: SharpenPostProcess;
  65351. private _sharpenEffect;
  65352. private bloom;
  65353. /**
  65354. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65355. */
  65356. depthOfField: DepthOfFieldEffect;
  65357. /**
  65358. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65359. */
  65360. fxaa: FxaaPostProcess;
  65361. /**
  65362. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65363. */
  65364. imageProcessing: ImageProcessingPostProcess;
  65365. /**
  65366. * Chromatic aberration post process which will shift rgb colors in the image
  65367. */
  65368. chromaticAberration: ChromaticAberrationPostProcess;
  65369. private _chromaticAberrationEffect;
  65370. /**
  65371. * Grain post process which add noise to the image
  65372. */
  65373. grain: GrainPostProcess;
  65374. private _grainEffect;
  65375. /**
  65376. * Glow post process which adds a glow to emissive areas of the image
  65377. */
  65378. private _glowLayer;
  65379. /**
  65380. * Animations which can be used to tweak settings over a period of time
  65381. */
  65382. animations: Animation[];
  65383. private _imageProcessingConfigurationObserver;
  65384. private _sharpenEnabled;
  65385. private _bloomEnabled;
  65386. private _depthOfFieldEnabled;
  65387. private _depthOfFieldBlurLevel;
  65388. private _fxaaEnabled;
  65389. private _imageProcessingEnabled;
  65390. private _defaultPipelineTextureType;
  65391. private _bloomScale;
  65392. private _chromaticAberrationEnabled;
  65393. private _grainEnabled;
  65394. private _buildAllowed;
  65395. /**
  65396. * Gets active scene
  65397. */
  65398. readonly scene: Scene;
  65399. /**
  65400. * Enable or disable the sharpen process from the pipeline
  65401. */
  65402. sharpenEnabled: boolean;
  65403. private _resizeObserver;
  65404. private _hardwareScaleLevel;
  65405. private _bloomKernel;
  65406. /**
  65407. * Specifies the size of the bloom blur kernel, relative to the final output size
  65408. */
  65409. bloomKernel: number;
  65410. /**
  65411. * Specifies the weight of the bloom in the final rendering
  65412. */
  65413. private _bloomWeight;
  65414. /**
  65415. * Specifies the luma threshold for the area that will be blurred by the bloom
  65416. */
  65417. private _bloomThreshold;
  65418. private _hdr;
  65419. /**
  65420. * The strength of the bloom.
  65421. */
  65422. bloomWeight: number;
  65423. /**
  65424. * The strength of the bloom.
  65425. */
  65426. bloomThreshold: number;
  65427. /**
  65428. * The scale of the bloom, lower value will provide better performance.
  65429. */
  65430. bloomScale: number;
  65431. /**
  65432. * Enable or disable the bloom from the pipeline
  65433. */
  65434. bloomEnabled: boolean;
  65435. private _rebuildBloom;
  65436. /**
  65437. * If the depth of field is enabled.
  65438. */
  65439. depthOfFieldEnabled: boolean;
  65440. /**
  65441. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65442. */
  65443. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65444. /**
  65445. * If the anti aliasing is enabled.
  65446. */
  65447. fxaaEnabled: boolean;
  65448. private _samples;
  65449. /**
  65450. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65451. */
  65452. samples: number;
  65453. /**
  65454. * If image processing is enabled.
  65455. */
  65456. imageProcessingEnabled: boolean;
  65457. /**
  65458. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65459. */
  65460. glowLayerEnabled: boolean;
  65461. /**
  65462. * Gets the glow layer (or null if not defined)
  65463. */
  65464. readonly glowLayer: Nullable<GlowLayer>;
  65465. /**
  65466. * Enable or disable the chromaticAberration process from the pipeline
  65467. */
  65468. chromaticAberrationEnabled: boolean;
  65469. /**
  65470. * Enable or disable the grain process from the pipeline
  65471. */
  65472. grainEnabled: boolean;
  65473. /**
  65474. * @constructor
  65475. * @param name - The rendering pipeline name (default: "")
  65476. * @param hdr - If high dynamic range textures should be used (default: true)
  65477. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65478. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65479. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65480. */
  65481. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65482. /**
  65483. * Get the class name
  65484. * @returns "DefaultRenderingPipeline"
  65485. */
  65486. getClassName(): string;
  65487. /**
  65488. * Force the compilation of the entire pipeline.
  65489. */
  65490. prepare(): void;
  65491. private _hasCleared;
  65492. private _prevPostProcess;
  65493. private _prevPrevPostProcess;
  65494. private _setAutoClearAndTextureSharing;
  65495. private _depthOfFieldSceneObserver;
  65496. private _buildPipeline;
  65497. private _disposePostProcesses;
  65498. /**
  65499. * Adds a camera to the pipeline
  65500. * @param camera the camera to be added
  65501. */
  65502. addCamera(camera: Camera): void;
  65503. /**
  65504. * Removes a camera from the pipeline
  65505. * @param camera the camera to remove
  65506. */
  65507. removeCamera(camera: Camera): void;
  65508. /**
  65509. * Dispose of the pipeline and stop all post processes
  65510. */
  65511. dispose(): void;
  65512. /**
  65513. * Serialize the rendering pipeline (Used when exporting)
  65514. * @returns the serialized object
  65515. */
  65516. serialize(): any;
  65517. /**
  65518. * Parse the serialized pipeline
  65519. * @param source Source pipeline.
  65520. * @param scene The scene to load the pipeline to.
  65521. * @param rootUrl The URL of the serialized pipeline.
  65522. * @returns An instantiated pipeline from the serialized object.
  65523. */
  65524. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65525. }
  65526. }
  65527. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65528. /** @hidden */
  65529. export var lensHighlightsPixelShader: {
  65530. name: string;
  65531. shader: string;
  65532. };
  65533. }
  65534. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65535. /** @hidden */
  65536. export var depthOfFieldPixelShader: {
  65537. name: string;
  65538. shader: string;
  65539. };
  65540. }
  65541. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65542. import { Camera } from "babylonjs/Cameras/camera";
  65543. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65544. import { Scene } from "babylonjs/scene";
  65545. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65546. import "babylonjs/Shaders/chromaticAberration.fragment";
  65547. import "babylonjs/Shaders/lensHighlights.fragment";
  65548. import "babylonjs/Shaders/depthOfField.fragment";
  65549. /**
  65550. * BABYLON.JS Chromatic Aberration GLSL Shader
  65551. * Author: Olivier Guyot
  65552. * Separates very slightly R, G and B colors on the edges of the screen
  65553. * Inspired by Francois Tarlier & Martins Upitis
  65554. */
  65555. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65556. /**
  65557. * @ignore
  65558. * The chromatic aberration PostProcess id in the pipeline
  65559. */
  65560. LensChromaticAberrationEffect: string;
  65561. /**
  65562. * @ignore
  65563. * The highlights enhancing PostProcess id in the pipeline
  65564. */
  65565. HighlightsEnhancingEffect: string;
  65566. /**
  65567. * @ignore
  65568. * The depth-of-field PostProcess id in the pipeline
  65569. */
  65570. LensDepthOfFieldEffect: string;
  65571. private _scene;
  65572. private _depthTexture;
  65573. private _grainTexture;
  65574. private _chromaticAberrationPostProcess;
  65575. private _highlightsPostProcess;
  65576. private _depthOfFieldPostProcess;
  65577. private _edgeBlur;
  65578. private _grainAmount;
  65579. private _chromaticAberration;
  65580. private _distortion;
  65581. private _highlightsGain;
  65582. private _highlightsThreshold;
  65583. private _dofDistance;
  65584. private _dofAperture;
  65585. private _dofDarken;
  65586. private _dofPentagon;
  65587. private _blurNoise;
  65588. /**
  65589. * @constructor
  65590. *
  65591. * Effect parameters are as follow:
  65592. * {
  65593. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65594. * edge_blur: number; // from 0 to x (1 for realism)
  65595. * distortion: number; // from 0 to x (1 for realism)
  65596. * grain_amount: number; // from 0 to 1
  65597. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65598. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65599. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65600. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65601. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65602. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65603. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65604. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65605. * }
  65606. * Note: if an effect parameter is unset, effect is disabled
  65607. *
  65608. * @param name The rendering pipeline name
  65609. * @param parameters - An object containing all parameters (see above)
  65610. * @param scene The scene linked to this pipeline
  65611. * @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)
  65612. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65613. */
  65614. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65615. /**
  65616. * Get the class name
  65617. * @returns "LensRenderingPipeline"
  65618. */
  65619. getClassName(): string;
  65620. /**
  65621. * Gets associated scene
  65622. */
  65623. readonly scene: Scene;
  65624. /**
  65625. * Gets or sets the edge blur
  65626. */
  65627. edgeBlur: number;
  65628. /**
  65629. * Gets or sets the grain amount
  65630. */
  65631. grainAmount: number;
  65632. /**
  65633. * Gets or sets the chromatic aberration amount
  65634. */
  65635. chromaticAberration: number;
  65636. /**
  65637. * Gets or sets the depth of field aperture
  65638. */
  65639. dofAperture: number;
  65640. /**
  65641. * Gets or sets the edge distortion
  65642. */
  65643. edgeDistortion: number;
  65644. /**
  65645. * Gets or sets the depth of field distortion
  65646. */
  65647. dofDistortion: number;
  65648. /**
  65649. * Gets or sets the darken out of focus amount
  65650. */
  65651. darkenOutOfFocus: number;
  65652. /**
  65653. * Gets or sets a boolean indicating if blur noise is enabled
  65654. */
  65655. blurNoise: boolean;
  65656. /**
  65657. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65658. */
  65659. pentagonBokeh: boolean;
  65660. /**
  65661. * Gets or sets the highlight grain amount
  65662. */
  65663. highlightsGain: number;
  65664. /**
  65665. * Gets or sets the highlight threshold
  65666. */
  65667. highlightsThreshold: number;
  65668. /**
  65669. * Sets the amount of blur at the edges
  65670. * @param amount blur amount
  65671. */
  65672. setEdgeBlur(amount: number): void;
  65673. /**
  65674. * Sets edge blur to 0
  65675. */
  65676. disableEdgeBlur(): void;
  65677. /**
  65678. * Sets the amout of grain
  65679. * @param amount Amount of grain
  65680. */
  65681. setGrainAmount(amount: number): void;
  65682. /**
  65683. * Set grain amount to 0
  65684. */
  65685. disableGrain(): void;
  65686. /**
  65687. * Sets the chromatic aberration amount
  65688. * @param amount amount of chromatic aberration
  65689. */
  65690. setChromaticAberration(amount: number): void;
  65691. /**
  65692. * Sets chromatic aberration amount to 0
  65693. */
  65694. disableChromaticAberration(): void;
  65695. /**
  65696. * Sets the EdgeDistortion amount
  65697. * @param amount amount of EdgeDistortion
  65698. */
  65699. setEdgeDistortion(amount: number): void;
  65700. /**
  65701. * Sets edge distortion to 0
  65702. */
  65703. disableEdgeDistortion(): void;
  65704. /**
  65705. * Sets the FocusDistance amount
  65706. * @param amount amount of FocusDistance
  65707. */
  65708. setFocusDistance(amount: number): void;
  65709. /**
  65710. * Disables depth of field
  65711. */
  65712. disableDepthOfField(): void;
  65713. /**
  65714. * Sets the Aperture amount
  65715. * @param amount amount of Aperture
  65716. */
  65717. setAperture(amount: number): void;
  65718. /**
  65719. * Sets the DarkenOutOfFocus amount
  65720. * @param amount amount of DarkenOutOfFocus
  65721. */
  65722. setDarkenOutOfFocus(amount: number): void;
  65723. private _pentagonBokehIsEnabled;
  65724. /**
  65725. * Creates a pentagon bokeh effect
  65726. */
  65727. enablePentagonBokeh(): void;
  65728. /**
  65729. * Disables the pentagon bokeh effect
  65730. */
  65731. disablePentagonBokeh(): void;
  65732. /**
  65733. * Enables noise blur
  65734. */
  65735. enableNoiseBlur(): void;
  65736. /**
  65737. * Disables noise blur
  65738. */
  65739. disableNoiseBlur(): void;
  65740. /**
  65741. * Sets the HighlightsGain amount
  65742. * @param amount amount of HighlightsGain
  65743. */
  65744. setHighlightsGain(amount: number): void;
  65745. /**
  65746. * Sets the HighlightsThreshold amount
  65747. * @param amount amount of HighlightsThreshold
  65748. */
  65749. setHighlightsThreshold(amount: number): void;
  65750. /**
  65751. * Disables highlights
  65752. */
  65753. disableHighlights(): void;
  65754. /**
  65755. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65756. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65757. */
  65758. dispose(disableDepthRender?: boolean): void;
  65759. private _createChromaticAberrationPostProcess;
  65760. private _createHighlightsPostProcess;
  65761. private _createDepthOfFieldPostProcess;
  65762. private _createGrainTexture;
  65763. }
  65764. }
  65765. declare module "babylonjs/Shaders/ssao2.fragment" {
  65766. /** @hidden */
  65767. export var ssao2PixelShader: {
  65768. name: string;
  65769. shader: string;
  65770. };
  65771. }
  65772. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65773. /** @hidden */
  65774. export var ssaoCombinePixelShader: {
  65775. name: string;
  65776. shader: string;
  65777. };
  65778. }
  65779. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65780. import { Camera } from "babylonjs/Cameras/camera";
  65781. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65782. import { Scene } from "babylonjs/scene";
  65783. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65784. import "babylonjs/Shaders/ssao2.fragment";
  65785. import "babylonjs/Shaders/ssaoCombine.fragment";
  65786. /**
  65787. * Render pipeline to produce ssao effect
  65788. */
  65789. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65790. /**
  65791. * @ignore
  65792. * The PassPostProcess id in the pipeline that contains the original scene color
  65793. */
  65794. SSAOOriginalSceneColorEffect: string;
  65795. /**
  65796. * @ignore
  65797. * The SSAO PostProcess id in the pipeline
  65798. */
  65799. SSAORenderEffect: string;
  65800. /**
  65801. * @ignore
  65802. * The horizontal blur PostProcess id in the pipeline
  65803. */
  65804. SSAOBlurHRenderEffect: string;
  65805. /**
  65806. * @ignore
  65807. * The vertical blur PostProcess id in the pipeline
  65808. */
  65809. SSAOBlurVRenderEffect: string;
  65810. /**
  65811. * @ignore
  65812. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65813. */
  65814. SSAOCombineRenderEffect: string;
  65815. /**
  65816. * The output strength of the SSAO post-process. Default value is 1.0.
  65817. */
  65818. totalStrength: number;
  65819. /**
  65820. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65821. */
  65822. maxZ: number;
  65823. /**
  65824. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65825. */
  65826. minZAspect: number;
  65827. private _samples;
  65828. /**
  65829. * Number of samples used for the SSAO calculations. Default value is 8
  65830. */
  65831. samples: number;
  65832. private _textureSamples;
  65833. /**
  65834. * Number of samples to use for antialiasing
  65835. */
  65836. textureSamples: number;
  65837. /**
  65838. * Ratio object used for SSAO ratio and blur ratio
  65839. */
  65840. private _ratio;
  65841. /**
  65842. * Dynamically generated sphere sampler.
  65843. */
  65844. private _sampleSphere;
  65845. /**
  65846. * Blur filter offsets
  65847. */
  65848. private _samplerOffsets;
  65849. private _expensiveBlur;
  65850. /**
  65851. * If bilateral blur should be used
  65852. */
  65853. expensiveBlur: boolean;
  65854. /**
  65855. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65856. */
  65857. radius: number;
  65858. /**
  65859. * The base color of the SSAO post-process
  65860. * The final result is "base + ssao" between [0, 1]
  65861. */
  65862. base: number;
  65863. /**
  65864. * Support test.
  65865. */
  65866. static readonly IsSupported: boolean;
  65867. private _scene;
  65868. private _depthTexture;
  65869. private _normalTexture;
  65870. private _randomTexture;
  65871. private _originalColorPostProcess;
  65872. private _ssaoPostProcess;
  65873. private _blurHPostProcess;
  65874. private _blurVPostProcess;
  65875. private _ssaoCombinePostProcess;
  65876. /**
  65877. * Gets active scene
  65878. */
  65879. readonly scene: Scene;
  65880. /**
  65881. * @constructor
  65882. * @param name The rendering pipeline name
  65883. * @param scene The scene linked to this pipeline
  65884. * @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 }
  65885. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65886. */
  65887. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65888. /**
  65889. * Get the class name
  65890. * @returns "SSAO2RenderingPipeline"
  65891. */
  65892. getClassName(): string;
  65893. /**
  65894. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65895. */
  65896. dispose(disableGeometryBufferRenderer?: boolean): void;
  65897. private _createBlurPostProcess;
  65898. /** @hidden */
  65899. _rebuild(): void;
  65900. private _bits;
  65901. private _radicalInverse_VdC;
  65902. private _hammersley;
  65903. private _hemisphereSample_uniform;
  65904. private _generateHemisphere;
  65905. private _createSSAOPostProcess;
  65906. private _createSSAOCombinePostProcess;
  65907. private _createRandomTexture;
  65908. /**
  65909. * Serialize the rendering pipeline (Used when exporting)
  65910. * @returns the serialized object
  65911. */
  65912. serialize(): any;
  65913. /**
  65914. * Parse the serialized pipeline
  65915. * @param source Source pipeline.
  65916. * @param scene The scene to load the pipeline to.
  65917. * @param rootUrl The URL of the serialized pipeline.
  65918. * @returns An instantiated pipeline from the serialized object.
  65919. */
  65920. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65921. }
  65922. }
  65923. declare module "babylonjs/Shaders/ssao.fragment" {
  65924. /** @hidden */
  65925. export var ssaoPixelShader: {
  65926. name: string;
  65927. shader: string;
  65928. };
  65929. }
  65930. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65931. import { Camera } from "babylonjs/Cameras/camera";
  65932. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65933. import { Scene } from "babylonjs/scene";
  65934. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65935. import "babylonjs/Shaders/ssao.fragment";
  65936. import "babylonjs/Shaders/ssaoCombine.fragment";
  65937. /**
  65938. * Render pipeline to produce ssao effect
  65939. */
  65940. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65941. /**
  65942. * @ignore
  65943. * The PassPostProcess id in the pipeline that contains the original scene color
  65944. */
  65945. SSAOOriginalSceneColorEffect: string;
  65946. /**
  65947. * @ignore
  65948. * The SSAO PostProcess id in the pipeline
  65949. */
  65950. SSAORenderEffect: string;
  65951. /**
  65952. * @ignore
  65953. * The horizontal blur PostProcess id in the pipeline
  65954. */
  65955. SSAOBlurHRenderEffect: string;
  65956. /**
  65957. * @ignore
  65958. * The vertical blur PostProcess id in the pipeline
  65959. */
  65960. SSAOBlurVRenderEffect: string;
  65961. /**
  65962. * @ignore
  65963. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65964. */
  65965. SSAOCombineRenderEffect: string;
  65966. /**
  65967. * The output strength of the SSAO post-process. Default value is 1.0.
  65968. */
  65969. totalStrength: number;
  65970. /**
  65971. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65972. */
  65973. radius: number;
  65974. /**
  65975. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65976. * Must not be equal to fallOff and superior to fallOff.
  65977. * Default value is 0.0075
  65978. */
  65979. area: number;
  65980. /**
  65981. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65982. * Must not be equal to area and inferior to area.
  65983. * Default value is 0.000001
  65984. */
  65985. fallOff: number;
  65986. /**
  65987. * The base color of the SSAO post-process
  65988. * The final result is "base + ssao" between [0, 1]
  65989. */
  65990. base: number;
  65991. private _scene;
  65992. private _depthTexture;
  65993. private _randomTexture;
  65994. private _originalColorPostProcess;
  65995. private _ssaoPostProcess;
  65996. private _blurHPostProcess;
  65997. private _blurVPostProcess;
  65998. private _ssaoCombinePostProcess;
  65999. private _firstUpdate;
  66000. /**
  66001. * Gets active scene
  66002. */
  66003. readonly scene: Scene;
  66004. /**
  66005. * @constructor
  66006. * @param name - The rendering pipeline name
  66007. * @param scene - The scene linked to this pipeline
  66008. * @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 }
  66009. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66010. */
  66011. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66012. /**
  66013. * Get the class name
  66014. * @returns "SSAORenderingPipeline"
  66015. */
  66016. getClassName(): string;
  66017. /**
  66018. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66019. */
  66020. dispose(disableDepthRender?: boolean): void;
  66021. private _createBlurPostProcess;
  66022. /** @hidden */
  66023. _rebuild(): void;
  66024. private _createSSAOPostProcess;
  66025. private _createSSAOCombinePostProcess;
  66026. private _createRandomTexture;
  66027. }
  66028. }
  66029. declare module "babylonjs/Shaders/standard.fragment" {
  66030. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66031. /** @hidden */
  66032. export var standardPixelShader: {
  66033. name: string;
  66034. shader: string;
  66035. };
  66036. }
  66037. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66038. import { Nullable } from "babylonjs/types";
  66039. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66040. import { Camera } from "babylonjs/Cameras/camera";
  66041. import { Texture } from "babylonjs/Materials/Textures/texture";
  66042. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66043. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66044. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66045. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66046. import { IDisposable } from "babylonjs/scene";
  66047. import { SpotLight } from "babylonjs/Lights/spotLight";
  66048. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66049. import { Scene } from "babylonjs/scene";
  66050. import { Animation } from "babylonjs/Animations/animation";
  66051. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66052. import "babylonjs/Shaders/standard.fragment";
  66053. /**
  66054. * Standard rendering pipeline
  66055. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66056. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66057. */
  66058. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66059. /**
  66060. * Public members
  66061. */
  66062. /**
  66063. * Post-process which contains the original scene color before the pipeline applies all the effects
  66064. */
  66065. originalPostProcess: Nullable<PostProcess>;
  66066. /**
  66067. * Post-process used to down scale an image x4
  66068. */
  66069. downSampleX4PostProcess: Nullable<PostProcess>;
  66070. /**
  66071. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66072. */
  66073. brightPassPostProcess: Nullable<PostProcess>;
  66074. /**
  66075. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66076. */
  66077. blurHPostProcesses: PostProcess[];
  66078. /**
  66079. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66080. */
  66081. blurVPostProcesses: PostProcess[];
  66082. /**
  66083. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66084. */
  66085. textureAdderPostProcess: Nullable<PostProcess>;
  66086. /**
  66087. * Post-process used to create volumetric lighting effect
  66088. */
  66089. volumetricLightPostProcess: Nullable<PostProcess>;
  66090. /**
  66091. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66092. */
  66093. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66094. /**
  66095. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66096. */
  66097. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66098. /**
  66099. * Post-process used to merge the volumetric light effect and the real scene color
  66100. */
  66101. volumetricLightMergePostProces: Nullable<PostProcess>;
  66102. /**
  66103. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66104. */
  66105. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66106. /**
  66107. * Base post-process used to calculate the average luminance of the final image for HDR
  66108. */
  66109. luminancePostProcess: Nullable<PostProcess>;
  66110. /**
  66111. * Post-processes used to create down sample post-processes in order to get
  66112. * the average luminance of the final image for HDR
  66113. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66114. */
  66115. luminanceDownSamplePostProcesses: PostProcess[];
  66116. /**
  66117. * Post-process used to create a HDR effect (light adaptation)
  66118. */
  66119. hdrPostProcess: Nullable<PostProcess>;
  66120. /**
  66121. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66122. */
  66123. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66124. /**
  66125. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66126. */
  66127. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66128. /**
  66129. * Post-process used to merge the final HDR post-process and the real scene color
  66130. */
  66131. hdrFinalPostProcess: Nullable<PostProcess>;
  66132. /**
  66133. * Post-process used to create a lens flare effect
  66134. */
  66135. lensFlarePostProcess: Nullable<PostProcess>;
  66136. /**
  66137. * Post-process that merges the result of the lens flare post-process and the real scene color
  66138. */
  66139. lensFlareComposePostProcess: Nullable<PostProcess>;
  66140. /**
  66141. * Post-process used to create a motion blur effect
  66142. */
  66143. motionBlurPostProcess: Nullable<PostProcess>;
  66144. /**
  66145. * Post-process used to create a depth of field effect
  66146. */
  66147. depthOfFieldPostProcess: Nullable<PostProcess>;
  66148. /**
  66149. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66150. */
  66151. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66152. /**
  66153. * Represents the brightness threshold in order to configure the illuminated surfaces
  66154. */
  66155. brightThreshold: number;
  66156. /**
  66157. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66158. */
  66159. blurWidth: number;
  66160. /**
  66161. * Sets if the blur for highlighted surfaces must be only horizontal
  66162. */
  66163. horizontalBlur: boolean;
  66164. /**
  66165. * Gets the overall exposure used by the pipeline
  66166. */
  66167. /**
  66168. * Sets the overall exposure used by the pipeline
  66169. */
  66170. exposure: number;
  66171. /**
  66172. * Texture used typically to simulate "dirty" on camera lens
  66173. */
  66174. lensTexture: Nullable<Texture>;
  66175. /**
  66176. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66177. */
  66178. volumetricLightCoefficient: number;
  66179. /**
  66180. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66181. */
  66182. volumetricLightPower: number;
  66183. /**
  66184. * Used the set the blur intensity to smooth the volumetric lights
  66185. */
  66186. volumetricLightBlurScale: number;
  66187. /**
  66188. * Light (spot or directional) used to generate the volumetric lights rays
  66189. * The source light must have a shadow generate so the pipeline can get its
  66190. * depth map
  66191. */
  66192. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66193. /**
  66194. * For eye adaptation, represents the minimum luminance the eye can see
  66195. */
  66196. hdrMinimumLuminance: number;
  66197. /**
  66198. * For eye adaptation, represents the decrease luminance speed
  66199. */
  66200. hdrDecreaseRate: number;
  66201. /**
  66202. * For eye adaptation, represents the increase luminance speed
  66203. */
  66204. hdrIncreaseRate: number;
  66205. /**
  66206. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66207. */
  66208. /**
  66209. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66210. */
  66211. hdrAutoExposure: boolean;
  66212. /**
  66213. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66214. */
  66215. lensColorTexture: Nullable<Texture>;
  66216. /**
  66217. * The overall strengh for the lens flare effect
  66218. */
  66219. lensFlareStrength: number;
  66220. /**
  66221. * Dispersion coefficient for lens flare ghosts
  66222. */
  66223. lensFlareGhostDispersal: number;
  66224. /**
  66225. * Main lens flare halo width
  66226. */
  66227. lensFlareHaloWidth: number;
  66228. /**
  66229. * Based on the lens distortion effect, defines how much the lens flare result
  66230. * is distorted
  66231. */
  66232. lensFlareDistortionStrength: number;
  66233. /**
  66234. * Configures the blur intensity used for for lens flare (halo)
  66235. */
  66236. lensFlareBlurWidth: number;
  66237. /**
  66238. * Lens star texture must be used to simulate rays on the flares and is available
  66239. * in the documentation
  66240. */
  66241. lensStarTexture: Nullable<Texture>;
  66242. /**
  66243. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66244. * flare effect by taking account of the dirt texture
  66245. */
  66246. lensFlareDirtTexture: Nullable<Texture>;
  66247. /**
  66248. * Represents the focal length for the depth of field effect
  66249. */
  66250. depthOfFieldDistance: number;
  66251. /**
  66252. * Represents the blur intensity for the blurred part of the depth of field effect
  66253. */
  66254. depthOfFieldBlurWidth: number;
  66255. /**
  66256. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66257. */
  66258. /**
  66259. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66260. */
  66261. motionStrength: number;
  66262. /**
  66263. * Gets wether or not the motion blur post-process is object based or screen based.
  66264. */
  66265. /**
  66266. * Sets wether or not the motion blur post-process should be object based or screen based
  66267. */
  66268. objectBasedMotionBlur: boolean;
  66269. /**
  66270. * List of animations for the pipeline (IAnimatable implementation)
  66271. */
  66272. animations: Animation[];
  66273. /**
  66274. * Private members
  66275. */
  66276. private _scene;
  66277. private _currentDepthOfFieldSource;
  66278. private _basePostProcess;
  66279. private _fixedExposure;
  66280. private _currentExposure;
  66281. private _hdrAutoExposure;
  66282. private _hdrCurrentLuminance;
  66283. private _motionStrength;
  66284. private _isObjectBasedMotionBlur;
  66285. private _floatTextureType;
  66286. private _camerasToBeAttached;
  66287. private _ratio;
  66288. private _bloomEnabled;
  66289. private _depthOfFieldEnabled;
  66290. private _vlsEnabled;
  66291. private _lensFlareEnabled;
  66292. private _hdrEnabled;
  66293. private _motionBlurEnabled;
  66294. private _fxaaEnabled;
  66295. private _motionBlurSamples;
  66296. private _volumetricLightStepsCount;
  66297. private _samples;
  66298. /**
  66299. * @ignore
  66300. * Specifies if the bloom pipeline is enabled
  66301. */
  66302. BloomEnabled: boolean;
  66303. /**
  66304. * @ignore
  66305. * Specifies if the depth of field pipeline is enabed
  66306. */
  66307. DepthOfFieldEnabled: boolean;
  66308. /**
  66309. * @ignore
  66310. * Specifies if the lens flare pipeline is enabed
  66311. */
  66312. LensFlareEnabled: boolean;
  66313. /**
  66314. * @ignore
  66315. * Specifies if the HDR pipeline is enabled
  66316. */
  66317. HDREnabled: boolean;
  66318. /**
  66319. * @ignore
  66320. * Specifies if the volumetric lights scattering effect is enabled
  66321. */
  66322. VLSEnabled: boolean;
  66323. /**
  66324. * @ignore
  66325. * Specifies if the motion blur effect is enabled
  66326. */
  66327. MotionBlurEnabled: boolean;
  66328. /**
  66329. * Specifies if anti-aliasing is enabled
  66330. */
  66331. fxaaEnabled: boolean;
  66332. /**
  66333. * Specifies the number of steps used to calculate the volumetric lights
  66334. * Typically in interval [50, 200]
  66335. */
  66336. volumetricLightStepsCount: number;
  66337. /**
  66338. * Specifies the number of samples used for the motion blur effect
  66339. * Typically in interval [16, 64]
  66340. */
  66341. motionBlurSamples: number;
  66342. /**
  66343. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66344. */
  66345. samples: number;
  66346. /**
  66347. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66348. * @constructor
  66349. * @param name The rendering pipeline name
  66350. * @param scene The scene linked to this pipeline
  66351. * @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)
  66352. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66353. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66354. */
  66355. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66356. private _buildPipeline;
  66357. private _createDownSampleX4PostProcess;
  66358. private _createBrightPassPostProcess;
  66359. private _createBlurPostProcesses;
  66360. private _createTextureAdderPostProcess;
  66361. private _createVolumetricLightPostProcess;
  66362. private _createLuminancePostProcesses;
  66363. private _createHdrPostProcess;
  66364. private _createLensFlarePostProcess;
  66365. private _createDepthOfFieldPostProcess;
  66366. private _createMotionBlurPostProcess;
  66367. private _getDepthTexture;
  66368. private _disposePostProcesses;
  66369. /**
  66370. * Dispose of the pipeline and stop all post processes
  66371. */
  66372. dispose(): void;
  66373. /**
  66374. * Serialize the rendering pipeline (Used when exporting)
  66375. * @returns the serialized object
  66376. */
  66377. serialize(): any;
  66378. /**
  66379. * Parse the serialized pipeline
  66380. * @param source Source pipeline.
  66381. * @param scene The scene to load the pipeline to.
  66382. * @param rootUrl The URL of the serialized pipeline.
  66383. * @returns An instantiated pipeline from the serialized object.
  66384. */
  66385. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66386. /**
  66387. * Luminance steps
  66388. */
  66389. static LuminanceSteps: number;
  66390. }
  66391. }
  66392. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66393. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66394. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66395. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66396. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66397. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66398. }
  66399. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66400. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66401. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66402. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66403. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66404. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66405. }
  66406. declare module "babylonjs/Shaders/tonemap.fragment" {
  66407. /** @hidden */
  66408. export var tonemapPixelShader: {
  66409. name: string;
  66410. shader: string;
  66411. };
  66412. }
  66413. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66414. import { Camera } from "babylonjs/Cameras/camera";
  66415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66416. import "babylonjs/Shaders/tonemap.fragment";
  66417. import { Engine } from "babylonjs/Engines/engine";
  66418. /** Defines operator used for tonemapping */
  66419. export enum TonemappingOperator {
  66420. /** Hable */
  66421. Hable = 0,
  66422. /** Reinhard */
  66423. Reinhard = 1,
  66424. /** HejiDawson */
  66425. HejiDawson = 2,
  66426. /** Photographic */
  66427. Photographic = 3
  66428. }
  66429. /**
  66430. * Defines a post process to apply tone mapping
  66431. */
  66432. export class TonemapPostProcess extends PostProcess {
  66433. private _operator;
  66434. /** Defines the required exposure adjustement */
  66435. exposureAdjustment: number;
  66436. /**
  66437. * Creates a new TonemapPostProcess
  66438. * @param name defines the name of the postprocess
  66439. * @param _operator defines the operator to use
  66440. * @param exposureAdjustment defines the required exposure adjustement
  66441. * @param camera defines the camera to use (can be null)
  66442. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66443. * @param engine defines the hosting engine (can be ignore if camera is set)
  66444. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66445. */
  66446. constructor(name: string, _operator: TonemappingOperator,
  66447. /** Defines the required exposure adjustement */
  66448. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66449. }
  66450. }
  66451. declare module "babylonjs/Shaders/depth.vertex" {
  66452. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66455. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66457. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66458. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66459. /** @hidden */
  66460. export var depthVertexShader: {
  66461. name: string;
  66462. shader: string;
  66463. };
  66464. }
  66465. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66466. /** @hidden */
  66467. export var volumetricLightScatteringPixelShader: {
  66468. name: string;
  66469. shader: string;
  66470. };
  66471. }
  66472. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66473. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66474. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66475. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66476. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66477. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66478. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66479. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66480. /** @hidden */
  66481. export var volumetricLightScatteringPassVertexShader: {
  66482. name: string;
  66483. shader: string;
  66484. };
  66485. }
  66486. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66487. /** @hidden */
  66488. export var volumetricLightScatteringPassPixelShader: {
  66489. name: string;
  66490. shader: string;
  66491. };
  66492. }
  66493. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66494. import { Vector3 } from "babylonjs/Maths/math.vector";
  66495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66496. import { Mesh } from "babylonjs/Meshes/mesh";
  66497. import { Camera } from "babylonjs/Cameras/camera";
  66498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66499. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66500. import { Scene } from "babylonjs/scene";
  66501. import "babylonjs/Meshes/Builders/planeBuilder";
  66502. import "babylonjs/Shaders/depth.vertex";
  66503. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66504. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66505. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66506. import { Engine } from "babylonjs/Engines/engine";
  66507. /**
  66508. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66509. */
  66510. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66511. private _volumetricLightScatteringPass;
  66512. private _volumetricLightScatteringRTT;
  66513. private _viewPort;
  66514. private _screenCoordinates;
  66515. private _cachedDefines;
  66516. /**
  66517. * If not undefined, the mesh position is computed from the attached node position
  66518. */
  66519. attachedNode: {
  66520. position: Vector3;
  66521. };
  66522. /**
  66523. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66524. */
  66525. customMeshPosition: Vector3;
  66526. /**
  66527. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66528. */
  66529. useCustomMeshPosition: boolean;
  66530. /**
  66531. * If the post-process should inverse the light scattering direction
  66532. */
  66533. invert: boolean;
  66534. /**
  66535. * The internal mesh used by the post-process
  66536. */
  66537. mesh: Mesh;
  66538. /**
  66539. * @hidden
  66540. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66541. */
  66542. useDiffuseColor: boolean;
  66543. /**
  66544. * Array containing the excluded meshes not rendered in the internal pass
  66545. */
  66546. excludedMeshes: AbstractMesh[];
  66547. /**
  66548. * Controls the overall intensity of the post-process
  66549. */
  66550. exposure: number;
  66551. /**
  66552. * Dissipates each sample's contribution in range [0, 1]
  66553. */
  66554. decay: number;
  66555. /**
  66556. * Controls the overall intensity of each sample
  66557. */
  66558. weight: number;
  66559. /**
  66560. * Controls the density of each sample
  66561. */
  66562. density: number;
  66563. /**
  66564. * @constructor
  66565. * @param name The post-process name
  66566. * @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)
  66567. * @param camera The camera that the post-process will be attached to
  66568. * @param mesh The mesh used to create the light scattering
  66569. * @param samples The post-process quality, default 100
  66570. * @param samplingModeThe post-process filtering mode
  66571. * @param engine The babylon engine
  66572. * @param reusable If the post-process is reusable
  66573. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66574. */
  66575. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66576. /**
  66577. * Returns the string "VolumetricLightScatteringPostProcess"
  66578. * @returns "VolumetricLightScatteringPostProcess"
  66579. */
  66580. getClassName(): string;
  66581. private _isReady;
  66582. /**
  66583. * Sets the new light position for light scattering effect
  66584. * @param position The new custom light position
  66585. */
  66586. setCustomMeshPosition(position: Vector3): void;
  66587. /**
  66588. * Returns the light position for light scattering effect
  66589. * @return Vector3 The custom light position
  66590. */
  66591. getCustomMeshPosition(): Vector3;
  66592. /**
  66593. * Disposes the internal assets and detaches the post-process from the camera
  66594. */
  66595. dispose(camera: Camera): void;
  66596. /**
  66597. * Returns the render target texture used by the post-process
  66598. * @return the render target texture used by the post-process
  66599. */
  66600. getPass(): RenderTargetTexture;
  66601. private _meshExcluded;
  66602. private _createPass;
  66603. private _updateMeshScreenCoordinates;
  66604. /**
  66605. * Creates a default mesh for the Volumeric Light Scattering post-process
  66606. * @param name The mesh name
  66607. * @param scene The scene where to create the mesh
  66608. * @return the default mesh
  66609. */
  66610. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66611. }
  66612. }
  66613. declare module "babylonjs/PostProcesses/index" {
  66614. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66615. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66616. export * from "babylonjs/PostProcesses/bloomEffect";
  66617. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66618. export * from "babylonjs/PostProcesses/blurPostProcess";
  66619. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66620. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66621. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66622. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66623. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66624. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66625. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66626. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66627. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66628. export * from "babylonjs/PostProcesses/filterPostProcess";
  66629. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66630. export * from "babylonjs/PostProcesses/grainPostProcess";
  66631. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66632. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66633. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66634. export * from "babylonjs/PostProcesses/passPostProcess";
  66635. export * from "babylonjs/PostProcesses/postProcess";
  66636. export * from "babylonjs/PostProcesses/postProcessManager";
  66637. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66638. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66639. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66640. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66641. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66642. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66643. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66644. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66645. }
  66646. declare module "babylonjs/Probes/index" {
  66647. export * from "babylonjs/Probes/reflectionProbe";
  66648. }
  66649. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66650. import { Scene } from "babylonjs/scene";
  66651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66652. import { SmartArray } from "babylonjs/Misc/smartArray";
  66653. import { ISceneComponent } from "babylonjs/sceneComponent";
  66654. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66655. import "babylonjs/Meshes/Builders/boxBuilder";
  66656. import "babylonjs/Shaders/color.fragment";
  66657. import "babylonjs/Shaders/color.vertex";
  66658. import { Color3 } from "babylonjs/Maths/math.color";
  66659. module "babylonjs/scene" {
  66660. interface Scene {
  66661. /** @hidden (Backing field) */
  66662. _boundingBoxRenderer: BoundingBoxRenderer;
  66663. /** @hidden (Backing field) */
  66664. _forceShowBoundingBoxes: boolean;
  66665. /**
  66666. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66667. */
  66668. forceShowBoundingBoxes: boolean;
  66669. /**
  66670. * Gets the bounding box renderer associated with the scene
  66671. * @returns a BoundingBoxRenderer
  66672. */
  66673. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66674. }
  66675. }
  66676. module "babylonjs/Meshes/abstractMesh" {
  66677. interface AbstractMesh {
  66678. /** @hidden (Backing field) */
  66679. _showBoundingBox: boolean;
  66680. /**
  66681. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66682. */
  66683. showBoundingBox: boolean;
  66684. }
  66685. }
  66686. /**
  66687. * Component responsible of rendering the bounding box of the meshes in a scene.
  66688. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66689. */
  66690. export class BoundingBoxRenderer implements ISceneComponent {
  66691. /**
  66692. * The component name helpfull to identify the component in the list of scene components.
  66693. */
  66694. readonly name: string;
  66695. /**
  66696. * The scene the component belongs to.
  66697. */
  66698. scene: Scene;
  66699. /**
  66700. * Color of the bounding box lines placed in front of an object
  66701. */
  66702. frontColor: Color3;
  66703. /**
  66704. * Color of the bounding box lines placed behind an object
  66705. */
  66706. backColor: Color3;
  66707. /**
  66708. * Defines if the renderer should show the back lines or not
  66709. */
  66710. showBackLines: boolean;
  66711. /**
  66712. * @hidden
  66713. */
  66714. renderList: SmartArray<BoundingBox>;
  66715. private _colorShader;
  66716. private _vertexBuffers;
  66717. private _indexBuffer;
  66718. private _fillIndexBuffer;
  66719. private _fillIndexData;
  66720. /**
  66721. * Instantiates a new bounding box renderer in a scene.
  66722. * @param scene the scene the renderer renders in
  66723. */
  66724. constructor(scene: Scene);
  66725. /**
  66726. * Registers the component in a given scene
  66727. */
  66728. register(): void;
  66729. private _evaluateSubMesh;
  66730. private _activeMesh;
  66731. private _prepareRessources;
  66732. private _createIndexBuffer;
  66733. /**
  66734. * Rebuilds the elements related to this component in case of
  66735. * context lost for instance.
  66736. */
  66737. rebuild(): void;
  66738. /**
  66739. * @hidden
  66740. */
  66741. reset(): void;
  66742. /**
  66743. * Render the bounding boxes of a specific rendering group
  66744. * @param renderingGroupId defines the rendering group to render
  66745. */
  66746. render(renderingGroupId: number): void;
  66747. /**
  66748. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66749. * @param mesh Define the mesh to render the occlusion bounding box for
  66750. */
  66751. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66752. /**
  66753. * Dispose and release the resources attached to this renderer.
  66754. */
  66755. dispose(): void;
  66756. }
  66757. }
  66758. declare module "babylonjs/Shaders/depth.fragment" {
  66759. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66760. /** @hidden */
  66761. export var depthPixelShader: {
  66762. name: string;
  66763. shader: string;
  66764. };
  66765. }
  66766. declare module "babylonjs/Rendering/depthRenderer" {
  66767. import { Nullable } from "babylonjs/types";
  66768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66769. import { Scene } from "babylonjs/scene";
  66770. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66771. import { Camera } from "babylonjs/Cameras/camera";
  66772. import "babylonjs/Shaders/depth.fragment";
  66773. import "babylonjs/Shaders/depth.vertex";
  66774. /**
  66775. * This represents a depth renderer in Babylon.
  66776. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66777. */
  66778. export class DepthRenderer {
  66779. private _scene;
  66780. private _depthMap;
  66781. private _effect;
  66782. private readonly _storeNonLinearDepth;
  66783. private readonly _clearColor;
  66784. /** Get if the depth renderer is using packed depth or not */
  66785. readonly isPacked: boolean;
  66786. private _cachedDefines;
  66787. private _camera;
  66788. /**
  66789. * Specifiess that the depth renderer will only be used within
  66790. * the camera it is created for.
  66791. * This can help forcing its rendering during the camera processing.
  66792. */
  66793. useOnlyInActiveCamera: boolean;
  66794. /** @hidden */
  66795. static _SceneComponentInitialization: (scene: Scene) => void;
  66796. /**
  66797. * Instantiates a depth renderer
  66798. * @param scene The scene the renderer belongs to
  66799. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66800. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66801. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66802. */
  66803. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66804. /**
  66805. * Creates the depth rendering effect and checks if the effect is ready.
  66806. * @param subMesh The submesh to be used to render the depth map of
  66807. * @param useInstances If multiple world instances should be used
  66808. * @returns if the depth renderer is ready to render the depth map
  66809. */
  66810. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66811. /**
  66812. * Gets the texture which the depth map will be written to.
  66813. * @returns The depth map texture
  66814. */
  66815. getDepthMap(): RenderTargetTexture;
  66816. /**
  66817. * Disposes of the depth renderer.
  66818. */
  66819. dispose(): void;
  66820. }
  66821. }
  66822. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66823. import { Nullable } from "babylonjs/types";
  66824. import { Scene } from "babylonjs/scene";
  66825. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66826. import { Camera } from "babylonjs/Cameras/camera";
  66827. import { ISceneComponent } from "babylonjs/sceneComponent";
  66828. module "babylonjs/scene" {
  66829. interface Scene {
  66830. /** @hidden (Backing field) */
  66831. _depthRenderer: {
  66832. [id: string]: DepthRenderer;
  66833. };
  66834. /**
  66835. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66836. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66837. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66838. * @returns the created depth renderer
  66839. */
  66840. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66841. /**
  66842. * Disables a depth renderer for a given camera
  66843. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66844. */
  66845. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66846. }
  66847. }
  66848. /**
  66849. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66850. * in several rendering techniques.
  66851. */
  66852. export class DepthRendererSceneComponent implements ISceneComponent {
  66853. /**
  66854. * The component name helpfull to identify the component in the list of scene components.
  66855. */
  66856. readonly name: string;
  66857. /**
  66858. * The scene the component belongs to.
  66859. */
  66860. scene: Scene;
  66861. /**
  66862. * Creates a new instance of the component for the given scene
  66863. * @param scene Defines the scene to register the component in
  66864. */
  66865. constructor(scene: Scene);
  66866. /**
  66867. * Registers the component in a given scene
  66868. */
  66869. register(): void;
  66870. /**
  66871. * Rebuilds the elements related to this component in case of
  66872. * context lost for instance.
  66873. */
  66874. rebuild(): void;
  66875. /**
  66876. * Disposes the component and the associated ressources
  66877. */
  66878. dispose(): void;
  66879. private _gatherRenderTargets;
  66880. private _gatherActiveCameraRenderTargets;
  66881. }
  66882. }
  66883. declare module "babylonjs/Shaders/outline.fragment" {
  66884. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66885. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66886. /** @hidden */
  66887. export var outlinePixelShader: {
  66888. name: string;
  66889. shader: string;
  66890. };
  66891. }
  66892. declare module "babylonjs/Shaders/outline.vertex" {
  66893. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66896. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66897. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66898. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66899. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66900. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66901. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66902. /** @hidden */
  66903. export var outlineVertexShader: {
  66904. name: string;
  66905. shader: string;
  66906. };
  66907. }
  66908. declare module "babylonjs/Rendering/outlineRenderer" {
  66909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66910. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66911. import { Scene } from "babylonjs/scene";
  66912. import { ISceneComponent } from "babylonjs/sceneComponent";
  66913. import "babylonjs/Shaders/outline.fragment";
  66914. import "babylonjs/Shaders/outline.vertex";
  66915. module "babylonjs/scene" {
  66916. interface Scene {
  66917. /** @hidden */
  66918. _outlineRenderer: OutlineRenderer;
  66919. /**
  66920. * Gets the outline renderer associated with the scene
  66921. * @returns a OutlineRenderer
  66922. */
  66923. getOutlineRenderer(): OutlineRenderer;
  66924. }
  66925. }
  66926. module "babylonjs/Meshes/abstractMesh" {
  66927. interface AbstractMesh {
  66928. /** @hidden (Backing field) */
  66929. _renderOutline: boolean;
  66930. /**
  66931. * Gets or sets a boolean indicating if the outline must be rendered as well
  66932. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66933. */
  66934. renderOutline: boolean;
  66935. /** @hidden (Backing field) */
  66936. _renderOverlay: boolean;
  66937. /**
  66938. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66939. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66940. */
  66941. renderOverlay: boolean;
  66942. }
  66943. }
  66944. /**
  66945. * This class is responsible to draw bothe outline/overlay of meshes.
  66946. * It should not be used directly but through the available method on mesh.
  66947. */
  66948. export class OutlineRenderer implements ISceneComponent {
  66949. /**
  66950. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66951. */
  66952. private static _StencilReference;
  66953. /**
  66954. * The name of the component. Each component must have a unique name.
  66955. */
  66956. name: string;
  66957. /**
  66958. * The scene the component belongs to.
  66959. */
  66960. scene: Scene;
  66961. /**
  66962. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66963. */
  66964. zOffset: number;
  66965. private _engine;
  66966. private _effect;
  66967. private _cachedDefines;
  66968. private _savedDepthWrite;
  66969. /**
  66970. * Instantiates a new outline renderer. (There could be only one per scene).
  66971. * @param scene Defines the scene it belongs to
  66972. */
  66973. constructor(scene: Scene);
  66974. /**
  66975. * Register the component to one instance of a scene.
  66976. */
  66977. register(): void;
  66978. /**
  66979. * Rebuilds the elements related to this component in case of
  66980. * context lost for instance.
  66981. */
  66982. rebuild(): void;
  66983. /**
  66984. * Disposes the component and the associated ressources.
  66985. */
  66986. dispose(): void;
  66987. /**
  66988. * Renders the outline in the canvas.
  66989. * @param subMesh Defines the sumesh to render
  66990. * @param batch Defines the batch of meshes in case of instances
  66991. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66992. */
  66993. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66994. /**
  66995. * Returns whether or not the outline renderer is ready for a given submesh.
  66996. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66997. * @param subMesh Defines the submesh to check readyness for
  66998. * @param useInstances Defines wheter wee are trying to render instances or not
  66999. * @returns true if ready otherwise false
  67000. */
  67001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67002. private _beforeRenderingMesh;
  67003. private _afterRenderingMesh;
  67004. }
  67005. }
  67006. declare module "babylonjs/Rendering/index" {
  67007. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67008. export * from "babylonjs/Rendering/depthRenderer";
  67009. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67010. export * from "babylonjs/Rendering/edgesRenderer";
  67011. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67012. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67013. export * from "babylonjs/Rendering/outlineRenderer";
  67014. export * from "babylonjs/Rendering/renderingGroup";
  67015. export * from "babylonjs/Rendering/renderingManager";
  67016. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67017. }
  67018. declare module "babylonjs/Sprites/spritePackedManager" {
  67019. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67020. import { Scene } from "babylonjs/scene";
  67021. /**
  67022. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67023. * @see http://doc.babylonjs.com/babylon101/sprites
  67024. */
  67025. export class SpritePackedManager extends SpriteManager {
  67026. /** defines the packed manager's name */
  67027. name: string;
  67028. /**
  67029. * Creates a new sprite manager from a packed sprite sheet
  67030. * @param name defines the manager's name
  67031. * @param imgUrl defines the sprite sheet url
  67032. * @param capacity defines the maximum allowed number of sprites
  67033. * @param scene defines the hosting scene
  67034. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67035. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67036. * @param samplingMode defines the smapling mode to use with spritesheet
  67037. * @param fromPacked set to true; do not alter
  67038. */
  67039. constructor(
  67040. /** defines the packed manager's name */
  67041. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67042. }
  67043. }
  67044. declare module "babylonjs/Sprites/index" {
  67045. export * from "babylonjs/Sprites/sprite";
  67046. export * from "babylonjs/Sprites/spriteManager";
  67047. export * from "babylonjs/Sprites/spritePackedManager";
  67048. export * from "babylonjs/Sprites/spriteSceneComponent";
  67049. }
  67050. declare module "babylonjs/States/index" {
  67051. export * from "babylonjs/States/alphaCullingState";
  67052. export * from "babylonjs/States/depthCullingState";
  67053. export * from "babylonjs/States/stencilState";
  67054. }
  67055. declare module "babylonjs/Misc/assetsManager" {
  67056. import { Scene } from "babylonjs/scene";
  67057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67058. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67059. import { Skeleton } from "babylonjs/Bones/skeleton";
  67060. import { Observable } from "babylonjs/Misc/observable";
  67061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67062. import { Texture } from "babylonjs/Materials/Textures/texture";
  67063. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67064. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67065. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67066. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67067. /**
  67068. * Defines the list of states available for a task inside a AssetsManager
  67069. */
  67070. export enum AssetTaskState {
  67071. /**
  67072. * Initialization
  67073. */
  67074. INIT = 0,
  67075. /**
  67076. * Running
  67077. */
  67078. RUNNING = 1,
  67079. /**
  67080. * Done
  67081. */
  67082. DONE = 2,
  67083. /**
  67084. * Error
  67085. */
  67086. ERROR = 3
  67087. }
  67088. /**
  67089. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67090. */
  67091. export abstract class AbstractAssetTask {
  67092. /**
  67093. * Task name
  67094. */ name: string;
  67095. /**
  67096. * Callback called when the task is successful
  67097. */
  67098. onSuccess: (task: any) => void;
  67099. /**
  67100. * Callback called when the task is not successful
  67101. */
  67102. onError: (task: any, message?: string, exception?: any) => void;
  67103. /**
  67104. * Creates a new AssetsManager
  67105. * @param name defines the name of the task
  67106. */
  67107. constructor(
  67108. /**
  67109. * Task name
  67110. */ name: string);
  67111. private _isCompleted;
  67112. private _taskState;
  67113. private _errorObject;
  67114. /**
  67115. * Get if the task is completed
  67116. */
  67117. readonly isCompleted: boolean;
  67118. /**
  67119. * Gets the current state of the task
  67120. */
  67121. readonly taskState: AssetTaskState;
  67122. /**
  67123. * Gets the current error object (if task is in error)
  67124. */
  67125. readonly errorObject: {
  67126. message?: string;
  67127. exception?: any;
  67128. };
  67129. /**
  67130. * Internal only
  67131. * @hidden
  67132. */
  67133. _setErrorObject(message?: string, exception?: any): void;
  67134. /**
  67135. * Execute the current task
  67136. * @param scene defines the scene where you want your assets to be loaded
  67137. * @param onSuccess is a callback called when the task is successfully executed
  67138. * @param onError is a callback called if an error occurs
  67139. */
  67140. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67141. /**
  67142. * Execute the current task
  67143. * @param scene defines the scene where you want your assets to be loaded
  67144. * @param onSuccess is a callback called when the task is successfully executed
  67145. * @param onError is a callback called if an error occurs
  67146. */
  67147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67148. /**
  67149. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67150. * This can be used with failed tasks that have the reason for failure fixed.
  67151. */
  67152. reset(): void;
  67153. private onErrorCallback;
  67154. private onDoneCallback;
  67155. }
  67156. /**
  67157. * Define the interface used by progress events raised during assets loading
  67158. */
  67159. export interface IAssetsProgressEvent {
  67160. /**
  67161. * Defines the number of remaining tasks to process
  67162. */
  67163. remainingCount: number;
  67164. /**
  67165. * Defines the total number of tasks
  67166. */
  67167. totalCount: number;
  67168. /**
  67169. * Defines the task that was just processed
  67170. */
  67171. task: AbstractAssetTask;
  67172. }
  67173. /**
  67174. * Class used to share progress information about assets loading
  67175. */
  67176. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67177. /**
  67178. * Defines the number of remaining tasks to process
  67179. */
  67180. remainingCount: number;
  67181. /**
  67182. * Defines the total number of tasks
  67183. */
  67184. totalCount: number;
  67185. /**
  67186. * Defines the task that was just processed
  67187. */
  67188. task: AbstractAssetTask;
  67189. /**
  67190. * Creates a AssetsProgressEvent
  67191. * @param remainingCount defines the number of remaining tasks to process
  67192. * @param totalCount defines the total number of tasks
  67193. * @param task defines the task that was just processed
  67194. */
  67195. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67196. }
  67197. /**
  67198. * Define a task used by AssetsManager to load meshes
  67199. */
  67200. export class MeshAssetTask extends AbstractAssetTask {
  67201. /**
  67202. * Defines the name of the task
  67203. */
  67204. name: string;
  67205. /**
  67206. * Defines the list of mesh's names you want to load
  67207. */
  67208. meshesNames: any;
  67209. /**
  67210. * Defines the root url to use as a base to load your meshes and associated resources
  67211. */
  67212. rootUrl: string;
  67213. /**
  67214. * Defines the filename of the scene to load from
  67215. */
  67216. sceneFilename: string;
  67217. /**
  67218. * Gets the list of loaded meshes
  67219. */
  67220. loadedMeshes: Array<AbstractMesh>;
  67221. /**
  67222. * Gets the list of loaded particle systems
  67223. */
  67224. loadedParticleSystems: Array<IParticleSystem>;
  67225. /**
  67226. * Gets the list of loaded skeletons
  67227. */
  67228. loadedSkeletons: Array<Skeleton>;
  67229. /**
  67230. * Gets the list of loaded animation groups
  67231. */
  67232. loadedAnimationGroups: Array<AnimationGroup>;
  67233. /**
  67234. * Callback called when the task is successful
  67235. */
  67236. onSuccess: (task: MeshAssetTask) => void;
  67237. /**
  67238. * Callback called when the task is successful
  67239. */
  67240. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67241. /**
  67242. * Creates a new MeshAssetTask
  67243. * @param name defines the name of the task
  67244. * @param meshesNames defines the list of mesh's names you want to load
  67245. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67246. * @param sceneFilename defines the filename of the scene to load from
  67247. */
  67248. constructor(
  67249. /**
  67250. * Defines the name of the task
  67251. */
  67252. name: string,
  67253. /**
  67254. * Defines the list of mesh's names you want to load
  67255. */
  67256. meshesNames: any,
  67257. /**
  67258. * Defines the root url to use as a base to load your meshes and associated resources
  67259. */
  67260. rootUrl: string,
  67261. /**
  67262. * Defines the filename of the scene to load from
  67263. */
  67264. sceneFilename: string);
  67265. /**
  67266. * Execute the current task
  67267. * @param scene defines the scene where you want your assets to be loaded
  67268. * @param onSuccess is a callback called when the task is successfully executed
  67269. * @param onError is a callback called if an error occurs
  67270. */
  67271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67272. }
  67273. /**
  67274. * Define a task used by AssetsManager to load text content
  67275. */
  67276. export class TextFileAssetTask extends AbstractAssetTask {
  67277. /**
  67278. * Defines the name of the task
  67279. */
  67280. name: string;
  67281. /**
  67282. * Defines the location of the file to load
  67283. */
  67284. url: string;
  67285. /**
  67286. * Gets the loaded text string
  67287. */
  67288. text: string;
  67289. /**
  67290. * Callback called when the task is successful
  67291. */
  67292. onSuccess: (task: TextFileAssetTask) => void;
  67293. /**
  67294. * Callback called when the task is successful
  67295. */
  67296. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67297. /**
  67298. * Creates a new TextFileAssetTask object
  67299. * @param name defines the name of the task
  67300. * @param url defines the location of the file to load
  67301. */
  67302. constructor(
  67303. /**
  67304. * Defines the name of the task
  67305. */
  67306. name: string,
  67307. /**
  67308. * Defines the location of the file to load
  67309. */
  67310. url: string);
  67311. /**
  67312. * Execute the current task
  67313. * @param scene defines the scene where you want your assets to be loaded
  67314. * @param onSuccess is a callback called when the task is successfully executed
  67315. * @param onError is a callback called if an error occurs
  67316. */
  67317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67318. }
  67319. /**
  67320. * Define a task used by AssetsManager to load binary data
  67321. */
  67322. export class BinaryFileAssetTask extends AbstractAssetTask {
  67323. /**
  67324. * Defines the name of the task
  67325. */
  67326. name: string;
  67327. /**
  67328. * Defines the location of the file to load
  67329. */
  67330. url: string;
  67331. /**
  67332. * Gets the lodaded data (as an array buffer)
  67333. */
  67334. data: ArrayBuffer;
  67335. /**
  67336. * Callback called when the task is successful
  67337. */
  67338. onSuccess: (task: BinaryFileAssetTask) => void;
  67339. /**
  67340. * Callback called when the task is successful
  67341. */
  67342. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67343. /**
  67344. * Creates a new BinaryFileAssetTask object
  67345. * @param name defines the name of the new task
  67346. * @param url defines the location of the file to load
  67347. */
  67348. constructor(
  67349. /**
  67350. * Defines the name of the task
  67351. */
  67352. name: string,
  67353. /**
  67354. * Defines the location of the file to load
  67355. */
  67356. url: string);
  67357. /**
  67358. * Execute the current task
  67359. * @param scene defines the scene where you want your assets to be loaded
  67360. * @param onSuccess is a callback called when the task is successfully executed
  67361. * @param onError is a callback called if an error occurs
  67362. */
  67363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67364. }
  67365. /**
  67366. * Define a task used by AssetsManager to load images
  67367. */
  67368. export class ImageAssetTask extends AbstractAssetTask {
  67369. /**
  67370. * Defines the name of the task
  67371. */
  67372. name: string;
  67373. /**
  67374. * Defines the location of the image to load
  67375. */
  67376. url: string;
  67377. /**
  67378. * Gets the loaded images
  67379. */
  67380. image: HTMLImageElement;
  67381. /**
  67382. * Callback called when the task is successful
  67383. */
  67384. onSuccess: (task: ImageAssetTask) => void;
  67385. /**
  67386. * Callback called when the task is successful
  67387. */
  67388. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67389. /**
  67390. * Creates a new ImageAssetTask
  67391. * @param name defines the name of the task
  67392. * @param url defines the location of the image to load
  67393. */
  67394. constructor(
  67395. /**
  67396. * Defines the name of the task
  67397. */
  67398. name: string,
  67399. /**
  67400. * Defines the location of the image to load
  67401. */
  67402. url: string);
  67403. /**
  67404. * Execute the current task
  67405. * @param scene defines the scene where you want your assets to be loaded
  67406. * @param onSuccess is a callback called when the task is successfully executed
  67407. * @param onError is a callback called if an error occurs
  67408. */
  67409. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67410. }
  67411. /**
  67412. * Defines the interface used by texture loading tasks
  67413. */
  67414. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67415. /**
  67416. * Gets the loaded texture
  67417. */
  67418. texture: TEX;
  67419. }
  67420. /**
  67421. * Define a task used by AssetsManager to load 2D textures
  67422. */
  67423. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67424. /**
  67425. * Defines the name of the task
  67426. */
  67427. name: string;
  67428. /**
  67429. * Defines the location of the file to load
  67430. */
  67431. url: string;
  67432. /**
  67433. * Defines if mipmap should not be generated (default is false)
  67434. */
  67435. noMipmap?: boolean | undefined;
  67436. /**
  67437. * Defines if texture must be inverted on Y axis (default is false)
  67438. */
  67439. invertY?: boolean | undefined;
  67440. /**
  67441. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67442. */
  67443. samplingMode: number;
  67444. /**
  67445. * Gets the loaded texture
  67446. */
  67447. texture: Texture;
  67448. /**
  67449. * Callback called when the task is successful
  67450. */
  67451. onSuccess: (task: TextureAssetTask) => void;
  67452. /**
  67453. * Callback called when the task is successful
  67454. */
  67455. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67456. /**
  67457. * Creates a new TextureAssetTask object
  67458. * @param name defines the name of the task
  67459. * @param url defines the location of the file to load
  67460. * @param noMipmap defines if mipmap should not be generated (default is false)
  67461. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67462. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67463. */
  67464. constructor(
  67465. /**
  67466. * Defines the name of the task
  67467. */
  67468. name: string,
  67469. /**
  67470. * Defines the location of the file to load
  67471. */
  67472. url: string,
  67473. /**
  67474. * Defines if mipmap should not be generated (default is false)
  67475. */
  67476. noMipmap?: boolean | undefined,
  67477. /**
  67478. * Defines if texture must be inverted on Y axis (default is false)
  67479. */
  67480. invertY?: boolean | undefined,
  67481. /**
  67482. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67483. */
  67484. samplingMode?: number);
  67485. /**
  67486. * Execute the current task
  67487. * @param scene defines the scene where you want your assets to be loaded
  67488. * @param onSuccess is a callback called when the task is successfully executed
  67489. * @param onError is a callback called if an error occurs
  67490. */
  67491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67492. }
  67493. /**
  67494. * Define a task used by AssetsManager to load cube textures
  67495. */
  67496. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67497. /**
  67498. * Defines the name of the task
  67499. */
  67500. name: string;
  67501. /**
  67502. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67503. */
  67504. url: string;
  67505. /**
  67506. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67507. */
  67508. extensions?: string[] | undefined;
  67509. /**
  67510. * Defines if mipmaps should not be generated (default is false)
  67511. */
  67512. noMipmap?: boolean | undefined;
  67513. /**
  67514. * Defines the explicit list of files (undefined by default)
  67515. */
  67516. files?: string[] | undefined;
  67517. /**
  67518. * Gets the loaded texture
  67519. */
  67520. texture: CubeTexture;
  67521. /**
  67522. * Callback called when the task is successful
  67523. */
  67524. onSuccess: (task: CubeTextureAssetTask) => void;
  67525. /**
  67526. * Callback called when the task is successful
  67527. */
  67528. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67529. /**
  67530. * Creates a new CubeTextureAssetTask
  67531. * @param name defines the name of the task
  67532. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67533. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67534. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67535. * @param files defines the explicit list of files (undefined by default)
  67536. */
  67537. constructor(
  67538. /**
  67539. * Defines the name of the task
  67540. */
  67541. name: string,
  67542. /**
  67543. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67544. */
  67545. url: string,
  67546. /**
  67547. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67548. */
  67549. extensions?: string[] | undefined,
  67550. /**
  67551. * Defines if mipmaps should not be generated (default is false)
  67552. */
  67553. noMipmap?: boolean | undefined,
  67554. /**
  67555. * Defines the explicit list of files (undefined by default)
  67556. */
  67557. files?: string[] | undefined);
  67558. /**
  67559. * Execute the current task
  67560. * @param scene defines the scene where you want your assets to be loaded
  67561. * @param onSuccess is a callback called when the task is successfully executed
  67562. * @param onError is a callback called if an error occurs
  67563. */
  67564. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67565. }
  67566. /**
  67567. * Define a task used by AssetsManager to load HDR cube textures
  67568. */
  67569. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67570. /**
  67571. * Defines the name of the task
  67572. */
  67573. name: string;
  67574. /**
  67575. * Defines the location of the file to load
  67576. */
  67577. url: string;
  67578. /**
  67579. * Defines the desired size (the more it increases the longer the generation will be)
  67580. */
  67581. size: number;
  67582. /**
  67583. * Defines if mipmaps should not be generated (default is false)
  67584. */
  67585. noMipmap: boolean;
  67586. /**
  67587. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67588. */
  67589. generateHarmonics: boolean;
  67590. /**
  67591. * 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)
  67592. */
  67593. gammaSpace: boolean;
  67594. /**
  67595. * Internal Use Only
  67596. */
  67597. reserved: boolean;
  67598. /**
  67599. * Gets the loaded texture
  67600. */
  67601. texture: HDRCubeTexture;
  67602. /**
  67603. * Callback called when the task is successful
  67604. */
  67605. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67606. /**
  67607. * Callback called when the task is successful
  67608. */
  67609. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67610. /**
  67611. * Creates a new HDRCubeTextureAssetTask object
  67612. * @param name defines the name of the task
  67613. * @param url defines the location of the file to load
  67614. * @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.
  67615. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67616. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67617. * @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)
  67618. * @param reserved Internal use only
  67619. */
  67620. constructor(
  67621. /**
  67622. * Defines the name of the task
  67623. */
  67624. name: string,
  67625. /**
  67626. * Defines the location of the file to load
  67627. */
  67628. url: string,
  67629. /**
  67630. * Defines the desired size (the more it increases the longer the generation will be)
  67631. */
  67632. size: number,
  67633. /**
  67634. * Defines if mipmaps should not be generated (default is false)
  67635. */
  67636. noMipmap?: boolean,
  67637. /**
  67638. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67639. */
  67640. generateHarmonics?: boolean,
  67641. /**
  67642. * 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)
  67643. */
  67644. gammaSpace?: boolean,
  67645. /**
  67646. * Internal Use Only
  67647. */
  67648. reserved?: boolean);
  67649. /**
  67650. * Execute the current task
  67651. * @param scene defines the scene where you want your assets to be loaded
  67652. * @param onSuccess is a callback called when the task is successfully executed
  67653. * @param onError is a callback called if an error occurs
  67654. */
  67655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67656. }
  67657. /**
  67658. * Define a task used by AssetsManager to load Equirectangular cube textures
  67659. */
  67660. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67661. /**
  67662. * Defines the name of the task
  67663. */
  67664. name: string;
  67665. /**
  67666. * Defines the location of the file to load
  67667. */
  67668. url: string;
  67669. /**
  67670. * Defines the desired size (the more it increases the longer the generation will be)
  67671. */
  67672. size: number;
  67673. /**
  67674. * Defines if mipmaps should not be generated (default is false)
  67675. */
  67676. noMipmap: boolean;
  67677. /**
  67678. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67679. * but the standard material would require them in Gamma space) (default is true)
  67680. */
  67681. gammaSpace: boolean;
  67682. /**
  67683. * Gets the loaded texture
  67684. */
  67685. texture: EquiRectangularCubeTexture;
  67686. /**
  67687. * Callback called when the task is successful
  67688. */
  67689. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67690. /**
  67691. * Callback called when the task is successful
  67692. */
  67693. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67694. /**
  67695. * Creates a new EquiRectangularCubeTextureAssetTask object
  67696. * @param name defines the name of the task
  67697. * @param url defines the location of the file to load
  67698. * @param size defines the desired size (the more it increases the longer the generation will be)
  67699. * If the size is omitted this implies you are using a preprocessed cubemap.
  67700. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67701. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67702. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67703. * (default is true)
  67704. */
  67705. constructor(
  67706. /**
  67707. * Defines the name of the task
  67708. */
  67709. name: string,
  67710. /**
  67711. * Defines the location of the file to load
  67712. */
  67713. url: string,
  67714. /**
  67715. * Defines the desired size (the more it increases the longer the generation will be)
  67716. */
  67717. size: number,
  67718. /**
  67719. * Defines if mipmaps should not be generated (default is false)
  67720. */
  67721. noMipmap?: boolean,
  67722. /**
  67723. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67724. * but the standard material would require them in Gamma space) (default is true)
  67725. */
  67726. gammaSpace?: boolean);
  67727. /**
  67728. * Execute the current task
  67729. * @param scene defines the scene where you want your assets to be loaded
  67730. * @param onSuccess is a callback called when the task is successfully executed
  67731. * @param onError is a callback called if an error occurs
  67732. */
  67733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67734. }
  67735. /**
  67736. * This class can be used to easily import assets into a scene
  67737. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67738. */
  67739. export class AssetsManager {
  67740. private _scene;
  67741. private _isLoading;
  67742. protected _tasks: AbstractAssetTask[];
  67743. protected _waitingTasksCount: number;
  67744. protected _totalTasksCount: number;
  67745. /**
  67746. * Callback called when all tasks are processed
  67747. */
  67748. onFinish: (tasks: AbstractAssetTask[]) => void;
  67749. /**
  67750. * Callback called when a task is successful
  67751. */
  67752. onTaskSuccess: (task: AbstractAssetTask) => void;
  67753. /**
  67754. * Callback called when a task had an error
  67755. */
  67756. onTaskError: (task: AbstractAssetTask) => void;
  67757. /**
  67758. * Callback called when a task is done (whatever the result is)
  67759. */
  67760. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67761. /**
  67762. * Observable called when all tasks are processed
  67763. */
  67764. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67765. /**
  67766. * Observable called when a task had an error
  67767. */
  67768. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67769. /**
  67770. * Observable called when all tasks were executed
  67771. */
  67772. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67773. /**
  67774. * Observable called when a task is done (whatever the result is)
  67775. */
  67776. onProgressObservable: Observable<IAssetsProgressEvent>;
  67777. /**
  67778. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67779. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67780. */
  67781. useDefaultLoadingScreen: boolean;
  67782. /**
  67783. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67784. * when all assets have been downloaded.
  67785. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67786. */
  67787. autoHideLoadingUI: boolean;
  67788. /**
  67789. * Creates a new AssetsManager
  67790. * @param scene defines the scene to work on
  67791. */
  67792. constructor(scene: Scene);
  67793. /**
  67794. * Add a MeshAssetTask to the list of active tasks
  67795. * @param taskName defines the name of the new task
  67796. * @param meshesNames defines the name of meshes to load
  67797. * @param rootUrl defines the root url to use to locate files
  67798. * @param sceneFilename defines the filename of the scene file
  67799. * @returns a new MeshAssetTask object
  67800. */
  67801. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67802. /**
  67803. * Add a TextFileAssetTask to the list of active tasks
  67804. * @param taskName defines the name of the new task
  67805. * @param url defines the url of the file to load
  67806. * @returns a new TextFileAssetTask object
  67807. */
  67808. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67809. /**
  67810. * Add a BinaryFileAssetTask to the list of active tasks
  67811. * @param taskName defines the name of the new task
  67812. * @param url defines the url of the file to load
  67813. * @returns a new BinaryFileAssetTask object
  67814. */
  67815. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67816. /**
  67817. * Add a ImageAssetTask to the list of active tasks
  67818. * @param taskName defines the name of the new task
  67819. * @param url defines the url of the file to load
  67820. * @returns a new ImageAssetTask object
  67821. */
  67822. addImageTask(taskName: string, url: string): ImageAssetTask;
  67823. /**
  67824. * Add a TextureAssetTask to the list of active tasks
  67825. * @param taskName defines the name of the new task
  67826. * @param url defines the url of the file to load
  67827. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67828. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67829. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67830. * @returns a new TextureAssetTask object
  67831. */
  67832. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67833. /**
  67834. * Add a CubeTextureAssetTask to the list of active tasks
  67835. * @param taskName defines the name of the new task
  67836. * @param url defines the url of the file to load
  67837. * @param extensions defines the extension to use to load the cube map (can be null)
  67838. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67839. * @param files defines the list of files to load (can be null)
  67840. * @returns a new CubeTextureAssetTask object
  67841. */
  67842. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67843. /**
  67844. *
  67845. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67846. * @param taskName defines the name of the new task
  67847. * @param url defines the url of the file to load
  67848. * @param size defines the size you want for the cubemap (can be null)
  67849. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67850. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67851. * @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)
  67852. * @param reserved Internal use only
  67853. * @returns a new HDRCubeTextureAssetTask object
  67854. */
  67855. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67856. /**
  67857. *
  67858. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67859. * @param taskName defines the name of the new task
  67860. * @param url defines the url of the file to load
  67861. * @param size defines the size you want for the cubemap (can be null)
  67862. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67863. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67864. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67865. * @returns a new EquiRectangularCubeTextureAssetTask object
  67866. */
  67867. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67868. /**
  67869. * Remove a task from the assets manager.
  67870. * @param task the task to remove
  67871. */
  67872. removeTask(task: AbstractAssetTask): void;
  67873. private _decreaseWaitingTasksCount;
  67874. private _runTask;
  67875. /**
  67876. * Reset the AssetsManager and remove all tasks
  67877. * @return the current instance of the AssetsManager
  67878. */
  67879. reset(): AssetsManager;
  67880. /**
  67881. * Start the loading process
  67882. * @return the current instance of the AssetsManager
  67883. */
  67884. load(): AssetsManager;
  67885. /**
  67886. * Start the loading process as an async operation
  67887. * @return a promise returning the list of failed tasks
  67888. */
  67889. loadAsync(): Promise<void>;
  67890. }
  67891. }
  67892. declare module "babylonjs/Misc/deferred" {
  67893. /**
  67894. * Wrapper class for promise with external resolve and reject.
  67895. */
  67896. export class Deferred<T> {
  67897. /**
  67898. * The promise associated with this deferred object.
  67899. */
  67900. readonly promise: Promise<T>;
  67901. private _resolve;
  67902. private _reject;
  67903. /**
  67904. * The resolve method of the promise associated with this deferred object.
  67905. */
  67906. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67907. /**
  67908. * The reject method of the promise associated with this deferred object.
  67909. */
  67910. readonly reject: (reason?: any) => void;
  67911. /**
  67912. * Constructor for this deferred object.
  67913. */
  67914. constructor();
  67915. }
  67916. }
  67917. declare module "babylonjs/Misc/meshExploder" {
  67918. import { Mesh } from "babylonjs/Meshes/mesh";
  67919. /**
  67920. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67921. */
  67922. export class MeshExploder {
  67923. private _centerMesh;
  67924. private _meshes;
  67925. private _meshesOrigins;
  67926. private _toCenterVectors;
  67927. private _scaledDirection;
  67928. private _newPosition;
  67929. private _centerPosition;
  67930. /**
  67931. * Explodes meshes from a center mesh.
  67932. * @param meshes The meshes to explode.
  67933. * @param centerMesh The mesh to be center of explosion.
  67934. */
  67935. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67936. private _setCenterMesh;
  67937. /**
  67938. * Get class name
  67939. * @returns "MeshExploder"
  67940. */
  67941. getClassName(): string;
  67942. /**
  67943. * "Exploded meshes"
  67944. * @returns Array of meshes with the centerMesh at index 0.
  67945. */
  67946. getMeshes(): Array<Mesh>;
  67947. /**
  67948. * Explodes meshes giving a specific direction
  67949. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67950. */
  67951. explode(direction?: number): void;
  67952. }
  67953. }
  67954. declare module "babylonjs/Misc/filesInput" {
  67955. import { Engine } from "babylonjs/Engines/engine";
  67956. import { Scene } from "babylonjs/scene";
  67957. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67958. /**
  67959. * Class used to help managing file picking and drag'n'drop
  67960. */
  67961. export class FilesInput {
  67962. /**
  67963. * List of files ready to be loaded
  67964. */
  67965. static readonly FilesToLoad: {
  67966. [key: string]: File;
  67967. };
  67968. /**
  67969. * Callback called when a file is processed
  67970. */
  67971. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67972. private _engine;
  67973. private _currentScene;
  67974. private _sceneLoadedCallback;
  67975. private _progressCallback;
  67976. private _additionalRenderLoopLogicCallback;
  67977. private _textureLoadingCallback;
  67978. private _startingProcessingFilesCallback;
  67979. private _onReloadCallback;
  67980. private _errorCallback;
  67981. private _elementToMonitor;
  67982. private _sceneFileToLoad;
  67983. private _filesToLoad;
  67984. /**
  67985. * Creates a new FilesInput
  67986. * @param engine defines the rendering engine
  67987. * @param scene defines the hosting scene
  67988. * @param sceneLoadedCallback callback called when scene is loaded
  67989. * @param progressCallback callback called to track progress
  67990. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67991. * @param textureLoadingCallback callback called when a texture is loading
  67992. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67993. * @param onReloadCallback callback called when a reload is requested
  67994. * @param errorCallback callback call if an error occurs
  67995. */
  67996. 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);
  67997. private _dragEnterHandler;
  67998. private _dragOverHandler;
  67999. private _dropHandler;
  68000. /**
  68001. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68002. * @param elementToMonitor defines the DOM element to track
  68003. */
  68004. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68005. /**
  68006. * Release all associated resources
  68007. */
  68008. dispose(): void;
  68009. private renderFunction;
  68010. private drag;
  68011. private drop;
  68012. private _traverseFolder;
  68013. private _processFiles;
  68014. /**
  68015. * Load files from a drop event
  68016. * @param event defines the drop event to use as source
  68017. */
  68018. loadFiles(event: any): void;
  68019. private _processReload;
  68020. /**
  68021. * Reload the current scene from the loaded files
  68022. */
  68023. reload(): void;
  68024. }
  68025. }
  68026. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68027. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68028. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68029. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68030. }
  68031. declare module "babylonjs/Misc/sceneOptimizer" {
  68032. import { Scene, IDisposable } from "babylonjs/scene";
  68033. import { Observable } from "babylonjs/Misc/observable";
  68034. /**
  68035. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68037. */
  68038. export class SceneOptimization {
  68039. /**
  68040. * Defines the priority of this optimization (0 by default which means first in the list)
  68041. */
  68042. priority: number;
  68043. /**
  68044. * Gets a string describing the action executed by the current optimization
  68045. * @returns description string
  68046. */
  68047. getDescription(): string;
  68048. /**
  68049. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68050. * @param scene defines the current scene where to apply this optimization
  68051. * @param optimizer defines the current optimizer
  68052. * @returns true if everything that can be done was applied
  68053. */
  68054. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68055. /**
  68056. * Creates the SceneOptimization object
  68057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68058. * @param desc defines the description associated with the optimization
  68059. */
  68060. constructor(
  68061. /**
  68062. * Defines the priority of this optimization (0 by default which means first in the list)
  68063. */
  68064. priority?: number);
  68065. }
  68066. /**
  68067. * Defines an optimization used to reduce the size of render target textures
  68068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68069. */
  68070. export class TextureOptimization extends SceneOptimization {
  68071. /**
  68072. * Defines the priority of this optimization (0 by default which means first in the list)
  68073. */
  68074. priority: number;
  68075. /**
  68076. * 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
  68077. */
  68078. maximumSize: number;
  68079. /**
  68080. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68081. */
  68082. step: number;
  68083. /**
  68084. * Gets a string describing the action executed by the current optimization
  68085. * @returns description string
  68086. */
  68087. getDescription(): string;
  68088. /**
  68089. * Creates the TextureOptimization object
  68090. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68091. * @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
  68092. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68093. */
  68094. constructor(
  68095. /**
  68096. * Defines the priority of this optimization (0 by default which means first in the list)
  68097. */
  68098. priority?: number,
  68099. /**
  68100. * 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
  68101. */
  68102. maximumSize?: number,
  68103. /**
  68104. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68105. */
  68106. step?: number);
  68107. /**
  68108. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68109. * @param scene defines the current scene where to apply this optimization
  68110. * @param optimizer defines the current optimizer
  68111. * @returns true if everything that can be done was applied
  68112. */
  68113. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68114. }
  68115. /**
  68116. * Defines an optimization used to increase or decrease the rendering resolution
  68117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68118. */
  68119. export class HardwareScalingOptimization extends SceneOptimization {
  68120. /**
  68121. * Defines the priority of this optimization (0 by default which means first in the list)
  68122. */
  68123. priority: number;
  68124. /**
  68125. * Defines the maximum scale to use (2 by default)
  68126. */
  68127. maximumScale: number;
  68128. /**
  68129. * Defines the step to use between two passes (0.5 by default)
  68130. */
  68131. step: number;
  68132. private _currentScale;
  68133. private _directionOffset;
  68134. /**
  68135. * Gets a string describing the action executed by the current optimization
  68136. * @return description string
  68137. */
  68138. getDescription(): string;
  68139. /**
  68140. * Creates the HardwareScalingOptimization object
  68141. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68142. * @param maximumScale defines the maximum scale to use (2 by default)
  68143. * @param step defines the step to use between two passes (0.5 by default)
  68144. */
  68145. constructor(
  68146. /**
  68147. * Defines the priority of this optimization (0 by default which means first in the list)
  68148. */
  68149. priority?: number,
  68150. /**
  68151. * Defines the maximum scale to use (2 by default)
  68152. */
  68153. maximumScale?: number,
  68154. /**
  68155. * Defines the step to use between two passes (0.5 by default)
  68156. */
  68157. step?: number);
  68158. /**
  68159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68160. * @param scene defines the current scene where to apply this optimization
  68161. * @param optimizer defines the current optimizer
  68162. * @returns true if everything that can be done was applied
  68163. */
  68164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68165. }
  68166. /**
  68167. * Defines an optimization used to remove shadows
  68168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68169. */
  68170. export class ShadowsOptimization extends SceneOptimization {
  68171. /**
  68172. * Gets a string describing the action executed by the current optimization
  68173. * @return description string
  68174. */
  68175. getDescription(): string;
  68176. /**
  68177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68178. * @param scene defines the current scene where to apply this optimization
  68179. * @param optimizer defines the current optimizer
  68180. * @returns true if everything that can be done was applied
  68181. */
  68182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68183. }
  68184. /**
  68185. * Defines an optimization used to turn post-processes off
  68186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68187. */
  68188. export class PostProcessesOptimization extends SceneOptimization {
  68189. /**
  68190. * Gets a string describing the action executed by the current optimization
  68191. * @return description string
  68192. */
  68193. getDescription(): string;
  68194. /**
  68195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68196. * @param scene defines the current scene where to apply this optimization
  68197. * @param optimizer defines the current optimizer
  68198. * @returns true if everything that can be done was applied
  68199. */
  68200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68201. }
  68202. /**
  68203. * Defines an optimization used to turn lens flares off
  68204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68205. */
  68206. export class LensFlaresOptimization extends SceneOptimization {
  68207. /**
  68208. * Gets a string describing the action executed by the current optimization
  68209. * @return description string
  68210. */
  68211. getDescription(): string;
  68212. /**
  68213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68214. * @param scene defines the current scene where to apply this optimization
  68215. * @param optimizer defines the current optimizer
  68216. * @returns true if everything that can be done was applied
  68217. */
  68218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68219. }
  68220. /**
  68221. * Defines an optimization based on user defined callback.
  68222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68223. */
  68224. export class CustomOptimization extends SceneOptimization {
  68225. /**
  68226. * Callback called to apply the custom optimization.
  68227. */
  68228. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68229. /**
  68230. * Callback called to get custom description
  68231. */
  68232. onGetDescription: () => string;
  68233. /**
  68234. * Gets a string describing the action executed by the current optimization
  68235. * @returns description string
  68236. */
  68237. getDescription(): string;
  68238. /**
  68239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68240. * @param scene defines the current scene where to apply this optimization
  68241. * @param optimizer defines the current optimizer
  68242. * @returns true if everything that can be done was applied
  68243. */
  68244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68245. }
  68246. /**
  68247. * Defines an optimization used to turn particles off
  68248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68249. */
  68250. export class ParticlesOptimization extends SceneOptimization {
  68251. /**
  68252. * Gets a string describing the action executed by the current optimization
  68253. * @return description string
  68254. */
  68255. getDescription(): string;
  68256. /**
  68257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68258. * @param scene defines the current scene where to apply this optimization
  68259. * @param optimizer defines the current optimizer
  68260. * @returns true if everything that can be done was applied
  68261. */
  68262. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68263. }
  68264. /**
  68265. * Defines an optimization used to turn render targets off
  68266. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68267. */
  68268. export class RenderTargetsOptimization extends SceneOptimization {
  68269. /**
  68270. * Gets a string describing the action executed by the current optimization
  68271. * @return description string
  68272. */
  68273. getDescription(): string;
  68274. /**
  68275. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68276. * @param scene defines the current scene where to apply this optimization
  68277. * @param optimizer defines the current optimizer
  68278. * @returns true if everything that can be done was applied
  68279. */
  68280. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68281. }
  68282. /**
  68283. * Defines an optimization used to merge meshes with compatible materials
  68284. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68285. */
  68286. export class MergeMeshesOptimization extends SceneOptimization {
  68287. private static _UpdateSelectionTree;
  68288. /**
  68289. * Gets or sets a boolean which defines if optimization octree has to be updated
  68290. */
  68291. /**
  68292. * Gets or sets a boolean which defines if optimization octree has to be updated
  68293. */
  68294. static UpdateSelectionTree: boolean;
  68295. /**
  68296. * Gets a string describing the action executed by the current optimization
  68297. * @return description string
  68298. */
  68299. getDescription(): string;
  68300. private _canBeMerged;
  68301. /**
  68302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68303. * @param scene defines the current scene where to apply this optimization
  68304. * @param optimizer defines the current optimizer
  68305. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68306. * @returns true if everything that can be done was applied
  68307. */
  68308. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68309. }
  68310. /**
  68311. * Defines a list of options used by SceneOptimizer
  68312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68313. */
  68314. export class SceneOptimizerOptions {
  68315. /**
  68316. * Defines the target frame rate to reach (60 by default)
  68317. */
  68318. targetFrameRate: number;
  68319. /**
  68320. * Defines the interval between two checkes (2000ms by default)
  68321. */
  68322. trackerDuration: number;
  68323. /**
  68324. * Gets the list of optimizations to apply
  68325. */
  68326. optimizations: SceneOptimization[];
  68327. /**
  68328. * Creates a new list of options used by SceneOptimizer
  68329. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68330. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68331. */
  68332. constructor(
  68333. /**
  68334. * Defines the target frame rate to reach (60 by default)
  68335. */
  68336. targetFrameRate?: number,
  68337. /**
  68338. * Defines the interval between two checkes (2000ms by default)
  68339. */
  68340. trackerDuration?: number);
  68341. /**
  68342. * Add a new optimization
  68343. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68344. * @returns the current SceneOptimizerOptions
  68345. */
  68346. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68347. /**
  68348. * Add a new custom optimization
  68349. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68350. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68351. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68352. * @returns the current SceneOptimizerOptions
  68353. */
  68354. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68355. /**
  68356. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68357. * @param targetFrameRate defines the target frame rate (60 by default)
  68358. * @returns a SceneOptimizerOptions object
  68359. */
  68360. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68361. /**
  68362. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68363. * @param targetFrameRate defines the target frame rate (60 by default)
  68364. * @returns a SceneOptimizerOptions object
  68365. */
  68366. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68367. /**
  68368. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68369. * @param targetFrameRate defines the target frame rate (60 by default)
  68370. * @returns a SceneOptimizerOptions object
  68371. */
  68372. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68373. }
  68374. /**
  68375. * Class used to run optimizations in order to reach a target frame rate
  68376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68377. */
  68378. export class SceneOptimizer implements IDisposable {
  68379. private _isRunning;
  68380. private _options;
  68381. private _scene;
  68382. private _currentPriorityLevel;
  68383. private _targetFrameRate;
  68384. private _trackerDuration;
  68385. private _currentFrameRate;
  68386. private _sceneDisposeObserver;
  68387. private _improvementMode;
  68388. /**
  68389. * Defines an observable called when the optimizer reaches the target frame rate
  68390. */
  68391. onSuccessObservable: Observable<SceneOptimizer>;
  68392. /**
  68393. * Defines an observable called when the optimizer enables an optimization
  68394. */
  68395. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68396. /**
  68397. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68398. */
  68399. onFailureObservable: Observable<SceneOptimizer>;
  68400. /**
  68401. * Gets a boolean indicating if the optimizer is in improvement mode
  68402. */
  68403. readonly isInImprovementMode: boolean;
  68404. /**
  68405. * Gets the current priority level (0 at start)
  68406. */
  68407. readonly currentPriorityLevel: number;
  68408. /**
  68409. * Gets the current frame rate checked by the SceneOptimizer
  68410. */
  68411. readonly currentFrameRate: number;
  68412. /**
  68413. * Gets or sets the current target frame rate (60 by default)
  68414. */
  68415. /**
  68416. * Gets or sets the current target frame rate (60 by default)
  68417. */
  68418. targetFrameRate: number;
  68419. /**
  68420. * Gets or sets the current interval between two checks (every 2000ms by default)
  68421. */
  68422. /**
  68423. * Gets or sets the current interval between two checks (every 2000ms by default)
  68424. */
  68425. trackerDuration: number;
  68426. /**
  68427. * Gets the list of active optimizations
  68428. */
  68429. readonly optimizations: SceneOptimization[];
  68430. /**
  68431. * Creates a new SceneOptimizer
  68432. * @param scene defines the scene to work on
  68433. * @param options defines the options to use with the SceneOptimizer
  68434. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68435. * @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)
  68436. */
  68437. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68438. /**
  68439. * Stops the current optimizer
  68440. */
  68441. stop(): void;
  68442. /**
  68443. * Reset the optimizer to initial step (current priority level = 0)
  68444. */
  68445. reset(): void;
  68446. /**
  68447. * Start the optimizer. By default it will try to reach a specific framerate
  68448. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68449. */
  68450. start(): void;
  68451. private _checkCurrentState;
  68452. /**
  68453. * Release all resources
  68454. */
  68455. dispose(): void;
  68456. /**
  68457. * Helper function to create a SceneOptimizer with one single line of code
  68458. * @param scene defines the scene to work on
  68459. * @param options defines the options to use with the SceneOptimizer
  68460. * @param onSuccess defines a callback to call on success
  68461. * @param onFailure defines a callback to call on failure
  68462. * @returns the new SceneOptimizer object
  68463. */
  68464. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68465. }
  68466. }
  68467. declare module "babylonjs/Misc/sceneSerializer" {
  68468. import { Scene } from "babylonjs/scene";
  68469. /**
  68470. * Class used to serialize a scene into a string
  68471. */
  68472. export class SceneSerializer {
  68473. /**
  68474. * Clear cache used by a previous serialization
  68475. */
  68476. static ClearCache(): void;
  68477. /**
  68478. * Serialize a scene into a JSON compatible object
  68479. * @param scene defines the scene to serialize
  68480. * @returns a JSON compatible object
  68481. */
  68482. static Serialize(scene: Scene): any;
  68483. /**
  68484. * Serialize a mesh into a JSON compatible object
  68485. * @param toSerialize defines the mesh to serialize
  68486. * @param withParents defines if parents must be serialized as well
  68487. * @param withChildren defines if children must be serialized as well
  68488. * @returns a JSON compatible object
  68489. */
  68490. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68491. }
  68492. }
  68493. declare module "babylonjs/Misc/textureTools" {
  68494. import { Texture } from "babylonjs/Materials/Textures/texture";
  68495. /**
  68496. * Class used to host texture specific utilities
  68497. */
  68498. export class TextureTools {
  68499. /**
  68500. * Uses the GPU to create a copy texture rescaled at a given size
  68501. * @param texture Texture to copy from
  68502. * @param width defines the desired width
  68503. * @param height defines the desired height
  68504. * @param useBilinearMode defines if bilinear mode has to be used
  68505. * @return the generated texture
  68506. */
  68507. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68508. }
  68509. }
  68510. declare module "babylonjs/Misc/videoRecorder" {
  68511. import { Nullable } from "babylonjs/types";
  68512. import { Engine } from "babylonjs/Engines/engine";
  68513. /**
  68514. * This represents the different options available for the video capture.
  68515. */
  68516. export interface VideoRecorderOptions {
  68517. /** Defines the mime type of the video. */
  68518. mimeType: string;
  68519. /** Defines the FPS the video should be recorded at. */
  68520. fps: number;
  68521. /** Defines the chunk size for the recording data. */
  68522. recordChunckSize: number;
  68523. /** The audio tracks to attach to the recording. */
  68524. audioTracks?: MediaStreamTrack[];
  68525. }
  68526. /**
  68527. * This can help with recording videos from BabylonJS.
  68528. * This is based on the available WebRTC functionalities of the browser.
  68529. *
  68530. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68531. */
  68532. export class VideoRecorder {
  68533. private static readonly _defaultOptions;
  68534. /**
  68535. * Returns whether or not the VideoRecorder is available in your browser.
  68536. * @param engine Defines the Babylon Engine.
  68537. * @returns true if supported otherwise false.
  68538. */
  68539. static IsSupported(engine: Engine): boolean;
  68540. private readonly _options;
  68541. private _canvas;
  68542. private _mediaRecorder;
  68543. private _recordedChunks;
  68544. private _fileName;
  68545. private _resolve;
  68546. private _reject;
  68547. /**
  68548. * True when a recording is already in progress.
  68549. */
  68550. readonly isRecording: boolean;
  68551. /**
  68552. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68553. * @param engine Defines the BabylonJS Engine you wish to record.
  68554. * @param options Defines options that can be used to customize the capture.
  68555. */
  68556. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68557. /**
  68558. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68559. */
  68560. stopRecording(): void;
  68561. /**
  68562. * Starts recording the canvas for a max duration specified in parameters.
  68563. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68564. * If null no automatic download will start and you can rely on the promise to get the data back.
  68565. * @param maxDuration Defines the maximum recording time in seconds.
  68566. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68567. * @return A promise callback at the end of the recording with the video data in Blob.
  68568. */
  68569. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68570. /**
  68571. * Releases internal resources used during the recording.
  68572. */
  68573. dispose(): void;
  68574. private _handleDataAvailable;
  68575. private _handleError;
  68576. private _handleStop;
  68577. }
  68578. }
  68579. declare module "babylonjs/Misc/screenshotTools" {
  68580. import { Camera } from "babylonjs/Cameras/camera";
  68581. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68582. import { Engine } from "babylonjs/Engines/engine";
  68583. /**
  68584. * Class containing a set of static utilities functions for screenshots
  68585. */
  68586. export class ScreenshotTools {
  68587. /**
  68588. * Captures a screenshot of the current rendering
  68589. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68590. * @param engine defines the rendering engine
  68591. * @param camera defines the source camera
  68592. * @param size This parameter can be set to a single number or to an object with the
  68593. * following (optional) properties: precision, width, height. If a single number is passed,
  68594. * it will be used for both width and height. If an object is passed, the screenshot size
  68595. * will be derived from the parameters. The precision property is a multiplier allowing
  68596. * rendering at a higher or lower resolution
  68597. * @param successCallback defines the callback receives a single parameter which contains the
  68598. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68599. * src parameter of an <img> to display it
  68600. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68601. * Check your browser for supported MIME types
  68602. */
  68603. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68604. /**
  68605. * Captures a screenshot of the current rendering
  68606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68607. * @param engine defines the rendering engine
  68608. * @param camera defines the source camera
  68609. * @param size This parameter can be set to a single number or to an object with the
  68610. * following (optional) properties: precision, width, height. If a single number is passed,
  68611. * it will be used for both width and height. If an object is passed, the screenshot size
  68612. * will be derived from the parameters. The precision property is a multiplier allowing
  68613. * rendering at a higher or lower resolution
  68614. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68615. * Check your browser for supported MIME types
  68616. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68617. * to the src parameter of an <img> to display it
  68618. */
  68619. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68620. /**
  68621. * Generates an image screenshot from the specified camera.
  68622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68623. * @param engine The engine to use for rendering
  68624. * @param camera The camera to use for rendering
  68625. * @param size This parameter can be set to a single number or to an object with the
  68626. * following (optional) properties: precision, width, height. If a single number is passed,
  68627. * it will be used for both width and height. If an object is passed, the screenshot size
  68628. * will be derived from the parameters. The precision property is a multiplier allowing
  68629. * rendering at a higher or lower resolution
  68630. * @param successCallback The callback receives a single parameter which contains the
  68631. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68632. * src parameter of an <img> to display it
  68633. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68634. * Check your browser for supported MIME types
  68635. * @param samples Texture samples (default: 1)
  68636. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68637. * @param fileName A name for for the downloaded file.
  68638. */
  68639. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68640. /**
  68641. * Generates an image screenshot from the specified camera.
  68642. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68643. * @param engine The engine to use for rendering
  68644. * @param camera The camera to use for rendering
  68645. * @param size This parameter can be set to a single number or to an object with the
  68646. * following (optional) properties: precision, width, height. If a single number is passed,
  68647. * it will be used for both width and height. If an object is passed, the screenshot size
  68648. * will be derived from the parameters. The precision property is a multiplier allowing
  68649. * rendering at a higher or lower resolution
  68650. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68651. * Check your browser for supported MIME types
  68652. * @param samples Texture samples (default: 1)
  68653. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68654. * @param fileName A name for for the downloaded file.
  68655. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68656. * to the src parameter of an <img> to display it
  68657. */
  68658. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68659. /**
  68660. * Gets height and width for screenshot size
  68661. * @private
  68662. */
  68663. private static _getScreenshotSize;
  68664. }
  68665. }
  68666. declare module "babylonjs/Misc/dataReader" {
  68667. /**
  68668. * Interface for a data buffer
  68669. */
  68670. export interface IDataBuffer {
  68671. /**
  68672. * Reads bytes from the data buffer.
  68673. * @param byteOffset The byte offset to read
  68674. * @param byteLength The byte length to read
  68675. * @returns A promise that resolves when the bytes are read
  68676. */
  68677. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68678. /**
  68679. * The byte length of the buffer.
  68680. */
  68681. readonly byteLength: number;
  68682. }
  68683. /**
  68684. * Utility class for reading from a data buffer
  68685. */
  68686. export class DataReader {
  68687. /**
  68688. * The data buffer associated with this data reader.
  68689. */
  68690. readonly buffer: IDataBuffer;
  68691. /**
  68692. * The current byte offset from the beginning of the data buffer.
  68693. */
  68694. byteOffset: number;
  68695. private _dataView;
  68696. private _dataByteOffset;
  68697. /**
  68698. * Constructor
  68699. * @param buffer The buffer to read
  68700. */
  68701. constructor(buffer: IDataBuffer);
  68702. /**
  68703. * Loads the given byte length.
  68704. * @param byteLength The byte length to load
  68705. * @returns A promise that resolves when the load is complete
  68706. */
  68707. loadAsync(byteLength: number): Promise<void>;
  68708. /**
  68709. * Read a unsigned 32-bit integer from the currently loaded data range.
  68710. * @returns The 32-bit integer read
  68711. */
  68712. readUint32(): number;
  68713. /**
  68714. * Read a byte array from the currently loaded data range.
  68715. * @param byteLength The byte length to read
  68716. * @returns The byte array read
  68717. */
  68718. readUint8Array(byteLength: number): Uint8Array;
  68719. /**
  68720. * Read a string from the currently loaded data range.
  68721. * @param byteLength The byte length to read
  68722. * @returns The string read
  68723. */
  68724. readString(byteLength: number): string;
  68725. /**
  68726. * Skips the given byte length the currently loaded data range.
  68727. * @param byteLength The byte length to skip
  68728. */
  68729. skipBytes(byteLength: number): void;
  68730. }
  68731. }
  68732. declare module "babylonjs/Misc/index" {
  68733. export * from "babylonjs/Misc/andOrNotEvaluator";
  68734. export * from "babylonjs/Misc/assetsManager";
  68735. export * from "babylonjs/Misc/basis";
  68736. export * from "babylonjs/Misc/dds";
  68737. export * from "babylonjs/Misc/decorators";
  68738. export * from "babylonjs/Misc/deferred";
  68739. export * from "babylonjs/Misc/environmentTextureTools";
  68740. export * from "babylonjs/Misc/meshExploder";
  68741. export * from "babylonjs/Misc/filesInput";
  68742. export * from "babylonjs/Misc/HighDynamicRange/index";
  68743. export * from "babylonjs/Misc/khronosTextureContainer";
  68744. export * from "babylonjs/Misc/observable";
  68745. export * from "babylonjs/Misc/performanceMonitor";
  68746. export * from "babylonjs/Misc/promise";
  68747. export * from "babylonjs/Misc/sceneOptimizer";
  68748. export * from "babylonjs/Misc/sceneSerializer";
  68749. export * from "babylonjs/Misc/smartArray";
  68750. export * from "babylonjs/Misc/stringDictionary";
  68751. export * from "babylonjs/Misc/tags";
  68752. export * from "babylonjs/Misc/textureTools";
  68753. export * from "babylonjs/Misc/tga";
  68754. export * from "babylonjs/Misc/tools";
  68755. export * from "babylonjs/Misc/videoRecorder";
  68756. export * from "babylonjs/Misc/virtualJoystick";
  68757. export * from "babylonjs/Misc/workerPool";
  68758. export * from "babylonjs/Misc/logger";
  68759. export * from "babylonjs/Misc/typeStore";
  68760. export * from "babylonjs/Misc/filesInputStore";
  68761. export * from "babylonjs/Misc/deepCopier";
  68762. export * from "babylonjs/Misc/pivotTools";
  68763. export * from "babylonjs/Misc/precisionDate";
  68764. export * from "babylonjs/Misc/screenshotTools";
  68765. export * from "babylonjs/Misc/typeStore";
  68766. export * from "babylonjs/Misc/webRequest";
  68767. export * from "babylonjs/Misc/iInspectable";
  68768. export * from "babylonjs/Misc/brdfTextureTools";
  68769. export * from "babylonjs/Misc/rgbdTextureTools";
  68770. export * from "babylonjs/Misc/gradients";
  68771. export * from "babylonjs/Misc/perfCounter";
  68772. export * from "babylonjs/Misc/fileRequest";
  68773. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68774. export * from "babylonjs/Misc/retryStrategy";
  68775. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68776. export * from "babylonjs/Misc/canvasGenerator";
  68777. export * from "babylonjs/Misc/fileTools";
  68778. export * from "babylonjs/Misc/stringTools";
  68779. export * from "babylonjs/Misc/dataReader";
  68780. }
  68781. declare module "babylonjs/index" {
  68782. export * from "babylonjs/abstractScene";
  68783. export * from "babylonjs/Actions/index";
  68784. export * from "babylonjs/Animations/index";
  68785. export * from "babylonjs/assetContainer";
  68786. export * from "babylonjs/Audio/index";
  68787. export * from "babylonjs/Behaviors/index";
  68788. export * from "babylonjs/Bones/index";
  68789. export * from "babylonjs/Cameras/index";
  68790. export * from "babylonjs/Collisions/index";
  68791. export * from "babylonjs/Culling/index";
  68792. export * from "babylonjs/Debug/index";
  68793. export * from "babylonjs/Engines/index";
  68794. export * from "babylonjs/Events/index";
  68795. export * from "babylonjs/Gamepads/index";
  68796. export * from "babylonjs/Gizmos/index";
  68797. export * from "babylonjs/Helpers/index";
  68798. export * from "babylonjs/Instrumentation/index";
  68799. export * from "babylonjs/Layers/index";
  68800. export * from "babylonjs/LensFlares/index";
  68801. export * from "babylonjs/Lights/index";
  68802. export * from "babylonjs/Loading/index";
  68803. export * from "babylonjs/Materials/index";
  68804. export * from "babylonjs/Maths/index";
  68805. export * from "babylonjs/Meshes/index";
  68806. export * from "babylonjs/Morph/index";
  68807. export * from "babylonjs/Navigation/index";
  68808. export * from "babylonjs/node";
  68809. export * from "babylonjs/Offline/index";
  68810. export * from "babylonjs/Particles/index";
  68811. export * from "babylonjs/Physics/index";
  68812. export * from "babylonjs/PostProcesses/index";
  68813. export * from "babylonjs/Probes/index";
  68814. export * from "babylonjs/Rendering/index";
  68815. export * from "babylonjs/scene";
  68816. export * from "babylonjs/sceneComponent";
  68817. export * from "babylonjs/Sprites/index";
  68818. export * from "babylonjs/States/index";
  68819. export * from "babylonjs/Misc/index";
  68820. export * from "babylonjs/types";
  68821. }
  68822. declare module "babylonjs/Animations/pathCursor" {
  68823. import { Vector3 } from "babylonjs/Maths/math.vector";
  68824. import { Path2 } from "babylonjs/Maths/math.path";
  68825. /**
  68826. * A cursor which tracks a point on a path
  68827. */
  68828. export class PathCursor {
  68829. private path;
  68830. /**
  68831. * Stores path cursor callbacks for when an onchange event is triggered
  68832. */
  68833. private _onchange;
  68834. /**
  68835. * The value of the path cursor
  68836. */
  68837. value: number;
  68838. /**
  68839. * The animation array of the path cursor
  68840. */
  68841. animations: Animation[];
  68842. /**
  68843. * Initializes the path cursor
  68844. * @param path The path to track
  68845. */
  68846. constructor(path: Path2);
  68847. /**
  68848. * Gets the cursor point on the path
  68849. * @returns A point on the path cursor at the cursor location
  68850. */
  68851. getPoint(): Vector3;
  68852. /**
  68853. * Moves the cursor ahead by the step amount
  68854. * @param step The amount to move the cursor forward
  68855. * @returns This path cursor
  68856. */
  68857. moveAhead(step?: number): PathCursor;
  68858. /**
  68859. * Moves the cursor behind by the step amount
  68860. * @param step The amount to move the cursor back
  68861. * @returns This path cursor
  68862. */
  68863. moveBack(step?: number): PathCursor;
  68864. /**
  68865. * Moves the cursor by the step amount
  68866. * If the step amount is greater than one, an exception is thrown
  68867. * @param step The amount to move the cursor
  68868. * @returns This path cursor
  68869. */
  68870. move(step: number): PathCursor;
  68871. /**
  68872. * Ensures that the value is limited between zero and one
  68873. * @returns This path cursor
  68874. */
  68875. private ensureLimits;
  68876. /**
  68877. * Runs onchange callbacks on change (used by the animation engine)
  68878. * @returns This path cursor
  68879. */
  68880. private raiseOnChange;
  68881. /**
  68882. * Executes a function on change
  68883. * @param f A path cursor onchange callback
  68884. * @returns This path cursor
  68885. */
  68886. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68887. }
  68888. }
  68889. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68890. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68891. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68892. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68893. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68894. }
  68895. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68896. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68897. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68898. }
  68899. declare module "babylonjs/Engines/Processors/index" {
  68900. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68901. export * from "babylonjs/Engines/Processors/Expressions/index";
  68902. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68903. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68904. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68905. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68906. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68907. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68908. }
  68909. declare module "babylonjs/Legacy/legacy" {
  68910. import * as Babylon from "babylonjs/index";
  68911. export * from "babylonjs/index";
  68912. }
  68913. declare module "babylonjs/Shaders/blur.fragment" {
  68914. /** @hidden */
  68915. export var blurPixelShader: {
  68916. name: string;
  68917. shader: string;
  68918. };
  68919. }
  68920. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68921. /** @hidden */
  68922. export var pointCloudVertexDeclaration: {
  68923. name: string;
  68924. shader: string;
  68925. };
  68926. }
  68927. declare module "babylonjs" {
  68928. export * from "babylonjs/Legacy/legacy";
  68929. }
  68930. declare module BABYLON {
  68931. /** Alias type for value that can be null */
  68932. export type Nullable<T> = T | null;
  68933. /**
  68934. * Alias type for number that are floats
  68935. * @ignorenaming
  68936. */
  68937. export type float = number;
  68938. /**
  68939. * Alias type for number that are doubles.
  68940. * @ignorenaming
  68941. */
  68942. export type double = number;
  68943. /**
  68944. * Alias type for number that are integer
  68945. * @ignorenaming
  68946. */
  68947. export type int = number;
  68948. /** Alias type for number array or Float32Array */
  68949. export type FloatArray = number[] | Float32Array;
  68950. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68951. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68952. /**
  68953. * Alias for types that can be used by a Buffer or VertexBuffer.
  68954. */
  68955. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68956. /**
  68957. * Alias type for primitive types
  68958. * @ignorenaming
  68959. */
  68960. type Primitive = undefined | null | boolean | string | number | Function;
  68961. /**
  68962. * Type modifier to make all the properties of an object Readonly
  68963. */
  68964. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68965. /**
  68966. * Type modifier to make all the properties of an object Readonly recursively
  68967. */
  68968. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68969. /**
  68970. * Type modifier to make object properties readonly.
  68971. */
  68972. export type DeepImmutableObject<T> = {
  68973. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68974. };
  68975. /** @hidden */
  68976. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68977. }
  68978. }
  68979. declare module BABYLON {
  68980. /**
  68981. * A class serves as a medium between the observable and its observers
  68982. */
  68983. export class EventState {
  68984. /**
  68985. * Create a new EventState
  68986. * @param mask defines the mask associated with this state
  68987. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68988. * @param target defines the original target of the state
  68989. * @param currentTarget defines the current target of the state
  68990. */
  68991. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68992. /**
  68993. * Initialize the current event state
  68994. * @param mask defines the mask associated with this state
  68995. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68996. * @param target defines the original target of the state
  68997. * @param currentTarget defines the current target of the state
  68998. * @returns the current event state
  68999. */
  69000. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  69001. /**
  69002. * An Observer can set this property to true to prevent subsequent observers of being notified
  69003. */
  69004. skipNextObservers: boolean;
  69005. /**
  69006. * Get the mask value that were used to trigger the event corresponding to this EventState object
  69007. */
  69008. mask: number;
  69009. /**
  69010. * The object that originally notified the event
  69011. */
  69012. target?: any;
  69013. /**
  69014. * The current object in the bubbling phase
  69015. */
  69016. currentTarget?: any;
  69017. /**
  69018. * This will be populated with the return value of the last function that was executed.
  69019. * If it is the first function in the callback chain it will be the event data.
  69020. */
  69021. lastReturnValue?: any;
  69022. }
  69023. /**
  69024. * Represent an Observer registered to a given Observable object.
  69025. */
  69026. export class Observer<T> {
  69027. /**
  69028. * Defines the callback to call when the observer is notified
  69029. */
  69030. callback: (eventData: T, eventState: EventState) => void;
  69031. /**
  69032. * Defines the mask of the observer (used to filter notifications)
  69033. */
  69034. mask: number;
  69035. /**
  69036. * Defines the current scope used to restore the JS context
  69037. */
  69038. scope: any;
  69039. /** @hidden */
  69040. _willBeUnregistered: boolean;
  69041. /**
  69042. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69043. */
  69044. unregisterOnNextCall: boolean;
  69045. /**
  69046. * Creates a new observer
  69047. * @param callback defines the callback to call when the observer is notified
  69048. * @param mask defines the mask of the observer (used to filter notifications)
  69049. * @param scope defines the current scope used to restore the JS context
  69050. */
  69051. constructor(
  69052. /**
  69053. * Defines the callback to call when the observer is notified
  69054. */
  69055. callback: (eventData: T, eventState: EventState) => void,
  69056. /**
  69057. * Defines the mask of the observer (used to filter notifications)
  69058. */
  69059. mask: number,
  69060. /**
  69061. * Defines the current scope used to restore the JS context
  69062. */
  69063. scope?: any);
  69064. }
  69065. /**
  69066. * Represent a list of observers registered to multiple Observables object.
  69067. */
  69068. export class MultiObserver<T> {
  69069. private _observers;
  69070. private _observables;
  69071. /**
  69072. * Release associated resources
  69073. */
  69074. dispose(): void;
  69075. /**
  69076. * Raise a callback when one of the observable will notify
  69077. * @param observables defines a list of observables to watch
  69078. * @param callback defines the callback to call on notification
  69079. * @param mask defines the mask used to filter notifications
  69080. * @param scope defines the current scope used to restore the JS context
  69081. * @returns the new MultiObserver
  69082. */
  69083. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69084. }
  69085. /**
  69086. * The Observable class is a simple implementation of the Observable pattern.
  69087. *
  69088. * 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.
  69089. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69090. * 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).
  69091. * 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.
  69092. */
  69093. export class Observable<T> {
  69094. private _observers;
  69095. private _eventState;
  69096. private _onObserverAdded;
  69097. /**
  69098. * Gets the list of observers
  69099. */
  69100. readonly observers: Array<Observer<T>>;
  69101. /**
  69102. * Creates a new observable
  69103. * @param onObserverAdded defines a callback to call when a new observer is added
  69104. */
  69105. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69106. /**
  69107. * Create a new Observer with the specified callback
  69108. * @param callback the callback that will be executed for that Observer
  69109. * @param mask the mask used to filter observers
  69110. * @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.
  69111. * @param scope optional scope for the callback to be called from
  69112. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69113. * @returns the new observer created for the callback
  69114. */
  69115. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69116. /**
  69117. * Create a new Observer with the specified callback and unregisters after the next notification
  69118. * @param callback the callback that will be executed for that Observer
  69119. * @returns the new observer created for the callback
  69120. */
  69121. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69122. /**
  69123. * Remove an Observer from the Observable object
  69124. * @param observer the instance of the Observer to remove
  69125. * @returns false if it doesn't belong to this Observable
  69126. */
  69127. remove(observer: Nullable<Observer<T>>): boolean;
  69128. /**
  69129. * Remove a callback from the Observable object
  69130. * @param callback the callback to remove
  69131. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69132. * @returns false if it doesn't belong to this Observable
  69133. */
  69134. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69135. private _deferUnregister;
  69136. private _remove;
  69137. /**
  69138. * Moves the observable to the top of the observer list making it get called first when notified
  69139. * @param observer the observer to move
  69140. */
  69141. makeObserverTopPriority(observer: Observer<T>): void;
  69142. /**
  69143. * Moves the observable to the bottom of the observer list making it get called last when notified
  69144. * @param observer the observer to move
  69145. */
  69146. makeObserverBottomPriority(observer: Observer<T>): void;
  69147. /**
  69148. * Notify all Observers by calling their respective callback with the given data
  69149. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69150. * @param eventData defines the data to send to all observers
  69151. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69152. * @param target defines the original target of the state
  69153. * @param currentTarget defines the current target of the state
  69154. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69155. */
  69156. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69157. /**
  69158. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69159. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69160. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69161. * and it is crucial that all callbacks will be executed.
  69162. * The order of the callbacks is kept, callbacks are not executed parallel.
  69163. *
  69164. * @param eventData The data to be sent to each callback
  69165. * @param mask is used to filter observers defaults to -1
  69166. * @param target defines the callback target (see EventState)
  69167. * @param currentTarget defines he current object in the bubbling phase
  69168. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69169. */
  69170. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69171. /**
  69172. * Notify a specific observer
  69173. * @param observer defines the observer to notify
  69174. * @param eventData defines the data to be sent to each callback
  69175. * @param mask is used to filter observers defaults to -1
  69176. */
  69177. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69178. /**
  69179. * Gets a boolean indicating if the observable has at least one observer
  69180. * @returns true is the Observable has at least one Observer registered
  69181. */
  69182. hasObservers(): boolean;
  69183. /**
  69184. * Clear the list of observers
  69185. */
  69186. clear(): void;
  69187. /**
  69188. * Clone the current observable
  69189. * @returns a new observable
  69190. */
  69191. clone(): Observable<T>;
  69192. /**
  69193. * Does this observable handles observer registered with a given mask
  69194. * @param mask defines the mask to be tested
  69195. * @return whether or not one observer registered with the given mask is handeled
  69196. **/
  69197. hasSpecificMask(mask?: number): boolean;
  69198. }
  69199. }
  69200. declare module BABYLON {
  69201. /**
  69202. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69203. * Babylon.js
  69204. */
  69205. export class DomManagement {
  69206. /**
  69207. * Checks if the window object exists
  69208. * @returns true if the window object exists
  69209. */
  69210. static IsWindowObjectExist(): boolean;
  69211. /**
  69212. * Checks if the navigator object exists
  69213. * @returns true if the navigator object exists
  69214. */
  69215. static IsNavigatorAvailable(): boolean;
  69216. /**
  69217. * Extracts text content from a DOM element hierarchy
  69218. * @param element defines the root element
  69219. * @returns a string
  69220. */
  69221. static GetDOMTextContent(element: HTMLElement): string;
  69222. }
  69223. }
  69224. declare module BABYLON {
  69225. /**
  69226. * Logger used througouht the application to allow configuration of
  69227. * the log level required for the messages.
  69228. */
  69229. export class Logger {
  69230. /**
  69231. * No log
  69232. */
  69233. static readonly NoneLogLevel: number;
  69234. /**
  69235. * Only message logs
  69236. */
  69237. static readonly MessageLogLevel: number;
  69238. /**
  69239. * Only warning logs
  69240. */
  69241. static readonly WarningLogLevel: number;
  69242. /**
  69243. * Only error logs
  69244. */
  69245. static readonly ErrorLogLevel: number;
  69246. /**
  69247. * All logs
  69248. */
  69249. static readonly AllLogLevel: number;
  69250. private static _LogCache;
  69251. /**
  69252. * Gets a value indicating the number of loading errors
  69253. * @ignorenaming
  69254. */
  69255. static errorsCount: number;
  69256. /**
  69257. * Callback called when a new log is added
  69258. */
  69259. static OnNewCacheEntry: (entry: string) => void;
  69260. private static _AddLogEntry;
  69261. private static _FormatMessage;
  69262. private static _LogDisabled;
  69263. private static _LogEnabled;
  69264. private static _WarnDisabled;
  69265. private static _WarnEnabled;
  69266. private static _ErrorDisabled;
  69267. private static _ErrorEnabled;
  69268. /**
  69269. * Log a message to the console
  69270. */
  69271. static Log: (message: string) => void;
  69272. /**
  69273. * Write a warning message to the console
  69274. */
  69275. static Warn: (message: string) => void;
  69276. /**
  69277. * Write an error message to the console
  69278. */
  69279. static Error: (message: string) => void;
  69280. /**
  69281. * Gets current log cache (list of logs)
  69282. */
  69283. static readonly LogCache: string;
  69284. /**
  69285. * Clears the log cache
  69286. */
  69287. static ClearLogCache(): void;
  69288. /**
  69289. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69290. */
  69291. static LogLevels: number;
  69292. }
  69293. }
  69294. declare module BABYLON {
  69295. /** @hidden */
  69296. export class _TypeStore {
  69297. /** @hidden */
  69298. static RegisteredTypes: {
  69299. [key: string]: Object;
  69300. };
  69301. /** @hidden */
  69302. static GetClass(fqdn: string): any;
  69303. }
  69304. }
  69305. declare module BABYLON {
  69306. /**
  69307. * Helper to manipulate strings
  69308. */
  69309. export class StringTools {
  69310. /**
  69311. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69312. * @param str Source string
  69313. * @param suffix Suffix to search for in the source string
  69314. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69315. */
  69316. static EndsWith(str: string, suffix: string): boolean;
  69317. /**
  69318. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69319. * @param str Source string
  69320. * @param suffix Suffix to search for in the source string
  69321. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69322. */
  69323. static StartsWith(str: string, suffix: string): boolean;
  69324. /**
  69325. * Decodes a buffer into a string
  69326. * @param buffer The buffer to decode
  69327. * @returns The decoded string
  69328. */
  69329. static Decode(buffer: Uint8Array | Uint16Array): string;
  69330. /**
  69331. * Encode a buffer to a base64 string
  69332. * @param buffer defines the buffer to encode
  69333. * @returns the encoded string
  69334. */
  69335. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69336. }
  69337. }
  69338. declare module BABYLON {
  69339. /**
  69340. * Class containing a set of static utilities functions for deep copy.
  69341. */
  69342. export class DeepCopier {
  69343. /**
  69344. * Tries to copy an object by duplicating every property
  69345. * @param source defines the source object
  69346. * @param destination defines the target object
  69347. * @param doNotCopyList defines a list of properties to avoid
  69348. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69349. */
  69350. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69351. }
  69352. }
  69353. declare module BABYLON {
  69354. /**
  69355. * Class containing a set of static utilities functions for precision date
  69356. */
  69357. export class PrecisionDate {
  69358. /**
  69359. * Gets either window.performance.now() if supported or Date.now() else
  69360. */
  69361. static readonly Now: number;
  69362. }
  69363. }
  69364. declare module BABYLON {
  69365. /** @hidden */
  69366. export class _DevTools {
  69367. static WarnImport(name: string): string;
  69368. }
  69369. }
  69370. declare module BABYLON {
  69371. /**
  69372. * Interface used to define the mechanism to get data from the network
  69373. */
  69374. export interface IWebRequest {
  69375. /**
  69376. * Returns client's response url
  69377. */
  69378. responseURL: string;
  69379. /**
  69380. * Returns client's status
  69381. */
  69382. status: number;
  69383. /**
  69384. * Returns client's status as a text
  69385. */
  69386. statusText: string;
  69387. }
  69388. }
  69389. declare module BABYLON {
  69390. /**
  69391. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69392. */
  69393. export class WebRequest implements IWebRequest {
  69394. private _xhr;
  69395. /**
  69396. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69397. * i.e. when loading files, where the server/service expects an Authorization header
  69398. */
  69399. static CustomRequestHeaders: {
  69400. [key: string]: string;
  69401. };
  69402. /**
  69403. * Add callback functions in this array to update all the requests before they get sent to the network
  69404. */
  69405. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69406. private _injectCustomRequestHeaders;
  69407. /**
  69408. * Gets or sets a function to be called when loading progress changes
  69409. */
  69410. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69411. /**
  69412. * Returns client's state
  69413. */
  69414. readonly readyState: number;
  69415. /**
  69416. * Returns client's status
  69417. */
  69418. readonly status: number;
  69419. /**
  69420. * Returns client's status as a text
  69421. */
  69422. readonly statusText: string;
  69423. /**
  69424. * Returns client's response
  69425. */
  69426. readonly response: any;
  69427. /**
  69428. * Returns client's response url
  69429. */
  69430. readonly responseURL: string;
  69431. /**
  69432. * Returns client's response as text
  69433. */
  69434. readonly responseText: string;
  69435. /**
  69436. * Gets or sets the expected response type
  69437. */
  69438. responseType: XMLHttpRequestResponseType;
  69439. /** @hidden */
  69440. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69441. /** @hidden */
  69442. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69443. /**
  69444. * Cancels any network activity
  69445. */
  69446. abort(): void;
  69447. /**
  69448. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69449. * @param body defines an optional request body
  69450. */
  69451. send(body?: Document | BodyInit | null): void;
  69452. /**
  69453. * Sets the request method, request URL
  69454. * @param method defines the method to use (GET, POST, etc..)
  69455. * @param url defines the url to connect with
  69456. */
  69457. open(method: string, url: string): void;
  69458. /**
  69459. * Sets the value of a request header.
  69460. * @param name The name of the header whose value is to be set
  69461. * @param value The value to set as the body of the header
  69462. */
  69463. setRequestHeader(name: string, value: string): void;
  69464. /**
  69465. * Get the string containing the text of a particular header's value.
  69466. * @param name The name of the header
  69467. * @returns The string containing the text of the given header name
  69468. */
  69469. getResponseHeader(name: string): Nullable<string>;
  69470. }
  69471. }
  69472. declare module BABYLON {
  69473. /**
  69474. * File request interface
  69475. */
  69476. export interface IFileRequest {
  69477. /**
  69478. * Raised when the request is complete (success or error).
  69479. */
  69480. onCompleteObservable: Observable<IFileRequest>;
  69481. /**
  69482. * Aborts the request for a file.
  69483. */
  69484. abort: () => void;
  69485. }
  69486. }
  69487. declare module BABYLON {
  69488. /**
  69489. * Define options used to create a render target texture
  69490. */
  69491. export class RenderTargetCreationOptions {
  69492. /**
  69493. * Specifies is mipmaps must be generated
  69494. */
  69495. generateMipMaps?: boolean;
  69496. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69497. generateDepthBuffer?: boolean;
  69498. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69499. generateStencilBuffer?: boolean;
  69500. /** Defines texture type (int by default) */
  69501. type?: number;
  69502. /** Defines sampling mode (trilinear by default) */
  69503. samplingMode?: number;
  69504. /** Defines format (RGBA by default) */
  69505. format?: number;
  69506. }
  69507. }
  69508. declare module BABYLON {
  69509. /**
  69510. * @hidden
  69511. **/
  69512. export class _TimeToken {
  69513. _startTimeQuery: Nullable<WebGLQuery>;
  69514. _endTimeQuery: Nullable<WebGLQuery>;
  69515. _timeElapsedQuery: Nullable<WebGLQuery>;
  69516. _timeElapsedQueryEnded: boolean;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /** Defines the cross module used constants to avoid circular dependncies */
  69521. export class Constants {
  69522. /** Defines that alpha blending is disabled */
  69523. static readonly ALPHA_DISABLE: number;
  69524. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69525. static readonly ALPHA_ADD: number;
  69526. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69527. static readonly ALPHA_COMBINE: number;
  69528. /** Defines that alpha blending to DEST - SRC * DEST */
  69529. static readonly ALPHA_SUBTRACT: number;
  69530. /** Defines that alpha blending to SRC * DEST */
  69531. static readonly ALPHA_MULTIPLY: number;
  69532. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69533. static readonly ALPHA_MAXIMIZED: number;
  69534. /** Defines that alpha blending to SRC + DEST */
  69535. static readonly ALPHA_ONEONE: number;
  69536. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69537. static readonly ALPHA_PREMULTIPLIED: number;
  69538. /**
  69539. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69540. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69541. */
  69542. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69543. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69544. static readonly ALPHA_INTERPOLATE: number;
  69545. /**
  69546. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69547. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69548. */
  69549. static readonly ALPHA_SCREENMODE: number;
  69550. /**
  69551. * Defines that alpha blending to SRC + DST
  69552. * Alpha will be set to SRC ALPHA + DST ALPHA
  69553. */
  69554. static readonly ALPHA_ONEONE_ONEONE: number;
  69555. /**
  69556. * Defines that alpha blending to SRC * DST ALPHA + DST
  69557. * Alpha will be set to 0
  69558. */
  69559. static readonly ALPHA_ALPHATOCOLOR: number;
  69560. /**
  69561. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69562. */
  69563. static readonly ALPHA_REVERSEONEMINUS: number;
  69564. /**
  69565. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69566. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69567. */
  69568. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69569. /**
  69570. * Defines that alpha blending to SRC + DST
  69571. * Alpha will be set to SRC ALPHA
  69572. */
  69573. static readonly ALPHA_ONEONE_ONEZERO: number;
  69574. /** Defines that alpha blending equation a SUM */
  69575. static readonly ALPHA_EQUATION_ADD: number;
  69576. /** Defines that alpha blending equation a SUBSTRACTION */
  69577. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69578. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69579. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69580. /** Defines that alpha blending equation a MAX operation */
  69581. static readonly ALPHA_EQUATION_MAX: number;
  69582. /** Defines that alpha blending equation a MIN operation */
  69583. static readonly ALPHA_EQUATION_MIN: number;
  69584. /**
  69585. * Defines that alpha blending equation a DARKEN operation:
  69586. * It takes the min of the src and sums the alpha channels.
  69587. */
  69588. static readonly ALPHA_EQUATION_DARKEN: number;
  69589. /** Defines that the ressource is not delayed*/
  69590. static readonly DELAYLOADSTATE_NONE: number;
  69591. /** Defines that the ressource was successfully delay loaded */
  69592. static readonly DELAYLOADSTATE_LOADED: number;
  69593. /** Defines that the ressource is currently delay loading */
  69594. static readonly DELAYLOADSTATE_LOADING: number;
  69595. /** Defines that the ressource is delayed and has not started loading */
  69596. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69597. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69598. static readonly NEVER: number;
  69599. /** 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 */
  69600. static readonly ALWAYS: number;
  69601. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69602. static readonly LESS: number;
  69603. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69604. static readonly EQUAL: number;
  69605. /** 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 */
  69606. static readonly LEQUAL: number;
  69607. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69608. static readonly GREATER: number;
  69609. /** 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 */
  69610. static readonly GEQUAL: number;
  69611. /** 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 */
  69612. static readonly NOTEQUAL: number;
  69613. /** Passed to stencilOperation to specify that stencil value must be kept */
  69614. static readonly KEEP: number;
  69615. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69616. static readonly REPLACE: number;
  69617. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69618. static readonly INCR: number;
  69619. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69620. static readonly DECR: number;
  69621. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69622. static readonly INVERT: number;
  69623. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69624. static readonly INCR_WRAP: number;
  69625. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69626. static readonly DECR_WRAP: number;
  69627. /** Texture is not repeating outside of 0..1 UVs */
  69628. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69629. /** Texture is repeating outside of 0..1 UVs */
  69630. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69631. /** Texture is repeating and mirrored */
  69632. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69633. /** ALPHA */
  69634. static readonly TEXTUREFORMAT_ALPHA: number;
  69635. /** LUMINANCE */
  69636. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69637. /** LUMINANCE_ALPHA */
  69638. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69639. /** RGB */
  69640. static readonly TEXTUREFORMAT_RGB: number;
  69641. /** RGBA */
  69642. static readonly TEXTUREFORMAT_RGBA: number;
  69643. /** RED */
  69644. static readonly TEXTUREFORMAT_RED: number;
  69645. /** RED (2nd reference) */
  69646. static readonly TEXTUREFORMAT_R: number;
  69647. /** RG */
  69648. static readonly TEXTUREFORMAT_RG: number;
  69649. /** RED_INTEGER */
  69650. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69651. /** RED_INTEGER (2nd reference) */
  69652. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69653. /** RG_INTEGER */
  69654. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69655. /** RGB_INTEGER */
  69656. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69657. /** RGBA_INTEGER */
  69658. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69659. /** UNSIGNED_BYTE */
  69660. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69661. /** UNSIGNED_BYTE (2nd reference) */
  69662. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69663. /** FLOAT */
  69664. static readonly TEXTURETYPE_FLOAT: number;
  69665. /** HALF_FLOAT */
  69666. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69667. /** BYTE */
  69668. static readonly TEXTURETYPE_BYTE: number;
  69669. /** SHORT */
  69670. static readonly TEXTURETYPE_SHORT: number;
  69671. /** UNSIGNED_SHORT */
  69672. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69673. /** INT */
  69674. static readonly TEXTURETYPE_INT: number;
  69675. /** UNSIGNED_INT */
  69676. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69677. /** UNSIGNED_SHORT_4_4_4_4 */
  69678. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69679. /** UNSIGNED_SHORT_5_5_5_1 */
  69680. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69681. /** UNSIGNED_SHORT_5_6_5 */
  69682. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69683. /** UNSIGNED_INT_2_10_10_10_REV */
  69684. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69685. /** UNSIGNED_INT_24_8 */
  69686. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69687. /** UNSIGNED_INT_10F_11F_11F_REV */
  69688. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69689. /** UNSIGNED_INT_5_9_9_9_REV */
  69690. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69691. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69692. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69693. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69694. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69695. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69696. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69697. /** Trilinear is mag = linear and min = linear and mip = linear */
  69698. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69699. /** nearest is mag = nearest and min = nearest and mip = linear */
  69700. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69701. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69702. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69703. /** Trilinear is mag = linear and min = linear and mip = linear */
  69704. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69705. /** mag = nearest and min = nearest and mip = nearest */
  69706. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69707. /** mag = nearest and min = linear and mip = nearest */
  69708. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69709. /** mag = nearest and min = linear and mip = linear */
  69710. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69711. /** mag = nearest and min = linear and mip = none */
  69712. static readonly TEXTURE_NEAREST_LINEAR: number;
  69713. /** mag = nearest and min = nearest and mip = none */
  69714. static readonly TEXTURE_NEAREST_NEAREST: number;
  69715. /** mag = linear and min = nearest and mip = nearest */
  69716. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69717. /** mag = linear and min = nearest and mip = linear */
  69718. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69719. /** mag = linear and min = linear and mip = none */
  69720. static readonly TEXTURE_LINEAR_LINEAR: number;
  69721. /** mag = linear and min = nearest and mip = none */
  69722. static readonly TEXTURE_LINEAR_NEAREST: number;
  69723. /** Explicit coordinates mode */
  69724. static readonly TEXTURE_EXPLICIT_MODE: number;
  69725. /** Spherical coordinates mode */
  69726. static readonly TEXTURE_SPHERICAL_MODE: number;
  69727. /** Planar coordinates mode */
  69728. static readonly TEXTURE_PLANAR_MODE: number;
  69729. /** Cubic coordinates mode */
  69730. static readonly TEXTURE_CUBIC_MODE: number;
  69731. /** Projection coordinates mode */
  69732. static readonly TEXTURE_PROJECTION_MODE: number;
  69733. /** Skybox coordinates mode */
  69734. static readonly TEXTURE_SKYBOX_MODE: number;
  69735. /** Inverse Cubic coordinates mode */
  69736. static readonly TEXTURE_INVCUBIC_MODE: number;
  69737. /** Equirectangular coordinates mode */
  69738. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69739. /** Equirectangular Fixed coordinates mode */
  69740. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69741. /** Equirectangular Fixed Mirrored coordinates mode */
  69742. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69743. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69744. static readonly SCALEMODE_FLOOR: number;
  69745. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69746. static readonly SCALEMODE_NEAREST: number;
  69747. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69748. static readonly SCALEMODE_CEILING: number;
  69749. /**
  69750. * The dirty texture flag value
  69751. */
  69752. static readonly MATERIAL_TextureDirtyFlag: number;
  69753. /**
  69754. * The dirty light flag value
  69755. */
  69756. static readonly MATERIAL_LightDirtyFlag: number;
  69757. /**
  69758. * The dirty fresnel flag value
  69759. */
  69760. static readonly MATERIAL_FresnelDirtyFlag: number;
  69761. /**
  69762. * The dirty attribute flag value
  69763. */
  69764. static readonly MATERIAL_AttributesDirtyFlag: number;
  69765. /**
  69766. * The dirty misc flag value
  69767. */
  69768. static readonly MATERIAL_MiscDirtyFlag: number;
  69769. /**
  69770. * The all dirty flag value
  69771. */
  69772. static readonly MATERIAL_AllDirtyFlag: number;
  69773. /**
  69774. * Returns the triangle fill mode
  69775. */
  69776. static readonly MATERIAL_TriangleFillMode: number;
  69777. /**
  69778. * Returns the wireframe mode
  69779. */
  69780. static readonly MATERIAL_WireFrameFillMode: number;
  69781. /**
  69782. * Returns the point fill mode
  69783. */
  69784. static readonly MATERIAL_PointFillMode: number;
  69785. /**
  69786. * Returns the point list draw mode
  69787. */
  69788. static readonly MATERIAL_PointListDrawMode: number;
  69789. /**
  69790. * Returns the line list draw mode
  69791. */
  69792. static readonly MATERIAL_LineListDrawMode: number;
  69793. /**
  69794. * Returns the line loop draw mode
  69795. */
  69796. static readonly MATERIAL_LineLoopDrawMode: number;
  69797. /**
  69798. * Returns the line strip draw mode
  69799. */
  69800. static readonly MATERIAL_LineStripDrawMode: number;
  69801. /**
  69802. * Returns the triangle strip draw mode
  69803. */
  69804. static readonly MATERIAL_TriangleStripDrawMode: number;
  69805. /**
  69806. * Returns the triangle fan draw mode
  69807. */
  69808. static readonly MATERIAL_TriangleFanDrawMode: number;
  69809. /**
  69810. * Stores the clock-wise side orientation
  69811. */
  69812. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69813. /**
  69814. * Stores the counter clock-wise side orientation
  69815. */
  69816. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69817. /**
  69818. * Nothing
  69819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69820. */
  69821. static readonly ACTION_NothingTrigger: number;
  69822. /**
  69823. * On pick
  69824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69825. */
  69826. static readonly ACTION_OnPickTrigger: number;
  69827. /**
  69828. * On left pick
  69829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69830. */
  69831. static readonly ACTION_OnLeftPickTrigger: number;
  69832. /**
  69833. * On right pick
  69834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69835. */
  69836. static readonly ACTION_OnRightPickTrigger: number;
  69837. /**
  69838. * On center pick
  69839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69840. */
  69841. static readonly ACTION_OnCenterPickTrigger: number;
  69842. /**
  69843. * On pick down
  69844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69845. */
  69846. static readonly ACTION_OnPickDownTrigger: number;
  69847. /**
  69848. * On double pick
  69849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69850. */
  69851. static readonly ACTION_OnDoublePickTrigger: number;
  69852. /**
  69853. * On pick up
  69854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69855. */
  69856. static readonly ACTION_OnPickUpTrigger: number;
  69857. /**
  69858. * On pick out.
  69859. * This trigger will only be raised if you also declared a OnPickDown
  69860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69861. */
  69862. static readonly ACTION_OnPickOutTrigger: number;
  69863. /**
  69864. * On long press
  69865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69866. */
  69867. static readonly ACTION_OnLongPressTrigger: number;
  69868. /**
  69869. * On pointer over
  69870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69871. */
  69872. static readonly ACTION_OnPointerOverTrigger: number;
  69873. /**
  69874. * On pointer out
  69875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69876. */
  69877. static readonly ACTION_OnPointerOutTrigger: number;
  69878. /**
  69879. * On every frame
  69880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69881. */
  69882. static readonly ACTION_OnEveryFrameTrigger: number;
  69883. /**
  69884. * On intersection enter
  69885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69886. */
  69887. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69888. /**
  69889. * On intersection exit
  69890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69891. */
  69892. static readonly ACTION_OnIntersectionExitTrigger: number;
  69893. /**
  69894. * On key down
  69895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69896. */
  69897. static readonly ACTION_OnKeyDownTrigger: number;
  69898. /**
  69899. * On key up
  69900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69901. */
  69902. static readonly ACTION_OnKeyUpTrigger: number;
  69903. /**
  69904. * Billboard mode will only apply to Y axis
  69905. */
  69906. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69907. /**
  69908. * Billboard mode will apply to all axes
  69909. */
  69910. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69911. /**
  69912. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69913. */
  69914. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69915. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69916. * Test order :
  69917. * Is the bounding sphere outside the frustum ?
  69918. * If not, are the bounding box vertices outside the frustum ?
  69919. * It not, then the cullable object is in the frustum.
  69920. */
  69921. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69922. /** Culling strategy : Bounding Sphere Only.
  69923. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69924. * It's also less accurate than the standard because some not visible objects can still be selected.
  69925. * Test : is the bounding sphere outside the frustum ?
  69926. * If not, then the cullable object is in the frustum.
  69927. */
  69928. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69929. /** Culling strategy : Optimistic Inclusion.
  69930. * This in an inclusion test first, then the standard exclusion test.
  69931. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69932. * 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.
  69933. * Anyway, it's as accurate as the standard strategy.
  69934. * Test :
  69935. * Is the cullable object bounding sphere center in the frustum ?
  69936. * If not, apply the default culling strategy.
  69937. */
  69938. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69939. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69940. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69941. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69942. * 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.
  69943. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69944. * Test :
  69945. * Is the cullable object bounding sphere center in the frustum ?
  69946. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69947. */
  69948. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69949. /**
  69950. * No logging while loading
  69951. */
  69952. static readonly SCENELOADER_NO_LOGGING: number;
  69953. /**
  69954. * Minimal logging while loading
  69955. */
  69956. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69957. /**
  69958. * Summary logging while loading
  69959. */
  69960. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69961. /**
  69962. * Detailled logging while loading
  69963. */
  69964. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69965. }
  69966. }
  69967. declare module BABYLON {
  69968. /**
  69969. * This represents the required contract to create a new type of texture loader.
  69970. */
  69971. export interface IInternalTextureLoader {
  69972. /**
  69973. * Defines wether the loader supports cascade loading the different faces.
  69974. */
  69975. supportCascades: boolean;
  69976. /**
  69977. * This returns if the loader support the current file information.
  69978. * @param extension defines the file extension of the file being loaded
  69979. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69980. * @param fallback defines the fallback internal texture if any
  69981. * @param isBase64 defines whether the texture is encoded as a base64
  69982. * @param isBuffer defines whether the texture data are stored as a buffer
  69983. * @returns true if the loader can load the specified file
  69984. */
  69985. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69986. /**
  69987. * Transform the url before loading if required.
  69988. * @param rootUrl the url of the texture
  69989. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69990. * @returns the transformed texture
  69991. */
  69992. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69993. /**
  69994. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69995. * @param rootUrl the url of the texture
  69996. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69997. * @returns the fallback texture
  69998. */
  69999. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70000. /**
  70001. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70002. * @param data contains the texture data
  70003. * @param texture defines the BabylonJS internal texture
  70004. * @param createPolynomials will be true if polynomials have been requested
  70005. * @param onLoad defines the callback to trigger once the texture is ready
  70006. * @param onError defines the callback to trigger in case of error
  70007. */
  70008. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70009. /**
  70010. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70011. * @param data contains the texture data
  70012. * @param texture defines the BabylonJS internal texture
  70013. * @param callback defines the method to call once ready to upload
  70014. */
  70015. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70016. }
  70017. }
  70018. declare module BABYLON {
  70019. /**
  70020. * Class used to store and describe the pipeline context associated with an effect
  70021. */
  70022. export interface IPipelineContext {
  70023. /**
  70024. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70025. */
  70026. isAsync: boolean;
  70027. /**
  70028. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70029. */
  70030. isReady: boolean;
  70031. /** @hidden */
  70032. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70033. }
  70034. }
  70035. declare module BABYLON {
  70036. /**
  70037. * Class used to store gfx data (like WebGLBuffer)
  70038. */
  70039. export class DataBuffer {
  70040. /**
  70041. * Gets or sets the number of objects referencing this buffer
  70042. */
  70043. references: number;
  70044. /** Gets or sets the size of the underlying buffer */
  70045. capacity: number;
  70046. /**
  70047. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70048. */
  70049. is32Bits: boolean;
  70050. /**
  70051. * Gets the underlying buffer
  70052. */
  70053. readonly underlyingResource: any;
  70054. }
  70055. }
  70056. declare module BABYLON {
  70057. /** @hidden */
  70058. export interface IShaderProcessor {
  70059. attributeProcessor?: (attribute: string) => string;
  70060. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70061. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70062. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70063. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70064. lineProcessor?: (line: string, isFragment: boolean) => string;
  70065. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70066. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70067. }
  70068. }
  70069. declare module BABYLON {
  70070. /** @hidden */
  70071. export interface ProcessingOptions {
  70072. defines: string[];
  70073. indexParameters: any;
  70074. isFragment: boolean;
  70075. shouldUseHighPrecisionShader: boolean;
  70076. supportsUniformBuffers: boolean;
  70077. shadersRepository: string;
  70078. includesShadersStore: {
  70079. [key: string]: string;
  70080. };
  70081. processor?: IShaderProcessor;
  70082. version: string;
  70083. platformName: string;
  70084. lookForClosingBracketForUniformBuffer?: boolean;
  70085. }
  70086. }
  70087. declare module BABYLON {
  70088. /** @hidden */
  70089. export class ShaderCodeNode {
  70090. line: string;
  70091. children: ShaderCodeNode[];
  70092. additionalDefineKey?: string;
  70093. additionalDefineValue?: string;
  70094. isValid(preprocessors: {
  70095. [key: string]: string;
  70096. }): boolean;
  70097. process(preprocessors: {
  70098. [key: string]: string;
  70099. }, options: ProcessingOptions): string;
  70100. }
  70101. }
  70102. declare module BABYLON {
  70103. /** @hidden */
  70104. export class ShaderCodeCursor {
  70105. private _lines;
  70106. lineIndex: number;
  70107. readonly currentLine: string;
  70108. readonly canRead: boolean;
  70109. lines: string[];
  70110. }
  70111. }
  70112. declare module BABYLON {
  70113. /** @hidden */
  70114. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70115. process(preprocessors: {
  70116. [key: string]: string;
  70117. }, options: ProcessingOptions): string;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /** @hidden */
  70122. export class ShaderDefineExpression {
  70123. isTrue(preprocessors: {
  70124. [key: string]: string;
  70125. }): boolean;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /** @hidden */
  70130. export class ShaderCodeTestNode extends ShaderCodeNode {
  70131. testExpression: ShaderDefineExpression;
  70132. isValid(preprocessors: {
  70133. [key: string]: string;
  70134. }): boolean;
  70135. }
  70136. }
  70137. declare module BABYLON {
  70138. /** @hidden */
  70139. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70140. define: string;
  70141. not: boolean;
  70142. constructor(define: string, not?: boolean);
  70143. isTrue(preprocessors: {
  70144. [key: string]: string;
  70145. }): boolean;
  70146. }
  70147. }
  70148. declare module BABYLON {
  70149. /** @hidden */
  70150. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70151. leftOperand: ShaderDefineExpression;
  70152. rightOperand: ShaderDefineExpression;
  70153. isTrue(preprocessors: {
  70154. [key: string]: string;
  70155. }): boolean;
  70156. }
  70157. }
  70158. declare module BABYLON {
  70159. /** @hidden */
  70160. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70161. leftOperand: ShaderDefineExpression;
  70162. rightOperand: ShaderDefineExpression;
  70163. isTrue(preprocessors: {
  70164. [key: string]: string;
  70165. }): boolean;
  70166. }
  70167. }
  70168. declare module BABYLON {
  70169. /** @hidden */
  70170. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70171. define: string;
  70172. operand: string;
  70173. testValue: string;
  70174. constructor(define: string, operand: string, testValue: string);
  70175. isTrue(preprocessors: {
  70176. [key: string]: string;
  70177. }): boolean;
  70178. }
  70179. }
  70180. declare module BABYLON {
  70181. /**
  70182. * Class used to enable access to offline support
  70183. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70184. */
  70185. export interface IOfflineProvider {
  70186. /**
  70187. * Gets a boolean indicating if scene must be saved in the database
  70188. */
  70189. enableSceneOffline: boolean;
  70190. /**
  70191. * Gets a boolean indicating if textures must be saved in the database
  70192. */
  70193. enableTexturesOffline: boolean;
  70194. /**
  70195. * Open the offline support and make it available
  70196. * @param successCallback defines the callback to call on success
  70197. * @param errorCallback defines the callback to call on error
  70198. */
  70199. open(successCallback: () => void, errorCallback: () => void): void;
  70200. /**
  70201. * Loads an image from the offline support
  70202. * @param url defines the url to load from
  70203. * @param image defines the target DOM image
  70204. */
  70205. loadImage(url: string, image: HTMLImageElement): void;
  70206. /**
  70207. * Loads a file from offline support
  70208. * @param url defines the URL to load from
  70209. * @param sceneLoaded defines a callback to call on success
  70210. * @param progressCallBack defines a callback to call when progress changed
  70211. * @param errorCallback defines a callback to call on error
  70212. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70213. */
  70214. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70215. }
  70216. }
  70217. declare module BABYLON {
  70218. /**
  70219. * Class used to help managing file picking and drag'n'drop
  70220. * File Storage
  70221. */
  70222. export class FilesInputStore {
  70223. /**
  70224. * List of files ready to be loaded
  70225. */
  70226. static FilesToLoad: {
  70227. [key: string]: File;
  70228. };
  70229. }
  70230. }
  70231. declare module BABYLON {
  70232. /**
  70233. * Class used to define a retry strategy when error happens while loading assets
  70234. */
  70235. export class RetryStrategy {
  70236. /**
  70237. * Function used to defines an exponential back off strategy
  70238. * @param maxRetries defines the maximum number of retries (3 by default)
  70239. * @param baseInterval defines the interval between retries
  70240. * @returns the strategy function to use
  70241. */
  70242. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70243. }
  70244. }
  70245. declare module BABYLON {
  70246. /**
  70247. * @ignore
  70248. * Application error to support additional information when loading a file
  70249. */
  70250. export abstract class BaseError extends Error {
  70251. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70252. }
  70253. }
  70254. declare module BABYLON {
  70255. /** @ignore */
  70256. export class LoadFileError extends BaseError {
  70257. request?: WebRequest;
  70258. file?: File;
  70259. /**
  70260. * Creates a new LoadFileError
  70261. * @param message defines the message of the error
  70262. * @param request defines the optional web request
  70263. * @param file defines the optional file
  70264. */
  70265. constructor(message: string, object?: WebRequest | File);
  70266. }
  70267. /** @ignore */
  70268. export class RequestFileError extends BaseError {
  70269. request: WebRequest;
  70270. /**
  70271. * Creates a new LoadFileError
  70272. * @param message defines the message of the error
  70273. * @param request defines the optional web request
  70274. */
  70275. constructor(message: string, request: WebRequest);
  70276. }
  70277. /** @ignore */
  70278. export class ReadFileError extends BaseError {
  70279. file: File;
  70280. /**
  70281. * Creates a new ReadFileError
  70282. * @param message defines the message of the error
  70283. * @param file defines the optional file
  70284. */
  70285. constructor(message: string, file: File);
  70286. }
  70287. /**
  70288. * @hidden
  70289. */
  70290. export class FileTools {
  70291. /**
  70292. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70293. */
  70294. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70295. /**
  70296. * Gets or sets the base URL to use to load assets
  70297. */
  70298. static BaseUrl: string;
  70299. /**
  70300. * Default behaviour for cors in the application.
  70301. * It can be a string if the expected behavior is identical in the entire app.
  70302. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70303. */
  70304. static CorsBehavior: string | ((url: string | string[]) => string);
  70305. /**
  70306. * Gets or sets a function used to pre-process url before using them to load assets
  70307. */
  70308. static PreprocessUrl: (url: string) => string;
  70309. /**
  70310. * Removes unwanted characters from an url
  70311. * @param url defines the url to clean
  70312. * @returns the cleaned url
  70313. */
  70314. private static _CleanUrl;
  70315. /**
  70316. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70317. * @param url define the url we are trying
  70318. * @param element define the dom element where to configure the cors policy
  70319. */
  70320. static SetCorsBehavior(url: string | string[], element: {
  70321. crossOrigin: string | null;
  70322. }): void;
  70323. /**
  70324. * Loads an image as an HTMLImageElement.
  70325. * @param input url string, ArrayBuffer, or Blob to load
  70326. * @param onLoad callback called when the image successfully loads
  70327. * @param onError callback called when the image fails to load
  70328. * @param offlineProvider offline provider for caching
  70329. * @param mimeType optional mime type
  70330. * @returns the HTMLImageElement of the loaded image
  70331. */
  70332. 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>;
  70333. /**
  70334. * Reads a file from a File object
  70335. * @param file defines the file to load
  70336. * @param onSuccess defines the callback to call when data is loaded
  70337. * @param onProgress defines the callback to call during loading process
  70338. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70339. * @param onError defines the callback to call when an error occurs
  70340. * @returns a file request object
  70341. */
  70342. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70343. /**
  70344. * Loads a file from a url
  70345. * @param url url to load
  70346. * @param onSuccess callback called when the file successfully loads
  70347. * @param onProgress callback called while file is loading (if the server supports this mode)
  70348. * @param offlineProvider defines the offline provider for caching
  70349. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70350. * @param onError callback called when the file fails to load
  70351. * @returns a file request object
  70352. */
  70353. 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;
  70354. /**
  70355. * Loads a file
  70356. * @param url url to load
  70357. * @param onSuccess callback called when the file successfully loads
  70358. * @param onProgress callback called while file is loading (if the server supports this mode)
  70359. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70360. * @param onError callback called when the file fails to load
  70361. * @param onOpened callback called when the web request is opened
  70362. * @returns a file request object
  70363. */
  70364. 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;
  70365. /**
  70366. * Checks if the loaded document was accessed via `file:`-Protocol.
  70367. * @returns boolean
  70368. */
  70369. static IsFileURL(): boolean;
  70370. }
  70371. }
  70372. declare module BABYLON {
  70373. /** @hidden */
  70374. export class ShaderProcessor {
  70375. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70376. private static _ProcessPrecision;
  70377. private static _ExtractOperation;
  70378. private static _BuildSubExpression;
  70379. private static _BuildExpression;
  70380. private static _MoveCursorWithinIf;
  70381. private static _MoveCursor;
  70382. private static _EvaluatePreProcessors;
  70383. private static _PreparePreProcessors;
  70384. private static _ProcessShaderConversion;
  70385. private static _ProcessIncludes;
  70386. }
  70387. }
  70388. declare module BABYLON {
  70389. /**
  70390. * @hidden
  70391. */
  70392. export interface IColor4Like {
  70393. r: float;
  70394. g: float;
  70395. b: float;
  70396. a: float;
  70397. }
  70398. /**
  70399. * @hidden
  70400. */
  70401. export interface IColor3Like {
  70402. r: float;
  70403. g: float;
  70404. b: float;
  70405. }
  70406. /**
  70407. * @hidden
  70408. */
  70409. export interface IVector4Like {
  70410. x: float;
  70411. y: float;
  70412. z: float;
  70413. w: float;
  70414. }
  70415. /**
  70416. * @hidden
  70417. */
  70418. export interface IVector3Like {
  70419. x: float;
  70420. y: float;
  70421. z: float;
  70422. }
  70423. /**
  70424. * @hidden
  70425. */
  70426. export interface IVector2Like {
  70427. x: float;
  70428. y: float;
  70429. }
  70430. /**
  70431. * @hidden
  70432. */
  70433. export interface IMatrixLike {
  70434. toArray(): DeepImmutable<Float32Array>;
  70435. updateFlag: int;
  70436. }
  70437. /**
  70438. * @hidden
  70439. */
  70440. export interface IViewportLike {
  70441. x: float;
  70442. y: float;
  70443. width: float;
  70444. height: float;
  70445. }
  70446. /**
  70447. * @hidden
  70448. */
  70449. export interface IPlaneLike {
  70450. normal: IVector3Like;
  70451. d: float;
  70452. normalize(): void;
  70453. }
  70454. }
  70455. declare module BABYLON {
  70456. /**
  70457. * Interface used to define common properties for effect fallbacks
  70458. */
  70459. export interface IEffectFallbacks {
  70460. /**
  70461. * Removes the defines that should be removed when falling back.
  70462. * @param currentDefines defines the current define statements for the shader.
  70463. * @param effect defines the current effect we try to compile
  70464. * @returns The resulting defines with defines of the current rank removed.
  70465. */
  70466. reduce(currentDefines: string, effect: Effect): string;
  70467. /**
  70468. * Removes the fallback from the bound mesh.
  70469. */
  70470. unBindMesh(): void;
  70471. /**
  70472. * Checks to see if more fallbacks are still availible.
  70473. */
  70474. hasMoreFallbacks: boolean;
  70475. }
  70476. }
  70477. declare module BABYLON {
  70478. /**
  70479. * Class used to evalaute queries containing `and` and `or` operators
  70480. */
  70481. export class AndOrNotEvaluator {
  70482. /**
  70483. * Evaluate a query
  70484. * @param query defines the query to evaluate
  70485. * @param evaluateCallback defines the callback used to filter result
  70486. * @returns true if the query matches
  70487. */
  70488. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70489. private static _HandleParenthesisContent;
  70490. private static _SimplifyNegation;
  70491. }
  70492. }
  70493. declare module BABYLON {
  70494. /**
  70495. * Class used to store custom tags
  70496. */
  70497. export class Tags {
  70498. /**
  70499. * Adds support for tags on the given object
  70500. * @param obj defines the object to use
  70501. */
  70502. static EnableFor(obj: any): void;
  70503. /**
  70504. * Removes tags support
  70505. * @param obj defines the object to use
  70506. */
  70507. static DisableFor(obj: any): void;
  70508. /**
  70509. * Gets a boolean indicating if the given object has tags
  70510. * @param obj defines the object to use
  70511. * @returns a boolean
  70512. */
  70513. static HasTags(obj: any): boolean;
  70514. /**
  70515. * Gets the tags available on a given object
  70516. * @param obj defines the object to use
  70517. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70518. * @returns the tags
  70519. */
  70520. static GetTags(obj: any, asString?: boolean): any;
  70521. /**
  70522. * Adds tags to an object
  70523. * @param obj defines the object to use
  70524. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70525. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70526. */
  70527. static AddTagsTo(obj: any, tagsString: string): void;
  70528. /**
  70529. * @hidden
  70530. */
  70531. static _AddTagTo(obj: any, tag: string): void;
  70532. /**
  70533. * Removes specific tags from a specific object
  70534. * @param obj defines the object to use
  70535. * @param tagsString defines the tags to remove
  70536. */
  70537. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70538. /**
  70539. * @hidden
  70540. */
  70541. static _RemoveTagFrom(obj: any, tag: string): void;
  70542. /**
  70543. * Defines if tags hosted on an object match a given query
  70544. * @param obj defines the object to use
  70545. * @param tagsQuery defines the tag query
  70546. * @returns a boolean
  70547. */
  70548. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70549. }
  70550. }
  70551. declare module BABYLON {
  70552. /**
  70553. * Scalar computation library
  70554. */
  70555. export class Scalar {
  70556. /**
  70557. * Two pi constants convenient for computation.
  70558. */
  70559. static TwoPi: number;
  70560. /**
  70561. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70562. * @param a number
  70563. * @param b number
  70564. * @param epsilon (default = 1.401298E-45)
  70565. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70566. */
  70567. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70568. /**
  70569. * Returns a string : the upper case translation of the number i to hexadecimal.
  70570. * @param i number
  70571. * @returns the upper case translation of the number i to hexadecimal.
  70572. */
  70573. static ToHex(i: number): string;
  70574. /**
  70575. * Returns -1 if value is negative and +1 is value is positive.
  70576. * @param value the value
  70577. * @returns the value itself if it's equal to zero.
  70578. */
  70579. static Sign(value: number): number;
  70580. /**
  70581. * Returns the value itself if it's between min and max.
  70582. * Returns min if the value is lower than min.
  70583. * Returns max if the value is greater than max.
  70584. * @param value the value to clmap
  70585. * @param min the min value to clamp to (default: 0)
  70586. * @param max the max value to clamp to (default: 1)
  70587. * @returns the clamped value
  70588. */
  70589. static Clamp(value: number, min?: number, max?: number): number;
  70590. /**
  70591. * the log2 of value.
  70592. * @param value the value to compute log2 of
  70593. * @returns the log2 of value.
  70594. */
  70595. static Log2(value: number): number;
  70596. /**
  70597. * Loops the value, so that it is never larger than length and never smaller than 0.
  70598. *
  70599. * This is similar to the modulo operator but it works with floating point numbers.
  70600. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70601. * With t = 5 and length = 2.5, the result would be 0.0.
  70602. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70603. * @param value the value
  70604. * @param length the length
  70605. * @returns the looped value
  70606. */
  70607. static Repeat(value: number, length: number): number;
  70608. /**
  70609. * Normalize the value between 0.0 and 1.0 using min and max values
  70610. * @param value value to normalize
  70611. * @param min max to normalize between
  70612. * @param max min to normalize between
  70613. * @returns the normalized value
  70614. */
  70615. static Normalize(value: number, min: number, max: number): number;
  70616. /**
  70617. * Denormalize the value from 0.0 and 1.0 using min and max values
  70618. * @param normalized value to denormalize
  70619. * @param min max to denormalize between
  70620. * @param max min to denormalize between
  70621. * @returns the denormalized value
  70622. */
  70623. static Denormalize(normalized: number, min: number, max: number): number;
  70624. /**
  70625. * Calculates the shortest difference between two given angles given in degrees.
  70626. * @param current current angle in degrees
  70627. * @param target target angle in degrees
  70628. * @returns the delta
  70629. */
  70630. static DeltaAngle(current: number, target: number): number;
  70631. /**
  70632. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70633. * @param tx value
  70634. * @param length length
  70635. * @returns The returned value will move back and forth between 0 and length
  70636. */
  70637. static PingPong(tx: number, length: number): number;
  70638. /**
  70639. * Interpolates between min and max with smoothing at the limits.
  70640. *
  70641. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70642. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70643. * @param from from
  70644. * @param to to
  70645. * @param tx value
  70646. * @returns the smooth stepped value
  70647. */
  70648. static SmoothStep(from: number, to: number, tx: number): number;
  70649. /**
  70650. * Moves a value current towards target.
  70651. *
  70652. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70653. * Negative values of maxDelta pushes the value away from target.
  70654. * @param current current value
  70655. * @param target target value
  70656. * @param maxDelta max distance to move
  70657. * @returns resulting value
  70658. */
  70659. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70660. /**
  70661. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70662. *
  70663. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70664. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70665. * @param current current value
  70666. * @param target target value
  70667. * @param maxDelta max distance to move
  70668. * @returns resulting angle
  70669. */
  70670. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70671. /**
  70672. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70673. * @param start start value
  70674. * @param end target value
  70675. * @param amount amount to lerp between
  70676. * @returns the lerped value
  70677. */
  70678. static Lerp(start: number, end: number, amount: number): number;
  70679. /**
  70680. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70681. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70682. * @param start start value
  70683. * @param end target value
  70684. * @param amount amount to lerp between
  70685. * @returns the lerped value
  70686. */
  70687. static LerpAngle(start: number, end: number, amount: number): number;
  70688. /**
  70689. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70690. * @param a start value
  70691. * @param b target value
  70692. * @param value value between a and b
  70693. * @returns the inverseLerp value
  70694. */
  70695. static InverseLerp(a: number, b: number, value: number): number;
  70696. /**
  70697. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70698. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70699. * @param value1 spline value
  70700. * @param tangent1 spline value
  70701. * @param value2 spline value
  70702. * @param tangent2 spline value
  70703. * @param amount input value
  70704. * @returns hermite result
  70705. */
  70706. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70707. /**
  70708. * Returns a random float number between and min and max values
  70709. * @param min min value of random
  70710. * @param max max value of random
  70711. * @returns random value
  70712. */
  70713. static RandomRange(min: number, max: number): number;
  70714. /**
  70715. * This function returns percentage of a number in a given range.
  70716. *
  70717. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70718. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70719. * @param number to convert to percentage
  70720. * @param min min range
  70721. * @param max max range
  70722. * @returns the percentage
  70723. */
  70724. static RangeToPercent(number: number, min: number, max: number): number;
  70725. /**
  70726. * This function returns number that corresponds to the percentage in a given range.
  70727. *
  70728. * PercentToRange(0.34,0,100) will return 34.
  70729. * @param percent to convert to number
  70730. * @param min min range
  70731. * @param max max range
  70732. * @returns the number
  70733. */
  70734. static PercentToRange(percent: number, min: number, max: number): number;
  70735. /**
  70736. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70737. * @param angle The angle to normalize in radian.
  70738. * @return The converted angle.
  70739. */
  70740. static NormalizeRadians(angle: number): number;
  70741. }
  70742. }
  70743. declare module BABYLON {
  70744. /**
  70745. * Constant used to convert a value to gamma space
  70746. * @ignorenaming
  70747. */
  70748. export const ToGammaSpace: number;
  70749. /**
  70750. * Constant used to convert a value to linear space
  70751. * @ignorenaming
  70752. */
  70753. export const ToLinearSpace = 2.2;
  70754. /**
  70755. * Constant used to define the minimal number value in Babylon.js
  70756. * @ignorenaming
  70757. */
  70758. let Epsilon: number;
  70759. }
  70760. declare module BABYLON {
  70761. /**
  70762. * Class used to represent a viewport on screen
  70763. */
  70764. export class Viewport {
  70765. /** viewport left coordinate */
  70766. x: number;
  70767. /** viewport top coordinate */
  70768. y: number;
  70769. /**viewport width */
  70770. width: number;
  70771. /** viewport height */
  70772. height: number;
  70773. /**
  70774. * Creates a Viewport object located at (x, y) and sized (width, height)
  70775. * @param x defines viewport left coordinate
  70776. * @param y defines viewport top coordinate
  70777. * @param width defines the viewport width
  70778. * @param height defines the viewport height
  70779. */
  70780. constructor(
  70781. /** viewport left coordinate */
  70782. x: number,
  70783. /** viewport top coordinate */
  70784. y: number,
  70785. /**viewport width */
  70786. width: number,
  70787. /** viewport height */
  70788. height: number);
  70789. /**
  70790. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70791. * @param renderWidth defines the rendering width
  70792. * @param renderHeight defines the rendering height
  70793. * @returns a new Viewport
  70794. */
  70795. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70796. /**
  70797. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70798. * @param renderWidth defines the rendering width
  70799. * @param renderHeight defines the rendering height
  70800. * @param ref defines the target viewport
  70801. * @returns the current viewport
  70802. */
  70803. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70804. /**
  70805. * Returns a new Viewport copied from the current one
  70806. * @returns a new Viewport
  70807. */
  70808. clone(): Viewport;
  70809. }
  70810. }
  70811. declare module BABYLON {
  70812. /**
  70813. * Class containing a set of static utilities functions for arrays.
  70814. */
  70815. export class ArrayTools {
  70816. /**
  70817. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70818. * @param size the number of element to construct and put in the array
  70819. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70820. * @returns a new array filled with new objects
  70821. */
  70822. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70823. }
  70824. }
  70825. declare module BABYLON {
  70826. /**
  70827. * Class representing a vector containing 2 coordinates
  70828. */
  70829. export class Vector2 {
  70830. /** defines the first coordinate */
  70831. x: number;
  70832. /** defines the second coordinate */
  70833. y: number;
  70834. /**
  70835. * Creates a new Vector2 from the given x and y coordinates
  70836. * @param x defines the first coordinate
  70837. * @param y defines the second coordinate
  70838. */
  70839. constructor(
  70840. /** defines the first coordinate */
  70841. x?: number,
  70842. /** defines the second coordinate */
  70843. y?: number);
  70844. /**
  70845. * Gets a string with the Vector2 coordinates
  70846. * @returns a string with the Vector2 coordinates
  70847. */
  70848. toString(): string;
  70849. /**
  70850. * Gets class name
  70851. * @returns the string "Vector2"
  70852. */
  70853. getClassName(): string;
  70854. /**
  70855. * Gets current vector hash code
  70856. * @returns the Vector2 hash code as a number
  70857. */
  70858. getHashCode(): number;
  70859. /**
  70860. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70861. * @param array defines the source array
  70862. * @param index defines the offset in source array
  70863. * @returns the current Vector2
  70864. */
  70865. toArray(array: FloatArray, index?: number): Vector2;
  70866. /**
  70867. * Copy the current vector to an array
  70868. * @returns a new array with 2 elements: the Vector2 coordinates.
  70869. */
  70870. asArray(): number[];
  70871. /**
  70872. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70873. * @param source defines the source Vector2
  70874. * @returns the current updated Vector2
  70875. */
  70876. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70877. /**
  70878. * Sets the Vector2 coordinates with the given floats
  70879. * @param x defines the first coordinate
  70880. * @param y defines the second coordinate
  70881. * @returns the current updated Vector2
  70882. */
  70883. copyFromFloats(x: number, y: number): Vector2;
  70884. /**
  70885. * Sets the Vector2 coordinates with the given floats
  70886. * @param x defines the first coordinate
  70887. * @param y defines the second coordinate
  70888. * @returns the current updated Vector2
  70889. */
  70890. set(x: number, y: number): Vector2;
  70891. /**
  70892. * Add another vector with the current one
  70893. * @param otherVector defines the other vector
  70894. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70895. */
  70896. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70897. /**
  70898. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70899. * @param otherVector defines the other vector
  70900. * @param result defines the target vector
  70901. * @returns the unmodified current Vector2
  70902. */
  70903. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70904. /**
  70905. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70906. * @param otherVector defines the other vector
  70907. * @returns the current updated Vector2
  70908. */
  70909. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70910. /**
  70911. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70912. * @param otherVector defines the other vector
  70913. * @returns a new Vector2
  70914. */
  70915. addVector3(otherVector: Vector3): Vector2;
  70916. /**
  70917. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70918. * @param otherVector defines the other vector
  70919. * @returns a new Vector2
  70920. */
  70921. subtract(otherVector: Vector2): Vector2;
  70922. /**
  70923. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70924. * @param otherVector defines the other vector
  70925. * @param result defines the target vector
  70926. * @returns the unmodified current Vector2
  70927. */
  70928. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70929. /**
  70930. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70931. * @param otherVector defines the other vector
  70932. * @returns the current updated Vector2
  70933. */
  70934. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70935. /**
  70936. * Multiplies in place the current Vector2 coordinates by the given ones
  70937. * @param otherVector defines the other vector
  70938. * @returns the current updated Vector2
  70939. */
  70940. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70941. /**
  70942. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70943. * @param otherVector defines the other vector
  70944. * @returns a new Vector2
  70945. */
  70946. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70947. /**
  70948. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70949. * @param otherVector defines the other vector
  70950. * @param result defines the target vector
  70951. * @returns the unmodified current Vector2
  70952. */
  70953. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70954. /**
  70955. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70956. * @param x defines the first coordinate
  70957. * @param y defines the second coordinate
  70958. * @returns a new Vector2
  70959. */
  70960. multiplyByFloats(x: number, y: number): Vector2;
  70961. /**
  70962. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70963. * @param otherVector defines the other vector
  70964. * @returns a new Vector2
  70965. */
  70966. divide(otherVector: Vector2): Vector2;
  70967. /**
  70968. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70969. * @param otherVector defines the other vector
  70970. * @param result defines the target vector
  70971. * @returns the unmodified current Vector2
  70972. */
  70973. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70974. /**
  70975. * Divides the current Vector2 coordinates by the given ones
  70976. * @param otherVector defines the other vector
  70977. * @returns the current updated Vector2
  70978. */
  70979. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70980. /**
  70981. * Gets a new Vector2 with current Vector2 negated coordinates
  70982. * @returns a new Vector2
  70983. */
  70984. negate(): Vector2;
  70985. /**
  70986. * Multiply the Vector2 coordinates by scale
  70987. * @param scale defines the scaling factor
  70988. * @returns the current updated Vector2
  70989. */
  70990. scaleInPlace(scale: number): Vector2;
  70991. /**
  70992. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70993. * @param scale defines the scaling factor
  70994. * @returns a new Vector2
  70995. */
  70996. scale(scale: number): Vector2;
  70997. /**
  70998. * Scale the current Vector2 values by a factor to a given Vector2
  70999. * @param scale defines the scale factor
  71000. * @param result defines the Vector2 object where to store the result
  71001. * @returns the unmodified current Vector2
  71002. */
  71003. scaleToRef(scale: number, result: Vector2): Vector2;
  71004. /**
  71005. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71006. * @param scale defines the scale factor
  71007. * @param result defines the Vector2 object where to store the result
  71008. * @returns the unmodified current Vector2
  71009. */
  71010. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  71011. /**
  71012. * Gets a boolean if two vectors are equals
  71013. * @param otherVector defines the other vector
  71014. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71015. */
  71016. equals(otherVector: DeepImmutable<Vector2>): boolean;
  71017. /**
  71018. * Gets a boolean if two vectors are equals (using an epsilon value)
  71019. * @param otherVector defines the other vector
  71020. * @param epsilon defines the minimal distance to consider equality
  71021. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71022. */
  71023. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71024. /**
  71025. * Gets a new Vector2 from current Vector2 floored values
  71026. * @returns a new Vector2
  71027. */
  71028. floor(): Vector2;
  71029. /**
  71030. * Gets a new Vector2 from current Vector2 floored values
  71031. * @returns a new Vector2
  71032. */
  71033. fract(): Vector2;
  71034. /**
  71035. * Gets the length of the vector
  71036. * @returns the vector length (float)
  71037. */
  71038. length(): number;
  71039. /**
  71040. * Gets the vector squared length
  71041. * @returns the vector squared length (float)
  71042. */
  71043. lengthSquared(): number;
  71044. /**
  71045. * Normalize the vector
  71046. * @returns the current updated Vector2
  71047. */
  71048. normalize(): Vector2;
  71049. /**
  71050. * Gets a new Vector2 copied from the Vector2
  71051. * @returns a new Vector2
  71052. */
  71053. clone(): Vector2;
  71054. /**
  71055. * Gets a new Vector2(0, 0)
  71056. * @returns a new Vector2
  71057. */
  71058. static Zero(): Vector2;
  71059. /**
  71060. * Gets a new Vector2(1, 1)
  71061. * @returns a new Vector2
  71062. */
  71063. static One(): Vector2;
  71064. /**
  71065. * Gets a new Vector2 set from the given index element of the given array
  71066. * @param array defines the data source
  71067. * @param offset defines the offset in the data source
  71068. * @returns a new Vector2
  71069. */
  71070. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71071. /**
  71072. * Sets "result" from the given index element of the given array
  71073. * @param array defines the data source
  71074. * @param offset defines the offset in the data source
  71075. * @param result defines the target vector
  71076. */
  71077. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71078. /**
  71079. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71080. * @param value1 defines 1st point of control
  71081. * @param value2 defines 2nd point of control
  71082. * @param value3 defines 3rd point of control
  71083. * @param value4 defines 4th point of control
  71084. * @param amount defines the interpolation factor
  71085. * @returns a new Vector2
  71086. */
  71087. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71088. /**
  71089. * 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".
  71090. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71091. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71092. * @param value defines the value to clamp
  71093. * @param min defines the lower limit
  71094. * @param max defines the upper limit
  71095. * @returns a new Vector2
  71096. */
  71097. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71098. /**
  71099. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71100. * @param value1 defines the 1st control point
  71101. * @param tangent1 defines the outgoing tangent
  71102. * @param value2 defines the 2nd control point
  71103. * @param tangent2 defines the incoming tangent
  71104. * @param amount defines the interpolation factor
  71105. * @returns a new Vector2
  71106. */
  71107. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71108. /**
  71109. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71110. * @param start defines the start vector
  71111. * @param end defines the end vector
  71112. * @param amount defines the interpolation factor
  71113. * @returns a new Vector2
  71114. */
  71115. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71116. /**
  71117. * Gets the dot product of the vector "left" and the vector "right"
  71118. * @param left defines first vector
  71119. * @param right defines second vector
  71120. * @returns the dot product (float)
  71121. */
  71122. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71123. /**
  71124. * Returns a new Vector2 equal to the normalized given vector
  71125. * @param vector defines the vector to normalize
  71126. * @returns a new Vector2
  71127. */
  71128. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71129. /**
  71130. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71131. * @param left defines 1st vector
  71132. * @param right defines 2nd vector
  71133. * @returns a new Vector2
  71134. */
  71135. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71136. /**
  71137. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71138. * @param left defines 1st vector
  71139. * @param right defines 2nd vector
  71140. * @returns a new Vector2
  71141. */
  71142. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71143. /**
  71144. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71145. * @param vector defines the vector to transform
  71146. * @param transformation defines the matrix to apply
  71147. * @returns a new Vector2
  71148. */
  71149. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71150. /**
  71151. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71152. * @param vector defines the vector to transform
  71153. * @param transformation defines the matrix to apply
  71154. * @param result defines the target vector
  71155. */
  71156. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71157. /**
  71158. * Determines if a given vector is included in a triangle
  71159. * @param p defines the vector to test
  71160. * @param p0 defines 1st triangle point
  71161. * @param p1 defines 2nd triangle point
  71162. * @param p2 defines 3rd triangle point
  71163. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71164. */
  71165. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71166. /**
  71167. * Gets the distance between the vectors "value1" and "value2"
  71168. * @param value1 defines first vector
  71169. * @param value2 defines second vector
  71170. * @returns the distance between vectors
  71171. */
  71172. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71173. /**
  71174. * Returns the squared distance between the vectors "value1" and "value2"
  71175. * @param value1 defines first vector
  71176. * @param value2 defines second vector
  71177. * @returns the squared distance between vectors
  71178. */
  71179. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71180. /**
  71181. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71182. * @param value1 defines first vector
  71183. * @param value2 defines second vector
  71184. * @returns a new Vector2
  71185. */
  71186. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71187. /**
  71188. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71189. * @param p defines the middle point
  71190. * @param segA defines one point of the segment
  71191. * @param segB defines the other point of the segment
  71192. * @returns the shortest distance
  71193. */
  71194. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71195. }
  71196. /**
  71197. * Class used to store (x,y,z) vector representation
  71198. * A Vector3 is the main object used in 3D geometry
  71199. * It can represent etiher the coordinates of a point the space, either a direction
  71200. * Reminder: js uses a left handed forward facing system
  71201. */
  71202. export class Vector3 {
  71203. /**
  71204. * Defines the first coordinates (on X axis)
  71205. */
  71206. x: number;
  71207. /**
  71208. * Defines the second coordinates (on Y axis)
  71209. */
  71210. y: number;
  71211. /**
  71212. * Defines the third coordinates (on Z axis)
  71213. */
  71214. z: number;
  71215. private static _UpReadOnly;
  71216. private static _ZeroReadOnly;
  71217. /**
  71218. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71219. * @param x defines the first coordinates (on X axis)
  71220. * @param y defines the second coordinates (on Y axis)
  71221. * @param z defines the third coordinates (on Z axis)
  71222. */
  71223. constructor(
  71224. /**
  71225. * Defines the first coordinates (on X axis)
  71226. */
  71227. x?: number,
  71228. /**
  71229. * Defines the second coordinates (on Y axis)
  71230. */
  71231. y?: number,
  71232. /**
  71233. * Defines the third coordinates (on Z axis)
  71234. */
  71235. z?: number);
  71236. /**
  71237. * Creates a string representation of the Vector3
  71238. * @returns a string with the Vector3 coordinates.
  71239. */
  71240. toString(): string;
  71241. /**
  71242. * Gets the class name
  71243. * @returns the string "Vector3"
  71244. */
  71245. getClassName(): string;
  71246. /**
  71247. * Creates the Vector3 hash code
  71248. * @returns a number which tends to be unique between Vector3 instances
  71249. */
  71250. getHashCode(): number;
  71251. /**
  71252. * Creates an array containing three elements : the coordinates of the Vector3
  71253. * @returns a new array of numbers
  71254. */
  71255. asArray(): number[];
  71256. /**
  71257. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71258. * @param array defines the destination array
  71259. * @param index defines the offset in the destination array
  71260. * @returns the current Vector3
  71261. */
  71262. toArray(array: FloatArray, index?: number): Vector3;
  71263. /**
  71264. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71265. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71266. */
  71267. toQuaternion(): Quaternion;
  71268. /**
  71269. * Adds the given vector to the current Vector3
  71270. * @param otherVector defines the second operand
  71271. * @returns the current updated Vector3
  71272. */
  71273. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71274. /**
  71275. * Adds the given coordinates to the current Vector3
  71276. * @param x defines the x coordinate of the operand
  71277. * @param y defines the y coordinate of the operand
  71278. * @param z defines the z coordinate of the operand
  71279. * @returns the current updated Vector3
  71280. */
  71281. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71282. /**
  71283. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71284. * @param otherVector defines the second operand
  71285. * @returns the resulting Vector3
  71286. */
  71287. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71288. /**
  71289. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71290. * @param otherVector defines the second operand
  71291. * @param result defines the Vector3 object where to store the result
  71292. * @returns the current Vector3
  71293. */
  71294. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71295. /**
  71296. * Subtract the given vector from the current Vector3
  71297. * @param otherVector defines the second operand
  71298. * @returns the current updated Vector3
  71299. */
  71300. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71301. /**
  71302. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71303. * @param otherVector defines the second operand
  71304. * @returns the resulting Vector3
  71305. */
  71306. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71307. /**
  71308. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71309. * @param otherVector defines the second operand
  71310. * @param result defines the Vector3 object where to store the result
  71311. * @returns the current Vector3
  71312. */
  71313. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71314. /**
  71315. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71316. * @param x defines the x coordinate of the operand
  71317. * @param y defines the y coordinate of the operand
  71318. * @param z defines the z coordinate of the operand
  71319. * @returns the resulting Vector3
  71320. */
  71321. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71322. /**
  71323. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71324. * @param x defines the x coordinate of the operand
  71325. * @param y defines the y coordinate of the operand
  71326. * @param z defines the z coordinate of the operand
  71327. * @param result defines the Vector3 object where to store the result
  71328. * @returns the current Vector3
  71329. */
  71330. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71331. /**
  71332. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71333. * @returns a new Vector3
  71334. */
  71335. negate(): Vector3;
  71336. /**
  71337. * Multiplies the Vector3 coordinates by the float "scale"
  71338. * @param scale defines the multiplier factor
  71339. * @returns the current updated Vector3
  71340. */
  71341. scaleInPlace(scale: number): Vector3;
  71342. /**
  71343. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71344. * @param scale defines the multiplier factor
  71345. * @returns a new Vector3
  71346. */
  71347. scale(scale: number): Vector3;
  71348. /**
  71349. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71350. * @param scale defines the multiplier factor
  71351. * @param result defines the Vector3 object where to store the result
  71352. * @returns the current Vector3
  71353. */
  71354. scaleToRef(scale: number, result: Vector3): Vector3;
  71355. /**
  71356. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71357. * @param scale defines the scale factor
  71358. * @param result defines the Vector3 object where to store the result
  71359. * @returns the unmodified current Vector3
  71360. */
  71361. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71362. /**
  71363. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71364. * @param otherVector defines the second operand
  71365. * @returns true if both vectors are equals
  71366. */
  71367. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71368. /**
  71369. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71370. * @param otherVector defines the second operand
  71371. * @param epsilon defines the minimal distance to define values as equals
  71372. * @returns true if both vectors are distant less than epsilon
  71373. */
  71374. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71375. /**
  71376. * Returns true if the current Vector3 coordinates equals the given floats
  71377. * @param x defines the x coordinate of the operand
  71378. * @param y defines the y coordinate of the operand
  71379. * @param z defines the z coordinate of the operand
  71380. * @returns true if both vectors are equals
  71381. */
  71382. equalsToFloats(x: number, y: number, z: number): boolean;
  71383. /**
  71384. * Multiplies the current Vector3 coordinates by the given ones
  71385. * @param otherVector defines the second operand
  71386. * @returns the current updated Vector3
  71387. */
  71388. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71389. /**
  71390. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71391. * @param otherVector defines the second operand
  71392. * @returns the new Vector3
  71393. */
  71394. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71395. /**
  71396. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71397. * @param otherVector defines the second operand
  71398. * @param result defines the Vector3 object where to store the result
  71399. * @returns the current Vector3
  71400. */
  71401. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71402. /**
  71403. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71404. * @param x defines the x coordinate of the operand
  71405. * @param y defines the y coordinate of the operand
  71406. * @param z defines the z coordinate of the operand
  71407. * @returns the new Vector3
  71408. */
  71409. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71410. /**
  71411. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71412. * @param otherVector defines the second operand
  71413. * @returns the new Vector3
  71414. */
  71415. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71416. /**
  71417. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71418. * @param otherVector defines the second operand
  71419. * @param result defines the Vector3 object where to store the result
  71420. * @returns the current Vector3
  71421. */
  71422. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71423. /**
  71424. * Divides the current Vector3 coordinates by the given ones.
  71425. * @param otherVector defines the second operand
  71426. * @returns the current updated Vector3
  71427. */
  71428. divideInPlace(otherVector: Vector3): Vector3;
  71429. /**
  71430. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71431. * @param other defines the second operand
  71432. * @returns the current updated Vector3
  71433. */
  71434. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71435. /**
  71436. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71437. * @param other defines the second operand
  71438. * @returns the current updated Vector3
  71439. */
  71440. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71441. /**
  71442. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71443. * @param x defines the x coordinate of the operand
  71444. * @param y defines the y coordinate of the operand
  71445. * @param z defines the z coordinate of the operand
  71446. * @returns the current updated Vector3
  71447. */
  71448. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71449. /**
  71450. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71451. * @param x defines the x coordinate of the operand
  71452. * @param y defines the y coordinate of the operand
  71453. * @param z defines the z coordinate of the operand
  71454. * @returns the current updated Vector3
  71455. */
  71456. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71457. /**
  71458. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71459. * Check if is non uniform within a certain amount of decimal places to account for this
  71460. * @param epsilon the amount the values can differ
  71461. * @returns if the the vector is non uniform to a certain number of decimal places
  71462. */
  71463. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71464. /**
  71465. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71466. */
  71467. readonly isNonUniform: boolean;
  71468. /**
  71469. * Gets a new Vector3 from current Vector3 floored values
  71470. * @returns a new Vector3
  71471. */
  71472. floor(): Vector3;
  71473. /**
  71474. * Gets a new Vector3 from current Vector3 floored values
  71475. * @returns a new Vector3
  71476. */
  71477. fract(): Vector3;
  71478. /**
  71479. * Gets the length of the Vector3
  71480. * @returns the length of the Vector3
  71481. */
  71482. length(): number;
  71483. /**
  71484. * Gets the squared length of the Vector3
  71485. * @returns squared length of the Vector3
  71486. */
  71487. lengthSquared(): number;
  71488. /**
  71489. * Normalize the current Vector3.
  71490. * Please note that this is an in place operation.
  71491. * @returns the current updated Vector3
  71492. */
  71493. normalize(): Vector3;
  71494. /**
  71495. * Reorders the x y z properties of the vector in place
  71496. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71497. * @returns the current updated vector
  71498. */
  71499. reorderInPlace(order: string): this;
  71500. /**
  71501. * Rotates the vector around 0,0,0 by a quaternion
  71502. * @param quaternion the rotation quaternion
  71503. * @param result vector to store the result
  71504. * @returns the resulting vector
  71505. */
  71506. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71507. /**
  71508. * Rotates a vector around a given point
  71509. * @param quaternion the rotation quaternion
  71510. * @param point the point to rotate around
  71511. * @param result vector to store the result
  71512. * @returns the resulting vector
  71513. */
  71514. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71515. /**
  71516. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71517. * The cross product is then orthogonal to both current and "other"
  71518. * @param other defines the right operand
  71519. * @returns the cross product
  71520. */
  71521. cross(other: Vector3): Vector3;
  71522. /**
  71523. * Normalize the current Vector3 with the given input length.
  71524. * Please note that this is an in place operation.
  71525. * @param len the length of the vector
  71526. * @returns the current updated Vector3
  71527. */
  71528. normalizeFromLength(len: number): Vector3;
  71529. /**
  71530. * Normalize the current Vector3 to a new vector
  71531. * @returns the new Vector3
  71532. */
  71533. normalizeToNew(): Vector3;
  71534. /**
  71535. * Normalize the current Vector3 to the reference
  71536. * @param reference define the Vector3 to update
  71537. * @returns the updated Vector3
  71538. */
  71539. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71540. /**
  71541. * Creates a new Vector3 copied from the current Vector3
  71542. * @returns the new Vector3
  71543. */
  71544. clone(): Vector3;
  71545. /**
  71546. * Copies the given vector coordinates to the current Vector3 ones
  71547. * @param source defines the source Vector3
  71548. * @returns the current updated Vector3
  71549. */
  71550. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71551. /**
  71552. * Copies the given floats to the current Vector3 coordinates
  71553. * @param x defines the x coordinate of the operand
  71554. * @param y defines the y coordinate of the operand
  71555. * @param z defines the z coordinate of the operand
  71556. * @returns the current updated Vector3
  71557. */
  71558. copyFromFloats(x: number, y: number, z: number): Vector3;
  71559. /**
  71560. * Copies the given floats to the current Vector3 coordinates
  71561. * @param x defines the x coordinate of the operand
  71562. * @param y defines the y coordinate of the operand
  71563. * @param z defines the z coordinate of the operand
  71564. * @returns the current updated Vector3
  71565. */
  71566. set(x: number, y: number, z: number): Vector3;
  71567. /**
  71568. * Copies the given float to the current Vector3 coordinates
  71569. * @param v defines the x, y and z coordinates of the operand
  71570. * @returns the current updated Vector3
  71571. */
  71572. setAll(v: number): Vector3;
  71573. /**
  71574. * Get the clip factor between two vectors
  71575. * @param vector0 defines the first operand
  71576. * @param vector1 defines the second operand
  71577. * @param axis defines the axis to use
  71578. * @param size defines the size along the axis
  71579. * @returns the clip factor
  71580. */
  71581. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71582. /**
  71583. * Get angle between two vectors
  71584. * @param vector0 angle between vector0 and vector1
  71585. * @param vector1 angle between vector0 and vector1
  71586. * @param normal direction of the normal
  71587. * @return the angle between vector0 and vector1
  71588. */
  71589. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71590. /**
  71591. * Returns a new Vector3 set from the index "offset" of the given array
  71592. * @param array defines the source array
  71593. * @param offset defines the offset in the source array
  71594. * @returns the new Vector3
  71595. */
  71596. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71597. /**
  71598. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71599. * @param array defines the source array
  71600. * @param offset defines the offset in the source array
  71601. * @returns the new Vector3
  71602. * @deprecated Please use FromArray instead.
  71603. */
  71604. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71605. /**
  71606. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71607. * @param array defines the source array
  71608. * @param offset defines the offset in the source array
  71609. * @param result defines the Vector3 where to store the result
  71610. */
  71611. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71612. /**
  71613. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71614. * @param array defines the source array
  71615. * @param offset defines the offset in the source array
  71616. * @param result defines the Vector3 where to store the result
  71617. * @deprecated Please use FromArrayToRef instead.
  71618. */
  71619. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71620. /**
  71621. * Sets the given vector "result" with the given floats.
  71622. * @param x defines the x coordinate of the source
  71623. * @param y defines the y coordinate of the source
  71624. * @param z defines the z coordinate of the source
  71625. * @param result defines the Vector3 where to store the result
  71626. */
  71627. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71628. /**
  71629. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71630. * @returns a new empty Vector3
  71631. */
  71632. static Zero(): Vector3;
  71633. /**
  71634. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71635. * @returns a new unit Vector3
  71636. */
  71637. static One(): Vector3;
  71638. /**
  71639. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71640. * @returns a new up Vector3
  71641. */
  71642. static Up(): Vector3;
  71643. /**
  71644. * Gets a up Vector3 that must not be updated
  71645. */
  71646. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71647. /**
  71648. * Gets a zero Vector3 that must not be updated
  71649. */
  71650. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71651. /**
  71652. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71653. * @returns a new down Vector3
  71654. */
  71655. static Down(): Vector3;
  71656. /**
  71657. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71658. * @returns a new forward Vector3
  71659. */
  71660. static Forward(): Vector3;
  71661. /**
  71662. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71663. * @returns a new forward Vector3
  71664. */
  71665. static Backward(): Vector3;
  71666. /**
  71667. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71668. * @returns a new right Vector3
  71669. */
  71670. static Right(): Vector3;
  71671. /**
  71672. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71673. * @returns a new left Vector3
  71674. */
  71675. static Left(): Vector3;
  71676. /**
  71677. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71679. * @param vector defines the Vector3 to transform
  71680. * @param transformation defines the transformation matrix
  71681. * @returns the transformed Vector3
  71682. */
  71683. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71684. /**
  71685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71686. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71687. * @param vector defines the Vector3 to transform
  71688. * @param transformation defines the transformation matrix
  71689. * @param result defines the Vector3 where to store the result
  71690. */
  71691. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71692. /**
  71693. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71694. * This method computes tranformed coordinates only, not transformed direction vectors
  71695. * @param x define the x coordinate of the source vector
  71696. * @param y define the y coordinate of the source vector
  71697. * @param z define the z coordinate of the source vector
  71698. * @param transformation defines the transformation matrix
  71699. * @param result defines the Vector3 where to store the result
  71700. */
  71701. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71702. /**
  71703. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71705. * @param vector defines the Vector3 to transform
  71706. * @param transformation defines the transformation matrix
  71707. * @returns the new Vector3
  71708. */
  71709. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71710. /**
  71711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71713. * @param vector defines the Vector3 to transform
  71714. * @param transformation defines the transformation matrix
  71715. * @param result defines the Vector3 where to store the result
  71716. */
  71717. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71718. /**
  71719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71720. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71721. * @param x define the x coordinate of the source vector
  71722. * @param y define the y coordinate of the source vector
  71723. * @param z define the z coordinate of the source vector
  71724. * @param transformation defines the transformation matrix
  71725. * @param result defines the Vector3 where to store the result
  71726. */
  71727. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71728. /**
  71729. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71730. * @param value1 defines the first control point
  71731. * @param value2 defines the second control point
  71732. * @param value3 defines the third control point
  71733. * @param value4 defines the fourth control point
  71734. * @param amount defines the amount on the spline to use
  71735. * @returns the new Vector3
  71736. */
  71737. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71738. /**
  71739. * 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"
  71740. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71741. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71742. * @param value defines the current value
  71743. * @param min defines the lower range value
  71744. * @param max defines the upper range value
  71745. * @returns the new Vector3
  71746. */
  71747. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71748. /**
  71749. * 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"
  71750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71752. * @param value defines the current value
  71753. * @param min defines the lower range value
  71754. * @param max defines the upper range value
  71755. * @param result defines the Vector3 where to store the result
  71756. */
  71757. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71758. /**
  71759. * Checks if a given vector is inside a specific range
  71760. * @param v defines the vector to test
  71761. * @param min defines the minimum range
  71762. * @param max defines the maximum range
  71763. */
  71764. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71765. /**
  71766. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71767. * @param value1 defines the first control point
  71768. * @param tangent1 defines the first tangent vector
  71769. * @param value2 defines the second control point
  71770. * @param tangent2 defines the second tangent vector
  71771. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71772. * @returns the new Vector3
  71773. */
  71774. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71775. /**
  71776. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71777. * @param start defines the start value
  71778. * @param end defines the end value
  71779. * @param amount max defines amount between both (between 0 and 1)
  71780. * @returns the new Vector3
  71781. */
  71782. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71783. /**
  71784. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71785. * @param start defines the start value
  71786. * @param end defines the end value
  71787. * @param amount max defines amount between both (between 0 and 1)
  71788. * @param result defines the Vector3 where to store the result
  71789. */
  71790. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71791. /**
  71792. * Returns the dot product (float) between the vectors "left" and "right"
  71793. * @param left defines the left operand
  71794. * @param right defines the right operand
  71795. * @returns the dot product
  71796. */
  71797. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71798. /**
  71799. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71800. * The cross product is then orthogonal to both "left" and "right"
  71801. * @param left defines the left operand
  71802. * @param right defines the right operand
  71803. * @returns the cross product
  71804. */
  71805. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71806. /**
  71807. * Sets the given vector "result" with the cross product of "left" and "right"
  71808. * The cross product is then orthogonal to both "left" and "right"
  71809. * @param left defines the left operand
  71810. * @param right defines the right operand
  71811. * @param result defines the Vector3 where to store the result
  71812. */
  71813. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71814. /**
  71815. * Returns a new Vector3 as the normalization of the given vector
  71816. * @param vector defines the Vector3 to normalize
  71817. * @returns the new Vector3
  71818. */
  71819. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71820. /**
  71821. * Sets the given vector "result" with the normalization of the given first vector
  71822. * @param vector defines the Vector3 to normalize
  71823. * @param result defines the Vector3 where to store the result
  71824. */
  71825. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71826. /**
  71827. * Project a Vector3 onto screen space
  71828. * @param vector defines the Vector3 to project
  71829. * @param world defines the world matrix to use
  71830. * @param transform defines the transform (view x projection) matrix to use
  71831. * @param viewport defines the screen viewport to use
  71832. * @returns the new Vector3
  71833. */
  71834. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71835. /** @hidden */
  71836. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71837. /**
  71838. * Unproject from screen space to object space
  71839. * @param source defines the screen space Vector3 to use
  71840. * @param viewportWidth defines the current width of the viewport
  71841. * @param viewportHeight defines the current height of the viewport
  71842. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71843. * @param transform defines the transform (view x projection) matrix to use
  71844. * @returns the new Vector3
  71845. */
  71846. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71847. /**
  71848. * Unproject from screen space to object space
  71849. * @param source defines the screen space Vector3 to use
  71850. * @param viewportWidth defines the current width of the viewport
  71851. * @param viewportHeight defines the current height of the viewport
  71852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71853. * @param view defines the view matrix to use
  71854. * @param projection defines the projection matrix to use
  71855. * @returns the new Vector3
  71856. */
  71857. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71858. /**
  71859. * Unproject from screen space to object space
  71860. * @param source defines the screen space Vector3 to use
  71861. * @param viewportWidth defines the current width of the viewport
  71862. * @param viewportHeight defines the current height of the viewport
  71863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71864. * @param view defines the view matrix to use
  71865. * @param projection defines the projection matrix to use
  71866. * @param result defines the Vector3 where to store the result
  71867. */
  71868. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71869. /**
  71870. * Unproject from screen space to object space
  71871. * @param sourceX defines the screen space x coordinate to use
  71872. * @param sourceY defines the screen space y coordinate to use
  71873. * @param sourceZ defines the screen space z coordinate to use
  71874. * @param viewportWidth defines the current width of the viewport
  71875. * @param viewportHeight defines the current height of the viewport
  71876. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71877. * @param view defines the view matrix to use
  71878. * @param projection defines the projection matrix to use
  71879. * @param result defines the Vector3 where to store the result
  71880. */
  71881. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71882. /**
  71883. * Gets the minimal coordinate values between two Vector3
  71884. * @param left defines the first operand
  71885. * @param right defines the second operand
  71886. * @returns the new Vector3
  71887. */
  71888. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71889. /**
  71890. * Gets the maximal coordinate values between two Vector3
  71891. * @param left defines the first operand
  71892. * @param right defines the second operand
  71893. * @returns the new Vector3
  71894. */
  71895. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71896. /**
  71897. * Returns the distance between the vectors "value1" and "value2"
  71898. * @param value1 defines the first operand
  71899. * @param value2 defines the second operand
  71900. * @returns the distance
  71901. */
  71902. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71903. /**
  71904. * Returns the squared distance between the vectors "value1" and "value2"
  71905. * @param value1 defines the first operand
  71906. * @param value2 defines the second operand
  71907. * @returns the squared distance
  71908. */
  71909. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71910. /**
  71911. * Returns a new Vector3 located at the center between "value1" and "value2"
  71912. * @param value1 defines the first operand
  71913. * @param value2 defines the second operand
  71914. * @returns the new Vector3
  71915. */
  71916. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71917. /**
  71918. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71919. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71920. * to something in order to rotate it from its local system to the given target system
  71921. * Note: axis1, axis2 and axis3 are normalized during this operation
  71922. * @param axis1 defines the first axis
  71923. * @param axis2 defines the second axis
  71924. * @param axis3 defines the third axis
  71925. * @returns a new Vector3
  71926. */
  71927. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71928. /**
  71929. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71930. * @param axis1 defines the first axis
  71931. * @param axis2 defines the second axis
  71932. * @param axis3 defines the third axis
  71933. * @param ref defines the Vector3 where to store the result
  71934. */
  71935. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71936. }
  71937. /**
  71938. * Vector4 class created for EulerAngle class conversion to Quaternion
  71939. */
  71940. export class Vector4 {
  71941. /** x value of the vector */
  71942. x: number;
  71943. /** y value of the vector */
  71944. y: number;
  71945. /** z value of the vector */
  71946. z: number;
  71947. /** w value of the vector */
  71948. w: number;
  71949. /**
  71950. * Creates a Vector4 object from the given floats.
  71951. * @param x x value of the vector
  71952. * @param y y value of the vector
  71953. * @param z z value of the vector
  71954. * @param w w value of the vector
  71955. */
  71956. constructor(
  71957. /** x value of the vector */
  71958. x: number,
  71959. /** y value of the vector */
  71960. y: number,
  71961. /** z value of the vector */
  71962. z: number,
  71963. /** w value of the vector */
  71964. w: number);
  71965. /**
  71966. * Returns the string with the Vector4 coordinates.
  71967. * @returns a string containing all the vector values
  71968. */
  71969. toString(): string;
  71970. /**
  71971. * Returns the string "Vector4".
  71972. * @returns "Vector4"
  71973. */
  71974. getClassName(): string;
  71975. /**
  71976. * Returns the Vector4 hash code.
  71977. * @returns a unique hash code
  71978. */
  71979. getHashCode(): number;
  71980. /**
  71981. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71982. * @returns the resulting array
  71983. */
  71984. asArray(): number[];
  71985. /**
  71986. * Populates the given array from the given index with the Vector4 coordinates.
  71987. * @param array array to populate
  71988. * @param index index of the array to start at (default: 0)
  71989. * @returns the Vector4.
  71990. */
  71991. toArray(array: FloatArray, index?: number): Vector4;
  71992. /**
  71993. * Adds the given vector to the current Vector4.
  71994. * @param otherVector the vector to add
  71995. * @returns the updated Vector4.
  71996. */
  71997. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71998. /**
  71999. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72000. * @param otherVector the vector to add
  72001. * @returns the resulting vector
  72002. */
  72003. add(otherVector: DeepImmutable<Vector4>): Vector4;
  72004. /**
  72005. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72006. * @param otherVector the vector to add
  72007. * @param result the vector to store the result
  72008. * @returns the current Vector4.
  72009. */
  72010. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72011. /**
  72012. * Subtract in place the given vector from the current Vector4.
  72013. * @param otherVector the vector to subtract
  72014. * @returns the updated Vector4.
  72015. */
  72016. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72017. /**
  72018. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72019. * @param otherVector the vector to add
  72020. * @returns the new vector with the result
  72021. */
  72022. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72023. /**
  72024. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72025. * @param otherVector the vector to subtract
  72026. * @param result the vector to store the result
  72027. * @returns the current Vector4.
  72028. */
  72029. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72030. /**
  72031. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72032. */
  72033. /**
  72034. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72035. * @param x value to subtract
  72036. * @param y value to subtract
  72037. * @param z value to subtract
  72038. * @param w value to subtract
  72039. * @returns new vector containing the result
  72040. */
  72041. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72042. /**
  72043. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72044. * @param x value to subtract
  72045. * @param y value to subtract
  72046. * @param z value to subtract
  72047. * @param w value to subtract
  72048. * @param result the vector to store the result in
  72049. * @returns the current Vector4.
  72050. */
  72051. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72052. /**
  72053. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72054. * @returns a new vector with the negated values
  72055. */
  72056. negate(): Vector4;
  72057. /**
  72058. * Multiplies the current Vector4 coordinates by scale (float).
  72059. * @param scale the number to scale with
  72060. * @returns the updated Vector4.
  72061. */
  72062. scaleInPlace(scale: number): Vector4;
  72063. /**
  72064. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72065. * @param scale the number to scale with
  72066. * @returns a new vector with the result
  72067. */
  72068. scale(scale: number): Vector4;
  72069. /**
  72070. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72071. * @param scale the number to scale with
  72072. * @param result a vector to store the result in
  72073. * @returns the current Vector4.
  72074. */
  72075. scaleToRef(scale: number, result: Vector4): Vector4;
  72076. /**
  72077. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72078. * @param scale defines the scale factor
  72079. * @param result defines the Vector4 object where to store the result
  72080. * @returns the unmodified current Vector4
  72081. */
  72082. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72083. /**
  72084. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72085. * @param otherVector the vector to compare against
  72086. * @returns true if they are equal
  72087. */
  72088. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72089. /**
  72090. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72091. * @param otherVector vector to compare against
  72092. * @param epsilon (Default: very small number)
  72093. * @returns true if they are equal
  72094. */
  72095. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72096. /**
  72097. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72098. * @param x x value to compare against
  72099. * @param y y value to compare against
  72100. * @param z z value to compare against
  72101. * @param w w value to compare against
  72102. * @returns true if equal
  72103. */
  72104. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72105. /**
  72106. * Multiplies in place the current Vector4 by the given one.
  72107. * @param otherVector vector to multiple with
  72108. * @returns the updated Vector4.
  72109. */
  72110. multiplyInPlace(otherVector: Vector4): Vector4;
  72111. /**
  72112. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72113. * @param otherVector vector to multiple with
  72114. * @returns resulting new vector
  72115. */
  72116. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72117. /**
  72118. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72119. * @param otherVector vector to multiple with
  72120. * @param result vector to store the result
  72121. * @returns the current Vector4.
  72122. */
  72123. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72124. /**
  72125. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72126. * @param x x value multiply with
  72127. * @param y y value multiply with
  72128. * @param z z value multiply with
  72129. * @param w w value multiply with
  72130. * @returns resulting new vector
  72131. */
  72132. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72133. /**
  72134. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72135. * @param otherVector vector to devide with
  72136. * @returns resulting new vector
  72137. */
  72138. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72139. /**
  72140. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72141. * @param otherVector vector to devide with
  72142. * @param result vector to store the result
  72143. * @returns the current Vector4.
  72144. */
  72145. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72146. /**
  72147. * Divides the current Vector3 coordinates by the given ones.
  72148. * @param otherVector vector to devide with
  72149. * @returns the updated Vector3.
  72150. */
  72151. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72152. /**
  72153. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72154. * @param other defines the second operand
  72155. * @returns the current updated Vector4
  72156. */
  72157. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72158. /**
  72159. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72160. * @param other defines the second operand
  72161. * @returns the current updated Vector4
  72162. */
  72163. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72164. /**
  72165. * Gets a new Vector4 from current Vector4 floored values
  72166. * @returns a new Vector4
  72167. */
  72168. floor(): Vector4;
  72169. /**
  72170. * Gets a new Vector4 from current Vector3 floored values
  72171. * @returns a new Vector4
  72172. */
  72173. fract(): Vector4;
  72174. /**
  72175. * Returns the Vector4 length (float).
  72176. * @returns the length
  72177. */
  72178. length(): number;
  72179. /**
  72180. * Returns the Vector4 squared length (float).
  72181. * @returns the length squared
  72182. */
  72183. lengthSquared(): number;
  72184. /**
  72185. * Normalizes in place the Vector4.
  72186. * @returns the updated Vector4.
  72187. */
  72188. normalize(): Vector4;
  72189. /**
  72190. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72191. * @returns this converted to a new vector3
  72192. */
  72193. toVector3(): Vector3;
  72194. /**
  72195. * Returns a new Vector4 copied from the current one.
  72196. * @returns the new cloned vector
  72197. */
  72198. clone(): Vector4;
  72199. /**
  72200. * Updates the current Vector4 with the given one coordinates.
  72201. * @param source the source vector to copy from
  72202. * @returns the updated Vector4.
  72203. */
  72204. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72205. /**
  72206. * Updates the current Vector4 coordinates with the given floats.
  72207. * @param x float to copy from
  72208. * @param y float to copy from
  72209. * @param z float to copy from
  72210. * @param w float to copy from
  72211. * @returns the updated Vector4.
  72212. */
  72213. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72214. /**
  72215. * Updates the current Vector4 coordinates with the given floats.
  72216. * @param x float to set from
  72217. * @param y float to set from
  72218. * @param z float to set from
  72219. * @param w float to set from
  72220. * @returns the updated Vector4.
  72221. */
  72222. set(x: number, y: number, z: number, w: number): Vector4;
  72223. /**
  72224. * Copies the given float to the current Vector3 coordinates
  72225. * @param v defines the x, y, z and w coordinates of the operand
  72226. * @returns the current updated Vector3
  72227. */
  72228. setAll(v: number): Vector4;
  72229. /**
  72230. * Returns a new Vector4 set from the starting index of the given array.
  72231. * @param array the array to pull values from
  72232. * @param offset the offset into the array to start at
  72233. * @returns the new vector
  72234. */
  72235. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72236. /**
  72237. * Updates the given vector "result" from the starting index of the given array.
  72238. * @param array the array to pull values from
  72239. * @param offset the offset into the array to start at
  72240. * @param result the vector to store the result in
  72241. */
  72242. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72243. /**
  72244. * Updates the given vector "result" from the starting index of the given Float32Array.
  72245. * @param array the array to pull values from
  72246. * @param offset the offset into the array to start at
  72247. * @param result the vector to store the result in
  72248. */
  72249. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72250. /**
  72251. * Updates the given vector "result" coordinates from the given floats.
  72252. * @param x float to set from
  72253. * @param y float to set from
  72254. * @param z float to set from
  72255. * @param w float to set from
  72256. * @param result the vector to the floats in
  72257. */
  72258. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72259. /**
  72260. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72261. * @returns the new vector
  72262. */
  72263. static Zero(): Vector4;
  72264. /**
  72265. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72266. * @returns the new vector
  72267. */
  72268. static One(): Vector4;
  72269. /**
  72270. * Returns a new normalized Vector4 from the given one.
  72271. * @param vector the vector to normalize
  72272. * @returns the vector
  72273. */
  72274. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72275. /**
  72276. * Updates the given vector "result" from the normalization of the given one.
  72277. * @param vector the vector to normalize
  72278. * @param result the vector to store the result in
  72279. */
  72280. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72281. /**
  72282. * Returns a vector with the minimum values from the left and right vectors
  72283. * @param left left vector to minimize
  72284. * @param right right vector to minimize
  72285. * @returns a new vector with the minimum of the left and right vector values
  72286. */
  72287. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72288. /**
  72289. * Returns a vector with the maximum values from the left and right vectors
  72290. * @param left left vector to maximize
  72291. * @param right right vector to maximize
  72292. * @returns a new vector with the maximum of the left and right vector values
  72293. */
  72294. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72295. /**
  72296. * Returns the distance (float) between the vectors "value1" and "value2".
  72297. * @param value1 value to calulate the distance between
  72298. * @param value2 value to calulate the distance between
  72299. * @return the distance between the two vectors
  72300. */
  72301. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72302. /**
  72303. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72304. * @param value1 value to calulate the distance between
  72305. * @param value2 value to calulate the distance between
  72306. * @return the distance between the two vectors squared
  72307. */
  72308. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72309. /**
  72310. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72311. * @param value1 value to calulate the center between
  72312. * @param value2 value to calulate the center between
  72313. * @return the center between the two vectors
  72314. */
  72315. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72316. /**
  72317. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72318. * This methods computes transformed normalized direction vectors only.
  72319. * @param vector the vector to transform
  72320. * @param transformation the transformation matrix to apply
  72321. * @returns the new vector
  72322. */
  72323. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72324. /**
  72325. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72326. * This methods computes transformed normalized direction vectors only.
  72327. * @param vector the vector to transform
  72328. * @param transformation the transformation matrix to apply
  72329. * @param result the vector to store the result in
  72330. */
  72331. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72332. /**
  72333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72334. * This methods computes transformed normalized direction vectors only.
  72335. * @param x value to transform
  72336. * @param y value to transform
  72337. * @param z value to transform
  72338. * @param w value to transform
  72339. * @param transformation the transformation matrix to apply
  72340. * @param result the vector to store the results in
  72341. */
  72342. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72343. /**
  72344. * Creates a new Vector4 from a Vector3
  72345. * @param source defines the source data
  72346. * @param w defines the 4th component (default is 0)
  72347. * @returns a new Vector4
  72348. */
  72349. static FromVector3(source: Vector3, w?: number): Vector4;
  72350. }
  72351. /**
  72352. * Class used to store quaternion data
  72353. * @see https://en.wikipedia.org/wiki/Quaternion
  72354. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72355. */
  72356. export class Quaternion {
  72357. /** defines the first component (0 by default) */
  72358. x: number;
  72359. /** defines the second component (0 by default) */
  72360. y: number;
  72361. /** defines the third component (0 by default) */
  72362. z: number;
  72363. /** defines the fourth component (1.0 by default) */
  72364. w: number;
  72365. /**
  72366. * Creates a new Quaternion from the given floats
  72367. * @param x defines the first component (0 by default)
  72368. * @param y defines the second component (0 by default)
  72369. * @param z defines the third component (0 by default)
  72370. * @param w defines the fourth component (1.0 by default)
  72371. */
  72372. constructor(
  72373. /** defines the first component (0 by default) */
  72374. x?: number,
  72375. /** defines the second component (0 by default) */
  72376. y?: number,
  72377. /** defines the third component (0 by default) */
  72378. z?: number,
  72379. /** defines the fourth component (1.0 by default) */
  72380. w?: number);
  72381. /**
  72382. * Gets a string representation for the current quaternion
  72383. * @returns a string with the Quaternion coordinates
  72384. */
  72385. toString(): string;
  72386. /**
  72387. * Gets the class name of the quaternion
  72388. * @returns the string "Quaternion"
  72389. */
  72390. getClassName(): string;
  72391. /**
  72392. * Gets a hash code for this quaternion
  72393. * @returns the quaternion hash code
  72394. */
  72395. getHashCode(): number;
  72396. /**
  72397. * Copy the quaternion to an array
  72398. * @returns a new array populated with 4 elements from the quaternion coordinates
  72399. */
  72400. asArray(): number[];
  72401. /**
  72402. * Check if two quaternions are equals
  72403. * @param otherQuaternion defines the second operand
  72404. * @return true if the current quaternion and the given one coordinates are strictly equals
  72405. */
  72406. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72407. /**
  72408. * Clone the current quaternion
  72409. * @returns a new quaternion copied from the current one
  72410. */
  72411. clone(): Quaternion;
  72412. /**
  72413. * Copy a quaternion to the current one
  72414. * @param other defines the other quaternion
  72415. * @returns the updated current quaternion
  72416. */
  72417. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72418. /**
  72419. * Updates the current quaternion with the given float coordinates
  72420. * @param x defines the x coordinate
  72421. * @param y defines the y coordinate
  72422. * @param z defines the z coordinate
  72423. * @param w defines the w coordinate
  72424. * @returns the updated current quaternion
  72425. */
  72426. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72427. /**
  72428. * Updates the current quaternion from the given float coordinates
  72429. * @param x defines the x coordinate
  72430. * @param y defines the y coordinate
  72431. * @param z defines the z coordinate
  72432. * @param w defines the w coordinate
  72433. * @returns the updated current quaternion
  72434. */
  72435. set(x: number, y: number, z: number, w: number): Quaternion;
  72436. /**
  72437. * Adds two quaternions
  72438. * @param other defines the second operand
  72439. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72440. */
  72441. add(other: DeepImmutable<Quaternion>): Quaternion;
  72442. /**
  72443. * Add a quaternion to the current one
  72444. * @param other defines the quaternion to add
  72445. * @returns the current quaternion
  72446. */
  72447. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72448. /**
  72449. * Subtract two quaternions
  72450. * @param other defines the second operand
  72451. * @returns a new quaternion as the subtraction result of the given one from the current one
  72452. */
  72453. subtract(other: Quaternion): Quaternion;
  72454. /**
  72455. * Multiplies the current quaternion by a scale factor
  72456. * @param value defines the scale factor
  72457. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72458. */
  72459. scale(value: number): Quaternion;
  72460. /**
  72461. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72462. * @param scale defines the scale factor
  72463. * @param result defines the Quaternion object where to store the result
  72464. * @returns the unmodified current quaternion
  72465. */
  72466. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72467. /**
  72468. * Multiplies in place the current quaternion by a scale factor
  72469. * @param value defines the scale factor
  72470. * @returns the current modified quaternion
  72471. */
  72472. scaleInPlace(value: number): Quaternion;
  72473. /**
  72474. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72475. * @param scale defines the scale factor
  72476. * @param result defines the Quaternion object where to store the result
  72477. * @returns the unmodified current quaternion
  72478. */
  72479. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72480. /**
  72481. * Multiplies two quaternions
  72482. * @param q1 defines the second operand
  72483. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72484. */
  72485. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72486. /**
  72487. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72488. * @param q1 defines the second operand
  72489. * @param result defines the target quaternion
  72490. * @returns the current quaternion
  72491. */
  72492. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72493. /**
  72494. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72495. * @param q1 defines the second operand
  72496. * @returns the currentupdated quaternion
  72497. */
  72498. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72499. /**
  72500. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72501. * @param ref defines the target quaternion
  72502. * @returns the current quaternion
  72503. */
  72504. conjugateToRef(ref: Quaternion): Quaternion;
  72505. /**
  72506. * Conjugates in place (1-q) the current quaternion
  72507. * @returns the current updated quaternion
  72508. */
  72509. conjugateInPlace(): Quaternion;
  72510. /**
  72511. * Conjugates in place (1-q) the current quaternion
  72512. * @returns a new quaternion
  72513. */
  72514. conjugate(): Quaternion;
  72515. /**
  72516. * Gets length of current quaternion
  72517. * @returns the quaternion length (float)
  72518. */
  72519. length(): number;
  72520. /**
  72521. * Normalize in place the current quaternion
  72522. * @returns the current updated quaternion
  72523. */
  72524. normalize(): Quaternion;
  72525. /**
  72526. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72527. * @param order is a reserved parameter and is ignore for now
  72528. * @returns a new Vector3 containing the Euler angles
  72529. */
  72530. toEulerAngles(order?: string): Vector3;
  72531. /**
  72532. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72533. * @param result defines the vector which will be filled with the Euler angles
  72534. * @param order is a reserved parameter and is ignore for now
  72535. * @returns the current unchanged quaternion
  72536. */
  72537. toEulerAnglesToRef(result: Vector3): Quaternion;
  72538. /**
  72539. * Updates the given rotation matrix with the current quaternion values
  72540. * @param result defines the target matrix
  72541. * @returns the current unchanged quaternion
  72542. */
  72543. toRotationMatrix(result: Matrix): Quaternion;
  72544. /**
  72545. * Updates the current quaternion from the given rotation matrix values
  72546. * @param matrix defines the source matrix
  72547. * @returns the current updated quaternion
  72548. */
  72549. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72550. /**
  72551. * Creates a new quaternion from a rotation matrix
  72552. * @param matrix defines the source matrix
  72553. * @returns a new quaternion created from the given rotation matrix values
  72554. */
  72555. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72556. /**
  72557. * Updates the given quaternion with the given rotation matrix values
  72558. * @param matrix defines the source matrix
  72559. * @param result defines the target quaternion
  72560. */
  72561. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72562. /**
  72563. * Returns the dot product (float) between the quaternions "left" and "right"
  72564. * @param left defines the left operand
  72565. * @param right defines the right operand
  72566. * @returns the dot product
  72567. */
  72568. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72569. /**
  72570. * Checks if the two quaternions are close to each other
  72571. * @param quat0 defines the first quaternion to check
  72572. * @param quat1 defines the second quaternion to check
  72573. * @returns true if the two quaternions are close to each other
  72574. */
  72575. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72576. /**
  72577. * Creates an empty quaternion
  72578. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72579. */
  72580. static Zero(): Quaternion;
  72581. /**
  72582. * Inverse a given quaternion
  72583. * @param q defines the source quaternion
  72584. * @returns a new quaternion as the inverted current quaternion
  72585. */
  72586. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72587. /**
  72588. * Inverse a given quaternion
  72589. * @param q defines the source quaternion
  72590. * @param result the quaternion the result will be stored in
  72591. * @returns the result quaternion
  72592. */
  72593. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72594. /**
  72595. * Creates an identity quaternion
  72596. * @returns the identity quaternion
  72597. */
  72598. static Identity(): Quaternion;
  72599. /**
  72600. * Gets a boolean indicating if the given quaternion is identity
  72601. * @param quaternion defines the quaternion to check
  72602. * @returns true if the quaternion is identity
  72603. */
  72604. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72605. /**
  72606. * Creates a quaternion from a rotation around an axis
  72607. * @param axis defines the axis to use
  72608. * @param angle defines the angle to use
  72609. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72610. */
  72611. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72612. /**
  72613. * Creates a rotation around an axis and stores it into the given quaternion
  72614. * @param axis defines the axis to use
  72615. * @param angle defines the angle to use
  72616. * @param result defines the target quaternion
  72617. * @returns the target quaternion
  72618. */
  72619. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72620. /**
  72621. * Creates a new quaternion from data stored into an array
  72622. * @param array defines the data source
  72623. * @param offset defines the offset in the source array where the data starts
  72624. * @returns a new quaternion
  72625. */
  72626. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72627. /**
  72628. * Create a quaternion from Euler rotation angles
  72629. * @param x Pitch
  72630. * @param y Yaw
  72631. * @param z Roll
  72632. * @returns the new Quaternion
  72633. */
  72634. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72635. /**
  72636. * Updates a quaternion from Euler rotation angles
  72637. * @param x Pitch
  72638. * @param y Yaw
  72639. * @param z Roll
  72640. * @param result the quaternion to store the result
  72641. * @returns the updated quaternion
  72642. */
  72643. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72644. /**
  72645. * Create a quaternion from Euler rotation vector
  72646. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72647. * @returns the new Quaternion
  72648. */
  72649. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72650. /**
  72651. * Updates a quaternion from Euler rotation vector
  72652. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72653. * @param result the quaternion to store the result
  72654. * @returns the updated quaternion
  72655. */
  72656. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72657. /**
  72658. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72659. * @param yaw defines the rotation around Y axis
  72660. * @param pitch defines the rotation around X axis
  72661. * @param roll defines the rotation around Z axis
  72662. * @returns the new quaternion
  72663. */
  72664. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72665. /**
  72666. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72667. * @param yaw defines the rotation around Y axis
  72668. * @param pitch defines the rotation around X axis
  72669. * @param roll defines the rotation around Z axis
  72670. * @param result defines the target quaternion
  72671. */
  72672. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72673. /**
  72674. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72675. * @param alpha defines the rotation around first axis
  72676. * @param beta defines the rotation around second axis
  72677. * @param gamma defines the rotation around third axis
  72678. * @returns the new quaternion
  72679. */
  72680. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72681. /**
  72682. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72683. * @param alpha defines the rotation around first axis
  72684. * @param beta defines the rotation around second axis
  72685. * @param gamma defines the rotation around third axis
  72686. * @param result defines the target quaternion
  72687. */
  72688. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72689. /**
  72690. * 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)
  72691. * @param axis1 defines the first axis
  72692. * @param axis2 defines the second axis
  72693. * @param axis3 defines the third axis
  72694. * @returns the new quaternion
  72695. */
  72696. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72697. /**
  72698. * 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
  72699. * @param axis1 defines the first axis
  72700. * @param axis2 defines the second axis
  72701. * @param axis3 defines the third axis
  72702. * @param ref defines the target quaternion
  72703. */
  72704. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72705. /**
  72706. * Interpolates between two quaternions
  72707. * @param left defines first quaternion
  72708. * @param right defines second quaternion
  72709. * @param amount defines the gradient to use
  72710. * @returns the new interpolated quaternion
  72711. */
  72712. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72713. /**
  72714. * Interpolates between two quaternions and stores it into a target quaternion
  72715. * @param left defines first quaternion
  72716. * @param right defines second quaternion
  72717. * @param amount defines the gradient to use
  72718. * @param result defines the target quaternion
  72719. */
  72720. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72721. /**
  72722. * Interpolate between two quaternions using Hermite interpolation
  72723. * @param value1 defines first quaternion
  72724. * @param tangent1 defines the incoming tangent
  72725. * @param value2 defines second quaternion
  72726. * @param tangent2 defines the outgoing tangent
  72727. * @param amount defines the target quaternion
  72728. * @returns the new interpolated quaternion
  72729. */
  72730. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72731. }
  72732. /**
  72733. * Class used to store matrix data (4x4)
  72734. */
  72735. export class Matrix {
  72736. private static _updateFlagSeed;
  72737. private static _identityReadOnly;
  72738. private _isIdentity;
  72739. private _isIdentityDirty;
  72740. private _isIdentity3x2;
  72741. private _isIdentity3x2Dirty;
  72742. /**
  72743. * Gets the update flag of the matrix which is an unique number for the matrix.
  72744. * It will be incremented every time the matrix data change.
  72745. * You can use it to speed the comparison between two versions of the same matrix.
  72746. */
  72747. updateFlag: number;
  72748. private readonly _m;
  72749. /**
  72750. * Gets the internal data of the matrix
  72751. */
  72752. readonly m: DeepImmutable<Float32Array>;
  72753. /** @hidden */
  72754. _markAsUpdated(): void;
  72755. /** @hidden */
  72756. private _updateIdentityStatus;
  72757. /**
  72758. * Creates an empty matrix (filled with zeros)
  72759. */
  72760. constructor();
  72761. /**
  72762. * Check if the current matrix is identity
  72763. * @returns true is the matrix is the identity matrix
  72764. */
  72765. isIdentity(): boolean;
  72766. /**
  72767. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72768. * @returns true is the matrix is the identity matrix
  72769. */
  72770. isIdentityAs3x2(): boolean;
  72771. /**
  72772. * Gets the determinant of the matrix
  72773. * @returns the matrix determinant
  72774. */
  72775. determinant(): number;
  72776. /**
  72777. * Returns the matrix as a Float32Array
  72778. * @returns the matrix underlying array
  72779. */
  72780. toArray(): DeepImmutable<Float32Array>;
  72781. /**
  72782. * Returns the matrix as a Float32Array
  72783. * @returns the matrix underlying array.
  72784. */
  72785. asArray(): DeepImmutable<Float32Array>;
  72786. /**
  72787. * Inverts the current matrix in place
  72788. * @returns the current inverted matrix
  72789. */
  72790. invert(): Matrix;
  72791. /**
  72792. * Sets all the matrix elements to zero
  72793. * @returns the current matrix
  72794. */
  72795. reset(): Matrix;
  72796. /**
  72797. * Adds the current matrix with a second one
  72798. * @param other defines the matrix to add
  72799. * @returns a new matrix as the addition of the current matrix and the given one
  72800. */
  72801. add(other: DeepImmutable<Matrix>): Matrix;
  72802. /**
  72803. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72804. * @param other defines the matrix to add
  72805. * @param result defines the target matrix
  72806. * @returns the current matrix
  72807. */
  72808. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72809. /**
  72810. * Adds in place the given matrix to the current matrix
  72811. * @param other defines the second operand
  72812. * @returns the current updated matrix
  72813. */
  72814. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72815. /**
  72816. * Sets the given matrix to the current inverted Matrix
  72817. * @param other defines the target matrix
  72818. * @returns the unmodified current matrix
  72819. */
  72820. invertToRef(other: Matrix): Matrix;
  72821. /**
  72822. * add a value at the specified position in the current Matrix
  72823. * @param index the index of the value within the matrix. between 0 and 15.
  72824. * @param value the value to be added
  72825. * @returns the current updated matrix
  72826. */
  72827. addAtIndex(index: number, value: number): Matrix;
  72828. /**
  72829. * mutiply the specified position in the current Matrix by a value
  72830. * @param index the index of the value within the matrix. between 0 and 15.
  72831. * @param value the value to be added
  72832. * @returns the current updated matrix
  72833. */
  72834. multiplyAtIndex(index: number, value: number): Matrix;
  72835. /**
  72836. * Inserts the translation vector (using 3 floats) in the current matrix
  72837. * @param x defines the 1st component of the translation
  72838. * @param y defines the 2nd component of the translation
  72839. * @param z defines the 3rd component of the translation
  72840. * @returns the current updated matrix
  72841. */
  72842. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72843. /**
  72844. * Adds the translation vector (using 3 floats) in the current matrix
  72845. * @param x defines the 1st component of the translation
  72846. * @param y defines the 2nd component of the translation
  72847. * @param z defines the 3rd component of the translation
  72848. * @returns the current updated matrix
  72849. */
  72850. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72851. /**
  72852. * Inserts the translation vector in the current matrix
  72853. * @param vector3 defines the translation to insert
  72854. * @returns the current updated matrix
  72855. */
  72856. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72857. /**
  72858. * Gets the translation value of the current matrix
  72859. * @returns a new Vector3 as the extracted translation from the matrix
  72860. */
  72861. getTranslation(): Vector3;
  72862. /**
  72863. * Fill a Vector3 with the extracted translation from the matrix
  72864. * @param result defines the Vector3 where to store the translation
  72865. * @returns the current matrix
  72866. */
  72867. getTranslationToRef(result: Vector3): Matrix;
  72868. /**
  72869. * Remove rotation and scaling part from the matrix
  72870. * @returns the updated matrix
  72871. */
  72872. removeRotationAndScaling(): Matrix;
  72873. /**
  72874. * Multiply two matrices
  72875. * @param other defines the second operand
  72876. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72877. */
  72878. multiply(other: DeepImmutable<Matrix>): Matrix;
  72879. /**
  72880. * Copy the current matrix from the given one
  72881. * @param other defines the source matrix
  72882. * @returns the current updated matrix
  72883. */
  72884. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72885. /**
  72886. * Populates the given array from the starting index with the current matrix values
  72887. * @param array defines the target array
  72888. * @param offset defines the offset in the target array where to start storing values
  72889. * @returns the current matrix
  72890. */
  72891. copyToArray(array: Float32Array, offset?: number): Matrix;
  72892. /**
  72893. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72894. * @param other defines the second operand
  72895. * @param result defines the matrix where to store the multiplication
  72896. * @returns the current matrix
  72897. */
  72898. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72899. /**
  72900. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72901. * @param other defines the second operand
  72902. * @param result defines the array where to store the multiplication
  72903. * @param offset defines the offset in the target array where to start storing values
  72904. * @returns the current matrix
  72905. */
  72906. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72907. /**
  72908. * Check equality between this matrix and a second one
  72909. * @param value defines the second matrix to compare
  72910. * @returns true is the current matrix and the given one values are strictly equal
  72911. */
  72912. equals(value: DeepImmutable<Matrix>): boolean;
  72913. /**
  72914. * Clone the current matrix
  72915. * @returns a new matrix from the current matrix
  72916. */
  72917. clone(): Matrix;
  72918. /**
  72919. * Returns the name of the current matrix class
  72920. * @returns the string "Matrix"
  72921. */
  72922. getClassName(): string;
  72923. /**
  72924. * Gets the hash code of the current matrix
  72925. * @returns the hash code
  72926. */
  72927. getHashCode(): number;
  72928. /**
  72929. * Decomposes the current Matrix into a translation, rotation and scaling components
  72930. * @param scale defines the scale vector3 given as a reference to update
  72931. * @param rotation defines the rotation quaternion given as a reference to update
  72932. * @param translation defines the translation vector3 given as a reference to update
  72933. * @returns true if operation was successful
  72934. */
  72935. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72936. /**
  72937. * Gets specific row of the matrix
  72938. * @param index defines the number of the row to get
  72939. * @returns the index-th row of the current matrix as a new Vector4
  72940. */
  72941. getRow(index: number): Nullable<Vector4>;
  72942. /**
  72943. * Sets the index-th row of the current matrix to the vector4 values
  72944. * @param index defines the number of the row to set
  72945. * @param row defines the target vector4
  72946. * @returns the updated current matrix
  72947. */
  72948. setRow(index: number, row: Vector4): Matrix;
  72949. /**
  72950. * Compute the transpose of the matrix
  72951. * @returns the new transposed matrix
  72952. */
  72953. transpose(): Matrix;
  72954. /**
  72955. * Compute the transpose of the matrix and store it in a given matrix
  72956. * @param result defines the target matrix
  72957. * @returns the current matrix
  72958. */
  72959. transposeToRef(result: Matrix): Matrix;
  72960. /**
  72961. * Sets the index-th row of the current matrix with the given 4 x float values
  72962. * @param index defines the row index
  72963. * @param x defines the x component to set
  72964. * @param y defines the y component to set
  72965. * @param z defines the z component to set
  72966. * @param w defines the w component to set
  72967. * @returns the updated current matrix
  72968. */
  72969. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72970. /**
  72971. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72972. * @param scale defines the scale factor
  72973. * @returns a new matrix
  72974. */
  72975. scale(scale: number): Matrix;
  72976. /**
  72977. * Scale the current matrix values by a factor to a given result matrix
  72978. * @param scale defines the scale factor
  72979. * @param result defines the matrix to store the result
  72980. * @returns the current matrix
  72981. */
  72982. scaleToRef(scale: number, result: Matrix): Matrix;
  72983. /**
  72984. * Scale the current matrix values by a factor and add the result to a given matrix
  72985. * @param scale defines the scale factor
  72986. * @param result defines the Matrix to store the result
  72987. * @returns the current matrix
  72988. */
  72989. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72990. /**
  72991. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72992. * @param ref matrix to store the result
  72993. */
  72994. toNormalMatrix(ref: Matrix): void;
  72995. /**
  72996. * Gets only rotation part of the current matrix
  72997. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72998. */
  72999. getRotationMatrix(): Matrix;
  73000. /**
  73001. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73002. * @param result defines the target matrix to store data to
  73003. * @returns the current matrix
  73004. */
  73005. getRotationMatrixToRef(result: Matrix): Matrix;
  73006. /**
  73007. * Toggles model matrix from being right handed to left handed in place and vice versa
  73008. */
  73009. toggleModelMatrixHandInPlace(): void;
  73010. /**
  73011. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73012. */
  73013. toggleProjectionMatrixHandInPlace(): void;
  73014. /**
  73015. * Creates a matrix from an array
  73016. * @param array defines the source array
  73017. * @param offset defines an offset in the source array
  73018. * @returns a new Matrix set from the starting index of the given array
  73019. */
  73020. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73021. /**
  73022. * Copy the content of an array into a given matrix
  73023. * @param array defines the source array
  73024. * @param offset defines an offset in the source array
  73025. * @param result defines the target matrix
  73026. */
  73027. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73028. /**
  73029. * Stores an array into a matrix after having multiplied each component by a given factor
  73030. * @param array defines the source array
  73031. * @param offset defines the offset in the source array
  73032. * @param scale defines the scaling factor
  73033. * @param result defines the target matrix
  73034. */
  73035. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73036. /**
  73037. * Gets an identity matrix that must not be updated
  73038. */
  73039. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73040. /**
  73041. * Stores a list of values (16) inside a given matrix
  73042. * @param initialM11 defines 1st value of 1st row
  73043. * @param initialM12 defines 2nd value of 1st row
  73044. * @param initialM13 defines 3rd value of 1st row
  73045. * @param initialM14 defines 4th value of 1st row
  73046. * @param initialM21 defines 1st value of 2nd row
  73047. * @param initialM22 defines 2nd value of 2nd row
  73048. * @param initialM23 defines 3rd value of 2nd row
  73049. * @param initialM24 defines 4th value of 2nd row
  73050. * @param initialM31 defines 1st value of 3rd row
  73051. * @param initialM32 defines 2nd value of 3rd row
  73052. * @param initialM33 defines 3rd value of 3rd row
  73053. * @param initialM34 defines 4th value of 3rd row
  73054. * @param initialM41 defines 1st value of 4th row
  73055. * @param initialM42 defines 2nd value of 4th row
  73056. * @param initialM43 defines 3rd value of 4th row
  73057. * @param initialM44 defines 4th value of 4th row
  73058. * @param result defines the target matrix
  73059. */
  73060. 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;
  73061. /**
  73062. * Creates new matrix from a list of values (16)
  73063. * @param initialM11 defines 1st value of 1st row
  73064. * @param initialM12 defines 2nd value of 1st row
  73065. * @param initialM13 defines 3rd value of 1st row
  73066. * @param initialM14 defines 4th value of 1st row
  73067. * @param initialM21 defines 1st value of 2nd row
  73068. * @param initialM22 defines 2nd value of 2nd row
  73069. * @param initialM23 defines 3rd value of 2nd row
  73070. * @param initialM24 defines 4th value of 2nd row
  73071. * @param initialM31 defines 1st value of 3rd row
  73072. * @param initialM32 defines 2nd value of 3rd row
  73073. * @param initialM33 defines 3rd value of 3rd row
  73074. * @param initialM34 defines 4th value of 3rd row
  73075. * @param initialM41 defines 1st value of 4th row
  73076. * @param initialM42 defines 2nd value of 4th row
  73077. * @param initialM43 defines 3rd value of 4th row
  73078. * @param initialM44 defines 4th value of 4th row
  73079. * @returns the new matrix
  73080. */
  73081. 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;
  73082. /**
  73083. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73084. * @param scale defines the scale vector3
  73085. * @param rotation defines the rotation quaternion
  73086. * @param translation defines the translation vector3
  73087. * @returns a new matrix
  73088. */
  73089. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73090. /**
  73091. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73092. * @param scale defines the scale vector3
  73093. * @param rotation defines the rotation quaternion
  73094. * @param translation defines the translation vector3
  73095. * @param result defines the target matrix
  73096. */
  73097. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73098. /**
  73099. * Creates a new identity matrix
  73100. * @returns a new identity matrix
  73101. */
  73102. static Identity(): Matrix;
  73103. /**
  73104. * Creates a new identity matrix and stores the result in a given matrix
  73105. * @param result defines the target matrix
  73106. */
  73107. static IdentityToRef(result: Matrix): void;
  73108. /**
  73109. * Creates a new zero matrix
  73110. * @returns a new zero matrix
  73111. */
  73112. static Zero(): Matrix;
  73113. /**
  73114. * Creates a new rotation matrix for "angle" radians around the X axis
  73115. * @param angle defines the angle (in radians) to use
  73116. * @return the new matrix
  73117. */
  73118. static RotationX(angle: number): Matrix;
  73119. /**
  73120. * Creates a new matrix as the invert of a given matrix
  73121. * @param source defines the source matrix
  73122. * @returns the new matrix
  73123. */
  73124. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73125. /**
  73126. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73127. * @param angle defines the angle (in radians) to use
  73128. * @param result defines the target matrix
  73129. */
  73130. static RotationXToRef(angle: number, result: Matrix): void;
  73131. /**
  73132. * Creates a new rotation matrix for "angle" radians around the Y axis
  73133. * @param angle defines the angle (in radians) to use
  73134. * @return the new matrix
  73135. */
  73136. static RotationY(angle: number): Matrix;
  73137. /**
  73138. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73139. * @param angle defines the angle (in radians) to use
  73140. * @param result defines the target matrix
  73141. */
  73142. static RotationYToRef(angle: number, result: Matrix): void;
  73143. /**
  73144. * Creates a new rotation matrix for "angle" radians around the Z axis
  73145. * @param angle defines the angle (in radians) to use
  73146. * @return the new matrix
  73147. */
  73148. static RotationZ(angle: number): Matrix;
  73149. /**
  73150. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73151. * @param angle defines the angle (in radians) to use
  73152. * @param result defines the target matrix
  73153. */
  73154. static RotationZToRef(angle: number, result: Matrix): void;
  73155. /**
  73156. * Creates a new rotation matrix for "angle" radians around the given axis
  73157. * @param axis defines the axis to use
  73158. * @param angle defines the angle (in radians) to use
  73159. * @return the new matrix
  73160. */
  73161. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73162. /**
  73163. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73164. * @param axis defines the axis to use
  73165. * @param angle defines the angle (in radians) to use
  73166. * @param result defines the target matrix
  73167. */
  73168. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73169. /**
  73170. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73171. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73172. * @param from defines the vector to align
  73173. * @param to defines the vector to align to
  73174. * @param result defines the target matrix
  73175. */
  73176. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73177. /**
  73178. * Creates a rotation matrix
  73179. * @param yaw defines the yaw angle in radians (Y axis)
  73180. * @param pitch defines the pitch angle in radians (X axis)
  73181. * @param roll defines the roll angle in radians (X axis)
  73182. * @returns the new rotation matrix
  73183. */
  73184. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73185. /**
  73186. * Creates a rotation matrix and stores it in a given matrix
  73187. * @param yaw defines the yaw angle in radians (Y axis)
  73188. * @param pitch defines the pitch angle in radians (X axis)
  73189. * @param roll defines the roll angle in radians (X axis)
  73190. * @param result defines the target matrix
  73191. */
  73192. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73193. /**
  73194. * Creates a scaling matrix
  73195. * @param x defines the scale factor on X axis
  73196. * @param y defines the scale factor on Y axis
  73197. * @param z defines the scale factor on Z axis
  73198. * @returns the new matrix
  73199. */
  73200. static Scaling(x: number, y: number, z: number): Matrix;
  73201. /**
  73202. * Creates a scaling matrix and stores it in a given matrix
  73203. * @param x defines the scale factor on X axis
  73204. * @param y defines the scale factor on Y axis
  73205. * @param z defines the scale factor on Z axis
  73206. * @param result defines the target matrix
  73207. */
  73208. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73209. /**
  73210. * Creates a translation matrix
  73211. * @param x defines the translation on X axis
  73212. * @param y defines the translation on Y axis
  73213. * @param z defines the translationon Z axis
  73214. * @returns the new matrix
  73215. */
  73216. static Translation(x: number, y: number, z: number): Matrix;
  73217. /**
  73218. * Creates a translation matrix and stores it in a given matrix
  73219. * @param x defines the translation on X axis
  73220. * @param y defines the translation on Y axis
  73221. * @param z defines the translationon Z axis
  73222. * @param result defines the target matrix
  73223. */
  73224. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73225. /**
  73226. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73227. * @param startValue defines the start value
  73228. * @param endValue defines the end value
  73229. * @param gradient defines the gradient factor
  73230. * @returns the new matrix
  73231. */
  73232. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73233. /**
  73234. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73235. * @param startValue defines the start value
  73236. * @param endValue defines the end value
  73237. * @param gradient defines the gradient factor
  73238. * @param result defines the Matrix object where to store data
  73239. */
  73240. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73241. /**
  73242. * Builds a new matrix whose values are computed by:
  73243. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73244. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73245. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73246. * @param startValue defines the first matrix
  73247. * @param endValue defines the second matrix
  73248. * @param gradient defines the gradient between the two matrices
  73249. * @returns the new matrix
  73250. */
  73251. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73252. /**
  73253. * Update a matrix to values which are computed by:
  73254. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73255. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73256. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73257. * @param startValue defines the first matrix
  73258. * @param endValue defines the second matrix
  73259. * @param gradient defines the gradient between the two matrices
  73260. * @param result defines the target matrix
  73261. */
  73262. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73263. /**
  73264. * 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"
  73265. * This function works in left handed mode
  73266. * @param eye defines the final position of the entity
  73267. * @param target defines where the entity should look at
  73268. * @param up defines the up vector for the entity
  73269. * @returns the new matrix
  73270. */
  73271. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73272. /**
  73273. * 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".
  73274. * This function works in left handed mode
  73275. * @param eye defines the final position of the entity
  73276. * @param target defines where the entity should look at
  73277. * @param up defines the up vector for the entity
  73278. * @param result defines the target matrix
  73279. */
  73280. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73281. /**
  73282. * 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"
  73283. * This function works in right handed mode
  73284. * @param eye defines the final position of the entity
  73285. * @param target defines where the entity should look at
  73286. * @param up defines the up vector for the entity
  73287. * @returns the new matrix
  73288. */
  73289. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73290. /**
  73291. * 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".
  73292. * This function works in right handed mode
  73293. * @param eye defines the final position of the entity
  73294. * @param target defines where the entity should look at
  73295. * @param up defines the up vector for the entity
  73296. * @param result defines the target matrix
  73297. */
  73298. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73299. /**
  73300. * Create a left-handed orthographic projection matrix
  73301. * @param width defines the viewport width
  73302. * @param height defines the viewport height
  73303. * @param znear defines the near clip plane
  73304. * @param zfar defines the far clip plane
  73305. * @returns a new matrix as a left-handed orthographic projection matrix
  73306. */
  73307. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73308. /**
  73309. * Store a left-handed orthographic projection to a given matrix
  73310. * @param width defines the viewport width
  73311. * @param height defines the viewport height
  73312. * @param znear defines the near clip plane
  73313. * @param zfar defines the far clip plane
  73314. * @param result defines the target matrix
  73315. */
  73316. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73317. /**
  73318. * Create a left-handed orthographic projection matrix
  73319. * @param left defines the viewport left coordinate
  73320. * @param right defines the viewport right coordinate
  73321. * @param bottom defines the viewport bottom coordinate
  73322. * @param top defines the viewport top coordinate
  73323. * @param znear defines the near clip plane
  73324. * @param zfar defines the far clip plane
  73325. * @returns a new matrix as a left-handed orthographic projection matrix
  73326. */
  73327. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73328. /**
  73329. * Stores a left-handed orthographic projection into a given matrix
  73330. * @param left defines the viewport left coordinate
  73331. * @param right defines the viewport right coordinate
  73332. * @param bottom defines the viewport bottom coordinate
  73333. * @param top defines the viewport top coordinate
  73334. * @param znear defines the near clip plane
  73335. * @param zfar defines the far clip plane
  73336. * @param result defines the target matrix
  73337. */
  73338. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73339. /**
  73340. * Creates a right-handed orthographic projection matrix
  73341. * @param left defines the viewport left coordinate
  73342. * @param right defines the viewport right coordinate
  73343. * @param bottom defines the viewport bottom coordinate
  73344. * @param top defines the viewport top coordinate
  73345. * @param znear defines the near clip plane
  73346. * @param zfar defines the far clip plane
  73347. * @returns a new matrix as a right-handed orthographic projection matrix
  73348. */
  73349. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73350. /**
  73351. * Stores a right-handed orthographic projection into a given matrix
  73352. * @param left defines the viewport left coordinate
  73353. * @param right defines the viewport right coordinate
  73354. * @param bottom defines the viewport bottom coordinate
  73355. * @param top defines the viewport top coordinate
  73356. * @param znear defines the near clip plane
  73357. * @param zfar defines the far clip plane
  73358. * @param result defines the target matrix
  73359. */
  73360. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73361. /**
  73362. * Creates a left-handed perspective projection matrix
  73363. * @param width defines the viewport width
  73364. * @param height defines the viewport height
  73365. * @param znear defines the near clip plane
  73366. * @param zfar defines the far clip plane
  73367. * @returns a new matrix as a left-handed perspective projection matrix
  73368. */
  73369. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73370. /**
  73371. * Creates a left-handed perspective projection matrix
  73372. * @param fov defines the horizontal field of view
  73373. * @param aspect defines the aspect ratio
  73374. * @param znear defines the near clip plane
  73375. * @param zfar defines the far clip plane
  73376. * @returns a new matrix as a left-handed perspective projection matrix
  73377. */
  73378. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73379. /**
  73380. * Stores a left-handed perspective projection into a given matrix
  73381. * @param fov defines the horizontal field of view
  73382. * @param aspect defines the aspect ratio
  73383. * @param znear defines the near clip plane
  73384. * @param zfar defines the far clip plane
  73385. * @param result defines the target matrix
  73386. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73387. */
  73388. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73389. /**
  73390. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73391. * @param fov defines the horizontal field of view
  73392. * @param aspect defines the aspect ratio
  73393. * @param znear defines the near clip plane
  73394. * @param zfar not used as infinity is used as far clip
  73395. * @param result defines the target matrix
  73396. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73397. */
  73398. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73399. /**
  73400. * Creates a right-handed perspective projection matrix
  73401. * @param fov defines the horizontal field of view
  73402. * @param aspect defines the aspect ratio
  73403. * @param znear defines the near clip plane
  73404. * @param zfar defines the far clip plane
  73405. * @returns a new matrix as a right-handed perspective projection matrix
  73406. */
  73407. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73408. /**
  73409. * Stores a right-handed perspective projection into a given matrix
  73410. * @param fov defines the horizontal field of view
  73411. * @param aspect defines the aspect ratio
  73412. * @param znear defines the near clip plane
  73413. * @param zfar defines the far clip plane
  73414. * @param result defines the target matrix
  73415. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73416. */
  73417. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73418. /**
  73419. * Stores a right-handed perspective projection into a given matrix
  73420. * @param fov defines the horizontal field of view
  73421. * @param aspect defines the aspect ratio
  73422. * @param znear defines the near clip plane
  73423. * @param zfar not used as infinity is used as far clip
  73424. * @param result defines the target matrix
  73425. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73426. */
  73427. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73428. /**
  73429. * Stores a perspective projection for WebVR info a given matrix
  73430. * @param fov defines the field of view
  73431. * @param znear defines the near clip plane
  73432. * @param zfar defines the far clip plane
  73433. * @param result defines the target matrix
  73434. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73435. */
  73436. static PerspectiveFovWebVRToRef(fov: {
  73437. upDegrees: number;
  73438. downDegrees: number;
  73439. leftDegrees: number;
  73440. rightDegrees: number;
  73441. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73442. /**
  73443. * Computes a complete transformation matrix
  73444. * @param viewport defines the viewport to use
  73445. * @param world defines the world matrix
  73446. * @param view defines the view matrix
  73447. * @param projection defines the projection matrix
  73448. * @param zmin defines the near clip plane
  73449. * @param zmax defines the far clip plane
  73450. * @returns the transformation matrix
  73451. */
  73452. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73453. /**
  73454. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73455. * @param matrix defines the matrix to use
  73456. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73457. */
  73458. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73459. /**
  73460. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73461. * @param matrix defines the matrix to use
  73462. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73463. */
  73464. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73465. /**
  73466. * Compute the transpose of a given matrix
  73467. * @param matrix defines the matrix to transpose
  73468. * @returns the new matrix
  73469. */
  73470. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73471. /**
  73472. * Compute the transpose of a matrix and store it in a target matrix
  73473. * @param matrix defines the matrix to transpose
  73474. * @param result defines the target matrix
  73475. */
  73476. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73477. /**
  73478. * Computes a reflection matrix from a plane
  73479. * @param plane defines the reflection plane
  73480. * @returns a new matrix
  73481. */
  73482. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73483. /**
  73484. * Computes a reflection matrix from a plane
  73485. * @param plane defines the reflection plane
  73486. * @param result defines the target matrix
  73487. */
  73488. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73489. /**
  73490. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73491. * @param xaxis defines the value of the 1st axis
  73492. * @param yaxis defines the value of the 2nd axis
  73493. * @param zaxis defines the value of the 3rd axis
  73494. * @param result defines the target matrix
  73495. */
  73496. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73497. /**
  73498. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73499. * @param quat defines the quaternion to use
  73500. * @param result defines the target matrix
  73501. */
  73502. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73503. }
  73504. /**
  73505. * @hidden
  73506. */
  73507. export class TmpVectors {
  73508. static Vector2: Vector2[];
  73509. static Vector3: Vector3[];
  73510. static Vector4: Vector4[];
  73511. static Quaternion: Quaternion[];
  73512. static Matrix: Matrix[];
  73513. }
  73514. }
  73515. declare module BABYLON {
  73516. /**
  73517. * Defines potential orientation for back face culling
  73518. */
  73519. export enum Orientation {
  73520. /**
  73521. * Clockwise
  73522. */
  73523. CW = 0,
  73524. /** Counter clockwise */
  73525. CCW = 1
  73526. }
  73527. /** Class used to represent a Bezier curve */
  73528. export class BezierCurve {
  73529. /**
  73530. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73531. * @param t defines the time
  73532. * @param x1 defines the left coordinate on X axis
  73533. * @param y1 defines the left coordinate on Y axis
  73534. * @param x2 defines the right coordinate on X axis
  73535. * @param y2 defines the right coordinate on Y axis
  73536. * @returns the interpolated value
  73537. */
  73538. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73539. }
  73540. /**
  73541. * Defines angle representation
  73542. */
  73543. export class Angle {
  73544. private _radians;
  73545. /**
  73546. * Creates an Angle object of "radians" radians (float).
  73547. * @param radians the angle in radians
  73548. */
  73549. constructor(radians: number);
  73550. /**
  73551. * Get value in degrees
  73552. * @returns the Angle value in degrees (float)
  73553. */
  73554. degrees(): number;
  73555. /**
  73556. * Get value in radians
  73557. * @returns the Angle value in radians (float)
  73558. */
  73559. radians(): number;
  73560. /**
  73561. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73562. * @param a defines first vector
  73563. * @param b defines second vector
  73564. * @returns a new Angle
  73565. */
  73566. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73567. /**
  73568. * Gets a new Angle object from the given float in radians
  73569. * @param radians defines the angle value in radians
  73570. * @returns a new Angle
  73571. */
  73572. static FromRadians(radians: number): Angle;
  73573. /**
  73574. * Gets a new Angle object from the given float in degrees
  73575. * @param degrees defines the angle value in degrees
  73576. * @returns a new Angle
  73577. */
  73578. static FromDegrees(degrees: number): Angle;
  73579. }
  73580. /**
  73581. * This represents an arc in a 2d space.
  73582. */
  73583. export class Arc2 {
  73584. /** Defines the start point of the arc */
  73585. startPoint: Vector2;
  73586. /** Defines the mid point of the arc */
  73587. midPoint: Vector2;
  73588. /** Defines the end point of the arc */
  73589. endPoint: Vector2;
  73590. /**
  73591. * Defines the center point of the arc.
  73592. */
  73593. centerPoint: Vector2;
  73594. /**
  73595. * Defines the radius of the arc.
  73596. */
  73597. radius: number;
  73598. /**
  73599. * Defines the angle of the arc (from mid point to end point).
  73600. */
  73601. angle: Angle;
  73602. /**
  73603. * Defines the start angle of the arc (from start point to middle point).
  73604. */
  73605. startAngle: Angle;
  73606. /**
  73607. * Defines the orientation of the arc (clock wise/counter clock wise).
  73608. */
  73609. orientation: Orientation;
  73610. /**
  73611. * Creates an Arc object from the three given points : start, middle and end.
  73612. * @param startPoint Defines the start point of the arc
  73613. * @param midPoint Defines the midlle point of the arc
  73614. * @param endPoint Defines the end point of the arc
  73615. */
  73616. constructor(
  73617. /** Defines the start point of the arc */
  73618. startPoint: Vector2,
  73619. /** Defines the mid point of the arc */
  73620. midPoint: Vector2,
  73621. /** Defines the end point of the arc */
  73622. endPoint: Vector2);
  73623. }
  73624. /**
  73625. * Represents a 2D path made up of multiple 2D points
  73626. */
  73627. export class Path2 {
  73628. private _points;
  73629. private _length;
  73630. /**
  73631. * If the path start and end point are the same
  73632. */
  73633. closed: boolean;
  73634. /**
  73635. * Creates a Path2 object from the starting 2D coordinates x and y.
  73636. * @param x the starting points x value
  73637. * @param y the starting points y value
  73638. */
  73639. constructor(x: number, y: number);
  73640. /**
  73641. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73642. * @param x the added points x value
  73643. * @param y the added points y value
  73644. * @returns the updated Path2.
  73645. */
  73646. addLineTo(x: number, y: number): Path2;
  73647. /**
  73648. * 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.
  73649. * @param midX middle point x value
  73650. * @param midY middle point y value
  73651. * @param endX end point x value
  73652. * @param endY end point y value
  73653. * @param numberOfSegments (default: 36)
  73654. * @returns the updated Path2.
  73655. */
  73656. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73657. /**
  73658. * Closes the Path2.
  73659. * @returns the Path2.
  73660. */
  73661. close(): Path2;
  73662. /**
  73663. * Gets the sum of the distance between each sequential point in the path
  73664. * @returns the Path2 total length (float).
  73665. */
  73666. length(): number;
  73667. /**
  73668. * Gets the points which construct the path
  73669. * @returns the Path2 internal array of points.
  73670. */
  73671. getPoints(): Vector2[];
  73672. /**
  73673. * Retreives the point at the distance aways from the starting point
  73674. * @param normalizedLengthPosition the length along the path to retreive the point from
  73675. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73676. */
  73677. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73678. /**
  73679. * Creates a new path starting from an x and y position
  73680. * @param x starting x value
  73681. * @param y starting y value
  73682. * @returns a new Path2 starting at the coordinates (x, y).
  73683. */
  73684. static StartingAt(x: number, y: number): Path2;
  73685. }
  73686. /**
  73687. * Represents a 3D path made up of multiple 3D points
  73688. */
  73689. export class Path3D {
  73690. /**
  73691. * an array of Vector3, the curve axis of the Path3D
  73692. */
  73693. path: Vector3[];
  73694. private _curve;
  73695. private _distances;
  73696. private _tangents;
  73697. private _normals;
  73698. private _binormals;
  73699. private _raw;
  73700. private _alignTangentsWithPath;
  73701. private readonly _pointAtData;
  73702. /**
  73703. * new Path3D(path, normal, raw)
  73704. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73705. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73706. * @param path an array of Vector3, the curve axis of the Path3D
  73707. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73708. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73709. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73710. */
  73711. constructor(
  73712. /**
  73713. * an array of Vector3, the curve axis of the Path3D
  73714. */
  73715. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73716. /**
  73717. * Returns the Path3D array of successive Vector3 designing its curve.
  73718. * @returns the Path3D array of successive Vector3 designing its curve.
  73719. */
  73720. getCurve(): Vector3[];
  73721. /**
  73722. * Returns the Path3D array of successive Vector3 designing its curve.
  73723. * @returns the Path3D array of successive Vector3 designing its curve.
  73724. */
  73725. getPoints(): Vector3[];
  73726. /**
  73727. * @returns the computed length (float) of the path.
  73728. */
  73729. length(): number;
  73730. /**
  73731. * Returns an array populated with tangent vectors on each Path3D curve point.
  73732. * @returns an array populated with tangent vectors on each Path3D curve point.
  73733. */
  73734. getTangents(): Vector3[];
  73735. /**
  73736. * Returns an array populated with normal vectors on each Path3D curve point.
  73737. * @returns an array populated with normal vectors on each Path3D curve point.
  73738. */
  73739. getNormals(): Vector3[];
  73740. /**
  73741. * Returns an array populated with binormal vectors on each Path3D curve point.
  73742. * @returns an array populated with binormal vectors on each Path3D curve point.
  73743. */
  73744. getBinormals(): Vector3[];
  73745. /**
  73746. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73747. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73748. */
  73749. getDistances(): number[];
  73750. /**
  73751. * Returns an interpolated point along this path
  73752. * @param position the position of the point along this path, from 0.0 to 1.0
  73753. * @returns a new Vector3 as the point
  73754. */
  73755. getPointAt(position: number): Vector3;
  73756. /**
  73757. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73758. * @param position the position of the point along this path, from 0.0 to 1.0
  73759. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73760. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73761. */
  73762. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73763. /**
  73764. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73765. * @param position the position of the point along this path, from 0.0 to 1.0
  73766. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73767. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73768. */
  73769. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73770. /**
  73771. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73772. * @param position the position of the point along this path, from 0.0 to 1.0
  73773. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73774. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73775. */
  73776. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73777. /**
  73778. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73779. * @param position the position of the point along this path, from 0.0 to 1.0
  73780. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73781. */
  73782. getDistanceAt(position: number): number;
  73783. /**
  73784. * Returns the array index of the previous point of an interpolated point along this path
  73785. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73786. * @returns the array index
  73787. */
  73788. getPreviousPointIndexAt(position: number): number;
  73789. /**
  73790. * 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)
  73791. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73792. * @returns the sub position
  73793. */
  73794. getSubPositionAt(position: number): number;
  73795. /**
  73796. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73797. * @param target the vector of which to get the closest position to
  73798. * @returns the position of the closest virtual point on this path to the target vector
  73799. */
  73800. getClosestPositionTo(target: Vector3): number;
  73801. /**
  73802. * Returns a sub path (slice) of this path
  73803. * @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
  73804. * @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
  73805. * @returns a sub path (slice) of this path
  73806. */
  73807. slice(start?: number, end?: number): Path3D;
  73808. /**
  73809. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73810. * @param path path which all values are copied into the curves points
  73811. * @param firstNormal which should be projected onto the curve
  73812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73813. * @returns the same object updated.
  73814. */
  73815. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73816. private _compute;
  73817. private _getFirstNonNullVector;
  73818. private _getLastNonNullVector;
  73819. private _normalVector;
  73820. /**
  73821. * Updates the point at data for an interpolated point along this curve
  73822. * @param position the position of the point along this curve, from 0.0 to 1.0
  73823. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73824. * @returns the (updated) point at data
  73825. */
  73826. private _updatePointAtData;
  73827. /**
  73828. * Updates the point at data from the specified parameters
  73829. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73830. * @param point the interpolated point
  73831. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73832. */
  73833. private _setPointAtData;
  73834. /**
  73835. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73836. */
  73837. private _updateInterpolationMatrix;
  73838. }
  73839. /**
  73840. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73841. * A Curve3 is designed from a series of successive Vector3.
  73842. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73843. */
  73844. export class Curve3 {
  73845. private _points;
  73846. private _length;
  73847. /**
  73848. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73849. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73850. * @param v1 (Vector3) the control point
  73851. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73852. * @param nbPoints (integer) the wanted number of points in the curve
  73853. * @returns the created Curve3
  73854. */
  73855. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73856. /**
  73857. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73858. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73859. * @param v1 (Vector3) the first control point
  73860. * @param v2 (Vector3) the second control point
  73861. * @param v3 (Vector3) the end point of the Cubic Bezier
  73862. * @param nbPoints (integer) the wanted number of points in the curve
  73863. * @returns the created Curve3
  73864. */
  73865. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73866. /**
  73867. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73868. * @param p1 (Vector3) the origin point of the Hermite Spline
  73869. * @param t1 (Vector3) the tangent vector at the origin point
  73870. * @param p2 (Vector3) the end point of the Hermite Spline
  73871. * @param t2 (Vector3) the tangent vector at the end point
  73872. * @param nbPoints (integer) the wanted number of points in the curve
  73873. * @returns the created Curve3
  73874. */
  73875. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73876. /**
  73877. * Returns a Curve3 object along a CatmullRom Spline curve :
  73878. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73879. * @param nbPoints (integer) the wanted number of points between each curve control points
  73880. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73881. * @returns the created Curve3
  73882. */
  73883. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73884. /**
  73885. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73886. * A Curve3 is designed from a series of successive Vector3.
  73887. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73888. * @param points points which make up the curve
  73889. */
  73890. constructor(points: Vector3[]);
  73891. /**
  73892. * @returns the Curve3 stored array of successive Vector3
  73893. */
  73894. getPoints(): Vector3[];
  73895. /**
  73896. * @returns the computed length (float) of the curve.
  73897. */
  73898. length(): number;
  73899. /**
  73900. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73901. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73902. * curveA and curveB keep unchanged.
  73903. * @param curve the curve to continue from this curve
  73904. * @returns the newly constructed curve
  73905. */
  73906. continue(curve: DeepImmutable<Curve3>): Curve3;
  73907. private _computeLength;
  73908. }
  73909. }
  73910. declare module BABYLON {
  73911. /**
  73912. * This represents the main contract an easing function should follow.
  73913. * Easing functions are used throughout the animation system.
  73914. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73915. */
  73916. export interface IEasingFunction {
  73917. /**
  73918. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73919. * of the easing function.
  73920. * The link below provides some of the most common examples of easing functions.
  73921. * @see https://easings.net/
  73922. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73923. * @returns the corresponding value on the curve defined by the easing function
  73924. */
  73925. ease(gradient: number): number;
  73926. }
  73927. /**
  73928. * Base class used for every default easing function.
  73929. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73930. */
  73931. export class EasingFunction implements IEasingFunction {
  73932. /**
  73933. * Interpolation follows the mathematical formula associated with the easing function.
  73934. */
  73935. static readonly EASINGMODE_EASEIN: number;
  73936. /**
  73937. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73938. */
  73939. static readonly EASINGMODE_EASEOUT: number;
  73940. /**
  73941. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73942. */
  73943. static readonly EASINGMODE_EASEINOUT: number;
  73944. private _easingMode;
  73945. /**
  73946. * Sets the easing mode of the current function.
  73947. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73948. */
  73949. setEasingMode(easingMode: number): void;
  73950. /**
  73951. * Gets the current easing mode.
  73952. * @returns the easing mode
  73953. */
  73954. getEasingMode(): number;
  73955. /**
  73956. * @hidden
  73957. */
  73958. easeInCore(gradient: number): number;
  73959. /**
  73960. * Given an input gradient between 0 and 1, this returns the corresponding value
  73961. * of the easing function.
  73962. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73963. * @returns the corresponding value on the curve defined by the easing function
  73964. */
  73965. ease(gradient: number): number;
  73966. }
  73967. /**
  73968. * Easing function with a circle shape (see link below).
  73969. * @see https://easings.net/#easeInCirc
  73970. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73971. */
  73972. export class CircleEase extends EasingFunction implements IEasingFunction {
  73973. /** @hidden */
  73974. easeInCore(gradient: number): number;
  73975. }
  73976. /**
  73977. * Easing function with a ease back shape (see link below).
  73978. * @see https://easings.net/#easeInBack
  73979. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73980. */
  73981. export class BackEase extends EasingFunction implements IEasingFunction {
  73982. /** Defines the amplitude of the function */
  73983. amplitude: number;
  73984. /**
  73985. * Instantiates a back ease easing
  73986. * @see https://easings.net/#easeInBack
  73987. * @param amplitude Defines the amplitude of the function
  73988. */
  73989. constructor(
  73990. /** Defines the amplitude of the function */
  73991. amplitude?: number);
  73992. /** @hidden */
  73993. easeInCore(gradient: number): number;
  73994. }
  73995. /**
  73996. * Easing function with a bouncing shape (see link below).
  73997. * @see https://easings.net/#easeInBounce
  73998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73999. */
  74000. export class BounceEase extends EasingFunction implements IEasingFunction {
  74001. /** Defines the number of bounces */
  74002. bounces: number;
  74003. /** Defines the amplitude of the bounce */
  74004. bounciness: number;
  74005. /**
  74006. * Instantiates a bounce easing
  74007. * @see https://easings.net/#easeInBounce
  74008. * @param bounces Defines the number of bounces
  74009. * @param bounciness Defines the amplitude of the bounce
  74010. */
  74011. constructor(
  74012. /** Defines the number of bounces */
  74013. bounces?: number,
  74014. /** Defines the amplitude of the bounce */
  74015. bounciness?: number);
  74016. /** @hidden */
  74017. easeInCore(gradient: number): number;
  74018. }
  74019. /**
  74020. * Easing function with a power of 3 shape (see link below).
  74021. * @see https://easings.net/#easeInCubic
  74022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74023. */
  74024. export class CubicEase extends EasingFunction implements IEasingFunction {
  74025. /** @hidden */
  74026. easeInCore(gradient: number): number;
  74027. }
  74028. /**
  74029. * Easing function with an elastic shape (see link below).
  74030. * @see https://easings.net/#easeInElastic
  74031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74032. */
  74033. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74034. /** Defines the number of oscillations*/
  74035. oscillations: number;
  74036. /** Defines the amplitude of the oscillations*/
  74037. springiness: number;
  74038. /**
  74039. * Instantiates an elastic easing function
  74040. * @see https://easings.net/#easeInElastic
  74041. * @param oscillations Defines the number of oscillations
  74042. * @param springiness Defines the amplitude of the oscillations
  74043. */
  74044. constructor(
  74045. /** Defines the number of oscillations*/
  74046. oscillations?: number,
  74047. /** Defines the amplitude of the oscillations*/
  74048. springiness?: number);
  74049. /** @hidden */
  74050. easeInCore(gradient: number): number;
  74051. }
  74052. /**
  74053. * Easing function with an exponential shape (see link below).
  74054. * @see https://easings.net/#easeInExpo
  74055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74056. */
  74057. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74058. /** Defines the exponent of the function */
  74059. exponent: number;
  74060. /**
  74061. * Instantiates an exponential easing function
  74062. * @see https://easings.net/#easeInExpo
  74063. * @param exponent Defines the exponent of the function
  74064. */
  74065. constructor(
  74066. /** Defines the exponent of the function */
  74067. exponent?: number);
  74068. /** @hidden */
  74069. easeInCore(gradient: number): number;
  74070. }
  74071. /**
  74072. * Easing function with a power shape (see link below).
  74073. * @see https://easings.net/#easeInQuad
  74074. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74075. */
  74076. export class PowerEase extends EasingFunction implements IEasingFunction {
  74077. /** Defines the power of the function */
  74078. power: number;
  74079. /**
  74080. * Instantiates an power base easing function
  74081. * @see https://easings.net/#easeInQuad
  74082. * @param power Defines the power of the function
  74083. */
  74084. constructor(
  74085. /** Defines the power of the function */
  74086. power?: number);
  74087. /** @hidden */
  74088. easeInCore(gradient: number): number;
  74089. }
  74090. /**
  74091. * Easing function with a power of 2 shape (see link below).
  74092. * @see https://easings.net/#easeInQuad
  74093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74094. */
  74095. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74096. /** @hidden */
  74097. easeInCore(gradient: number): number;
  74098. }
  74099. /**
  74100. * Easing function with a power of 4 shape (see link below).
  74101. * @see https://easings.net/#easeInQuart
  74102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74103. */
  74104. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74105. /** @hidden */
  74106. easeInCore(gradient: number): number;
  74107. }
  74108. /**
  74109. * Easing function with a power of 5 shape (see link below).
  74110. * @see https://easings.net/#easeInQuint
  74111. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74112. */
  74113. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74114. /** @hidden */
  74115. easeInCore(gradient: number): number;
  74116. }
  74117. /**
  74118. * Easing function with a sin shape (see link below).
  74119. * @see https://easings.net/#easeInSine
  74120. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74121. */
  74122. export class SineEase extends EasingFunction implements IEasingFunction {
  74123. /** @hidden */
  74124. easeInCore(gradient: number): number;
  74125. }
  74126. /**
  74127. * Easing function with a bezier shape (see link below).
  74128. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74129. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74130. */
  74131. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74132. /** Defines the x component of the start tangent in the bezier curve */
  74133. x1: number;
  74134. /** Defines the y component of the start tangent in the bezier curve */
  74135. y1: number;
  74136. /** Defines the x component of the end tangent in the bezier curve */
  74137. x2: number;
  74138. /** Defines the y component of the end tangent in the bezier curve */
  74139. y2: number;
  74140. /**
  74141. * Instantiates a bezier function
  74142. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74143. * @param x1 Defines the x component of the start tangent in the bezier curve
  74144. * @param y1 Defines the y component of the start tangent in the bezier curve
  74145. * @param x2 Defines the x component of the end tangent in the bezier curve
  74146. * @param y2 Defines the y component of the end tangent in the bezier curve
  74147. */
  74148. constructor(
  74149. /** Defines the x component of the start tangent in the bezier curve */
  74150. x1?: number,
  74151. /** Defines the y component of the start tangent in the bezier curve */
  74152. y1?: number,
  74153. /** Defines the x component of the end tangent in the bezier curve */
  74154. x2?: number,
  74155. /** Defines the y component of the end tangent in the bezier curve */
  74156. y2?: number);
  74157. /** @hidden */
  74158. easeInCore(gradient: number): number;
  74159. }
  74160. }
  74161. declare module BABYLON {
  74162. /**
  74163. * Class used to hold a RBG color
  74164. */
  74165. export class Color3 {
  74166. /**
  74167. * Defines the red component (between 0 and 1, default is 0)
  74168. */
  74169. r: number;
  74170. /**
  74171. * Defines the green component (between 0 and 1, default is 0)
  74172. */
  74173. g: number;
  74174. /**
  74175. * Defines the blue component (between 0 and 1, default is 0)
  74176. */
  74177. b: number;
  74178. /**
  74179. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74180. * @param r defines the red component (between 0 and 1, default is 0)
  74181. * @param g defines the green component (between 0 and 1, default is 0)
  74182. * @param b defines the blue component (between 0 and 1, default is 0)
  74183. */
  74184. constructor(
  74185. /**
  74186. * Defines the red component (between 0 and 1, default is 0)
  74187. */
  74188. r?: number,
  74189. /**
  74190. * Defines the green component (between 0 and 1, default is 0)
  74191. */
  74192. g?: number,
  74193. /**
  74194. * Defines the blue component (between 0 and 1, default is 0)
  74195. */
  74196. b?: number);
  74197. /**
  74198. * Creates a string with the Color3 current values
  74199. * @returns the string representation of the Color3 object
  74200. */
  74201. toString(): string;
  74202. /**
  74203. * Returns the string "Color3"
  74204. * @returns "Color3"
  74205. */
  74206. getClassName(): string;
  74207. /**
  74208. * Compute the Color3 hash code
  74209. * @returns an unique number that can be used to hash Color3 objects
  74210. */
  74211. getHashCode(): number;
  74212. /**
  74213. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74214. * @param array defines the array where to store the r,g,b components
  74215. * @param index defines an optional index in the target array to define where to start storing values
  74216. * @returns the current Color3 object
  74217. */
  74218. toArray(array: FloatArray, index?: number): Color3;
  74219. /**
  74220. * Returns a new Color4 object from the current Color3 and the given alpha
  74221. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74222. * @returns a new Color4 object
  74223. */
  74224. toColor4(alpha?: number): Color4;
  74225. /**
  74226. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74227. * @returns the new array
  74228. */
  74229. asArray(): number[];
  74230. /**
  74231. * Returns the luminance value
  74232. * @returns a float value
  74233. */
  74234. toLuminance(): number;
  74235. /**
  74236. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74237. * @param otherColor defines the second operand
  74238. * @returns the new Color3 object
  74239. */
  74240. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74241. /**
  74242. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74243. * @param otherColor defines the second operand
  74244. * @param result defines the Color3 object where to store the result
  74245. * @returns the current Color3
  74246. */
  74247. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74248. /**
  74249. * Determines equality between Color3 objects
  74250. * @param otherColor defines the second operand
  74251. * @returns true if the rgb values are equal to the given ones
  74252. */
  74253. equals(otherColor: DeepImmutable<Color3>): boolean;
  74254. /**
  74255. * Determines equality between the current Color3 object and a set of r,b,g values
  74256. * @param r defines the red component to check
  74257. * @param g defines the green component to check
  74258. * @param b defines the blue component to check
  74259. * @returns true if the rgb values are equal to the given ones
  74260. */
  74261. equalsFloats(r: number, g: number, b: number): boolean;
  74262. /**
  74263. * Multiplies in place each rgb value by scale
  74264. * @param scale defines the scaling factor
  74265. * @returns the updated Color3
  74266. */
  74267. scale(scale: number): Color3;
  74268. /**
  74269. * Multiplies the rgb values by scale and stores the result into "result"
  74270. * @param scale defines the scaling factor
  74271. * @param result defines the Color3 object where to store the result
  74272. * @returns the unmodified current Color3
  74273. */
  74274. scaleToRef(scale: number, result: Color3): Color3;
  74275. /**
  74276. * Scale the current Color3 values by a factor and add the result to a given Color3
  74277. * @param scale defines the scale factor
  74278. * @param result defines color to store the result into
  74279. * @returns the unmodified current Color3
  74280. */
  74281. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74282. /**
  74283. * Clamps the rgb values by the min and max values and stores the result into "result"
  74284. * @param min defines minimum clamping value (default is 0)
  74285. * @param max defines maximum clamping value (default is 1)
  74286. * @param result defines color to store the result into
  74287. * @returns the original Color3
  74288. */
  74289. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74290. /**
  74291. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74292. * @param otherColor defines the second operand
  74293. * @returns the new Color3
  74294. */
  74295. add(otherColor: DeepImmutable<Color3>): Color3;
  74296. /**
  74297. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74298. * @param otherColor defines the second operand
  74299. * @param result defines Color3 object to store the result into
  74300. * @returns the unmodified current Color3
  74301. */
  74302. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74303. /**
  74304. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74305. * @param otherColor defines the second operand
  74306. * @returns the new Color3
  74307. */
  74308. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74309. /**
  74310. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74311. * @param otherColor defines the second operand
  74312. * @param result defines Color3 object to store the result into
  74313. * @returns the unmodified current Color3
  74314. */
  74315. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74316. /**
  74317. * Copy the current object
  74318. * @returns a new Color3 copied the current one
  74319. */
  74320. clone(): Color3;
  74321. /**
  74322. * Copies the rgb values from the source in the current Color3
  74323. * @param source defines the source Color3 object
  74324. * @returns the updated Color3 object
  74325. */
  74326. copyFrom(source: DeepImmutable<Color3>): Color3;
  74327. /**
  74328. * Updates the Color3 rgb values from the given floats
  74329. * @param r defines the red component to read from
  74330. * @param g defines the green component to read from
  74331. * @param b defines the blue component to read from
  74332. * @returns the current Color3 object
  74333. */
  74334. copyFromFloats(r: number, g: number, b: number): Color3;
  74335. /**
  74336. * Updates the Color3 rgb values from the given floats
  74337. * @param r defines the red component to read from
  74338. * @param g defines the green component to read from
  74339. * @param b defines the blue component to read from
  74340. * @returns the current Color3 object
  74341. */
  74342. set(r: number, g: number, b: number): Color3;
  74343. /**
  74344. * Compute the Color3 hexadecimal code as a string
  74345. * @returns a string containing the hexadecimal representation of the Color3 object
  74346. */
  74347. toHexString(): string;
  74348. /**
  74349. * Computes a new Color3 converted from the current one to linear space
  74350. * @returns a new Color3 object
  74351. */
  74352. toLinearSpace(): Color3;
  74353. /**
  74354. * Converts current color in rgb space to HSV values
  74355. * @returns a new color3 representing the HSV values
  74356. */
  74357. toHSV(): Color3;
  74358. /**
  74359. * Converts current color in rgb space to HSV values
  74360. * @param result defines the Color3 where to store the HSV values
  74361. */
  74362. toHSVToRef(result: Color3): void;
  74363. /**
  74364. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74365. * @param convertedColor defines the Color3 object where to store the linear space version
  74366. * @returns the unmodified Color3
  74367. */
  74368. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74369. /**
  74370. * Computes a new Color3 converted from the current one to gamma space
  74371. * @returns a new Color3 object
  74372. */
  74373. toGammaSpace(): Color3;
  74374. /**
  74375. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74376. * @param convertedColor defines the Color3 object where to store the gamma space version
  74377. * @returns the unmodified Color3
  74378. */
  74379. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74380. private static _BlackReadOnly;
  74381. /**
  74382. * Convert Hue, saturation and value to a Color3 (RGB)
  74383. * @param hue defines the hue
  74384. * @param saturation defines the saturation
  74385. * @param value defines the value
  74386. * @param result defines the Color3 where to store the RGB values
  74387. */
  74388. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74389. /**
  74390. * Creates a new Color3 from the string containing valid hexadecimal values
  74391. * @param hex defines a string containing valid hexadecimal values
  74392. * @returns a new Color3 object
  74393. */
  74394. static FromHexString(hex: string): Color3;
  74395. /**
  74396. * Creates a new Color3 from the starting index of the given array
  74397. * @param array defines the source array
  74398. * @param offset defines an offset in the source array
  74399. * @returns a new Color3 object
  74400. */
  74401. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74402. /**
  74403. * Creates a new Color3 from integer values (< 256)
  74404. * @param r defines the red component to read from (value between 0 and 255)
  74405. * @param g defines the green component to read from (value between 0 and 255)
  74406. * @param b defines the blue component to read from (value between 0 and 255)
  74407. * @returns a new Color3 object
  74408. */
  74409. static FromInts(r: number, g: number, b: number): Color3;
  74410. /**
  74411. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74412. * @param start defines the start Color3 value
  74413. * @param end defines the end Color3 value
  74414. * @param amount defines the gradient value between start and end
  74415. * @returns a new Color3 object
  74416. */
  74417. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74418. /**
  74419. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74420. * @param left defines the start value
  74421. * @param right defines the end value
  74422. * @param amount defines the gradient factor
  74423. * @param result defines the Color3 object where to store the result
  74424. */
  74425. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74426. /**
  74427. * Returns a Color3 value containing a red color
  74428. * @returns a new Color3 object
  74429. */
  74430. static Red(): Color3;
  74431. /**
  74432. * Returns a Color3 value containing a green color
  74433. * @returns a new Color3 object
  74434. */
  74435. static Green(): Color3;
  74436. /**
  74437. * Returns a Color3 value containing a blue color
  74438. * @returns a new Color3 object
  74439. */
  74440. static Blue(): Color3;
  74441. /**
  74442. * Returns a Color3 value containing a black color
  74443. * @returns a new Color3 object
  74444. */
  74445. static Black(): Color3;
  74446. /**
  74447. * Gets a Color3 value containing a black color that must not be updated
  74448. */
  74449. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74450. /**
  74451. * Returns a Color3 value containing a white color
  74452. * @returns a new Color3 object
  74453. */
  74454. static White(): Color3;
  74455. /**
  74456. * Returns a Color3 value containing a purple color
  74457. * @returns a new Color3 object
  74458. */
  74459. static Purple(): Color3;
  74460. /**
  74461. * Returns a Color3 value containing a magenta color
  74462. * @returns a new Color3 object
  74463. */
  74464. static Magenta(): Color3;
  74465. /**
  74466. * Returns a Color3 value containing a yellow color
  74467. * @returns a new Color3 object
  74468. */
  74469. static Yellow(): Color3;
  74470. /**
  74471. * Returns a Color3 value containing a gray color
  74472. * @returns a new Color3 object
  74473. */
  74474. static Gray(): Color3;
  74475. /**
  74476. * Returns a Color3 value containing a teal color
  74477. * @returns a new Color3 object
  74478. */
  74479. static Teal(): Color3;
  74480. /**
  74481. * Returns a Color3 value containing a random color
  74482. * @returns a new Color3 object
  74483. */
  74484. static Random(): Color3;
  74485. }
  74486. /**
  74487. * Class used to hold a RBGA color
  74488. */
  74489. export class Color4 {
  74490. /**
  74491. * Defines the red component (between 0 and 1, default is 0)
  74492. */
  74493. r: number;
  74494. /**
  74495. * Defines the green component (between 0 and 1, default is 0)
  74496. */
  74497. g: number;
  74498. /**
  74499. * Defines the blue component (between 0 and 1, default is 0)
  74500. */
  74501. b: number;
  74502. /**
  74503. * Defines the alpha component (between 0 and 1, default is 1)
  74504. */
  74505. a: number;
  74506. /**
  74507. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74508. * @param r defines the red component (between 0 and 1, default is 0)
  74509. * @param g defines the green component (between 0 and 1, default is 0)
  74510. * @param b defines the blue component (between 0 and 1, default is 0)
  74511. * @param a defines the alpha component (between 0 and 1, default is 1)
  74512. */
  74513. constructor(
  74514. /**
  74515. * Defines the red component (between 0 and 1, default is 0)
  74516. */
  74517. r?: number,
  74518. /**
  74519. * Defines the green component (between 0 and 1, default is 0)
  74520. */
  74521. g?: number,
  74522. /**
  74523. * Defines the blue component (between 0 and 1, default is 0)
  74524. */
  74525. b?: number,
  74526. /**
  74527. * Defines the alpha component (between 0 and 1, default is 1)
  74528. */
  74529. a?: number);
  74530. /**
  74531. * Adds in place the given Color4 values to the current Color4 object
  74532. * @param right defines the second operand
  74533. * @returns the current updated Color4 object
  74534. */
  74535. addInPlace(right: DeepImmutable<Color4>): Color4;
  74536. /**
  74537. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74538. * @returns the new array
  74539. */
  74540. asArray(): number[];
  74541. /**
  74542. * Stores from the starting index in the given array the Color4 successive values
  74543. * @param array defines the array where to store the r,g,b components
  74544. * @param index defines an optional index in the target array to define where to start storing values
  74545. * @returns the current Color4 object
  74546. */
  74547. toArray(array: number[], index?: number): Color4;
  74548. /**
  74549. * Determines equality between Color4 objects
  74550. * @param otherColor defines the second operand
  74551. * @returns true if the rgba values are equal to the given ones
  74552. */
  74553. equals(otherColor: DeepImmutable<Color4>): boolean;
  74554. /**
  74555. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74556. * @param right defines the second operand
  74557. * @returns a new Color4 object
  74558. */
  74559. add(right: DeepImmutable<Color4>): Color4;
  74560. /**
  74561. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74562. * @param right defines the second operand
  74563. * @returns a new Color4 object
  74564. */
  74565. subtract(right: DeepImmutable<Color4>): Color4;
  74566. /**
  74567. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74568. * @param right defines the second operand
  74569. * @param result defines the Color4 object where to store the result
  74570. * @returns the current Color4 object
  74571. */
  74572. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74573. /**
  74574. * Creates a new Color4 with the current Color4 values multiplied by scale
  74575. * @param scale defines the scaling factor to apply
  74576. * @returns a new Color4 object
  74577. */
  74578. scale(scale: number): Color4;
  74579. /**
  74580. * Multiplies the current Color4 values by scale and stores the result in "result"
  74581. * @param scale defines the scaling factor to apply
  74582. * @param result defines the Color4 object where to store the result
  74583. * @returns the current unmodified Color4
  74584. */
  74585. scaleToRef(scale: number, result: Color4): Color4;
  74586. /**
  74587. * Scale the current Color4 values by a factor and add the result to a given Color4
  74588. * @param scale defines the scale factor
  74589. * @param result defines the Color4 object where to store the result
  74590. * @returns the unmodified current Color4
  74591. */
  74592. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74593. /**
  74594. * Clamps the rgb values by the min and max values and stores the result into "result"
  74595. * @param min defines minimum clamping value (default is 0)
  74596. * @param max defines maximum clamping value (default is 1)
  74597. * @param result defines color to store the result into.
  74598. * @returns the cuurent Color4
  74599. */
  74600. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74601. /**
  74602. * Multipy an Color4 value by another and return a new Color4 object
  74603. * @param color defines the Color4 value to multiply by
  74604. * @returns a new Color4 object
  74605. */
  74606. multiply(color: Color4): Color4;
  74607. /**
  74608. * Multipy a Color4 value by another and push the result in a reference value
  74609. * @param color defines the Color4 value to multiply by
  74610. * @param result defines the Color4 to fill the result in
  74611. * @returns the result Color4
  74612. */
  74613. multiplyToRef(color: Color4, result: Color4): Color4;
  74614. /**
  74615. * Creates a string with the Color4 current values
  74616. * @returns the string representation of the Color4 object
  74617. */
  74618. toString(): string;
  74619. /**
  74620. * Returns the string "Color4"
  74621. * @returns "Color4"
  74622. */
  74623. getClassName(): string;
  74624. /**
  74625. * Compute the Color4 hash code
  74626. * @returns an unique number that can be used to hash Color4 objects
  74627. */
  74628. getHashCode(): number;
  74629. /**
  74630. * Creates a new Color4 copied from the current one
  74631. * @returns a new Color4 object
  74632. */
  74633. clone(): Color4;
  74634. /**
  74635. * Copies the given Color4 values into the current one
  74636. * @param source defines the source Color4 object
  74637. * @returns the current updated Color4 object
  74638. */
  74639. copyFrom(source: Color4): Color4;
  74640. /**
  74641. * Copies the given float values into the current one
  74642. * @param r defines the red component to read from
  74643. * @param g defines the green component to read from
  74644. * @param b defines the blue component to read from
  74645. * @param a defines the alpha component to read from
  74646. * @returns the current updated Color4 object
  74647. */
  74648. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74649. /**
  74650. * Copies the given float values into the current one
  74651. * @param r defines the red component to read from
  74652. * @param g defines the green component to read from
  74653. * @param b defines the blue component to read from
  74654. * @param a defines the alpha component to read from
  74655. * @returns the current updated Color4 object
  74656. */
  74657. set(r: number, g: number, b: number, a: number): Color4;
  74658. /**
  74659. * Compute the Color4 hexadecimal code as a string
  74660. * @returns a string containing the hexadecimal representation of the Color4 object
  74661. */
  74662. toHexString(): string;
  74663. /**
  74664. * Computes a new Color4 converted from the current one to linear space
  74665. * @returns a new Color4 object
  74666. */
  74667. toLinearSpace(): Color4;
  74668. /**
  74669. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74670. * @param convertedColor defines the Color4 object where to store the linear space version
  74671. * @returns the unmodified Color4
  74672. */
  74673. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74674. /**
  74675. * Computes a new Color4 converted from the current one to gamma space
  74676. * @returns a new Color4 object
  74677. */
  74678. toGammaSpace(): Color4;
  74679. /**
  74680. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74681. * @param convertedColor defines the Color4 object where to store the gamma space version
  74682. * @returns the unmodified Color4
  74683. */
  74684. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74685. /**
  74686. * Creates a new Color4 from the string containing valid hexadecimal values
  74687. * @param hex defines a string containing valid hexadecimal values
  74688. * @returns a new Color4 object
  74689. */
  74690. static FromHexString(hex: string): Color4;
  74691. /**
  74692. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74693. * @param left defines the start value
  74694. * @param right defines the end value
  74695. * @param amount defines the gradient factor
  74696. * @returns a new Color4 object
  74697. */
  74698. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74699. /**
  74700. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74701. * @param left defines the start value
  74702. * @param right defines the end value
  74703. * @param amount defines the gradient factor
  74704. * @param result defines the Color4 object where to store data
  74705. */
  74706. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74707. /**
  74708. * Creates a new Color4 from a Color3 and an alpha value
  74709. * @param color3 defines the source Color3 to read from
  74710. * @param alpha defines the alpha component (1.0 by default)
  74711. * @returns a new Color4 object
  74712. */
  74713. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74714. /**
  74715. * Creates a new Color4 from the starting index element of the given array
  74716. * @param array defines the source array to read from
  74717. * @param offset defines the offset in the source array
  74718. * @returns a new Color4 object
  74719. */
  74720. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74721. /**
  74722. * Creates a new Color3 from integer values (< 256)
  74723. * @param r defines the red component to read from (value between 0 and 255)
  74724. * @param g defines the green component to read from (value between 0 and 255)
  74725. * @param b defines the blue component to read from (value between 0 and 255)
  74726. * @param a defines the alpha component to read from (value between 0 and 255)
  74727. * @returns a new Color3 object
  74728. */
  74729. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74730. /**
  74731. * Check the content of a given array and convert it to an array containing RGBA data
  74732. * If the original array was already containing count * 4 values then it is returned directly
  74733. * @param colors defines the array to check
  74734. * @param count defines the number of RGBA data to expect
  74735. * @returns an array containing count * 4 values (RGBA)
  74736. */
  74737. static CheckColors4(colors: number[], count: number): number[];
  74738. }
  74739. /**
  74740. * @hidden
  74741. */
  74742. export class TmpColors {
  74743. static Color3: Color3[];
  74744. static Color4: Color4[];
  74745. }
  74746. }
  74747. declare module BABYLON {
  74748. /**
  74749. * Defines an interface which represents an animation key frame
  74750. */
  74751. export interface IAnimationKey {
  74752. /**
  74753. * Frame of the key frame
  74754. */
  74755. frame: number;
  74756. /**
  74757. * Value at the specifies key frame
  74758. */
  74759. value: any;
  74760. /**
  74761. * The input tangent for the cubic hermite spline
  74762. */
  74763. inTangent?: any;
  74764. /**
  74765. * The output tangent for the cubic hermite spline
  74766. */
  74767. outTangent?: any;
  74768. /**
  74769. * The animation interpolation type
  74770. */
  74771. interpolation?: AnimationKeyInterpolation;
  74772. }
  74773. /**
  74774. * Enum for the animation key frame interpolation type
  74775. */
  74776. export enum AnimationKeyInterpolation {
  74777. /**
  74778. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74779. */
  74780. STEP = 1
  74781. }
  74782. }
  74783. declare module BABYLON {
  74784. /**
  74785. * Represents the range of an animation
  74786. */
  74787. export class AnimationRange {
  74788. /**The name of the animation range**/
  74789. name: string;
  74790. /**The starting frame of the animation */
  74791. from: number;
  74792. /**The ending frame of the animation*/
  74793. to: number;
  74794. /**
  74795. * Initializes the range of an animation
  74796. * @param name The name of the animation range
  74797. * @param from The starting frame of the animation
  74798. * @param to The ending frame of the animation
  74799. */
  74800. constructor(
  74801. /**The name of the animation range**/
  74802. name: string,
  74803. /**The starting frame of the animation */
  74804. from: number,
  74805. /**The ending frame of the animation*/
  74806. to: number);
  74807. /**
  74808. * Makes a copy of the animation range
  74809. * @returns A copy of the animation range
  74810. */
  74811. clone(): AnimationRange;
  74812. }
  74813. }
  74814. declare module BABYLON {
  74815. /**
  74816. * Composed of a frame, and an action function
  74817. */
  74818. export class AnimationEvent {
  74819. /** The frame for which the event is triggered **/
  74820. frame: number;
  74821. /** The event to perform when triggered **/
  74822. action: (currentFrame: number) => void;
  74823. /** Specifies if the event should be triggered only once**/
  74824. onlyOnce?: boolean | undefined;
  74825. /**
  74826. * Specifies if the animation event is done
  74827. */
  74828. isDone: boolean;
  74829. /**
  74830. * Initializes the animation event
  74831. * @param frame The frame for which the event is triggered
  74832. * @param action The event to perform when triggered
  74833. * @param onlyOnce Specifies if the event should be triggered only once
  74834. */
  74835. constructor(
  74836. /** The frame for which the event is triggered **/
  74837. frame: number,
  74838. /** The event to perform when triggered **/
  74839. action: (currentFrame: number) => void,
  74840. /** Specifies if the event should be triggered only once**/
  74841. onlyOnce?: boolean | undefined);
  74842. /** @hidden */
  74843. _clone(): AnimationEvent;
  74844. }
  74845. }
  74846. declare module BABYLON {
  74847. /**
  74848. * Interface used to define a behavior
  74849. */
  74850. export interface Behavior<T> {
  74851. /** gets or sets behavior's name */
  74852. name: string;
  74853. /**
  74854. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74855. */
  74856. init(): void;
  74857. /**
  74858. * Called when the behavior is attached to a target
  74859. * @param target defines the target where the behavior is attached to
  74860. */
  74861. attach(target: T): void;
  74862. /**
  74863. * Called when the behavior is detached from its target
  74864. */
  74865. detach(): void;
  74866. }
  74867. /**
  74868. * Interface implemented by classes supporting behaviors
  74869. */
  74870. export interface IBehaviorAware<T> {
  74871. /**
  74872. * Attach a behavior
  74873. * @param behavior defines the behavior to attach
  74874. * @returns the current host
  74875. */
  74876. addBehavior(behavior: Behavior<T>): T;
  74877. /**
  74878. * Remove a behavior from the current object
  74879. * @param behavior defines the behavior to detach
  74880. * @returns the current host
  74881. */
  74882. removeBehavior(behavior: Behavior<T>): T;
  74883. /**
  74884. * Gets a behavior using its name to search
  74885. * @param name defines the name to search
  74886. * @returns the behavior or null if not found
  74887. */
  74888. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74889. }
  74890. }
  74891. declare module BABYLON {
  74892. /**
  74893. * Defines an array and its length.
  74894. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74895. */
  74896. export interface ISmartArrayLike<T> {
  74897. /**
  74898. * The data of the array.
  74899. */
  74900. data: Array<T>;
  74901. /**
  74902. * The active length of the array.
  74903. */
  74904. length: number;
  74905. }
  74906. /**
  74907. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74908. */
  74909. export class SmartArray<T> implements ISmartArrayLike<T> {
  74910. /**
  74911. * The full set of data from the array.
  74912. */
  74913. data: Array<T>;
  74914. /**
  74915. * The active length of the array.
  74916. */
  74917. length: number;
  74918. protected _id: number;
  74919. /**
  74920. * Instantiates a Smart Array.
  74921. * @param capacity defines the default capacity of the array.
  74922. */
  74923. constructor(capacity: number);
  74924. /**
  74925. * Pushes a value at the end of the active data.
  74926. * @param value defines the object to push in the array.
  74927. */
  74928. push(value: T): void;
  74929. /**
  74930. * Iterates over the active data and apply the lambda to them.
  74931. * @param func defines the action to apply on each value.
  74932. */
  74933. forEach(func: (content: T) => void): void;
  74934. /**
  74935. * Sorts the full sets of data.
  74936. * @param compareFn defines the comparison function to apply.
  74937. */
  74938. sort(compareFn: (a: T, b: T) => number): void;
  74939. /**
  74940. * Resets the active data to an empty array.
  74941. */
  74942. reset(): void;
  74943. /**
  74944. * Releases all the data from the array as well as the array.
  74945. */
  74946. dispose(): void;
  74947. /**
  74948. * Concats the active data with a given array.
  74949. * @param array defines the data to concatenate with.
  74950. */
  74951. concat(array: any): void;
  74952. /**
  74953. * Returns the position of a value in the active data.
  74954. * @param value defines the value to find the index for
  74955. * @returns the index if found in the active data otherwise -1
  74956. */
  74957. indexOf(value: T): number;
  74958. /**
  74959. * Returns whether an element is part of the active data.
  74960. * @param value defines the value to look for
  74961. * @returns true if found in the active data otherwise false
  74962. */
  74963. contains(value: T): boolean;
  74964. private static _GlobalId;
  74965. }
  74966. /**
  74967. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74968. * The data in this array can only be present once
  74969. */
  74970. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74971. private _duplicateId;
  74972. /**
  74973. * Pushes a value at the end of the active data.
  74974. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74975. * @param value defines the object to push in the array.
  74976. */
  74977. push(value: T): void;
  74978. /**
  74979. * Pushes a value at the end of the active data.
  74980. * If the data is already present, it won t be added again
  74981. * @param value defines the object to push in the array.
  74982. * @returns true if added false if it was already present
  74983. */
  74984. pushNoDuplicate(value: T): boolean;
  74985. /**
  74986. * Resets the active data to an empty array.
  74987. */
  74988. reset(): void;
  74989. /**
  74990. * Concats the active data with a given array.
  74991. * This ensures no dupplicate will be present in the result.
  74992. * @param array defines the data to concatenate with.
  74993. */
  74994. concatWithNoDuplicate(array: any): void;
  74995. }
  74996. }
  74997. declare module BABYLON {
  74998. /**
  74999. * @ignore
  75000. * This is a list of all the different input types that are available in the application.
  75001. * Fo instance: ArcRotateCameraGamepadInput...
  75002. */
  75003. export var CameraInputTypes: {};
  75004. /**
  75005. * This is the contract to implement in order to create a new input class.
  75006. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  75007. */
  75008. export interface ICameraInput<TCamera extends Camera> {
  75009. /**
  75010. * Defines the camera the input is attached to.
  75011. */
  75012. camera: Nullable<TCamera>;
  75013. /**
  75014. * Gets the class name of the current intput.
  75015. * @returns the class name
  75016. */
  75017. getClassName(): string;
  75018. /**
  75019. * Get the friendly name associated with the input class.
  75020. * @returns the input friendly name
  75021. */
  75022. getSimpleName(): string;
  75023. /**
  75024. * Attach the input controls to a specific dom element to get the input from.
  75025. * @param element Defines the element the controls should be listened from
  75026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75027. */
  75028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75029. /**
  75030. * Detach the current controls from the specified dom element.
  75031. * @param element Defines the element to stop listening the inputs from
  75032. */
  75033. detachControl(element: Nullable<HTMLElement>): void;
  75034. /**
  75035. * Update the current camera state depending on the inputs that have been used this frame.
  75036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75037. */
  75038. checkInputs?: () => void;
  75039. }
  75040. /**
  75041. * Represents a map of input types to input instance or input index to input instance.
  75042. */
  75043. export interface CameraInputsMap<TCamera extends Camera> {
  75044. /**
  75045. * Accessor to the input by input type.
  75046. */
  75047. [name: string]: ICameraInput<TCamera>;
  75048. /**
  75049. * Accessor to the input by input index.
  75050. */
  75051. [idx: number]: ICameraInput<TCamera>;
  75052. }
  75053. /**
  75054. * This represents the input manager used within a camera.
  75055. * It helps dealing with all the different kind of input attached to a camera.
  75056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75057. */
  75058. export class CameraInputsManager<TCamera extends Camera> {
  75059. /**
  75060. * Defines the list of inputs attahed to the camera.
  75061. */
  75062. attached: CameraInputsMap<TCamera>;
  75063. /**
  75064. * Defines the dom element the camera is collecting inputs from.
  75065. * This is null if the controls have not been attached.
  75066. */
  75067. attachedElement: Nullable<HTMLElement>;
  75068. /**
  75069. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75070. */
  75071. noPreventDefault: boolean;
  75072. /**
  75073. * Defined the camera the input manager belongs to.
  75074. */
  75075. camera: TCamera;
  75076. /**
  75077. * Update the current camera state depending on the inputs that have been used this frame.
  75078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75079. */
  75080. checkInputs: () => void;
  75081. /**
  75082. * Instantiate a new Camera Input Manager.
  75083. * @param camera Defines the camera the input manager blongs to
  75084. */
  75085. constructor(camera: TCamera);
  75086. /**
  75087. * Add an input method to a camera
  75088. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75089. * @param input camera input method
  75090. */
  75091. add(input: ICameraInput<TCamera>): void;
  75092. /**
  75093. * Remove a specific input method from a camera
  75094. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75095. * @param inputToRemove camera input method
  75096. */
  75097. remove(inputToRemove: ICameraInput<TCamera>): void;
  75098. /**
  75099. * Remove a specific input type from a camera
  75100. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75101. * @param inputType the type of the input to remove
  75102. */
  75103. removeByType(inputType: string): void;
  75104. private _addCheckInputs;
  75105. /**
  75106. * Attach the input controls to the currently attached dom element to listen the events from.
  75107. * @param input Defines the input to attach
  75108. */
  75109. attachInput(input: ICameraInput<TCamera>): void;
  75110. /**
  75111. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75112. * @param element Defines the dom element to collect the events from
  75113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75114. */
  75115. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75116. /**
  75117. * Detach the current manager inputs controls from a specific dom element.
  75118. * @param element Defines the dom element to collect the events from
  75119. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75120. */
  75121. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75122. /**
  75123. * Rebuild the dynamic inputCheck function from the current list of
  75124. * defined inputs in the manager.
  75125. */
  75126. rebuildInputCheck(): void;
  75127. /**
  75128. * Remove all attached input methods from a camera
  75129. */
  75130. clear(): void;
  75131. /**
  75132. * Serialize the current input manager attached to a camera.
  75133. * This ensures than once parsed,
  75134. * the input associated to the camera will be identical to the current ones
  75135. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75136. */
  75137. serialize(serializedCamera: any): void;
  75138. /**
  75139. * Parses an input manager serialized JSON to restore the previous list of inputs
  75140. * and states associated to a camera.
  75141. * @param parsedCamera Defines the JSON to parse
  75142. */
  75143. parse(parsedCamera: any): void;
  75144. }
  75145. }
  75146. declare module BABYLON {
  75147. /**
  75148. * Class used to store data that will be store in GPU memory
  75149. */
  75150. export class Buffer {
  75151. private _engine;
  75152. private _buffer;
  75153. /** @hidden */
  75154. _data: Nullable<DataArray>;
  75155. private _updatable;
  75156. private _instanced;
  75157. private _divisor;
  75158. /**
  75159. * Gets the byte stride.
  75160. */
  75161. readonly byteStride: number;
  75162. /**
  75163. * Constructor
  75164. * @param engine the engine
  75165. * @param data the data to use for this buffer
  75166. * @param updatable whether the data is updatable
  75167. * @param stride the stride (optional)
  75168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75169. * @param instanced whether the buffer is instanced (optional)
  75170. * @param useBytes set to true if the stride in in bytes (optional)
  75171. * @param divisor sets an optional divisor for instances (1 by default)
  75172. */
  75173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75174. /**
  75175. * Create a new VertexBuffer based on the current buffer
  75176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75177. * @param offset defines offset in the buffer (0 by default)
  75178. * @param size defines the size in floats of attributes (position is 3 for instance)
  75179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75180. * @param instanced defines if the vertex buffer contains indexed data
  75181. * @param useBytes defines if the offset and stride are in bytes *
  75182. * @param divisor sets an optional divisor for instances (1 by default)
  75183. * @returns the new vertex buffer
  75184. */
  75185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75186. /**
  75187. * Gets a boolean indicating if the Buffer is updatable?
  75188. * @returns true if the buffer is updatable
  75189. */
  75190. isUpdatable(): boolean;
  75191. /**
  75192. * Gets current buffer's data
  75193. * @returns a DataArray or null
  75194. */
  75195. getData(): Nullable<DataArray>;
  75196. /**
  75197. * Gets underlying native buffer
  75198. * @returns underlying native buffer
  75199. */
  75200. getBuffer(): Nullable<DataBuffer>;
  75201. /**
  75202. * Gets the stride in float32 units (i.e. byte stride / 4).
  75203. * May not be an integer if the byte stride is not divisible by 4.
  75204. * @returns the stride in float32 units
  75205. * @deprecated Please use byteStride instead.
  75206. */
  75207. getStrideSize(): number;
  75208. /**
  75209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75210. * @param data defines the data to store
  75211. */
  75212. create(data?: Nullable<DataArray>): void;
  75213. /** @hidden */
  75214. _rebuild(): void;
  75215. /**
  75216. * Update current buffer data
  75217. * @param data defines the data to store
  75218. */
  75219. update(data: DataArray): void;
  75220. /**
  75221. * Updates the data directly.
  75222. * @param data the new data
  75223. * @param offset the new offset
  75224. * @param vertexCount the vertex count (optional)
  75225. * @param useBytes set to true if the offset is in bytes
  75226. */
  75227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75228. /**
  75229. * Release all resources
  75230. */
  75231. dispose(): void;
  75232. }
  75233. /**
  75234. * Specialized buffer used to store vertex data
  75235. */
  75236. export class VertexBuffer {
  75237. /** @hidden */
  75238. _buffer: Buffer;
  75239. private _kind;
  75240. private _size;
  75241. private _ownsBuffer;
  75242. private _instanced;
  75243. private _instanceDivisor;
  75244. /**
  75245. * The byte type.
  75246. */
  75247. static readonly BYTE: number;
  75248. /**
  75249. * The unsigned byte type.
  75250. */
  75251. static readonly UNSIGNED_BYTE: number;
  75252. /**
  75253. * The short type.
  75254. */
  75255. static readonly SHORT: number;
  75256. /**
  75257. * The unsigned short type.
  75258. */
  75259. static readonly UNSIGNED_SHORT: number;
  75260. /**
  75261. * The integer type.
  75262. */
  75263. static readonly INT: number;
  75264. /**
  75265. * The unsigned integer type.
  75266. */
  75267. static readonly UNSIGNED_INT: number;
  75268. /**
  75269. * The float type.
  75270. */
  75271. static readonly FLOAT: number;
  75272. /**
  75273. * Gets or sets the instance divisor when in instanced mode
  75274. */
  75275. instanceDivisor: number;
  75276. /**
  75277. * Gets the byte stride.
  75278. */
  75279. readonly byteStride: number;
  75280. /**
  75281. * Gets the byte offset.
  75282. */
  75283. readonly byteOffset: number;
  75284. /**
  75285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75286. */
  75287. readonly normalized: boolean;
  75288. /**
  75289. * Gets the data type of each component in the array.
  75290. */
  75291. readonly type: number;
  75292. /**
  75293. * Constructor
  75294. * @param engine the engine
  75295. * @param data the data to use for this vertex buffer
  75296. * @param kind the vertex buffer kind
  75297. * @param updatable whether the data is updatable
  75298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75299. * @param stride the stride (optional)
  75300. * @param instanced whether the buffer is instanced (optional)
  75301. * @param offset the offset of the data (optional)
  75302. * @param size the number of components (optional)
  75303. * @param type the type of the component (optional)
  75304. * @param normalized whether the data contains normalized data (optional)
  75305. * @param useBytes set to true if stride and offset are in bytes (optional)
  75306. * @param divisor defines the instance divisor to use (1 by default)
  75307. */
  75308. 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);
  75309. /** @hidden */
  75310. _rebuild(): void;
  75311. /**
  75312. * Returns the kind of the VertexBuffer (string)
  75313. * @returns a string
  75314. */
  75315. getKind(): string;
  75316. /**
  75317. * Gets a boolean indicating if the VertexBuffer is updatable?
  75318. * @returns true if the buffer is updatable
  75319. */
  75320. isUpdatable(): boolean;
  75321. /**
  75322. * Gets current buffer's data
  75323. * @returns a DataArray or null
  75324. */
  75325. getData(): Nullable<DataArray>;
  75326. /**
  75327. * Gets underlying native buffer
  75328. * @returns underlying native buffer
  75329. */
  75330. getBuffer(): Nullable<DataBuffer>;
  75331. /**
  75332. * Gets the stride in float32 units (i.e. byte stride / 4).
  75333. * May not be an integer if the byte stride is not divisible by 4.
  75334. * @returns the stride in float32 units
  75335. * @deprecated Please use byteStride instead.
  75336. */
  75337. getStrideSize(): number;
  75338. /**
  75339. * Returns the offset as a multiple of the type byte length.
  75340. * @returns the offset in bytes
  75341. * @deprecated Please use byteOffset instead.
  75342. */
  75343. getOffset(): number;
  75344. /**
  75345. * Returns the number of components per vertex attribute (integer)
  75346. * @returns the size in float
  75347. */
  75348. getSize(): number;
  75349. /**
  75350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75351. * @returns true if this buffer is instanced
  75352. */
  75353. getIsInstanced(): boolean;
  75354. /**
  75355. * Returns the instancing divisor, zero for non-instanced (integer).
  75356. * @returns a number
  75357. */
  75358. getInstanceDivisor(): number;
  75359. /**
  75360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75361. * @param data defines the data to store
  75362. */
  75363. create(data?: DataArray): void;
  75364. /**
  75365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75366. * This function will create a new buffer if the current one is not updatable
  75367. * @param data defines the data to store
  75368. */
  75369. update(data: DataArray): void;
  75370. /**
  75371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75372. * Returns the directly updated WebGLBuffer.
  75373. * @param data the new data
  75374. * @param offset the new offset
  75375. * @param useBytes set to true if the offset is in bytes
  75376. */
  75377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75378. /**
  75379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75380. */
  75381. dispose(): void;
  75382. /**
  75383. * Enumerates each value of this vertex buffer as numbers.
  75384. * @param count the number of values to enumerate
  75385. * @param callback the callback function called for each value
  75386. */
  75387. forEach(count: number, callback: (value: number, index: number) => void): void;
  75388. /**
  75389. * Positions
  75390. */
  75391. static readonly PositionKind: string;
  75392. /**
  75393. * Normals
  75394. */
  75395. static readonly NormalKind: string;
  75396. /**
  75397. * Tangents
  75398. */
  75399. static readonly TangentKind: string;
  75400. /**
  75401. * Texture coordinates
  75402. */
  75403. static readonly UVKind: string;
  75404. /**
  75405. * Texture coordinates 2
  75406. */
  75407. static readonly UV2Kind: string;
  75408. /**
  75409. * Texture coordinates 3
  75410. */
  75411. static readonly UV3Kind: string;
  75412. /**
  75413. * Texture coordinates 4
  75414. */
  75415. static readonly UV4Kind: string;
  75416. /**
  75417. * Texture coordinates 5
  75418. */
  75419. static readonly UV5Kind: string;
  75420. /**
  75421. * Texture coordinates 6
  75422. */
  75423. static readonly UV6Kind: string;
  75424. /**
  75425. * Colors
  75426. */
  75427. static readonly ColorKind: string;
  75428. /**
  75429. * Matrix indices (for bones)
  75430. */
  75431. static readonly MatricesIndicesKind: string;
  75432. /**
  75433. * Matrix weights (for bones)
  75434. */
  75435. static readonly MatricesWeightsKind: string;
  75436. /**
  75437. * Additional matrix indices (for bones)
  75438. */
  75439. static readonly MatricesIndicesExtraKind: string;
  75440. /**
  75441. * Additional matrix weights (for bones)
  75442. */
  75443. static readonly MatricesWeightsExtraKind: string;
  75444. /**
  75445. * Deduces the stride given a kind.
  75446. * @param kind The kind string to deduce
  75447. * @returns The deduced stride
  75448. */
  75449. static DeduceStride(kind: string): number;
  75450. /**
  75451. * Gets the byte length of the given type.
  75452. * @param type the type
  75453. * @returns the number of bytes
  75454. */
  75455. static GetTypeByteLength(type: number): number;
  75456. /**
  75457. * Enumerates each value of the given parameters as numbers.
  75458. * @param data the data to enumerate
  75459. * @param byteOffset the byte offset of the data
  75460. * @param byteStride the byte stride of the data
  75461. * @param componentCount the number of components per element
  75462. * @param componentType the type of the component
  75463. * @param count the number of values to enumerate
  75464. * @param normalized whether the data is normalized
  75465. * @param callback the callback function called for each value
  75466. */
  75467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75468. private static _GetFloatValue;
  75469. }
  75470. }
  75471. declare module BABYLON {
  75472. /**
  75473. * @hidden
  75474. */
  75475. export class IntersectionInfo {
  75476. bu: Nullable<number>;
  75477. bv: Nullable<number>;
  75478. distance: number;
  75479. faceId: number;
  75480. subMeshId: number;
  75481. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75482. }
  75483. }
  75484. declare module BABYLON {
  75485. /**
  75486. * Represens a plane by the equation ax + by + cz + d = 0
  75487. */
  75488. export class Plane {
  75489. private static _TmpMatrix;
  75490. /**
  75491. * Normal of the plane (a,b,c)
  75492. */
  75493. normal: Vector3;
  75494. /**
  75495. * d component of the plane
  75496. */
  75497. d: number;
  75498. /**
  75499. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75500. * @param a a component of the plane
  75501. * @param b b component of the plane
  75502. * @param c c component of the plane
  75503. * @param d d component of the plane
  75504. */
  75505. constructor(a: number, b: number, c: number, d: number);
  75506. /**
  75507. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75508. */
  75509. asArray(): number[];
  75510. /**
  75511. * @returns a new plane copied from the current Plane.
  75512. */
  75513. clone(): Plane;
  75514. /**
  75515. * @returns the string "Plane".
  75516. */
  75517. getClassName(): string;
  75518. /**
  75519. * @returns the Plane hash code.
  75520. */
  75521. getHashCode(): number;
  75522. /**
  75523. * Normalize the current Plane in place.
  75524. * @returns the updated Plane.
  75525. */
  75526. normalize(): Plane;
  75527. /**
  75528. * Applies a transformation the plane and returns the result
  75529. * @param transformation the transformation matrix to be applied to the plane
  75530. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75531. */
  75532. transform(transformation: DeepImmutable<Matrix>): Plane;
  75533. /**
  75534. * Calcualtte the dot product between the point and the plane normal
  75535. * @param point point to calculate the dot product with
  75536. * @returns the dot product (float) of the point coordinates and the plane normal.
  75537. */
  75538. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75539. /**
  75540. * Updates the current Plane from the plane defined by the three given points.
  75541. * @param point1 one of the points used to contruct the plane
  75542. * @param point2 one of the points used to contruct the plane
  75543. * @param point3 one of the points used to contruct the plane
  75544. * @returns the updated Plane.
  75545. */
  75546. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75547. /**
  75548. * Checks if the plane is facing a given direction
  75549. * @param direction the direction to check if the plane is facing
  75550. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75551. * @returns True is the vector "direction" is the same side than the plane normal.
  75552. */
  75553. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75554. /**
  75555. * Calculates the distance to a point
  75556. * @param point point to calculate distance to
  75557. * @returns the signed distance (float) from the given point to the Plane.
  75558. */
  75559. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75560. /**
  75561. * Creates a plane from an array
  75562. * @param array the array to create a plane from
  75563. * @returns a new Plane from the given array.
  75564. */
  75565. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75566. /**
  75567. * Creates a plane from three points
  75568. * @param point1 point used to create the plane
  75569. * @param point2 point used to create the plane
  75570. * @param point3 point used to create the plane
  75571. * @returns a new Plane defined by the three given points.
  75572. */
  75573. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75574. /**
  75575. * Creates a plane from an origin point and a normal
  75576. * @param origin origin of the plane to be constructed
  75577. * @param normal normal of the plane to be constructed
  75578. * @returns a new Plane the normal vector to this plane at the given origin point.
  75579. * Note : the vector "normal" is updated because normalized.
  75580. */
  75581. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75582. /**
  75583. * Calculates the distance from a plane and a point
  75584. * @param origin origin of the plane to be constructed
  75585. * @param normal normal of the plane to be constructed
  75586. * @param point point to calculate distance to
  75587. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75588. */
  75589. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75590. }
  75591. }
  75592. declare module BABYLON {
  75593. /**
  75594. * Class used to store bounding sphere information
  75595. */
  75596. export class BoundingSphere {
  75597. /**
  75598. * Gets the center of the bounding sphere in local space
  75599. */
  75600. readonly center: Vector3;
  75601. /**
  75602. * Radius of the bounding sphere in local space
  75603. */
  75604. radius: number;
  75605. /**
  75606. * Gets the center of the bounding sphere in world space
  75607. */
  75608. readonly centerWorld: Vector3;
  75609. /**
  75610. * Radius of the bounding sphere in world space
  75611. */
  75612. radiusWorld: number;
  75613. /**
  75614. * Gets the minimum vector in local space
  75615. */
  75616. readonly minimum: Vector3;
  75617. /**
  75618. * Gets the maximum vector in local space
  75619. */
  75620. readonly maximum: Vector3;
  75621. private _worldMatrix;
  75622. private static readonly TmpVector3;
  75623. /**
  75624. * Creates a new bounding sphere
  75625. * @param min defines the minimum vector (in local space)
  75626. * @param max defines the maximum vector (in local space)
  75627. * @param worldMatrix defines the new world matrix
  75628. */
  75629. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75630. /**
  75631. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75632. * @param min defines the new minimum vector (in local space)
  75633. * @param max defines the new maximum vector (in local space)
  75634. * @param worldMatrix defines the new world matrix
  75635. */
  75636. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75637. /**
  75638. * Scale the current bounding sphere by applying a scale factor
  75639. * @param factor defines the scale factor to apply
  75640. * @returns the current bounding box
  75641. */
  75642. scale(factor: number): BoundingSphere;
  75643. /**
  75644. * Gets the world matrix of the bounding box
  75645. * @returns a matrix
  75646. */
  75647. getWorldMatrix(): DeepImmutable<Matrix>;
  75648. /** @hidden */
  75649. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75650. /**
  75651. * Tests if the bounding sphere is intersecting the frustum planes
  75652. * @param frustumPlanes defines the frustum planes to test
  75653. * @returns true if there is an intersection
  75654. */
  75655. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75656. /**
  75657. * Tests if the bounding sphere center is in between the frustum planes.
  75658. * Used for optimistic fast inclusion.
  75659. * @param frustumPlanes defines the frustum planes to test
  75660. * @returns true if the sphere center is in between the frustum planes
  75661. */
  75662. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75663. /**
  75664. * Tests if a point is inside the bounding sphere
  75665. * @param point defines the point to test
  75666. * @returns true if the point is inside the bounding sphere
  75667. */
  75668. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75669. /**
  75670. * Checks if two sphere intersct
  75671. * @param sphere0 sphere 0
  75672. * @param sphere1 sphere 1
  75673. * @returns true if the speres intersect
  75674. */
  75675. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75676. }
  75677. }
  75678. declare module BABYLON {
  75679. /**
  75680. * Class used to store bounding box information
  75681. */
  75682. export class BoundingBox implements ICullable {
  75683. /**
  75684. * Gets the 8 vectors representing the bounding box in local space
  75685. */
  75686. readonly vectors: Vector3[];
  75687. /**
  75688. * Gets the center of the bounding box in local space
  75689. */
  75690. readonly center: Vector3;
  75691. /**
  75692. * Gets the center of the bounding box in world space
  75693. */
  75694. readonly centerWorld: Vector3;
  75695. /**
  75696. * Gets the extend size in local space
  75697. */
  75698. readonly extendSize: Vector3;
  75699. /**
  75700. * Gets the extend size in world space
  75701. */
  75702. readonly extendSizeWorld: Vector3;
  75703. /**
  75704. * Gets the OBB (object bounding box) directions
  75705. */
  75706. readonly directions: Vector3[];
  75707. /**
  75708. * Gets the 8 vectors representing the bounding box in world space
  75709. */
  75710. readonly vectorsWorld: Vector3[];
  75711. /**
  75712. * Gets the minimum vector in world space
  75713. */
  75714. readonly minimumWorld: Vector3;
  75715. /**
  75716. * Gets the maximum vector in world space
  75717. */
  75718. readonly maximumWorld: Vector3;
  75719. /**
  75720. * Gets the minimum vector in local space
  75721. */
  75722. readonly minimum: Vector3;
  75723. /**
  75724. * Gets the maximum vector in local space
  75725. */
  75726. readonly maximum: Vector3;
  75727. private _worldMatrix;
  75728. private static readonly TmpVector3;
  75729. /**
  75730. * @hidden
  75731. */
  75732. _tag: number;
  75733. /**
  75734. * Creates a new bounding box
  75735. * @param min defines the minimum vector (in local space)
  75736. * @param max defines the maximum vector (in local space)
  75737. * @param worldMatrix defines the new world matrix
  75738. */
  75739. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75740. /**
  75741. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75742. * @param min defines the new minimum vector (in local space)
  75743. * @param max defines the new maximum vector (in local space)
  75744. * @param worldMatrix defines the new world matrix
  75745. */
  75746. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75747. /**
  75748. * Scale the current bounding box by applying a scale factor
  75749. * @param factor defines the scale factor to apply
  75750. * @returns the current bounding box
  75751. */
  75752. scale(factor: number): BoundingBox;
  75753. /**
  75754. * Gets the world matrix of the bounding box
  75755. * @returns a matrix
  75756. */
  75757. getWorldMatrix(): DeepImmutable<Matrix>;
  75758. /** @hidden */
  75759. _update(world: DeepImmutable<Matrix>): void;
  75760. /**
  75761. * Tests if the bounding box is intersecting the frustum planes
  75762. * @param frustumPlanes defines the frustum planes to test
  75763. * @returns true if there is an intersection
  75764. */
  75765. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75766. /**
  75767. * Tests if the bounding box is entirely inside the frustum planes
  75768. * @param frustumPlanes defines the frustum planes to test
  75769. * @returns true if there is an inclusion
  75770. */
  75771. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75772. /**
  75773. * Tests if a point is inside the bounding box
  75774. * @param point defines the point to test
  75775. * @returns true if the point is inside the bounding box
  75776. */
  75777. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75778. /**
  75779. * Tests if the bounding box intersects with a bounding sphere
  75780. * @param sphere defines the sphere to test
  75781. * @returns true if there is an intersection
  75782. */
  75783. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75784. /**
  75785. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75786. * @param min defines the min vector to use
  75787. * @param max defines the max vector to use
  75788. * @returns true if there is an intersection
  75789. */
  75790. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75791. /**
  75792. * Tests if two bounding boxes are intersections
  75793. * @param box0 defines the first box to test
  75794. * @param box1 defines the second box to test
  75795. * @returns true if there is an intersection
  75796. */
  75797. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75798. /**
  75799. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75800. * @param minPoint defines the minimum vector of the bounding box
  75801. * @param maxPoint defines the maximum vector of the bounding box
  75802. * @param sphereCenter defines the sphere center
  75803. * @param sphereRadius defines the sphere radius
  75804. * @returns true if there is an intersection
  75805. */
  75806. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75807. /**
  75808. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75809. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75810. * @param frustumPlanes defines the frustum planes to test
  75811. * @return true if there is an inclusion
  75812. */
  75813. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75814. /**
  75815. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75816. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75817. * @param frustumPlanes defines the frustum planes to test
  75818. * @return true if there is an intersection
  75819. */
  75820. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75821. }
  75822. }
  75823. declare module BABYLON {
  75824. /** @hidden */
  75825. export class Collider {
  75826. /** Define if a collision was found */
  75827. collisionFound: boolean;
  75828. /**
  75829. * Define last intersection point in local space
  75830. */
  75831. intersectionPoint: Vector3;
  75832. /**
  75833. * Define last collided mesh
  75834. */
  75835. collidedMesh: Nullable<AbstractMesh>;
  75836. private _collisionPoint;
  75837. private _planeIntersectionPoint;
  75838. private _tempVector;
  75839. private _tempVector2;
  75840. private _tempVector3;
  75841. private _tempVector4;
  75842. private _edge;
  75843. private _baseToVertex;
  75844. private _destinationPoint;
  75845. private _slidePlaneNormal;
  75846. private _displacementVector;
  75847. /** @hidden */
  75848. _radius: Vector3;
  75849. /** @hidden */
  75850. _retry: number;
  75851. private _velocity;
  75852. private _basePoint;
  75853. private _epsilon;
  75854. /** @hidden */
  75855. _velocityWorldLength: number;
  75856. /** @hidden */
  75857. _basePointWorld: Vector3;
  75858. private _velocityWorld;
  75859. private _normalizedVelocity;
  75860. /** @hidden */
  75861. _initialVelocity: Vector3;
  75862. /** @hidden */
  75863. _initialPosition: Vector3;
  75864. private _nearestDistance;
  75865. private _collisionMask;
  75866. collisionMask: number;
  75867. /**
  75868. * Gets the plane normal used to compute the sliding response (in local space)
  75869. */
  75870. readonly slidePlaneNormal: Vector3;
  75871. /** @hidden */
  75872. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75873. /** @hidden */
  75874. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75875. /** @hidden */
  75876. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75877. /** @hidden */
  75878. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75879. /** @hidden */
  75880. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75881. /** @hidden */
  75882. _getResponse(pos: Vector3, vel: Vector3): void;
  75883. }
  75884. }
  75885. declare module BABYLON {
  75886. /**
  75887. * Interface for cullable objects
  75888. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75889. */
  75890. export interface ICullable {
  75891. /**
  75892. * Checks if the object or part of the object is in the frustum
  75893. * @param frustumPlanes Camera near/planes
  75894. * @returns true if the object is in frustum otherwise false
  75895. */
  75896. isInFrustum(frustumPlanes: Plane[]): boolean;
  75897. /**
  75898. * Checks if a cullable object (mesh...) is in the camera frustum
  75899. * Unlike isInFrustum this cheks the full bounding box
  75900. * @param frustumPlanes Camera near/planes
  75901. * @returns true if the object is in frustum otherwise false
  75902. */
  75903. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75904. }
  75905. /**
  75906. * Info for a bounding data of a mesh
  75907. */
  75908. export class BoundingInfo implements ICullable {
  75909. /**
  75910. * Bounding box for the mesh
  75911. */
  75912. readonly boundingBox: BoundingBox;
  75913. /**
  75914. * Bounding sphere for the mesh
  75915. */
  75916. readonly boundingSphere: BoundingSphere;
  75917. private _isLocked;
  75918. private static readonly TmpVector3;
  75919. /**
  75920. * Constructs bounding info
  75921. * @param minimum min vector of the bounding box/sphere
  75922. * @param maximum max vector of the bounding box/sphere
  75923. * @param worldMatrix defines the new world matrix
  75924. */
  75925. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75926. /**
  75927. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75928. * @param min defines the new minimum vector (in local space)
  75929. * @param max defines the new maximum vector (in local space)
  75930. * @param worldMatrix defines the new world matrix
  75931. */
  75932. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75933. /**
  75934. * min vector of the bounding box/sphere
  75935. */
  75936. readonly minimum: Vector3;
  75937. /**
  75938. * max vector of the bounding box/sphere
  75939. */
  75940. readonly maximum: Vector3;
  75941. /**
  75942. * If the info is locked and won't be updated to avoid perf overhead
  75943. */
  75944. isLocked: boolean;
  75945. /**
  75946. * Updates the bounding sphere and box
  75947. * @param world world matrix to be used to update
  75948. */
  75949. update(world: DeepImmutable<Matrix>): void;
  75950. /**
  75951. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75952. * @param center New center of the bounding info
  75953. * @param extend New extend of the bounding info
  75954. * @returns the current bounding info
  75955. */
  75956. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75957. /**
  75958. * Scale the current bounding info by applying a scale factor
  75959. * @param factor defines the scale factor to apply
  75960. * @returns the current bounding info
  75961. */
  75962. scale(factor: number): BoundingInfo;
  75963. /**
  75964. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75965. * @param frustumPlanes defines the frustum to test
  75966. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75967. * @returns true if the bounding info is in the frustum planes
  75968. */
  75969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75970. /**
  75971. * Gets the world distance between the min and max points of the bounding box
  75972. */
  75973. readonly diagonalLength: number;
  75974. /**
  75975. * Checks if a cullable object (mesh...) is in the camera frustum
  75976. * Unlike isInFrustum this cheks the full bounding box
  75977. * @param frustumPlanes Camera near/planes
  75978. * @returns true if the object is in frustum otherwise false
  75979. */
  75980. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75981. /** @hidden */
  75982. _checkCollision(collider: Collider): boolean;
  75983. /**
  75984. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75985. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75986. * @param point the point to check intersection with
  75987. * @returns if the point intersects
  75988. */
  75989. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75990. /**
  75991. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75992. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75993. * @param boundingInfo the bounding info to check intersection with
  75994. * @param precise if the intersection should be done using OBB
  75995. * @returns if the bounding info intersects
  75996. */
  75997. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75998. }
  75999. }
  76000. declare module BABYLON {
  76001. /**
  76002. * Extracts minimum and maximum values from a list of indexed positions
  76003. * @param positions defines the positions to use
  76004. * @param indices defines the indices to the positions
  76005. * @param indexStart defines the start index
  76006. * @param indexCount defines the end index
  76007. * @param bias defines bias value to add to the result
  76008. * @return minimum and maximum values
  76009. */
  76010. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  76011. minimum: Vector3;
  76012. maximum: Vector3;
  76013. };
  76014. /**
  76015. * Extracts minimum and maximum values from a list of positions
  76016. * @param positions defines the positions to use
  76017. * @param start defines the start index in the positions array
  76018. * @param count defines the number of positions to handle
  76019. * @param bias defines bias value to add to the result
  76020. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76021. * @return minimum and maximum values
  76022. */
  76023. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76024. minimum: Vector3;
  76025. maximum: Vector3;
  76026. };
  76027. }
  76028. declare module BABYLON {
  76029. /** @hidden */
  76030. export class WebGLDataBuffer extends DataBuffer {
  76031. private _buffer;
  76032. constructor(resource: WebGLBuffer);
  76033. readonly underlyingResource: any;
  76034. }
  76035. }
  76036. declare module BABYLON {
  76037. /** @hidden */
  76038. export class WebGLPipelineContext implements IPipelineContext {
  76039. engine: ThinEngine;
  76040. program: Nullable<WebGLProgram>;
  76041. context?: WebGLRenderingContext;
  76042. vertexShader?: WebGLShader;
  76043. fragmentShader?: WebGLShader;
  76044. isParallelCompiled: boolean;
  76045. onCompiled?: () => void;
  76046. transformFeedback?: WebGLTransformFeedback | null;
  76047. readonly isAsync: boolean;
  76048. readonly isReady: boolean;
  76049. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76050. }
  76051. }
  76052. declare module BABYLON {
  76053. interface ThinEngine {
  76054. /**
  76055. * Create an uniform buffer
  76056. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76057. * @param elements defines the content of the uniform buffer
  76058. * @returns the webGL uniform buffer
  76059. */
  76060. createUniformBuffer(elements: FloatArray): DataBuffer;
  76061. /**
  76062. * Create a dynamic uniform buffer
  76063. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76064. * @param elements defines the content of the uniform buffer
  76065. * @returns the webGL uniform buffer
  76066. */
  76067. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76068. /**
  76069. * Update an existing uniform buffer
  76070. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76071. * @param uniformBuffer defines the target uniform buffer
  76072. * @param elements defines the content to update
  76073. * @param offset defines the offset in the uniform buffer where update should start
  76074. * @param count defines the size of the data to update
  76075. */
  76076. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76077. /**
  76078. * Bind an uniform buffer to the current webGL context
  76079. * @param buffer defines the buffer to bind
  76080. */
  76081. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76082. /**
  76083. * Bind a buffer to the current webGL context at a given location
  76084. * @param buffer defines the buffer to bind
  76085. * @param location defines the index where to bind the buffer
  76086. */
  76087. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76088. /**
  76089. * Bind a specific block at a given index in a specific shader program
  76090. * @param pipelineContext defines the pipeline context to use
  76091. * @param blockName defines the block name
  76092. * @param index defines the index where to bind the block
  76093. */
  76094. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76095. }
  76096. }
  76097. declare module BABYLON {
  76098. /**
  76099. * Uniform buffer objects.
  76100. *
  76101. * Handles blocks of uniform on the GPU.
  76102. *
  76103. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76104. *
  76105. * For more information, please refer to :
  76106. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76107. */
  76108. export class UniformBuffer {
  76109. private _engine;
  76110. private _buffer;
  76111. private _data;
  76112. private _bufferData;
  76113. private _dynamic?;
  76114. private _uniformLocations;
  76115. private _uniformSizes;
  76116. private _uniformLocationPointer;
  76117. private _needSync;
  76118. private _noUBO;
  76119. private _currentEffect;
  76120. /** @hidden */
  76121. _alreadyBound: boolean;
  76122. private static _MAX_UNIFORM_SIZE;
  76123. private static _tempBuffer;
  76124. /**
  76125. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76126. * This is dynamic to allow compat with webgl 1 and 2.
  76127. * You will need to pass the name of the uniform as well as the value.
  76128. */
  76129. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76130. /**
  76131. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76132. * This is dynamic to allow compat with webgl 1 and 2.
  76133. * You will need to pass the name of the uniform as well as the value.
  76134. */
  76135. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76136. /**
  76137. * Lambda to Update a single float in a uniform buffer.
  76138. * This is dynamic to allow compat with webgl 1 and 2.
  76139. * You will need to pass the name of the uniform as well as the value.
  76140. */
  76141. updateFloat: (name: string, x: number) => void;
  76142. /**
  76143. * Lambda to Update a vec2 of float in a uniform buffer.
  76144. * This is dynamic to allow compat with webgl 1 and 2.
  76145. * You will need to pass the name of the uniform as well as the value.
  76146. */
  76147. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76148. /**
  76149. * Lambda to Update a vec3 of float in a uniform buffer.
  76150. * This is dynamic to allow compat with webgl 1 and 2.
  76151. * You will need to pass the name of the uniform as well as the value.
  76152. */
  76153. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76154. /**
  76155. * Lambda to Update a vec4 of float in a uniform buffer.
  76156. * This is dynamic to allow compat with webgl 1 and 2.
  76157. * You will need to pass the name of the uniform as well as the value.
  76158. */
  76159. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76160. /**
  76161. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76162. * This is dynamic to allow compat with webgl 1 and 2.
  76163. * You will need to pass the name of the uniform as well as the value.
  76164. */
  76165. updateMatrix: (name: string, mat: Matrix) => void;
  76166. /**
  76167. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76168. * This is dynamic to allow compat with webgl 1 and 2.
  76169. * You will need to pass the name of the uniform as well as the value.
  76170. */
  76171. updateVector3: (name: string, vector: Vector3) => void;
  76172. /**
  76173. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76174. * This is dynamic to allow compat with webgl 1 and 2.
  76175. * You will need to pass the name of the uniform as well as the value.
  76176. */
  76177. updateVector4: (name: string, vector: Vector4) => void;
  76178. /**
  76179. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76180. * This is dynamic to allow compat with webgl 1 and 2.
  76181. * You will need to pass the name of the uniform as well as the value.
  76182. */
  76183. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76184. /**
  76185. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76186. * This is dynamic to allow compat with webgl 1 and 2.
  76187. * You will need to pass the name of the uniform as well as the value.
  76188. */
  76189. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76190. /**
  76191. * Instantiates a new Uniform buffer objects.
  76192. *
  76193. * Handles blocks of uniform on the GPU.
  76194. *
  76195. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76196. *
  76197. * For more information, please refer to :
  76198. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76199. * @param engine Define the engine the buffer is associated with
  76200. * @param data Define the data contained in the buffer
  76201. * @param dynamic Define if the buffer is updatable
  76202. */
  76203. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76204. /**
  76205. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76206. * or just falling back on setUniformXXX calls.
  76207. */
  76208. readonly useUbo: boolean;
  76209. /**
  76210. * Indicates if the WebGL underlying uniform buffer is in sync
  76211. * with the javascript cache data.
  76212. */
  76213. readonly isSync: boolean;
  76214. /**
  76215. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76216. * Also, a dynamic UniformBuffer will disable cache verification and always
  76217. * update the underlying WebGL uniform buffer to the GPU.
  76218. * @returns if Dynamic, otherwise false
  76219. */
  76220. isDynamic(): boolean;
  76221. /**
  76222. * The data cache on JS side.
  76223. * @returns the underlying data as a float array
  76224. */
  76225. getData(): Float32Array;
  76226. /**
  76227. * The underlying WebGL Uniform buffer.
  76228. * @returns the webgl buffer
  76229. */
  76230. getBuffer(): Nullable<DataBuffer>;
  76231. /**
  76232. * std140 layout specifies how to align data within an UBO structure.
  76233. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76234. * for specs.
  76235. */
  76236. private _fillAlignment;
  76237. /**
  76238. * Adds an uniform in the buffer.
  76239. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76240. * for the layout to be correct !
  76241. * @param name Name of the uniform, as used in the uniform block in the shader.
  76242. * @param size Data size, or data directly.
  76243. */
  76244. addUniform(name: string, size: number | number[]): void;
  76245. /**
  76246. * Adds a Matrix 4x4 to the uniform buffer.
  76247. * @param name Name of the uniform, as used in the uniform block in the shader.
  76248. * @param mat A 4x4 matrix.
  76249. */
  76250. addMatrix(name: string, mat: Matrix): void;
  76251. /**
  76252. * Adds a vec2 to the uniform buffer.
  76253. * @param name Name of the uniform, as used in the uniform block in the shader.
  76254. * @param x Define the x component value of the vec2
  76255. * @param y Define the y component value of the vec2
  76256. */
  76257. addFloat2(name: string, x: number, y: number): void;
  76258. /**
  76259. * Adds a vec3 to the uniform buffer.
  76260. * @param name Name of the uniform, as used in the uniform block in the shader.
  76261. * @param x Define the x component value of the vec3
  76262. * @param y Define the y component value of the vec3
  76263. * @param z Define the z component value of the vec3
  76264. */
  76265. addFloat3(name: string, x: number, y: number, z: number): void;
  76266. /**
  76267. * Adds a vec3 to the uniform buffer.
  76268. * @param name Name of the uniform, as used in the uniform block in the shader.
  76269. * @param color Define the vec3 from a Color
  76270. */
  76271. addColor3(name: string, color: Color3): void;
  76272. /**
  76273. * Adds a vec4 to the uniform buffer.
  76274. * @param name Name of the uniform, as used in the uniform block in the shader.
  76275. * @param color Define the rgb components from a Color
  76276. * @param alpha Define the a component of the vec4
  76277. */
  76278. addColor4(name: string, color: Color3, alpha: number): void;
  76279. /**
  76280. * Adds a vec3 to the uniform buffer.
  76281. * @param name Name of the uniform, as used in the uniform block in the shader.
  76282. * @param vector Define the vec3 components from a Vector
  76283. */
  76284. addVector3(name: string, vector: Vector3): void;
  76285. /**
  76286. * Adds a Matrix 3x3 to the uniform buffer.
  76287. * @param name Name of the uniform, as used in the uniform block in the shader.
  76288. */
  76289. addMatrix3x3(name: string): void;
  76290. /**
  76291. * Adds a Matrix 2x2 to the uniform buffer.
  76292. * @param name Name of the uniform, as used in the uniform block in the shader.
  76293. */
  76294. addMatrix2x2(name: string): void;
  76295. /**
  76296. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76297. */
  76298. create(): void;
  76299. /** @hidden */
  76300. _rebuild(): void;
  76301. /**
  76302. * Updates the WebGL Uniform Buffer on the GPU.
  76303. * If the `dynamic` flag is set to true, no cache comparison is done.
  76304. * Otherwise, the buffer will be updated only if the cache differs.
  76305. */
  76306. update(): void;
  76307. /**
  76308. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76309. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76310. * @param data Define the flattened data
  76311. * @param size Define the size of the data.
  76312. */
  76313. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76314. private _valueCache;
  76315. private _cacheMatrix;
  76316. private _updateMatrix3x3ForUniform;
  76317. private _updateMatrix3x3ForEffect;
  76318. private _updateMatrix2x2ForEffect;
  76319. private _updateMatrix2x2ForUniform;
  76320. private _updateFloatForEffect;
  76321. private _updateFloatForUniform;
  76322. private _updateFloat2ForEffect;
  76323. private _updateFloat2ForUniform;
  76324. private _updateFloat3ForEffect;
  76325. private _updateFloat3ForUniform;
  76326. private _updateFloat4ForEffect;
  76327. private _updateFloat4ForUniform;
  76328. private _updateMatrixForEffect;
  76329. private _updateMatrixForUniform;
  76330. private _updateVector3ForEffect;
  76331. private _updateVector3ForUniform;
  76332. private _updateVector4ForEffect;
  76333. private _updateVector4ForUniform;
  76334. private _updateColor3ForEffect;
  76335. private _updateColor3ForUniform;
  76336. private _updateColor4ForEffect;
  76337. private _updateColor4ForUniform;
  76338. /**
  76339. * Sets a sampler uniform on the effect.
  76340. * @param name Define the name of the sampler.
  76341. * @param texture Define the texture to set in the sampler
  76342. */
  76343. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76344. /**
  76345. * Directly updates the value of the uniform in the cache AND on the GPU.
  76346. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76347. * @param data Define the flattened data
  76348. */
  76349. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76350. /**
  76351. * Binds this uniform buffer to an effect.
  76352. * @param effect Define the effect to bind the buffer to
  76353. * @param name Name of the uniform block in the shader.
  76354. */
  76355. bindToEffect(effect: Effect, name: string): void;
  76356. /**
  76357. * Disposes the uniform buffer.
  76358. */
  76359. dispose(): void;
  76360. }
  76361. }
  76362. declare module BABYLON {
  76363. /**
  76364. * Enum that determines the text-wrapping mode to use.
  76365. */
  76366. export enum InspectableType {
  76367. /**
  76368. * Checkbox for booleans
  76369. */
  76370. Checkbox = 0,
  76371. /**
  76372. * Sliders for numbers
  76373. */
  76374. Slider = 1,
  76375. /**
  76376. * Vector3
  76377. */
  76378. Vector3 = 2,
  76379. /**
  76380. * Quaternions
  76381. */
  76382. Quaternion = 3,
  76383. /**
  76384. * Color3
  76385. */
  76386. Color3 = 4,
  76387. /**
  76388. * String
  76389. */
  76390. String = 5
  76391. }
  76392. /**
  76393. * Interface used to define custom inspectable properties.
  76394. * This interface is used by the inspector to display custom property grids
  76395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76396. */
  76397. export interface IInspectable {
  76398. /**
  76399. * Gets the label to display
  76400. */
  76401. label: string;
  76402. /**
  76403. * Gets the name of the property to edit
  76404. */
  76405. propertyName: string;
  76406. /**
  76407. * Gets the type of the editor to use
  76408. */
  76409. type: InspectableType;
  76410. /**
  76411. * Gets the minimum value of the property when using in "slider" mode
  76412. */
  76413. min?: number;
  76414. /**
  76415. * Gets the maximum value of the property when using in "slider" mode
  76416. */
  76417. max?: number;
  76418. /**
  76419. * Gets the setp to use when using in "slider" mode
  76420. */
  76421. step?: number;
  76422. }
  76423. }
  76424. declare module BABYLON {
  76425. /**
  76426. * Class used to provide helper for timing
  76427. */
  76428. export class TimingTools {
  76429. /**
  76430. * Polyfill for setImmediate
  76431. * @param action defines the action to execute after the current execution block
  76432. */
  76433. static SetImmediate(action: () => void): void;
  76434. }
  76435. }
  76436. declare module BABYLON {
  76437. /**
  76438. * Class used to enable instatition of objects by class name
  76439. */
  76440. export class InstantiationTools {
  76441. /**
  76442. * Use this object to register external classes like custom textures or material
  76443. * to allow the laoders to instantiate them
  76444. */
  76445. static RegisteredExternalClasses: {
  76446. [key: string]: Object;
  76447. };
  76448. /**
  76449. * Tries to instantiate a new object from a given class name
  76450. * @param className defines the class name to instantiate
  76451. * @returns the new object or null if the system was not able to do the instantiation
  76452. */
  76453. static Instantiate(className: string): any;
  76454. }
  76455. }
  76456. declare module BABYLON {
  76457. /**
  76458. * Define options used to create a depth texture
  76459. */
  76460. export class DepthTextureCreationOptions {
  76461. /** Specifies whether or not a stencil should be allocated in the texture */
  76462. generateStencil?: boolean;
  76463. /** Specifies whether or not bilinear filtering is enable on the texture */
  76464. bilinearFiltering?: boolean;
  76465. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76466. comparisonFunction?: number;
  76467. /** Specifies if the created texture is a cube texture */
  76468. isCube?: boolean;
  76469. }
  76470. }
  76471. declare module BABYLON {
  76472. interface ThinEngine {
  76473. /**
  76474. * Creates a depth stencil cube texture.
  76475. * This is only available in WebGL 2.
  76476. * @param size The size of face edge in the cube texture.
  76477. * @param options The options defining the cube texture.
  76478. * @returns The cube texture
  76479. */
  76480. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76481. /**
  76482. * Creates a cube texture
  76483. * @param rootUrl defines the url where the files to load is located
  76484. * @param scene defines the current scene
  76485. * @param files defines the list of files to load (1 per face)
  76486. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76487. * @param onLoad defines an optional callback raised when the texture is loaded
  76488. * @param onError defines an optional callback raised if there is an issue to load the texture
  76489. * @param format defines the format of the data
  76490. * @param forcedExtension defines the extension to use to pick the right loader
  76491. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76492. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76493. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76494. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76495. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76496. * @returns the cube texture as an InternalTexture
  76497. */
  76498. 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;
  76499. /**
  76500. * Creates a cube texture
  76501. * @param rootUrl defines the url where the files to load is located
  76502. * @param scene defines the current scene
  76503. * @param files defines the list of files to load (1 per face)
  76504. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76505. * @param onLoad defines an optional callback raised when the texture is loaded
  76506. * @param onError defines an optional callback raised if there is an issue to load the texture
  76507. * @param format defines the format of the data
  76508. * @param forcedExtension defines the extension to use to pick the right loader
  76509. * @returns the cube texture as an InternalTexture
  76510. */
  76511. 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;
  76512. /**
  76513. * Creates a cube texture
  76514. * @param rootUrl defines the url where the files to load is located
  76515. * @param scene defines the current scene
  76516. * @param files defines the list of files to load (1 per face)
  76517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76518. * @param onLoad defines an optional callback raised when the texture is loaded
  76519. * @param onError defines an optional callback raised if there is an issue to load the texture
  76520. * @param format defines the format of the data
  76521. * @param forcedExtension defines the extension to use to pick the right loader
  76522. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76523. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76524. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76525. * @returns the cube texture as an InternalTexture
  76526. */
  76527. 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;
  76528. /** @hidden */
  76529. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76530. /** @hidden */
  76531. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76532. /** @hidden */
  76533. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76534. /** @hidden */
  76535. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76536. /**
  76537. * @hidden
  76538. */
  76539. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76540. }
  76541. }
  76542. declare module BABYLON {
  76543. /**
  76544. * Class for creating a cube texture
  76545. */
  76546. export class CubeTexture extends BaseTexture {
  76547. private _delayedOnLoad;
  76548. /**
  76549. * The url of the texture
  76550. */
  76551. url: string;
  76552. /**
  76553. * Gets or sets the center of the bounding box associated with the cube texture.
  76554. * It must define where the camera used to render the texture was set
  76555. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76556. */
  76557. boundingBoxPosition: Vector3;
  76558. private _boundingBoxSize;
  76559. /**
  76560. * Gets or sets the size of the bounding box associated with the cube texture
  76561. * When defined, the cubemap will switch to local mode
  76562. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76563. * @example https://www.babylonjs-playground.com/#RNASML
  76564. */
  76565. /**
  76566. * Returns the bounding box size
  76567. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76568. */
  76569. boundingBoxSize: Vector3;
  76570. protected _rotationY: number;
  76571. /**
  76572. * Sets texture matrix rotation angle around Y axis in radians.
  76573. */
  76574. /**
  76575. * Gets texture matrix rotation angle around Y axis radians.
  76576. */
  76577. rotationY: number;
  76578. /**
  76579. * Are mip maps generated for this texture or not.
  76580. */
  76581. readonly noMipmap: boolean;
  76582. private _noMipmap;
  76583. private _files;
  76584. protected _forcedExtension: Nullable<string>;
  76585. private _extensions;
  76586. private _textureMatrix;
  76587. private _format;
  76588. private _createPolynomials;
  76589. /** @hidden */
  76590. _prefiltered: boolean;
  76591. /**
  76592. * Creates a cube texture from an array of image urls
  76593. * @param files defines an array of image urls
  76594. * @param scene defines the hosting scene
  76595. * @param noMipmap specifies if mip maps are not used
  76596. * @returns a cube texture
  76597. */
  76598. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76599. /**
  76600. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76601. * @param url defines the url of the prefiltered texture
  76602. * @param scene defines the scene the texture is attached to
  76603. * @param forcedExtension defines the extension of the file if different from the url
  76604. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76605. * @return the prefiltered texture
  76606. */
  76607. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76608. /**
  76609. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76610. * as prefiltered data.
  76611. * @param rootUrl defines the url of the texture or the root name of the six images
  76612. * @param scene defines the scene the texture is attached to
  76613. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76614. * @param noMipmap defines if mipmaps should be created or not
  76615. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76616. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76617. * @param onError defines a callback triggered in case of error during load
  76618. * @param format defines the internal format to use for the texture once loaded
  76619. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76620. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76621. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76622. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76623. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76624. * @return the cube texture
  76625. */
  76626. 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);
  76627. /**
  76628. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76629. */
  76630. readonly isPrefiltered: boolean;
  76631. /**
  76632. * Get the current class name of the texture useful for serialization or dynamic coding.
  76633. * @returns "CubeTexture"
  76634. */
  76635. getClassName(): string;
  76636. /**
  76637. * Update the url (and optional buffer) of this texture if url was null during construction.
  76638. * @param url the url of the texture
  76639. * @param forcedExtension defines the extension to use
  76640. * @param onLoad callback called when the texture is loaded (defaults to null)
  76641. */
  76642. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76643. /**
  76644. * Delays loading of the cube texture
  76645. * @param forcedExtension defines the extension to use
  76646. */
  76647. delayLoad(forcedExtension?: string): void;
  76648. /**
  76649. * Returns the reflection texture matrix
  76650. * @returns the reflection texture matrix
  76651. */
  76652. getReflectionTextureMatrix(): Matrix;
  76653. /**
  76654. * Sets the reflection texture matrix
  76655. * @param value Reflection texture matrix
  76656. */
  76657. setReflectionTextureMatrix(value: Matrix): void;
  76658. /**
  76659. * Parses text to create a cube texture
  76660. * @param parsedTexture define the serialized text to read from
  76661. * @param scene defines the hosting scene
  76662. * @param rootUrl defines the root url of the cube texture
  76663. * @returns a cube texture
  76664. */
  76665. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76666. /**
  76667. * Makes a clone, or deep copy, of the cube texture
  76668. * @returns a new cube texture
  76669. */
  76670. clone(): CubeTexture;
  76671. }
  76672. }
  76673. declare module BABYLON {
  76674. /**
  76675. * Manages the defines for the Material
  76676. */
  76677. export class MaterialDefines {
  76678. /** @hidden */
  76679. protected _keys: string[];
  76680. private _isDirty;
  76681. /** @hidden */
  76682. _renderId: number;
  76683. /** @hidden */
  76684. _areLightsDirty: boolean;
  76685. /** @hidden */
  76686. _areLightsDisposed: boolean;
  76687. /** @hidden */
  76688. _areAttributesDirty: boolean;
  76689. /** @hidden */
  76690. _areTexturesDirty: boolean;
  76691. /** @hidden */
  76692. _areFresnelDirty: boolean;
  76693. /** @hidden */
  76694. _areMiscDirty: boolean;
  76695. /** @hidden */
  76696. _areImageProcessingDirty: boolean;
  76697. /** @hidden */
  76698. _normals: boolean;
  76699. /** @hidden */
  76700. _uvs: boolean;
  76701. /** @hidden */
  76702. _needNormals: boolean;
  76703. /** @hidden */
  76704. _needUVs: boolean;
  76705. [id: string]: any;
  76706. /**
  76707. * Specifies if the material needs to be re-calculated
  76708. */
  76709. readonly isDirty: boolean;
  76710. /**
  76711. * Marks the material to indicate that it has been re-calculated
  76712. */
  76713. markAsProcessed(): void;
  76714. /**
  76715. * Marks the material to indicate that it needs to be re-calculated
  76716. */
  76717. markAsUnprocessed(): void;
  76718. /**
  76719. * Marks the material to indicate all of its defines need to be re-calculated
  76720. */
  76721. markAllAsDirty(): void;
  76722. /**
  76723. * Marks the material to indicate that image processing needs to be re-calculated
  76724. */
  76725. markAsImageProcessingDirty(): void;
  76726. /**
  76727. * Marks the material to indicate the lights need to be re-calculated
  76728. * @param disposed Defines whether the light is dirty due to dispose or not
  76729. */
  76730. markAsLightDirty(disposed?: boolean): void;
  76731. /**
  76732. * Marks the attribute state as changed
  76733. */
  76734. markAsAttributesDirty(): void;
  76735. /**
  76736. * Marks the texture state as changed
  76737. */
  76738. markAsTexturesDirty(): void;
  76739. /**
  76740. * Marks the fresnel state as changed
  76741. */
  76742. markAsFresnelDirty(): void;
  76743. /**
  76744. * Marks the misc state as changed
  76745. */
  76746. markAsMiscDirty(): void;
  76747. /**
  76748. * Rebuilds the material defines
  76749. */
  76750. rebuild(): void;
  76751. /**
  76752. * Specifies if two material defines are equal
  76753. * @param other - A material define instance to compare to
  76754. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76755. */
  76756. isEqual(other: MaterialDefines): boolean;
  76757. /**
  76758. * Clones this instance's defines to another instance
  76759. * @param other - material defines to clone values to
  76760. */
  76761. cloneTo(other: MaterialDefines): void;
  76762. /**
  76763. * Resets the material define values
  76764. */
  76765. reset(): void;
  76766. /**
  76767. * Converts the material define values to a string
  76768. * @returns - String of material define information
  76769. */
  76770. toString(): string;
  76771. }
  76772. }
  76773. declare module BABYLON {
  76774. /**
  76775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76777. * 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;
  76778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76779. */
  76780. export class ColorCurves {
  76781. private _dirty;
  76782. private _tempColor;
  76783. private _globalCurve;
  76784. private _highlightsCurve;
  76785. private _midtonesCurve;
  76786. private _shadowsCurve;
  76787. private _positiveCurve;
  76788. private _negativeCurve;
  76789. private _globalHue;
  76790. private _globalDensity;
  76791. private _globalSaturation;
  76792. private _globalExposure;
  76793. /**
  76794. * Gets the global Hue value.
  76795. * 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).
  76796. */
  76797. /**
  76798. * Sets the global Hue value.
  76799. * 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).
  76800. */
  76801. globalHue: number;
  76802. /**
  76803. * Gets the global Density value.
  76804. * 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.
  76805. * Values less than zero provide a filter of opposite hue.
  76806. */
  76807. /**
  76808. * Sets the global Density value.
  76809. * 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.
  76810. * Values less than zero provide a filter of opposite hue.
  76811. */
  76812. globalDensity: number;
  76813. /**
  76814. * Gets the global Saturation value.
  76815. * 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.
  76816. */
  76817. /**
  76818. * Sets the global Saturation value.
  76819. * 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.
  76820. */
  76821. globalSaturation: number;
  76822. /**
  76823. * Gets the global Exposure value.
  76824. * 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.
  76825. */
  76826. /**
  76827. * Sets the global Exposure value.
  76828. * 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.
  76829. */
  76830. globalExposure: number;
  76831. private _highlightsHue;
  76832. private _highlightsDensity;
  76833. private _highlightsSaturation;
  76834. private _highlightsExposure;
  76835. /**
  76836. * Gets the highlights Hue value.
  76837. * 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).
  76838. */
  76839. /**
  76840. * Sets the highlights Hue value.
  76841. * 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).
  76842. */
  76843. highlightsHue: number;
  76844. /**
  76845. * Gets the highlights Density value.
  76846. * 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.
  76847. * Values less than zero provide a filter of opposite hue.
  76848. */
  76849. /**
  76850. * Sets the highlights Density value.
  76851. * 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.
  76852. * Values less than zero provide a filter of opposite hue.
  76853. */
  76854. highlightsDensity: number;
  76855. /**
  76856. * Gets the highlights Saturation value.
  76857. * 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.
  76858. */
  76859. /**
  76860. * Sets the highlights Saturation value.
  76861. * 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.
  76862. */
  76863. highlightsSaturation: number;
  76864. /**
  76865. * Gets the highlights Exposure value.
  76866. * 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.
  76867. */
  76868. /**
  76869. * Sets the highlights Exposure value.
  76870. * 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.
  76871. */
  76872. highlightsExposure: number;
  76873. private _midtonesHue;
  76874. private _midtonesDensity;
  76875. private _midtonesSaturation;
  76876. private _midtonesExposure;
  76877. /**
  76878. * Gets the midtones Hue value.
  76879. * 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).
  76880. */
  76881. /**
  76882. * Sets the midtones Hue value.
  76883. * 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).
  76884. */
  76885. midtonesHue: number;
  76886. /**
  76887. * Gets the midtones Density value.
  76888. * 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.
  76889. * Values less than zero provide a filter of opposite hue.
  76890. */
  76891. /**
  76892. * Sets the midtones Density value.
  76893. * 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.
  76894. * Values less than zero provide a filter of opposite hue.
  76895. */
  76896. midtonesDensity: number;
  76897. /**
  76898. * Gets the midtones Saturation value.
  76899. * 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.
  76900. */
  76901. /**
  76902. * Sets the midtones Saturation value.
  76903. * 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.
  76904. */
  76905. midtonesSaturation: number;
  76906. /**
  76907. * Gets the midtones Exposure value.
  76908. * 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.
  76909. */
  76910. /**
  76911. * Sets the midtones Exposure value.
  76912. * 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.
  76913. */
  76914. midtonesExposure: number;
  76915. private _shadowsHue;
  76916. private _shadowsDensity;
  76917. private _shadowsSaturation;
  76918. private _shadowsExposure;
  76919. /**
  76920. * Gets the shadows Hue value.
  76921. * 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).
  76922. */
  76923. /**
  76924. * Sets the shadows Hue value.
  76925. * 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).
  76926. */
  76927. shadowsHue: number;
  76928. /**
  76929. * Gets the shadows Density value.
  76930. * 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.
  76931. * Values less than zero provide a filter of opposite hue.
  76932. */
  76933. /**
  76934. * Sets the shadows Density value.
  76935. * 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.
  76936. * Values less than zero provide a filter of opposite hue.
  76937. */
  76938. shadowsDensity: number;
  76939. /**
  76940. * Gets the shadows Saturation value.
  76941. * 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.
  76942. */
  76943. /**
  76944. * Sets the shadows Saturation value.
  76945. * 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.
  76946. */
  76947. shadowsSaturation: number;
  76948. /**
  76949. * Gets the shadows Exposure value.
  76950. * 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.
  76951. */
  76952. /**
  76953. * Sets the shadows Exposure value.
  76954. * 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.
  76955. */
  76956. shadowsExposure: number;
  76957. /**
  76958. * Returns the class name
  76959. * @returns The class name
  76960. */
  76961. getClassName(): string;
  76962. /**
  76963. * Binds the color curves to the shader.
  76964. * @param colorCurves The color curve to bind
  76965. * @param effect The effect to bind to
  76966. * @param positiveUniform The positive uniform shader parameter
  76967. * @param neutralUniform The neutral uniform shader parameter
  76968. * @param negativeUniform The negative uniform shader parameter
  76969. */
  76970. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76971. /**
  76972. * Prepare the list of uniforms associated with the ColorCurves effects.
  76973. * @param uniformsList The list of uniforms used in the effect
  76974. */
  76975. static PrepareUniforms(uniformsList: string[]): void;
  76976. /**
  76977. * Returns color grading data based on a hue, density, saturation and exposure value.
  76978. * @param filterHue The hue of the color filter.
  76979. * @param filterDensity The density of the color filter.
  76980. * @param saturation The saturation.
  76981. * @param exposure The exposure.
  76982. * @param result The result data container.
  76983. */
  76984. private getColorGradingDataToRef;
  76985. /**
  76986. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76987. * @param value The input slider value in range [-100,100].
  76988. * @returns Adjusted value.
  76989. */
  76990. private static applyColorGradingSliderNonlinear;
  76991. /**
  76992. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76993. * @param hue The hue (H) input.
  76994. * @param saturation The saturation (S) input.
  76995. * @param brightness The brightness (B) input.
  76996. * @result An RGBA color represented as Vector4.
  76997. */
  76998. private static fromHSBToRef;
  76999. /**
  77000. * Returns a value clamped between min and max
  77001. * @param value The value to clamp
  77002. * @param min The minimum of value
  77003. * @param max The maximum of value
  77004. * @returns The clamped value.
  77005. */
  77006. private static clamp;
  77007. /**
  77008. * Clones the current color curve instance.
  77009. * @return The cloned curves
  77010. */
  77011. clone(): ColorCurves;
  77012. /**
  77013. * Serializes the current color curve instance to a json representation.
  77014. * @return a JSON representation
  77015. */
  77016. serialize(): any;
  77017. /**
  77018. * Parses the color curve from a json representation.
  77019. * @param source the JSON source to parse
  77020. * @return The parsed curves
  77021. */
  77022. static Parse(source: any): ColorCurves;
  77023. }
  77024. }
  77025. declare module BABYLON {
  77026. /**
  77027. * Interface to follow in your material defines to integrate easily the
  77028. * Image proccessing functions.
  77029. * @hidden
  77030. */
  77031. export interface IImageProcessingConfigurationDefines {
  77032. IMAGEPROCESSING: boolean;
  77033. VIGNETTE: boolean;
  77034. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77035. VIGNETTEBLENDMODEOPAQUE: boolean;
  77036. TONEMAPPING: boolean;
  77037. TONEMAPPING_ACES: boolean;
  77038. CONTRAST: boolean;
  77039. EXPOSURE: boolean;
  77040. COLORCURVES: boolean;
  77041. COLORGRADING: boolean;
  77042. COLORGRADING3D: boolean;
  77043. SAMPLER3DGREENDEPTH: boolean;
  77044. SAMPLER3DBGRMAP: boolean;
  77045. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77046. }
  77047. /**
  77048. * @hidden
  77049. */
  77050. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77051. IMAGEPROCESSING: boolean;
  77052. VIGNETTE: boolean;
  77053. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77054. VIGNETTEBLENDMODEOPAQUE: boolean;
  77055. TONEMAPPING: boolean;
  77056. TONEMAPPING_ACES: boolean;
  77057. CONTRAST: boolean;
  77058. COLORCURVES: boolean;
  77059. COLORGRADING: boolean;
  77060. COLORGRADING3D: boolean;
  77061. SAMPLER3DGREENDEPTH: boolean;
  77062. SAMPLER3DBGRMAP: boolean;
  77063. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77064. EXPOSURE: boolean;
  77065. constructor();
  77066. }
  77067. /**
  77068. * This groups together the common properties used for image processing either in direct forward pass
  77069. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77070. * or not.
  77071. */
  77072. export class ImageProcessingConfiguration {
  77073. /**
  77074. * Default tone mapping applied in BabylonJS.
  77075. */
  77076. static readonly TONEMAPPING_STANDARD: number;
  77077. /**
  77078. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77079. * to other engines rendering to increase portability.
  77080. */
  77081. static readonly TONEMAPPING_ACES: number;
  77082. /**
  77083. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77084. */
  77085. colorCurves: Nullable<ColorCurves>;
  77086. private _colorCurvesEnabled;
  77087. /**
  77088. * Gets wether the color curves effect is enabled.
  77089. */
  77090. /**
  77091. * Sets wether the color curves effect is enabled.
  77092. */
  77093. colorCurvesEnabled: boolean;
  77094. private _colorGradingTexture;
  77095. /**
  77096. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77097. */
  77098. /**
  77099. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77100. */
  77101. colorGradingTexture: Nullable<BaseTexture>;
  77102. private _colorGradingEnabled;
  77103. /**
  77104. * Gets wether the color grading effect is enabled.
  77105. */
  77106. /**
  77107. * Sets wether the color grading effect is enabled.
  77108. */
  77109. colorGradingEnabled: boolean;
  77110. private _colorGradingWithGreenDepth;
  77111. /**
  77112. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77113. */
  77114. /**
  77115. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77116. */
  77117. colorGradingWithGreenDepth: boolean;
  77118. private _colorGradingBGR;
  77119. /**
  77120. * Gets wether the color grading texture contains BGR values.
  77121. */
  77122. /**
  77123. * Sets wether the color grading texture contains BGR values.
  77124. */
  77125. colorGradingBGR: boolean;
  77126. /** @hidden */
  77127. _exposure: number;
  77128. /**
  77129. * Gets the Exposure used in the effect.
  77130. */
  77131. /**
  77132. * Sets the Exposure used in the effect.
  77133. */
  77134. exposure: number;
  77135. private _toneMappingEnabled;
  77136. /**
  77137. * Gets wether the tone mapping effect is enabled.
  77138. */
  77139. /**
  77140. * Sets wether the tone mapping effect is enabled.
  77141. */
  77142. toneMappingEnabled: boolean;
  77143. private _toneMappingType;
  77144. /**
  77145. * Gets the type of tone mapping effect.
  77146. */
  77147. /**
  77148. * Sets the type of tone mapping effect used in BabylonJS.
  77149. */
  77150. toneMappingType: number;
  77151. protected _contrast: number;
  77152. /**
  77153. * Gets the contrast used in the effect.
  77154. */
  77155. /**
  77156. * Sets the contrast used in the effect.
  77157. */
  77158. contrast: number;
  77159. /**
  77160. * Vignette stretch size.
  77161. */
  77162. vignetteStretch: number;
  77163. /**
  77164. * Vignette centre X Offset.
  77165. */
  77166. vignetteCentreX: number;
  77167. /**
  77168. * Vignette centre Y Offset.
  77169. */
  77170. vignetteCentreY: number;
  77171. /**
  77172. * Vignette weight or intensity of the vignette effect.
  77173. */
  77174. vignetteWeight: number;
  77175. /**
  77176. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77177. * if vignetteEnabled is set to true.
  77178. */
  77179. vignetteColor: Color4;
  77180. /**
  77181. * Camera field of view used by the Vignette effect.
  77182. */
  77183. vignetteCameraFov: number;
  77184. private _vignetteBlendMode;
  77185. /**
  77186. * Gets the vignette blend mode allowing different kind of effect.
  77187. */
  77188. /**
  77189. * Sets the vignette blend mode allowing different kind of effect.
  77190. */
  77191. vignetteBlendMode: number;
  77192. private _vignetteEnabled;
  77193. /**
  77194. * Gets wether the vignette effect is enabled.
  77195. */
  77196. /**
  77197. * Sets wether the vignette effect is enabled.
  77198. */
  77199. vignetteEnabled: boolean;
  77200. private _applyByPostProcess;
  77201. /**
  77202. * Gets wether the image processing is applied through a post process or not.
  77203. */
  77204. /**
  77205. * Sets wether the image processing is applied through a post process or not.
  77206. */
  77207. applyByPostProcess: boolean;
  77208. private _isEnabled;
  77209. /**
  77210. * Gets wether the image processing is enabled or not.
  77211. */
  77212. /**
  77213. * Sets wether the image processing is enabled or not.
  77214. */
  77215. isEnabled: boolean;
  77216. /**
  77217. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77218. */
  77219. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77220. /**
  77221. * Method called each time the image processing information changes requires to recompile the effect.
  77222. */
  77223. protected _updateParameters(): void;
  77224. /**
  77225. * Gets the current class name.
  77226. * @return "ImageProcessingConfiguration"
  77227. */
  77228. getClassName(): string;
  77229. /**
  77230. * Prepare the list of uniforms associated with the Image Processing effects.
  77231. * @param uniforms The list of uniforms used in the effect
  77232. * @param defines the list of defines currently in use
  77233. */
  77234. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77235. /**
  77236. * Prepare the list of samplers associated with the Image Processing effects.
  77237. * @param samplersList The list of uniforms used in the effect
  77238. * @param defines the list of defines currently in use
  77239. */
  77240. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77241. /**
  77242. * Prepare the list of defines associated to the shader.
  77243. * @param defines the list of defines to complete
  77244. * @param forPostProcess Define if we are currently in post process mode or not
  77245. */
  77246. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77247. /**
  77248. * Returns true if all the image processing information are ready.
  77249. * @returns True if ready, otherwise, false
  77250. */
  77251. isReady(): boolean;
  77252. /**
  77253. * Binds the image processing to the shader.
  77254. * @param effect The effect to bind to
  77255. * @param overrideAspectRatio Override the aspect ratio of the effect
  77256. */
  77257. bind(effect: Effect, overrideAspectRatio?: number): void;
  77258. /**
  77259. * Clones the current image processing instance.
  77260. * @return The cloned image processing
  77261. */
  77262. clone(): ImageProcessingConfiguration;
  77263. /**
  77264. * Serializes the current image processing instance to a json representation.
  77265. * @return a JSON representation
  77266. */
  77267. serialize(): any;
  77268. /**
  77269. * Parses the image processing from a json representation.
  77270. * @param source the JSON source to parse
  77271. * @return The parsed image processing
  77272. */
  77273. static Parse(source: any): ImageProcessingConfiguration;
  77274. private static _VIGNETTEMODE_MULTIPLY;
  77275. private static _VIGNETTEMODE_OPAQUE;
  77276. /**
  77277. * Used to apply the vignette as a mix with the pixel color.
  77278. */
  77279. static readonly VIGNETTEMODE_MULTIPLY: number;
  77280. /**
  77281. * Used to apply the vignette as a replacement of the pixel color.
  77282. */
  77283. static readonly VIGNETTEMODE_OPAQUE: number;
  77284. }
  77285. }
  77286. declare module BABYLON {
  77287. /** @hidden */
  77288. export var postprocessVertexShader: {
  77289. name: string;
  77290. shader: string;
  77291. };
  77292. }
  77293. declare module BABYLON {
  77294. interface ThinEngine {
  77295. /**
  77296. * Creates a new render target texture
  77297. * @param size defines the size of the texture
  77298. * @param options defines the options used to create the texture
  77299. * @returns a new render target texture stored in an InternalTexture
  77300. */
  77301. createRenderTargetTexture(size: number | {
  77302. width: number;
  77303. height: number;
  77304. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77305. /**
  77306. * Creates a depth stencil texture.
  77307. * This is only available in WebGL 2 or with the depth texture extension available.
  77308. * @param size The size of face edge in the texture.
  77309. * @param options The options defining the texture.
  77310. * @returns The texture
  77311. */
  77312. createDepthStencilTexture(size: number | {
  77313. width: number;
  77314. height: number;
  77315. }, options: DepthTextureCreationOptions): InternalTexture;
  77316. /** @hidden */
  77317. _createDepthStencilTexture(size: number | {
  77318. width: number;
  77319. height: number;
  77320. }, options: DepthTextureCreationOptions): InternalTexture;
  77321. }
  77322. }
  77323. declare module BABYLON {
  77324. /** Defines supported spaces */
  77325. export enum Space {
  77326. /** Local (object) space */
  77327. LOCAL = 0,
  77328. /** World space */
  77329. WORLD = 1,
  77330. /** Bone space */
  77331. BONE = 2
  77332. }
  77333. /** Defines the 3 main axes */
  77334. export class Axis {
  77335. /** X axis */
  77336. static X: Vector3;
  77337. /** Y axis */
  77338. static Y: Vector3;
  77339. /** Z axis */
  77340. static Z: Vector3;
  77341. }
  77342. }
  77343. declare module BABYLON {
  77344. /**
  77345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77346. * This is the base of the follow, arc rotate cameras and Free camera
  77347. * @see http://doc.babylonjs.com/features/cameras
  77348. */
  77349. export class TargetCamera extends Camera {
  77350. private static _RigCamTransformMatrix;
  77351. private static _TargetTransformMatrix;
  77352. private static _TargetFocalPoint;
  77353. /**
  77354. * Define the current direction the camera is moving to
  77355. */
  77356. cameraDirection: Vector3;
  77357. /**
  77358. * Define the current rotation the camera is rotating to
  77359. */
  77360. cameraRotation: Vector2;
  77361. /**
  77362. * When set, the up vector of the camera will be updated by the rotation of the camera
  77363. */
  77364. updateUpVectorFromRotation: boolean;
  77365. private _tmpQuaternion;
  77366. /**
  77367. * Define the current rotation of the camera
  77368. */
  77369. rotation: Vector3;
  77370. /**
  77371. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77372. */
  77373. rotationQuaternion: Quaternion;
  77374. /**
  77375. * Define the current speed of the camera
  77376. */
  77377. speed: number;
  77378. /**
  77379. * Add constraint to the camera to prevent it to move freely in all directions and
  77380. * around all axis.
  77381. */
  77382. noRotationConstraint: boolean;
  77383. /**
  77384. * Define the current target of the camera as an object or a position.
  77385. */
  77386. lockedTarget: any;
  77387. /** @hidden */
  77388. _currentTarget: Vector3;
  77389. /** @hidden */
  77390. _initialFocalDistance: number;
  77391. /** @hidden */
  77392. _viewMatrix: Matrix;
  77393. /** @hidden */
  77394. _camMatrix: Matrix;
  77395. /** @hidden */
  77396. _cameraTransformMatrix: Matrix;
  77397. /** @hidden */
  77398. _cameraRotationMatrix: Matrix;
  77399. /** @hidden */
  77400. _referencePoint: Vector3;
  77401. /** @hidden */
  77402. _transformedReferencePoint: Vector3;
  77403. protected _globalCurrentTarget: Vector3;
  77404. protected _globalCurrentUpVector: Vector3;
  77405. /** @hidden */
  77406. _reset: () => void;
  77407. private _defaultUp;
  77408. /**
  77409. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77410. * This is the base of the follow, arc rotate cameras and Free camera
  77411. * @see http://doc.babylonjs.com/features/cameras
  77412. * @param name Defines the name of the camera in the scene
  77413. * @param position Defines the start position of the camera in the scene
  77414. * @param scene Defines the scene the camera belongs to
  77415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77416. */
  77417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77418. /**
  77419. * Gets the position in front of the camera at a given distance.
  77420. * @param distance The distance from the camera we want the position to be
  77421. * @returns the position
  77422. */
  77423. getFrontPosition(distance: number): Vector3;
  77424. /** @hidden */
  77425. _getLockedTargetPosition(): Nullable<Vector3>;
  77426. private _storedPosition;
  77427. private _storedRotation;
  77428. private _storedRotationQuaternion;
  77429. /**
  77430. * Store current camera state of the camera (fov, position, rotation, etc..)
  77431. * @returns the camera
  77432. */
  77433. storeState(): Camera;
  77434. /**
  77435. * Restored camera state. You must call storeState() first
  77436. * @returns whether it was successful or not
  77437. * @hidden
  77438. */
  77439. _restoreStateValues(): boolean;
  77440. /** @hidden */
  77441. _initCache(): void;
  77442. /** @hidden */
  77443. _updateCache(ignoreParentClass?: boolean): void;
  77444. /** @hidden */
  77445. _isSynchronizedViewMatrix(): boolean;
  77446. /** @hidden */
  77447. _computeLocalCameraSpeed(): number;
  77448. /**
  77449. * Defines the target the camera should look at.
  77450. * @param target Defines the new target as a Vector or a mesh
  77451. */
  77452. setTarget(target: Vector3): void;
  77453. /**
  77454. * Return the current target position of the camera. This value is expressed in local space.
  77455. * @returns the target position
  77456. */
  77457. getTarget(): Vector3;
  77458. /** @hidden */
  77459. _decideIfNeedsToMove(): boolean;
  77460. /** @hidden */
  77461. _updatePosition(): void;
  77462. /** @hidden */
  77463. _checkInputs(): void;
  77464. protected _updateCameraRotationMatrix(): void;
  77465. /**
  77466. * 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)
  77467. * @returns the current camera
  77468. */
  77469. private _rotateUpVectorWithCameraRotationMatrix;
  77470. private _cachedRotationZ;
  77471. private _cachedQuaternionRotationZ;
  77472. /** @hidden */
  77473. _getViewMatrix(): Matrix;
  77474. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77475. /**
  77476. * @hidden
  77477. */
  77478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77479. /**
  77480. * @hidden
  77481. */
  77482. _updateRigCameras(): void;
  77483. private _getRigCamPositionAndTarget;
  77484. /**
  77485. * Gets the current object class name.
  77486. * @return the class name
  77487. */
  77488. getClassName(): string;
  77489. }
  77490. }
  77491. declare module BABYLON {
  77492. /**
  77493. * Gather the list of keyboard event types as constants.
  77494. */
  77495. export class KeyboardEventTypes {
  77496. /**
  77497. * The keydown event is fired when a key becomes active (pressed).
  77498. */
  77499. static readonly KEYDOWN: number;
  77500. /**
  77501. * The keyup event is fired when a key has been released.
  77502. */
  77503. static readonly KEYUP: number;
  77504. }
  77505. /**
  77506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77507. */
  77508. export class KeyboardInfo {
  77509. /**
  77510. * Defines the type of event (KeyboardEventTypes)
  77511. */
  77512. type: number;
  77513. /**
  77514. * Defines the related dom event
  77515. */
  77516. event: KeyboardEvent;
  77517. /**
  77518. * Instantiates a new keyboard info.
  77519. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77520. * @param type Defines the type of event (KeyboardEventTypes)
  77521. * @param event Defines the related dom event
  77522. */
  77523. constructor(
  77524. /**
  77525. * Defines the type of event (KeyboardEventTypes)
  77526. */
  77527. type: number,
  77528. /**
  77529. * Defines the related dom event
  77530. */
  77531. event: KeyboardEvent);
  77532. }
  77533. /**
  77534. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77535. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77536. */
  77537. export class KeyboardInfoPre extends KeyboardInfo {
  77538. /**
  77539. * Defines the type of event (KeyboardEventTypes)
  77540. */
  77541. type: number;
  77542. /**
  77543. * Defines the related dom event
  77544. */
  77545. event: KeyboardEvent;
  77546. /**
  77547. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77548. */
  77549. skipOnPointerObservable: boolean;
  77550. /**
  77551. * Instantiates a new keyboard pre info.
  77552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77553. * @param type Defines the type of event (KeyboardEventTypes)
  77554. * @param event Defines the related dom event
  77555. */
  77556. constructor(
  77557. /**
  77558. * Defines the type of event (KeyboardEventTypes)
  77559. */
  77560. type: number,
  77561. /**
  77562. * Defines the related dom event
  77563. */
  77564. event: KeyboardEvent);
  77565. }
  77566. }
  77567. declare module BABYLON {
  77568. /**
  77569. * Manage the keyboard inputs to control the movement of a free camera.
  77570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77571. */
  77572. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77573. /**
  77574. * Defines the camera the input is attached to.
  77575. */
  77576. camera: FreeCamera;
  77577. /**
  77578. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77579. */
  77580. keysUp: number[];
  77581. /**
  77582. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77583. */
  77584. keysDown: number[];
  77585. /**
  77586. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77587. */
  77588. keysLeft: number[];
  77589. /**
  77590. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77591. */
  77592. keysRight: number[];
  77593. private _keys;
  77594. private _onCanvasBlurObserver;
  77595. private _onKeyboardObserver;
  77596. private _engine;
  77597. private _scene;
  77598. /**
  77599. * Attach the input controls to a specific dom element to get the input from.
  77600. * @param element Defines the element the controls should be listened from
  77601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77602. */
  77603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77604. /**
  77605. * Detach the current controls from the specified dom element.
  77606. * @param element Defines the element to stop listening the inputs from
  77607. */
  77608. detachControl(element: Nullable<HTMLElement>): void;
  77609. /**
  77610. * Update the current camera state depending on the inputs that have been used this frame.
  77611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77612. */
  77613. checkInputs(): void;
  77614. /**
  77615. * Gets the class name of the current intput.
  77616. * @returns the class name
  77617. */
  77618. getClassName(): string;
  77619. /** @hidden */
  77620. _onLostFocus(): void;
  77621. /**
  77622. * Get the friendly name associated with the input class.
  77623. * @returns the input friendly name
  77624. */
  77625. getSimpleName(): string;
  77626. }
  77627. }
  77628. declare module BABYLON {
  77629. /**
  77630. * Interface describing all the common properties and methods a shadow light needs to implement.
  77631. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77632. * as well as binding the different shadow properties to the effects.
  77633. */
  77634. export interface IShadowLight extends Light {
  77635. /**
  77636. * The light id in the scene (used in scene.findLighById for instance)
  77637. */
  77638. id: string;
  77639. /**
  77640. * The position the shdow will be casted from.
  77641. */
  77642. position: Vector3;
  77643. /**
  77644. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77645. */
  77646. direction: Vector3;
  77647. /**
  77648. * The transformed position. Position of the light in world space taking parenting in account.
  77649. */
  77650. transformedPosition: Vector3;
  77651. /**
  77652. * The transformed direction. Direction of the light in world space taking parenting in account.
  77653. */
  77654. transformedDirection: Vector3;
  77655. /**
  77656. * The friendly name of the light in the scene.
  77657. */
  77658. name: string;
  77659. /**
  77660. * Defines the shadow projection clipping minimum z value.
  77661. */
  77662. shadowMinZ: number;
  77663. /**
  77664. * Defines the shadow projection clipping maximum z value.
  77665. */
  77666. shadowMaxZ: number;
  77667. /**
  77668. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77669. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77670. */
  77671. computeTransformedInformation(): boolean;
  77672. /**
  77673. * Gets the scene the light belongs to.
  77674. * @returns The scene
  77675. */
  77676. getScene(): Scene;
  77677. /**
  77678. * Callback defining a custom Projection Matrix Builder.
  77679. * This can be used to override the default projection matrix computation.
  77680. */
  77681. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77682. /**
  77683. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77684. * @param matrix The materix to updated with the projection information
  77685. * @param viewMatrix The transform matrix of the light
  77686. * @param renderList The list of mesh to render in the map
  77687. * @returns The current light
  77688. */
  77689. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77690. /**
  77691. * Gets the current depth scale used in ESM.
  77692. * @returns The scale
  77693. */
  77694. getDepthScale(): number;
  77695. /**
  77696. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77697. * @returns true if a cube texture needs to be use
  77698. */
  77699. needCube(): boolean;
  77700. /**
  77701. * Detects if the projection matrix requires to be recomputed this frame.
  77702. * @returns true if it requires to be recomputed otherwise, false.
  77703. */
  77704. needProjectionMatrixCompute(): boolean;
  77705. /**
  77706. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77707. */
  77708. forceProjectionMatrixCompute(): void;
  77709. /**
  77710. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77711. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77712. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77713. */
  77714. getShadowDirection(faceIndex?: number): Vector3;
  77715. /**
  77716. * Gets the minZ used for shadow according to both the scene and the light.
  77717. * @param activeCamera The camera we are returning the min for
  77718. * @returns the depth min z
  77719. */
  77720. getDepthMinZ(activeCamera: Camera): number;
  77721. /**
  77722. * Gets the maxZ used for shadow according to both the scene and the light.
  77723. * @param activeCamera The camera we are returning the max for
  77724. * @returns the depth max z
  77725. */
  77726. getDepthMaxZ(activeCamera: Camera): number;
  77727. }
  77728. /**
  77729. * Base implementation IShadowLight
  77730. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77731. */
  77732. export abstract class ShadowLight extends Light implements IShadowLight {
  77733. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77734. protected _position: Vector3;
  77735. protected _setPosition(value: Vector3): void;
  77736. /**
  77737. * Sets the position the shadow will be casted from. Also use as the light position for both
  77738. * point and spot lights.
  77739. */
  77740. /**
  77741. * Sets the position the shadow will be casted from. Also use as the light position for both
  77742. * point and spot lights.
  77743. */
  77744. position: Vector3;
  77745. protected _direction: Vector3;
  77746. protected _setDirection(value: Vector3): void;
  77747. /**
  77748. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77749. * Also use as the light direction on spot and directional lights.
  77750. */
  77751. /**
  77752. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77753. * Also use as the light direction on spot and directional lights.
  77754. */
  77755. direction: Vector3;
  77756. private _shadowMinZ;
  77757. /**
  77758. * Gets the shadow projection clipping minimum z value.
  77759. */
  77760. /**
  77761. * Sets the shadow projection clipping minimum z value.
  77762. */
  77763. shadowMinZ: number;
  77764. private _shadowMaxZ;
  77765. /**
  77766. * Sets the shadow projection clipping maximum z value.
  77767. */
  77768. /**
  77769. * Gets the shadow projection clipping maximum z value.
  77770. */
  77771. shadowMaxZ: number;
  77772. /**
  77773. * Callback defining a custom Projection Matrix Builder.
  77774. * This can be used to override the default projection matrix computation.
  77775. */
  77776. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77777. /**
  77778. * The transformed position. Position of the light in world space taking parenting in account.
  77779. */
  77780. transformedPosition: Vector3;
  77781. /**
  77782. * The transformed direction. Direction of the light in world space taking parenting in account.
  77783. */
  77784. transformedDirection: Vector3;
  77785. private _needProjectionMatrixCompute;
  77786. /**
  77787. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77788. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77789. */
  77790. computeTransformedInformation(): boolean;
  77791. /**
  77792. * Return the depth scale used for the shadow map.
  77793. * @returns the depth scale.
  77794. */
  77795. getDepthScale(): number;
  77796. /**
  77797. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77798. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77799. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77800. */
  77801. getShadowDirection(faceIndex?: number): Vector3;
  77802. /**
  77803. * Returns the ShadowLight absolute position in the World.
  77804. * @returns the position vector in world space
  77805. */
  77806. getAbsolutePosition(): Vector3;
  77807. /**
  77808. * Sets the ShadowLight direction toward the passed target.
  77809. * @param target The point to target in local space
  77810. * @returns the updated ShadowLight direction
  77811. */
  77812. setDirectionToTarget(target: Vector3): Vector3;
  77813. /**
  77814. * Returns the light rotation in euler definition.
  77815. * @returns the x y z rotation in local space.
  77816. */
  77817. getRotation(): Vector3;
  77818. /**
  77819. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77820. * @returns true if a cube texture needs to be use
  77821. */
  77822. needCube(): boolean;
  77823. /**
  77824. * Detects if the projection matrix requires to be recomputed this frame.
  77825. * @returns true if it requires to be recomputed otherwise, false.
  77826. */
  77827. needProjectionMatrixCompute(): boolean;
  77828. /**
  77829. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77830. */
  77831. forceProjectionMatrixCompute(): void;
  77832. /** @hidden */
  77833. _initCache(): void;
  77834. /** @hidden */
  77835. _isSynchronized(): boolean;
  77836. /**
  77837. * Computes the world matrix of the node
  77838. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77839. * @returns the world matrix
  77840. */
  77841. computeWorldMatrix(force?: boolean): Matrix;
  77842. /**
  77843. * Gets the minZ used for shadow according to both the scene and the light.
  77844. * @param activeCamera The camera we are returning the min for
  77845. * @returns the depth min z
  77846. */
  77847. getDepthMinZ(activeCamera: Camera): number;
  77848. /**
  77849. * Gets the maxZ used for shadow according to both the scene and the light.
  77850. * @param activeCamera The camera we are returning the max for
  77851. * @returns the depth max z
  77852. */
  77853. getDepthMaxZ(activeCamera: Camera): number;
  77854. /**
  77855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77856. * @param matrix The materix to updated with the projection information
  77857. * @param viewMatrix The transform matrix of the light
  77858. * @param renderList The list of mesh to render in the map
  77859. * @returns The current light
  77860. */
  77861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77862. }
  77863. }
  77864. declare module BABYLON {
  77865. /**
  77866. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77867. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77868. */
  77869. export class EffectFallbacks implements IEffectFallbacks {
  77870. private _defines;
  77871. private _currentRank;
  77872. private _maxRank;
  77873. private _mesh;
  77874. /**
  77875. * Removes the fallback from the bound mesh.
  77876. */
  77877. unBindMesh(): void;
  77878. /**
  77879. * Adds a fallback on the specified property.
  77880. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77881. * @param define The name of the define in the shader
  77882. */
  77883. addFallback(rank: number, define: string): void;
  77884. /**
  77885. * Sets the mesh to use CPU skinning when needing to fallback.
  77886. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77887. * @param mesh The mesh to use the fallbacks.
  77888. */
  77889. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77890. /**
  77891. * Checks to see if more fallbacks are still availible.
  77892. */
  77893. readonly hasMoreFallbacks: boolean;
  77894. /**
  77895. * Removes the defines that should be removed when falling back.
  77896. * @param currentDefines defines the current define statements for the shader.
  77897. * @param effect defines the current effect we try to compile
  77898. * @returns The resulting defines with defines of the current rank removed.
  77899. */
  77900. reduce(currentDefines: string, effect: Effect): string;
  77901. }
  77902. }
  77903. declare module BABYLON {
  77904. /**
  77905. * "Static Class" containing the most commonly used helper while dealing with material for
  77906. * rendering purpose.
  77907. *
  77908. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77909. *
  77910. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77911. */
  77912. export class MaterialHelper {
  77913. /**
  77914. * Bind the current view position to an effect.
  77915. * @param effect The effect to be bound
  77916. * @param scene The scene the eyes position is used from
  77917. */
  77918. static BindEyePosition(effect: Effect, scene: Scene): void;
  77919. /**
  77920. * Helps preparing the defines values about the UVs in used in the effect.
  77921. * UVs are shared as much as we can accross channels in the shaders.
  77922. * @param texture The texture we are preparing the UVs for
  77923. * @param defines The defines to update
  77924. * @param key The channel key "diffuse", "specular"... used in the shader
  77925. */
  77926. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77927. /**
  77928. * Binds a texture matrix value to its corrsponding uniform
  77929. * @param texture The texture to bind the matrix for
  77930. * @param uniformBuffer The uniform buffer receivin the data
  77931. * @param key The channel key "diffuse", "specular"... used in the shader
  77932. */
  77933. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77934. /**
  77935. * Gets the current status of the fog (should it be enabled?)
  77936. * @param mesh defines the mesh to evaluate for fog support
  77937. * @param scene defines the hosting scene
  77938. * @returns true if fog must be enabled
  77939. */
  77940. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77941. /**
  77942. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77943. * @param mesh defines the current mesh
  77944. * @param scene defines the current scene
  77945. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77946. * @param pointsCloud defines if point cloud rendering has to be turned on
  77947. * @param fogEnabled defines if fog has to be turned on
  77948. * @param alphaTest defines if alpha testing has to be turned on
  77949. * @param defines defines the current list of defines
  77950. */
  77951. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77952. /**
  77953. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77954. * @param scene defines the current scene
  77955. * @param engine defines the current engine
  77956. * @param defines specifies the list of active defines
  77957. * @param useInstances defines if instances have to be turned on
  77958. * @param useClipPlane defines if clip plane have to be turned on
  77959. */
  77960. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77961. /**
  77962. * Prepares the defines for bones
  77963. * @param mesh The mesh containing the geometry data we will draw
  77964. * @param defines The defines to update
  77965. */
  77966. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77967. /**
  77968. * Prepares the defines for morph targets
  77969. * @param mesh The mesh containing the geometry data we will draw
  77970. * @param defines The defines to update
  77971. */
  77972. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77973. /**
  77974. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77975. * @param mesh The mesh containing the geometry data we will draw
  77976. * @param defines The defines to update
  77977. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77978. * @param useBones Precise whether bones should be used or not (override mesh info)
  77979. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77980. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77981. * @returns false if defines are considered not dirty and have not been checked
  77982. */
  77983. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77984. /**
  77985. * Prepares the defines related to multiview
  77986. * @param scene The scene we are intending to draw
  77987. * @param defines The defines to update
  77988. */
  77989. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77990. /**
  77991. * Prepares the defines related to the light information passed in parameter
  77992. * @param scene The scene we are intending to draw
  77993. * @param mesh The mesh the effect is compiling for
  77994. * @param light The light the effect is compiling for
  77995. * @param lightIndex The index of the light
  77996. * @param defines The defines to update
  77997. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77998. * @param state Defines the current state regarding what is needed (normals, etc...)
  77999. */
  78000. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  78001. needNormals: boolean;
  78002. needRebuild: boolean;
  78003. shadowEnabled: boolean;
  78004. specularEnabled: boolean;
  78005. lightmapMode: boolean;
  78006. }): void;
  78007. /**
  78008. * Prepares the defines related to the light information passed in parameter
  78009. * @param scene The scene we are intending to draw
  78010. * @param mesh The mesh the effect is compiling for
  78011. * @param defines The defines to update
  78012. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78013. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  78014. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  78015. * @returns true if normals will be required for the rest of the effect
  78016. */
  78017. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  78018. /**
  78019. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78020. * @param lightIndex defines the light index
  78021. * @param uniformsList The uniform list
  78022. * @param samplersList The sampler list
  78023. * @param projectedLightTexture defines if projected texture must be used
  78024. * @param uniformBuffersList defines an optional list of uniform buffers
  78025. */
  78026. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78027. /**
  78028. * Prepares the uniforms and samplers list to be used in the effect
  78029. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78030. * @param samplersList The sampler list
  78031. * @param defines The defines helping in the list generation
  78032. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78033. */
  78034. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78035. /**
  78036. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78037. * @param defines The defines to update while falling back
  78038. * @param fallbacks The authorized effect fallbacks
  78039. * @param maxSimultaneousLights The maximum number of lights allowed
  78040. * @param rank the current rank of the Effect
  78041. * @returns The newly affected rank
  78042. */
  78043. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78044. private static _TmpMorphInfluencers;
  78045. /**
  78046. * Prepares the list of attributes required for morph targets according to the effect defines.
  78047. * @param attribs The current list of supported attribs
  78048. * @param mesh The mesh to prepare the morph targets attributes for
  78049. * @param influencers The number of influencers
  78050. */
  78051. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78052. /**
  78053. * Prepares the list of attributes required for morph targets according to the effect defines.
  78054. * @param attribs The current list of supported attribs
  78055. * @param mesh The mesh to prepare the morph targets attributes for
  78056. * @param defines The current Defines of the effect
  78057. */
  78058. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78059. /**
  78060. * Prepares the list of attributes required for bones according to the effect defines.
  78061. * @param attribs The current list of supported attribs
  78062. * @param mesh The mesh to prepare the bones attributes for
  78063. * @param defines The current Defines of the effect
  78064. * @param fallbacks The current efffect fallback strategy
  78065. */
  78066. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78067. /**
  78068. * Check and prepare the list of attributes required for instances according to the effect defines.
  78069. * @param attribs The current list of supported attribs
  78070. * @param defines The current MaterialDefines of the effect
  78071. */
  78072. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78073. /**
  78074. * Add the list of attributes required for instances to the attribs array.
  78075. * @param attribs The current list of supported attribs
  78076. */
  78077. static PushAttributesForInstances(attribs: string[]): void;
  78078. /**
  78079. * Binds the light information to the effect.
  78080. * @param light The light containing the generator
  78081. * @param effect The effect we are binding the data to
  78082. * @param lightIndex The light index in the effect used to render
  78083. */
  78084. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78085. /**
  78086. * Binds the lights information from the scene to the effect for the given mesh.
  78087. * @param light Light to bind
  78088. * @param lightIndex Light index
  78089. * @param scene The scene where the light belongs to
  78090. * @param effect The effect we are binding the data to
  78091. * @param useSpecular Defines if specular is supported
  78092. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78093. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78094. */
  78095. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78096. /**
  78097. * Binds the lights information from the scene to the effect for the given mesh.
  78098. * @param scene The scene the lights belongs to
  78099. * @param mesh The mesh we are binding the information to render
  78100. * @param effect The effect we are binding the data to
  78101. * @param defines The generated defines for the effect
  78102. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78103. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78104. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78105. */
  78106. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78107. private static _tempFogColor;
  78108. /**
  78109. * Binds the fog information from the scene to the effect for the given mesh.
  78110. * @param scene The scene the lights belongs to
  78111. * @param mesh The mesh we are binding the information to render
  78112. * @param effect The effect we are binding the data to
  78113. * @param linearSpace Defines if the fog effect is applied in linear space
  78114. */
  78115. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78116. /**
  78117. * Binds the bones information from the mesh to the effect.
  78118. * @param mesh The mesh we are binding the information to render
  78119. * @param effect The effect we are binding the data to
  78120. */
  78121. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78122. /**
  78123. * Binds the morph targets information from the mesh to the effect.
  78124. * @param abstractMesh The mesh we are binding the information to render
  78125. * @param effect The effect we are binding the data to
  78126. */
  78127. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78128. /**
  78129. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78130. * @param defines The generated defines used in the effect
  78131. * @param effect The effect we are binding the data to
  78132. * @param scene The scene we are willing to render with logarithmic scale for
  78133. */
  78134. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78135. /**
  78136. * Binds the clip plane information from the scene to the effect.
  78137. * @param scene The scene the clip plane information are extracted from
  78138. * @param effect The effect we are binding the data to
  78139. */
  78140. static BindClipPlane(effect: Effect, scene: Scene): void;
  78141. }
  78142. }
  78143. declare module BABYLON {
  78144. /** @hidden */
  78145. export var packingFunctions: {
  78146. name: string;
  78147. shader: string;
  78148. };
  78149. }
  78150. declare module BABYLON {
  78151. /** @hidden */
  78152. export var shadowMapPixelShader: {
  78153. name: string;
  78154. shader: string;
  78155. };
  78156. }
  78157. declare module BABYLON {
  78158. /** @hidden */
  78159. export var bonesDeclaration: {
  78160. name: string;
  78161. shader: string;
  78162. };
  78163. }
  78164. declare module BABYLON {
  78165. /** @hidden */
  78166. export var morphTargetsVertexGlobalDeclaration: {
  78167. name: string;
  78168. shader: string;
  78169. };
  78170. }
  78171. declare module BABYLON {
  78172. /** @hidden */
  78173. export var morphTargetsVertexDeclaration: {
  78174. name: string;
  78175. shader: string;
  78176. };
  78177. }
  78178. declare module BABYLON {
  78179. /** @hidden */
  78180. export var instancesDeclaration: {
  78181. name: string;
  78182. shader: string;
  78183. };
  78184. }
  78185. declare module BABYLON {
  78186. /** @hidden */
  78187. export var helperFunctions: {
  78188. name: string;
  78189. shader: string;
  78190. };
  78191. }
  78192. declare module BABYLON {
  78193. /** @hidden */
  78194. export var morphTargetsVertex: {
  78195. name: string;
  78196. shader: string;
  78197. };
  78198. }
  78199. declare module BABYLON {
  78200. /** @hidden */
  78201. export var instancesVertex: {
  78202. name: string;
  78203. shader: string;
  78204. };
  78205. }
  78206. declare module BABYLON {
  78207. /** @hidden */
  78208. export var bonesVertex: {
  78209. name: string;
  78210. shader: string;
  78211. };
  78212. }
  78213. declare module BABYLON {
  78214. /** @hidden */
  78215. export var shadowMapVertexShader: {
  78216. name: string;
  78217. shader: string;
  78218. };
  78219. }
  78220. declare module BABYLON {
  78221. /** @hidden */
  78222. export var depthBoxBlurPixelShader: {
  78223. name: string;
  78224. shader: string;
  78225. };
  78226. }
  78227. declare module BABYLON {
  78228. /**
  78229. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78230. */
  78231. export interface ICustomShaderOptions {
  78232. /**
  78233. * Gets or sets the custom shader name to use
  78234. */
  78235. shaderName: string;
  78236. /**
  78237. * The list of attribute names used in the shader
  78238. */
  78239. attributes?: string[];
  78240. /**
  78241. * The list of unifrom names used in the shader
  78242. */
  78243. uniforms?: string[];
  78244. /**
  78245. * The list of sampler names used in the shader
  78246. */
  78247. samplers?: string[];
  78248. /**
  78249. * The list of defines used in the shader
  78250. */
  78251. defines?: string[];
  78252. }
  78253. /**
  78254. * Interface to implement to create a shadow generator compatible with BJS.
  78255. */
  78256. export interface IShadowGenerator {
  78257. /**
  78258. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78259. * @returns The render target texture if present otherwise, null
  78260. */
  78261. getShadowMap(): Nullable<RenderTargetTexture>;
  78262. /**
  78263. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78264. * @returns The render target texture if the shadow map is present otherwise, null
  78265. */
  78266. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78267. /**
  78268. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78269. * @param subMesh The submesh we want to render in the shadow map
  78270. * @param useInstances Defines wether will draw in the map using instances
  78271. * @returns true if ready otherwise, false
  78272. */
  78273. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78274. /**
  78275. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78276. * @param defines Defines of the material we want to update
  78277. * @param lightIndex Index of the light in the enabled light list of the material
  78278. */
  78279. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78280. /**
  78281. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78282. * defined in the generator but impacting the effect).
  78283. * It implies the unifroms available on the materials are the standard BJS ones.
  78284. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78285. * @param effect The effect we are binfing the information for
  78286. */
  78287. bindShadowLight(lightIndex: string, effect: Effect): void;
  78288. /**
  78289. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78290. * (eq to shadow prjection matrix * light transform matrix)
  78291. * @returns The transform matrix used to create the shadow map
  78292. */
  78293. getTransformMatrix(): Matrix;
  78294. /**
  78295. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78296. * Cube and 2D textures for instance.
  78297. */
  78298. recreateShadowMap(): void;
  78299. /**
  78300. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78301. * @param onCompiled Callback triggered at the and of the effects compilation
  78302. * @param options Sets of optional options forcing the compilation with different modes
  78303. */
  78304. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78305. useInstances: boolean;
  78306. }>): void;
  78307. /**
  78308. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78309. * @param options Sets of optional options forcing the compilation with different modes
  78310. * @returns A promise that resolves when the compilation completes
  78311. */
  78312. forceCompilationAsync(options?: Partial<{
  78313. useInstances: boolean;
  78314. }>): Promise<void>;
  78315. /**
  78316. * Serializes the shadow generator setup to a json object.
  78317. * @returns The serialized JSON object
  78318. */
  78319. serialize(): any;
  78320. /**
  78321. * Disposes the Shadow map and related Textures and effects.
  78322. */
  78323. dispose(): void;
  78324. }
  78325. /**
  78326. * Default implementation IShadowGenerator.
  78327. * This is the main object responsible of generating shadows in the framework.
  78328. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78329. */
  78330. export class ShadowGenerator implements IShadowGenerator {
  78331. /**
  78332. * Shadow generator mode None: no filtering applied.
  78333. */
  78334. static readonly FILTER_NONE: number;
  78335. /**
  78336. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78337. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78338. */
  78339. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78340. /**
  78341. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78342. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78343. */
  78344. static readonly FILTER_POISSONSAMPLING: number;
  78345. /**
  78346. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78348. */
  78349. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78350. /**
  78351. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78352. * edge artifacts on steep falloff.
  78353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78354. */
  78355. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78356. /**
  78357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78358. * edge artifacts on steep falloff.
  78359. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78360. */
  78361. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78362. /**
  78363. * Shadow generator mode PCF: Percentage Closer Filtering
  78364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78365. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78366. */
  78367. static readonly FILTER_PCF: number;
  78368. /**
  78369. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78370. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78371. * Contact Hardening
  78372. */
  78373. static readonly FILTER_PCSS: number;
  78374. /**
  78375. * Reserved for PCF and PCSS
  78376. * Highest Quality.
  78377. *
  78378. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78379. *
  78380. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78381. */
  78382. static readonly QUALITY_HIGH: number;
  78383. /**
  78384. * Reserved for PCF and PCSS
  78385. * Good tradeoff for quality/perf cross devices
  78386. *
  78387. * Execute PCF on a 3*3 kernel.
  78388. *
  78389. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78390. */
  78391. static readonly QUALITY_MEDIUM: number;
  78392. /**
  78393. * Reserved for PCF and PCSS
  78394. * The lowest quality but the fastest.
  78395. *
  78396. * Execute PCF on a 1*1 kernel.
  78397. *
  78398. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78399. */
  78400. static readonly QUALITY_LOW: number;
  78401. /** Gets or sets the custom shader name to use */
  78402. customShaderOptions: ICustomShaderOptions;
  78403. /**
  78404. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78405. */
  78406. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78407. /**
  78408. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78409. */
  78410. onAfterShadowMapRenderObservable: Observable<Effect>;
  78411. /**
  78412. * Observable triggered before a mesh is rendered in the shadow map.
  78413. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78414. */
  78415. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78416. /**
  78417. * Observable triggered after a mesh is rendered in the shadow map.
  78418. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78419. */
  78420. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78421. private _bias;
  78422. /**
  78423. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78424. */
  78425. /**
  78426. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78427. */
  78428. bias: number;
  78429. private _normalBias;
  78430. /**
  78431. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78432. */
  78433. /**
  78434. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78435. */
  78436. normalBias: number;
  78437. private _blurBoxOffset;
  78438. /**
  78439. * Gets the blur box offset: offset applied during the blur pass.
  78440. * Only useful if useKernelBlur = false
  78441. */
  78442. /**
  78443. * Sets the blur box offset: offset applied during the blur pass.
  78444. * Only useful if useKernelBlur = false
  78445. */
  78446. blurBoxOffset: number;
  78447. private _blurScale;
  78448. /**
  78449. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78450. * 2 means half of the size.
  78451. */
  78452. /**
  78453. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78454. * 2 means half of the size.
  78455. */
  78456. blurScale: number;
  78457. private _blurKernel;
  78458. /**
  78459. * Gets the blur kernel: kernel size of the blur pass.
  78460. * Only useful if useKernelBlur = true
  78461. */
  78462. /**
  78463. * Sets the blur kernel: kernel size of the blur pass.
  78464. * Only useful if useKernelBlur = true
  78465. */
  78466. blurKernel: number;
  78467. private _useKernelBlur;
  78468. /**
  78469. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78470. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78471. */
  78472. /**
  78473. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78474. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78475. */
  78476. useKernelBlur: boolean;
  78477. private _depthScale;
  78478. /**
  78479. * Gets the depth scale used in ESM mode.
  78480. */
  78481. /**
  78482. * Sets the depth scale used in ESM mode.
  78483. * This can override the scale stored on the light.
  78484. */
  78485. depthScale: number;
  78486. private _filter;
  78487. /**
  78488. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78489. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78490. */
  78491. /**
  78492. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78493. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78494. */
  78495. filter: number;
  78496. /**
  78497. * Gets if the current filter is set to Poisson Sampling.
  78498. */
  78499. /**
  78500. * Sets the current filter to Poisson Sampling.
  78501. */
  78502. usePoissonSampling: boolean;
  78503. /**
  78504. * Gets if the current filter is set to ESM.
  78505. */
  78506. /**
  78507. * Sets the current filter is to ESM.
  78508. */
  78509. useExponentialShadowMap: boolean;
  78510. /**
  78511. * Gets if the current filter is set to filtered ESM.
  78512. */
  78513. /**
  78514. * Gets if the current filter is set to filtered ESM.
  78515. */
  78516. useBlurExponentialShadowMap: boolean;
  78517. /**
  78518. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78519. * exponential to prevent steep falloff artifacts).
  78520. */
  78521. /**
  78522. * Sets the current filter to "close ESM" (using the inverse of the
  78523. * exponential to prevent steep falloff artifacts).
  78524. */
  78525. useCloseExponentialShadowMap: boolean;
  78526. /**
  78527. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78528. * exponential to prevent steep falloff artifacts).
  78529. */
  78530. /**
  78531. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78532. * exponential to prevent steep falloff artifacts).
  78533. */
  78534. useBlurCloseExponentialShadowMap: boolean;
  78535. /**
  78536. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78537. */
  78538. /**
  78539. * Sets the current filter to "PCF" (percentage closer filtering).
  78540. */
  78541. usePercentageCloserFiltering: boolean;
  78542. private _filteringQuality;
  78543. /**
  78544. * Gets the PCF or PCSS Quality.
  78545. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78546. */
  78547. /**
  78548. * Sets the PCF or PCSS Quality.
  78549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78550. */
  78551. filteringQuality: number;
  78552. /**
  78553. * Gets if the current filter is set to "PCSS" (contact hardening).
  78554. */
  78555. /**
  78556. * Sets the current filter to "PCSS" (contact hardening).
  78557. */
  78558. useContactHardeningShadow: boolean;
  78559. private _contactHardeningLightSizeUVRatio;
  78560. /**
  78561. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78562. * Using a ratio helps keeping shape stability independently of the map size.
  78563. *
  78564. * It does not account for the light projection as it was having too much
  78565. * instability during the light setup or during light position changes.
  78566. *
  78567. * Only valid if useContactHardeningShadow is true.
  78568. */
  78569. /**
  78570. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78571. * Using a ratio helps keeping shape stability independently of the map size.
  78572. *
  78573. * It does not account for the light projection as it was having too much
  78574. * instability during the light setup or during light position changes.
  78575. *
  78576. * Only valid if useContactHardeningShadow is true.
  78577. */
  78578. contactHardeningLightSizeUVRatio: number;
  78579. private _darkness;
  78580. /** Gets or sets the actual darkness of a shadow */
  78581. darkness: number;
  78582. /**
  78583. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78584. * 0 means strongest and 1 would means no shadow.
  78585. * @returns the darkness.
  78586. */
  78587. getDarkness(): number;
  78588. /**
  78589. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78590. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78591. * @returns the shadow generator allowing fluent coding.
  78592. */
  78593. setDarkness(darkness: number): ShadowGenerator;
  78594. private _transparencyShadow;
  78595. /** Gets or sets the ability to have transparent shadow */
  78596. transparencyShadow: boolean;
  78597. /**
  78598. * Sets the ability to have transparent shadow (boolean).
  78599. * @param transparent True if transparent else False
  78600. * @returns the shadow generator allowing fluent coding
  78601. */
  78602. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78603. private _shadowMap;
  78604. private _shadowMap2;
  78605. /**
  78606. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78607. * @returns The render target texture if present otherwise, null
  78608. */
  78609. getShadowMap(): Nullable<RenderTargetTexture>;
  78610. /**
  78611. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78612. * @returns The render target texture if the shadow map is present otherwise, null
  78613. */
  78614. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78615. /**
  78616. * Gets the class name of that object
  78617. * @returns "ShadowGenerator"
  78618. */
  78619. getClassName(): string;
  78620. /**
  78621. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78622. * @param mesh Mesh to add
  78623. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78624. * @returns the Shadow Generator itself
  78625. */
  78626. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78627. /**
  78628. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78629. * @param mesh Mesh to remove
  78630. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78631. * @returns the Shadow Generator itself
  78632. */
  78633. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78634. /**
  78635. * Controls the extent to which the shadows fade out at the edge of the frustum
  78636. * Used only by directionals and spots
  78637. */
  78638. frustumEdgeFalloff: number;
  78639. private _light;
  78640. /**
  78641. * Returns the associated light object.
  78642. * @returns the light generating the shadow
  78643. */
  78644. getLight(): IShadowLight;
  78645. /**
  78646. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78647. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78648. * It might on the other hand introduce peter panning.
  78649. */
  78650. forceBackFacesOnly: boolean;
  78651. private _scene;
  78652. private _lightDirection;
  78653. private _effect;
  78654. private _viewMatrix;
  78655. private _projectionMatrix;
  78656. private _transformMatrix;
  78657. private _cachedPosition;
  78658. private _cachedDirection;
  78659. private _cachedDefines;
  78660. private _currentRenderID;
  78661. private _boxBlurPostprocess;
  78662. private _kernelBlurXPostprocess;
  78663. private _kernelBlurYPostprocess;
  78664. private _blurPostProcesses;
  78665. private _mapSize;
  78666. private _currentFaceIndex;
  78667. private _currentFaceIndexCache;
  78668. private _textureType;
  78669. private _defaultTextureMatrix;
  78670. private _storedUniqueId;
  78671. /** @hidden */
  78672. static _SceneComponentInitialization: (scene: Scene) => void;
  78673. /**
  78674. * Creates a ShadowGenerator object.
  78675. * A ShadowGenerator is the required tool to use the shadows.
  78676. * Each light casting shadows needs to use its own ShadowGenerator.
  78677. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78678. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78679. * @param light The light object generating the shadows.
  78680. * @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.
  78681. */
  78682. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78683. private _initializeGenerator;
  78684. private _initializeShadowMap;
  78685. private _initializeBlurRTTAndPostProcesses;
  78686. private _renderForShadowMap;
  78687. private _renderSubMeshForShadowMap;
  78688. private _applyFilterValues;
  78689. /**
  78690. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78691. * @param onCompiled Callback triggered at the and of the effects compilation
  78692. * @param options Sets of optional options forcing the compilation with different modes
  78693. */
  78694. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78695. useInstances: boolean;
  78696. }>): void;
  78697. /**
  78698. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78699. * @param options Sets of optional options forcing the compilation with different modes
  78700. * @returns A promise that resolves when the compilation completes
  78701. */
  78702. forceCompilationAsync(options?: Partial<{
  78703. useInstances: boolean;
  78704. }>): Promise<void>;
  78705. /**
  78706. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78707. * @param subMesh The submesh we want to render in the shadow map
  78708. * @param useInstances Defines wether will draw in the map using instances
  78709. * @returns true if ready otherwise, false
  78710. */
  78711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78712. /**
  78713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78714. * @param defines Defines of the material we want to update
  78715. * @param lightIndex Index of the light in the enabled light list of the material
  78716. */
  78717. prepareDefines(defines: any, lightIndex: number): void;
  78718. /**
  78719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78720. * defined in the generator but impacting the effect).
  78721. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78722. * @param effect The effect we are binfing the information for
  78723. */
  78724. bindShadowLight(lightIndex: string, effect: Effect): void;
  78725. /**
  78726. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78727. * (eq to shadow prjection matrix * light transform matrix)
  78728. * @returns The transform matrix used to create the shadow map
  78729. */
  78730. getTransformMatrix(): Matrix;
  78731. /**
  78732. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78733. * Cube and 2D textures for instance.
  78734. */
  78735. recreateShadowMap(): void;
  78736. private _disposeBlurPostProcesses;
  78737. private _disposeRTTandPostProcesses;
  78738. /**
  78739. * Disposes the ShadowGenerator.
  78740. * Returns nothing.
  78741. */
  78742. dispose(): void;
  78743. /**
  78744. * Serializes the shadow generator setup to a json object.
  78745. * @returns The serialized JSON object
  78746. */
  78747. serialize(): any;
  78748. /**
  78749. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78750. * @param parsedShadowGenerator The JSON object to parse
  78751. * @param scene The scene to create the shadow map for
  78752. * @returns The parsed shadow generator
  78753. */
  78754. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78755. }
  78756. }
  78757. declare module BABYLON {
  78758. /**
  78759. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78760. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78761. * 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.
  78762. */
  78763. export abstract class Light extends Node {
  78764. /**
  78765. * Falloff Default: light is falling off following the material specification:
  78766. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78767. */
  78768. static readonly FALLOFF_DEFAULT: number;
  78769. /**
  78770. * Falloff Physical: light is falling off following the inverse squared distance law.
  78771. */
  78772. static readonly FALLOFF_PHYSICAL: number;
  78773. /**
  78774. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78775. * to enhance interoperability with other engines.
  78776. */
  78777. static readonly FALLOFF_GLTF: number;
  78778. /**
  78779. * Falloff Standard: light is falling off like in the standard material
  78780. * to enhance interoperability with other materials.
  78781. */
  78782. static readonly FALLOFF_STANDARD: number;
  78783. /**
  78784. * If every light affecting the material is in this lightmapMode,
  78785. * material.lightmapTexture adds or multiplies
  78786. * (depends on material.useLightmapAsShadowmap)
  78787. * after every other light calculations.
  78788. */
  78789. static readonly LIGHTMAP_DEFAULT: number;
  78790. /**
  78791. * material.lightmapTexture as only diffuse lighting from this light
  78792. * adds only specular lighting from this light
  78793. * adds dynamic shadows
  78794. */
  78795. static readonly LIGHTMAP_SPECULAR: number;
  78796. /**
  78797. * material.lightmapTexture as only lighting
  78798. * no light calculation from this light
  78799. * only adds dynamic shadows from this light
  78800. */
  78801. static readonly LIGHTMAP_SHADOWSONLY: number;
  78802. /**
  78803. * Each light type uses the default quantity according to its type:
  78804. * point/spot lights use luminous intensity
  78805. * directional lights use illuminance
  78806. */
  78807. static readonly INTENSITYMODE_AUTOMATIC: number;
  78808. /**
  78809. * lumen (lm)
  78810. */
  78811. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78812. /**
  78813. * candela (lm/sr)
  78814. */
  78815. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78816. /**
  78817. * lux (lm/m^2)
  78818. */
  78819. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78820. /**
  78821. * nit (cd/m^2)
  78822. */
  78823. static readonly INTENSITYMODE_LUMINANCE: number;
  78824. /**
  78825. * Light type const id of the point light.
  78826. */
  78827. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78828. /**
  78829. * Light type const id of the directional light.
  78830. */
  78831. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78832. /**
  78833. * Light type const id of the spot light.
  78834. */
  78835. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78836. /**
  78837. * Light type const id of the hemispheric light.
  78838. */
  78839. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78840. /**
  78841. * Diffuse gives the basic color to an object.
  78842. */
  78843. diffuse: Color3;
  78844. /**
  78845. * Specular produces a highlight color on an object.
  78846. * Note: This is note affecting PBR materials.
  78847. */
  78848. specular: Color3;
  78849. /**
  78850. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78851. * falling off base on range or angle.
  78852. * This can be set to any values in Light.FALLOFF_x.
  78853. *
  78854. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78855. * other types of materials.
  78856. */
  78857. falloffType: number;
  78858. /**
  78859. * Strength of the light.
  78860. * Note: By default it is define in the framework own unit.
  78861. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78862. */
  78863. intensity: number;
  78864. private _range;
  78865. protected _inverseSquaredRange: number;
  78866. /**
  78867. * Defines how far from the source the light is impacting in scene units.
  78868. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78869. */
  78870. /**
  78871. * Defines how far from the source the light is impacting in scene units.
  78872. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78873. */
  78874. range: number;
  78875. /**
  78876. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78877. * of light.
  78878. */
  78879. private _photometricScale;
  78880. private _intensityMode;
  78881. /**
  78882. * Gets the photometric scale used to interpret the intensity.
  78883. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78884. */
  78885. /**
  78886. * Sets the photometric scale used to interpret the intensity.
  78887. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78888. */
  78889. intensityMode: number;
  78890. private _radius;
  78891. /**
  78892. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78893. */
  78894. /**
  78895. * sets the light radius used by PBR Materials to simulate soft area lights.
  78896. */
  78897. radius: number;
  78898. private _renderPriority;
  78899. /**
  78900. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78901. * exceeding the number allowed of the materials.
  78902. */
  78903. renderPriority: number;
  78904. private _shadowEnabled;
  78905. /**
  78906. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78907. * the current shadow generator.
  78908. */
  78909. /**
  78910. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78911. * the current shadow generator.
  78912. */
  78913. shadowEnabled: boolean;
  78914. private _includedOnlyMeshes;
  78915. /**
  78916. * Gets the only meshes impacted by this light.
  78917. */
  78918. /**
  78919. * Sets the only meshes impacted by this light.
  78920. */
  78921. includedOnlyMeshes: AbstractMesh[];
  78922. private _excludedMeshes;
  78923. /**
  78924. * Gets the meshes not impacted by this light.
  78925. */
  78926. /**
  78927. * Sets the meshes not impacted by this light.
  78928. */
  78929. excludedMeshes: AbstractMesh[];
  78930. private _excludeWithLayerMask;
  78931. /**
  78932. * Gets the layer id use to find what meshes are not impacted by the light.
  78933. * Inactive if 0
  78934. */
  78935. /**
  78936. * Sets the layer id use to find what meshes are not impacted by the light.
  78937. * Inactive if 0
  78938. */
  78939. excludeWithLayerMask: number;
  78940. private _includeOnlyWithLayerMask;
  78941. /**
  78942. * Gets the layer id use to find what meshes are impacted by the light.
  78943. * Inactive if 0
  78944. */
  78945. /**
  78946. * Sets the layer id use to find what meshes are impacted by the light.
  78947. * Inactive if 0
  78948. */
  78949. includeOnlyWithLayerMask: number;
  78950. private _lightmapMode;
  78951. /**
  78952. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78953. */
  78954. /**
  78955. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78956. */
  78957. lightmapMode: number;
  78958. /**
  78959. * Shadow generator associted to the light.
  78960. * @hidden Internal use only.
  78961. */
  78962. _shadowGenerator: Nullable<IShadowGenerator>;
  78963. /**
  78964. * @hidden Internal use only.
  78965. */
  78966. _excludedMeshesIds: string[];
  78967. /**
  78968. * @hidden Internal use only.
  78969. */
  78970. _includedOnlyMeshesIds: string[];
  78971. /**
  78972. * The current light unifom buffer.
  78973. * @hidden Internal use only.
  78974. */
  78975. _uniformBuffer: UniformBuffer;
  78976. /** @hidden */
  78977. _renderId: number;
  78978. /**
  78979. * Creates a Light object in the scene.
  78980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78981. * @param name The firendly name of the light
  78982. * @param scene The scene the light belongs too
  78983. */
  78984. constructor(name: string, scene: Scene);
  78985. protected abstract _buildUniformLayout(): void;
  78986. /**
  78987. * Sets the passed Effect "effect" with the Light information.
  78988. * @param effect The effect to update
  78989. * @param lightIndex The index of the light in the effect to update
  78990. * @returns The light
  78991. */
  78992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78993. /**
  78994. * Sets the passed Effect "effect" with the Light textures.
  78995. * @param effect The effect to update
  78996. * @param lightIndex The index of the light in the effect to update
  78997. * @returns The light
  78998. */
  78999. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  79000. /**
  79001. * Binds the lights information from the scene to the effect for the given mesh.
  79002. * @param lightIndex Light index
  79003. * @param scene The scene where the light belongs to
  79004. * @param effect The effect we are binding the data to
  79005. * @param useSpecular Defines if specular is supported
  79006. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79007. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79008. */
  79009. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79010. /**
  79011. * Sets the passed Effect "effect" with the Light information.
  79012. * @param effect The effect to update
  79013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  79014. * @returns The light
  79015. */
  79016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  79017. /**
  79018. * Returns the string "Light".
  79019. * @returns the class name
  79020. */
  79021. getClassName(): string;
  79022. /** @hidden */
  79023. readonly _isLight: boolean;
  79024. /**
  79025. * Converts the light information to a readable string for debug purpose.
  79026. * @param fullDetails Supports for multiple levels of logging within scene loading
  79027. * @returns the human readable light info
  79028. */
  79029. toString(fullDetails?: boolean): string;
  79030. /** @hidden */
  79031. protected _syncParentEnabledState(): void;
  79032. /**
  79033. * Set the enabled state of this node.
  79034. * @param value - the new enabled state
  79035. */
  79036. setEnabled(value: boolean): void;
  79037. /**
  79038. * Returns the Light associated shadow generator if any.
  79039. * @return the associated shadow generator.
  79040. */
  79041. getShadowGenerator(): Nullable<IShadowGenerator>;
  79042. /**
  79043. * Returns a Vector3, the absolute light position in the World.
  79044. * @returns the world space position of the light
  79045. */
  79046. getAbsolutePosition(): Vector3;
  79047. /**
  79048. * Specifies if the light will affect the passed mesh.
  79049. * @param mesh The mesh to test against the light
  79050. * @return true the mesh is affected otherwise, false.
  79051. */
  79052. canAffectMesh(mesh: AbstractMesh): boolean;
  79053. /**
  79054. * Sort function to order lights for rendering.
  79055. * @param a First Light object to compare to second.
  79056. * @param b Second Light object to compare first.
  79057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79058. */
  79059. static CompareLightsPriority(a: Light, b: Light): number;
  79060. /**
  79061. * Releases resources associated with this node.
  79062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79064. */
  79065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79066. /**
  79067. * Returns the light type ID (integer).
  79068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79069. */
  79070. getTypeID(): number;
  79071. /**
  79072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79073. * @returns the scaled intensity in intensity mode unit
  79074. */
  79075. getScaledIntensity(): number;
  79076. /**
  79077. * Returns a new Light object, named "name", from the current one.
  79078. * @param name The name of the cloned light
  79079. * @returns the new created light
  79080. */
  79081. clone(name: string): Nullable<Light>;
  79082. /**
  79083. * Serializes the current light into a Serialization object.
  79084. * @returns the serialized object.
  79085. */
  79086. serialize(): any;
  79087. /**
  79088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79089. * This new light is named "name" and added to the passed scene.
  79090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79091. * @param name The friendly name of the light
  79092. * @param scene The scene the new light will belong to
  79093. * @returns the constructor function
  79094. */
  79095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79096. /**
  79097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79098. * @param parsedLight The JSON representation of the light
  79099. * @param scene The scene to create the parsed light in
  79100. * @returns the created light after parsing
  79101. */
  79102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79103. private _hookArrayForExcluded;
  79104. private _hookArrayForIncludedOnly;
  79105. private _resyncMeshes;
  79106. /**
  79107. * Forces the meshes to update their light related information in their rendering used effects
  79108. * @hidden Internal Use Only
  79109. */
  79110. _markMeshesAsLightDirty(): void;
  79111. /**
  79112. * Recomputes the cached photometric scale if needed.
  79113. */
  79114. private _computePhotometricScale;
  79115. /**
  79116. * Returns the Photometric Scale according to the light type and intensity mode.
  79117. */
  79118. private _getPhotometricScale;
  79119. /**
  79120. * Reorder the light in the scene according to their defined priority.
  79121. * @hidden Internal Use Only
  79122. */
  79123. _reorderLightsInScene(): void;
  79124. /**
  79125. * Prepares the list of defines specific to the light type.
  79126. * @param defines the list of defines
  79127. * @param lightIndex defines the index of the light for the effect
  79128. */
  79129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79130. }
  79131. }
  79132. declare module BABYLON {
  79133. /**
  79134. * Interface used to define Action
  79135. */
  79136. export interface IAction {
  79137. /**
  79138. * Trigger for the action
  79139. */
  79140. trigger: number;
  79141. /** Options of the trigger */
  79142. triggerOptions: any;
  79143. /**
  79144. * Gets the trigger parameters
  79145. * @returns the trigger parameters
  79146. */
  79147. getTriggerParameter(): any;
  79148. /**
  79149. * Internal only - executes current action event
  79150. * @hidden
  79151. */
  79152. _executeCurrent(evt?: ActionEvent): void;
  79153. /**
  79154. * Serialize placeholder for child classes
  79155. * @param parent of child
  79156. * @returns the serialized object
  79157. */
  79158. serialize(parent: any): any;
  79159. /**
  79160. * Internal only
  79161. * @hidden
  79162. */
  79163. _prepare(): void;
  79164. /**
  79165. * Internal only - manager for action
  79166. * @hidden
  79167. */
  79168. _actionManager: AbstractActionManager;
  79169. /**
  79170. * Adds action to chain of actions, may be a DoNothingAction
  79171. * @param action defines the next action to execute
  79172. * @returns The action passed in
  79173. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79174. */
  79175. then(action: IAction): IAction;
  79176. }
  79177. /**
  79178. * The action to be carried out following a trigger
  79179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79180. */
  79181. export class Action implements IAction {
  79182. /** the trigger, with or without parameters, for the action */
  79183. triggerOptions: any;
  79184. /**
  79185. * Trigger for the action
  79186. */
  79187. trigger: number;
  79188. /**
  79189. * Internal only - manager for action
  79190. * @hidden
  79191. */
  79192. _actionManager: ActionManager;
  79193. private _nextActiveAction;
  79194. private _child;
  79195. private _condition?;
  79196. private _triggerParameter;
  79197. /**
  79198. * An event triggered prior to action being executed.
  79199. */
  79200. onBeforeExecuteObservable: Observable<Action>;
  79201. /**
  79202. * Creates a new Action
  79203. * @param triggerOptions the trigger, with or without parameters, for the action
  79204. * @param condition an optional determinant of action
  79205. */
  79206. constructor(
  79207. /** the trigger, with or without parameters, for the action */
  79208. triggerOptions: any, condition?: Condition);
  79209. /**
  79210. * Internal only
  79211. * @hidden
  79212. */
  79213. _prepare(): void;
  79214. /**
  79215. * Gets the trigger parameters
  79216. * @returns the trigger parameters
  79217. */
  79218. getTriggerParameter(): any;
  79219. /**
  79220. * Internal only - executes current action event
  79221. * @hidden
  79222. */
  79223. _executeCurrent(evt?: ActionEvent): void;
  79224. /**
  79225. * Execute placeholder for child classes
  79226. * @param evt optional action event
  79227. */
  79228. execute(evt?: ActionEvent): void;
  79229. /**
  79230. * Skips to next active action
  79231. */
  79232. skipToNextActiveAction(): void;
  79233. /**
  79234. * Adds action to chain of actions, may be a DoNothingAction
  79235. * @param action defines the next action to execute
  79236. * @returns The action passed in
  79237. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79238. */
  79239. then(action: Action): Action;
  79240. /**
  79241. * Internal only
  79242. * @hidden
  79243. */
  79244. _getProperty(propertyPath: string): string;
  79245. /**
  79246. * Internal only
  79247. * @hidden
  79248. */
  79249. _getEffectiveTarget(target: any, propertyPath: string): any;
  79250. /**
  79251. * Serialize placeholder for child classes
  79252. * @param parent of child
  79253. * @returns the serialized object
  79254. */
  79255. serialize(parent: any): any;
  79256. /**
  79257. * Internal only called by serialize
  79258. * @hidden
  79259. */
  79260. protected _serialize(serializedAction: any, parent?: any): any;
  79261. /**
  79262. * Internal only
  79263. * @hidden
  79264. */
  79265. static _SerializeValueAsString: (value: any) => string;
  79266. /**
  79267. * Internal only
  79268. * @hidden
  79269. */
  79270. static _GetTargetProperty: (target: Node | Scene) => {
  79271. name: string;
  79272. targetType: string;
  79273. value: string;
  79274. };
  79275. }
  79276. }
  79277. declare module BABYLON {
  79278. /**
  79279. * A Condition applied to an Action
  79280. */
  79281. export class Condition {
  79282. /**
  79283. * Internal only - manager for action
  79284. * @hidden
  79285. */
  79286. _actionManager: ActionManager;
  79287. /**
  79288. * Internal only
  79289. * @hidden
  79290. */
  79291. _evaluationId: number;
  79292. /**
  79293. * Internal only
  79294. * @hidden
  79295. */
  79296. _currentResult: boolean;
  79297. /**
  79298. * Creates a new Condition
  79299. * @param actionManager the manager of the action the condition is applied to
  79300. */
  79301. constructor(actionManager: ActionManager);
  79302. /**
  79303. * Check if the current condition is valid
  79304. * @returns a boolean
  79305. */
  79306. isValid(): boolean;
  79307. /**
  79308. * Internal only
  79309. * @hidden
  79310. */
  79311. _getProperty(propertyPath: string): string;
  79312. /**
  79313. * Internal only
  79314. * @hidden
  79315. */
  79316. _getEffectiveTarget(target: any, propertyPath: string): any;
  79317. /**
  79318. * Serialize placeholder for child classes
  79319. * @returns the serialized object
  79320. */
  79321. serialize(): any;
  79322. /**
  79323. * Internal only
  79324. * @hidden
  79325. */
  79326. protected _serialize(serializedCondition: any): any;
  79327. }
  79328. /**
  79329. * Defines specific conditional operators as extensions of Condition
  79330. */
  79331. export class ValueCondition extends Condition {
  79332. /** path to specify the property of the target the conditional operator uses */
  79333. propertyPath: string;
  79334. /** the value compared by the conditional operator against the current value of the property */
  79335. value: any;
  79336. /** the conditional operator, default ValueCondition.IsEqual */
  79337. operator: number;
  79338. /**
  79339. * Internal only
  79340. * @hidden
  79341. */
  79342. private static _IsEqual;
  79343. /**
  79344. * Internal only
  79345. * @hidden
  79346. */
  79347. private static _IsDifferent;
  79348. /**
  79349. * Internal only
  79350. * @hidden
  79351. */
  79352. private static _IsGreater;
  79353. /**
  79354. * Internal only
  79355. * @hidden
  79356. */
  79357. private static _IsLesser;
  79358. /**
  79359. * returns the number for IsEqual
  79360. */
  79361. static readonly IsEqual: number;
  79362. /**
  79363. * Returns the number for IsDifferent
  79364. */
  79365. static readonly IsDifferent: number;
  79366. /**
  79367. * Returns the number for IsGreater
  79368. */
  79369. static readonly IsGreater: number;
  79370. /**
  79371. * Returns the number for IsLesser
  79372. */
  79373. static readonly IsLesser: number;
  79374. /**
  79375. * Internal only The action manager for the condition
  79376. * @hidden
  79377. */
  79378. _actionManager: ActionManager;
  79379. /**
  79380. * Internal only
  79381. * @hidden
  79382. */
  79383. private _target;
  79384. /**
  79385. * Internal only
  79386. * @hidden
  79387. */
  79388. private _effectiveTarget;
  79389. /**
  79390. * Internal only
  79391. * @hidden
  79392. */
  79393. private _property;
  79394. /**
  79395. * Creates a new ValueCondition
  79396. * @param actionManager manager for the action the condition applies to
  79397. * @param target for the action
  79398. * @param propertyPath path to specify the property of the target the conditional operator uses
  79399. * @param value the value compared by the conditional operator against the current value of the property
  79400. * @param operator the conditional operator, default ValueCondition.IsEqual
  79401. */
  79402. constructor(actionManager: ActionManager, target: any,
  79403. /** path to specify the property of the target the conditional operator uses */
  79404. propertyPath: string,
  79405. /** the value compared by the conditional operator against the current value of the property */
  79406. value: any,
  79407. /** the conditional operator, default ValueCondition.IsEqual */
  79408. operator?: number);
  79409. /**
  79410. * Compares the given value with the property value for the specified conditional operator
  79411. * @returns the result of the comparison
  79412. */
  79413. isValid(): boolean;
  79414. /**
  79415. * Serialize the ValueCondition into a JSON compatible object
  79416. * @returns serialization object
  79417. */
  79418. serialize(): any;
  79419. /**
  79420. * Gets the name of the conditional operator for the ValueCondition
  79421. * @param operator the conditional operator
  79422. * @returns the name
  79423. */
  79424. static GetOperatorName(operator: number): string;
  79425. }
  79426. /**
  79427. * Defines a predicate condition as an extension of Condition
  79428. */
  79429. export class PredicateCondition extends Condition {
  79430. /** defines the predicate function used to validate the condition */
  79431. predicate: () => boolean;
  79432. /**
  79433. * Internal only - manager for action
  79434. * @hidden
  79435. */
  79436. _actionManager: ActionManager;
  79437. /**
  79438. * Creates a new PredicateCondition
  79439. * @param actionManager manager for the action the condition applies to
  79440. * @param predicate defines the predicate function used to validate the condition
  79441. */
  79442. constructor(actionManager: ActionManager,
  79443. /** defines the predicate function used to validate the condition */
  79444. predicate: () => boolean);
  79445. /**
  79446. * @returns the validity of the predicate condition
  79447. */
  79448. isValid(): boolean;
  79449. }
  79450. /**
  79451. * Defines a state condition as an extension of Condition
  79452. */
  79453. export class StateCondition extends Condition {
  79454. /** Value to compare with target state */
  79455. value: string;
  79456. /**
  79457. * Internal only - manager for action
  79458. * @hidden
  79459. */
  79460. _actionManager: ActionManager;
  79461. /**
  79462. * Internal only
  79463. * @hidden
  79464. */
  79465. private _target;
  79466. /**
  79467. * Creates a new StateCondition
  79468. * @param actionManager manager for the action the condition applies to
  79469. * @param target of the condition
  79470. * @param value to compare with target state
  79471. */
  79472. constructor(actionManager: ActionManager, target: any,
  79473. /** Value to compare with target state */
  79474. value: string);
  79475. /**
  79476. * Gets a boolean indicating if the current condition is met
  79477. * @returns the validity of the state
  79478. */
  79479. isValid(): boolean;
  79480. /**
  79481. * Serialize the StateCondition into a JSON compatible object
  79482. * @returns serialization object
  79483. */
  79484. serialize(): any;
  79485. }
  79486. }
  79487. declare module BABYLON {
  79488. /**
  79489. * This defines an action responsible to toggle a boolean once triggered.
  79490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79491. */
  79492. export class SwitchBooleanAction extends Action {
  79493. /**
  79494. * The path to the boolean property in the target object
  79495. */
  79496. propertyPath: string;
  79497. private _target;
  79498. private _effectiveTarget;
  79499. private _property;
  79500. /**
  79501. * Instantiate the action
  79502. * @param triggerOptions defines the trigger options
  79503. * @param target defines the object containing the boolean
  79504. * @param propertyPath defines the path to the boolean property in the target object
  79505. * @param condition defines the trigger related conditions
  79506. */
  79507. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79508. /** @hidden */
  79509. _prepare(): void;
  79510. /**
  79511. * Execute the action toggle the boolean value.
  79512. */
  79513. execute(): void;
  79514. /**
  79515. * Serializes the actions and its related information.
  79516. * @param parent defines the object to serialize in
  79517. * @returns the serialized object
  79518. */
  79519. serialize(parent: any): any;
  79520. }
  79521. /**
  79522. * This defines an action responsible to set a the state field of the target
  79523. * to a desired value once triggered.
  79524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79525. */
  79526. export class SetStateAction extends Action {
  79527. /**
  79528. * The value to store in the state field.
  79529. */
  79530. value: string;
  79531. private _target;
  79532. /**
  79533. * Instantiate the action
  79534. * @param triggerOptions defines the trigger options
  79535. * @param target defines the object containing the state property
  79536. * @param value defines the value to store in the state field
  79537. * @param condition defines the trigger related conditions
  79538. */
  79539. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79540. /**
  79541. * Execute the action and store the value on the target state property.
  79542. */
  79543. execute(): void;
  79544. /**
  79545. * Serializes the actions and its related information.
  79546. * @param parent defines the object to serialize in
  79547. * @returns the serialized object
  79548. */
  79549. serialize(parent: any): any;
  79550. }
  79551. /**
  79552. * This defines an action responsible to set a property of the target
  79553. * to a desired value once triggered.
  79554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79555. */
  79556. export class SetValueAction extends Action {
  79557. /**
  79558. * The path of the property to set in the target.
  79559. */
  79560. propertyPath: string;
  79561. /**
  79562. * The value to set in the property
  79563. */
  79564. value: any;
  79565. private _target;
  79566. private _effectiveTarget;
  79567. private _property;
  79568. /**
  79569. * Instantiate the action
  79570. * @param triggerOptions defines the trigger options
  79571. * @param target defines the object containing the property
  79572. * @param propertyPath defines the path of the property to set in the target
  79573. * @param value defines the value to set in the property
  79574. * @param condition defines the trigger related conditions
  79575. */
  79576. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79577. /** @hidden */
  79578. _prepare(): void;
  79579. /**
  79580. * Execute the action and set the targetted property to the desired value.
  79581. */
  79582. execute(): void;
  79583. /**
  79584. * Serializes the actions and its related information.
  79585. * @param parent defines the object to serialize in
  79586. * @returns the serialized object
  79587. */
  79588. serialize(parent: any): any;
  79589. }
  79590. /**
  79591. * This defines an action responsible to increment the target value
  79592. * to a desired value once triggered.
  79593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79594. */
  79595. export class IncrementValueAction extends Action {
  79596. /**
  79597. * The path of the property to increment in the target.
  79598. */
  79599. propertyPath: string;
  79600. /**
  79601. * The value we should increment the property by.
  79602. */
  79603. value: any;
  79604. private _target;
  79605. private _effectiveTarget;
  79606. private _property;
  79607. /**
  79608. * Instantiate the action
  79609. * @param triggerOptions defines the trigger options
  79610. * @param target defines the object containing the property
  79611. * @param propertyPath defines the path of the property to increment in the target
  79612. * @param value defines the value value we should increment the property by
  79613. * @param condition defines the trigger related conditions
  79614. */
  79615. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79616. /** @hidden */
  79617. _prepare(): void;
  79618. /**
  79619. * Execute the action and increment the target of the value amount.
  79620. */
  79621. execute(): void;
  79622. /**
  79623. * Serializes the actions and its related information.
  79624. * @param parent defines the object to serialize in
  79625. * @returns the serialized object
  79626. */
  79627. serialize(parent: any): any;
  79628. }
  79629. /**
  79630. * This defines an action responsible to start an animation once triggered.
  79631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79632. */
  79633. export class PlayAnimationAction extends Action {
  79634. /**
  79635. * Where the animation should start (animation frame)
  79636. */
  79637. from: number;
  79638. /**
  79639. * Where the animation should stop (animation frame)
  79640. */
  79641. to: number;
  79642. /**
  79643. * Define if the animation should loop or stop after the first play.
  79644. */
  79645. loop?: boolean;
  79646. private _target;
  79647. /**
  79648. * Instantiate the action
  79649. * @param triggerOptions defines the trigger options
  79650. * @param target defines the target animation or animation name
  79651. * @param from defines from where the animation should start (animation frame)
  79652. * @param end defines where the animation should stop (animation frame)
  79653. * @param loop defines if the animation should loop or stop after the first play
  79654. * @param condition defines the trigger related conditions
  79655. */
  79656. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79657. /** @hidden */
  79658. _prepare(): void;
  79659. /**
  79660. * Execute the action and play the animation.
  79661. */
  79662. execute(): void;
  79663. /**
  79664. * Serializes the actions and its related information.
  79665. * @param parent defines the object to serialize in
  79666. * @returns the serialized object
  79667. */
  79668. serialize(parent: any): any;
  79669. }
  79670. /**
  79671. * This defines an action responsible to stop an animation once triggered.
  79672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79673. */
  79674. export class StopAnimationAction extends Action {
  79675. private _target;
  79676. /**
  79677. * Instantiate the action
  79678. * @param triggerOptions defines the trigger options
  79679. * @param target defines the target animation or animation name
  79680. * @param condition defines the trigger related conditions
  79681. */
  79682. constructor(triggerOptions: any, target: any, condition?: Condition);
  79683. /** @hidden */
  79684. _prepare(): void;
  79685. /**
  79686. * Execute the action and stop the animation.
  79687. */
  79688. execute(): void;
  79689. /**
  79690. * Serializes the actions and its related information.
  79691. * @param parent defines the object to serialize in
  79692. * @returns the serialized object
  79693. */
  79694. serialize(parent: any): any;
  79695. }
  79696. /**
  79697. * This defines an action responsible that does nothing once triggered.
  79698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79699. */
  79700. export class DoNothingAction extends Action {
  79701. /**
  79702. * Instantiate the action
  79703. * @param triggerOptions defines the trigger options
  79704. * @param condition defines the trigger related conditions
  79705. */
  79706. constructor(triggerOptions?: any, condition?: Condition);
  79707. /**
  79708. * Execute the action and do nothing.
  79709. */
  79710. execute(): void;
  79711. /**
  79712. * Serializes the actions and its related information.
  79713. * @param parent defines the object to serialize in
  79714. * @returns the serialized object
  79715. */
  79716. serialize(parent: any): any;
  79717. }
  79718. /**
  79719. * This defines an action responsible to trigger several actions once triggered.
  79720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79721. */
  79722. export class CombineAction extends Action {
  79723. /**
  79724. * The list of aggregated animations to run.
  79725. */
  79726. children: Action[];
  79727. /**
  79728. * Instantiate the action
  79729. * @param triggerOptions defines the trigger options
  79730. * @param children defines the list of aggregated animations to run
  79731. * @param condition defines the trigger related conditions
  79732. */
  79733. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79734. /** @hidden */
  79735. _prepare(): void;
  79736. /**
  79737. * Execute the action and executes all the aggregated actions.
  79738. */
  79739. execute(evt: ActionEvent): void;
  79740. /**
  79741. * Serializes the actions and its related information.
  79742. * @param parent defines the object to serialize in
  79743. * @returns the serialized object
  79744. */
  79745. serialize(parent: any): any;
  79746. }
  79747. /**
  79748. * This defines an action responsible to run code (external event) once triggered.
  79749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79750. */
  79751. export class ExecuteCodeAction extends Action {
  79752. /**
  79753. * The callback function to run.
  79754. */
  79755. func: (evt: ActionEvent) => void;
  79756. /**
  79757. * Instantiate the action
  79758. * @param triggerOptions defines the trigger options
  79759. * @param func defines the callback function to run
  79760. * @param condition defines the trigger related conditions
  79761. */
  79762. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79763. /**
  79764. * Execute the action and run the attached code.
  79765. */
  79766. execute(evt: ActionEvent): void;
  79767. }
  79768. /**
  79769. * This defines an action responsible to set the parent property of the target once triggered.
  79770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79771. */
  79772. export class SetParentAction extends Action {
  79773. private _parent;
  79774. private _target;
  79775. /**
  79776. * Instantiate the action
  79777. * @param triggerOptions defines the trigger options
  79778. * @param target defines the target containing the parent property
  79779. * @param parent defines from where the animation should start (animation frame)
  79780. * @param condition defines the trigger related conditions
  79781. */
  79782. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79783. /** @hidden */
  79784. _prepare(): void;
  79785. /**
  79786. * Execute the action and set the parent property.
  79787. */
  79788. execute(): void;
  79789. /**
  79790. * Serializes the actions and its related information.
  79791. * @param parent defines the object to serialize in
  79792. * @returns the serialized object
  79793. */
  79794. serialize(parent: any): any;
  79795. }
  79796. }
  79797. declare module BABYLON {
  79798. /**
  79799. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79800. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79802. */
  79803. export class ActionManager extends AbstractActionManager {
  79804. /**
  79805. * Nothing
  79806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79807. */
  79808. static readonly NothingTrigger: number;
  79809. /**
  79810. * On pick
  79811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79812. */
  79813. static readonly OnPickTrigger: number;
  79814. /**
  79815. * On left pick
  79816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79817. */
  79818. static readonly OnLeftPickTrigger: number;
  79819. /**
  79820. * On right pick
  79821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79822. */
  79823. static readonly OnRightPickTrigger: number;
  79824. /**
  79825. * On center pick
  79826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79827. */
  79828. static readonly OnCenterPickTrigger: number;
  79829. /**
  79830. * On pick down
  79831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79832. */
  79833. static readonly OnPickDownTrigger: number;
  79834. /**
  79835. * On double pick
  79836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79837. */
  79838. static readonly OnDoublePickTrigger: number;
  79839. /**
  79840. * On pick up
  79841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79842. */
  79843. static readonly OnPickUpTrigger: number;
  79844. /**
  79845. * On pick out.
  79846. * This trigger will only be raised if you also declared a OnPickDown
  79847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79848. */
  79849. static readonly OnPickOutTrigger: number;
  79850. /**
  79851. * On long press
  79852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79853. */
  79854. static readonly OnLongPressTrigger: number;
  79855. /**
  79856. * On pointer over
  79857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79858. */
  79859. static readonly OnPointerOverTrigger: number;
  79860. /**
  79861. * On pointer out
  79862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79863. */
  79864. static readonly OnPointerOutTrigger: number;
  79865. /**
  79866. * On every frame
  79867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79868. */
  79869. static readonly OnEveryFrameTrigger: number;
  79870. /**
  79871. * On intersection enter
  79872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79873. */
  79874. static readonly OnIntersectionEnterTrigger: number;
  79875. /**
  79876. * On intersection exit
  79877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79878. */
  79879. static readonly OnIntersectionExitTrigger: number;
  79880. /**
  79881. * On key down
  79882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79883. */
  79884. static readonly OnKeyDownTrigger: number;
  79885. /**
  79886. * On key up
  79887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79888. */
  79889. static readonly OnKeyUpTrigger: number;
  79890. private _scene;
  79891. /**
  79892. * Creates a new action manager
  79893. * @param scene defines the hosting scene
  79894. */
  79895. constructor(scene: Scene);
  79896. /**
  79897. * Releases all associated resources
  79898. */
  79899. dispose(): void;
  79900. /**
  79901. * Gets hosting scene
  79902. * @returns the hosting scene
  79903. */
  79904. getScene(): Scene;
  79905. /**
  79906. * Does this action manager handles actions of any of the given triggers
  79907. * @param triggers defines the triggers to be tested
  79908. * @return a boolean indicating whether one (or more) of the triggers is handled
  79909. */
  79910. hasSpecificTriggers(triggers: number[]): boolean;
  79911. /**
  79912. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79913. * speed.
  79914. * @param triggerA defines the trigger to be tested
  79915. * @param triggerB defines the trigger to be tested
  79916. * @return a boolean indicating whether one (or more) of the triggers is handled
  79917. */
  79918. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79919. /**
  79920. * Does this action manager handles actions of a given trigger
  79921. * @param trigger defines the trigger to be tested
  79922. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79923. * @return whether the trigger is handled
  79924. */
  79925. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79926. /**
  79927. * Does this action manager has pointer triggers
  79928. */
  79929. readonly hasPointerTriggers: boolean;
  79930. /**
  79931. * Does this action manager has pick triggers
  79932. */
  79933. readonly hasPickTriggers: boolean;
  79934. /**
  79935. * Registers an action to this action manager
  79936. * @param action defines the action to be registered
  79937. * @return the action amended (prepared) after registration
  79938. */
  79939. registerAction(action: IAction): Nullable<IAction>;
  79940. /**
  79941. * Unregisters an action to this action manager
  79942. * @param action defines the action to be unregistered
  79943. * @return a boolean indicating whether the action has been unregistered
  79944. */
  79945. unregisterAction(action: IAction): Boolean;
  79946. /**
  79947. * Process a specific trigger
  79948. * @param trigger defines the trigger to process
  79949. * @param evt defines the event details to be processed
  79950. */
  79951. processTrigger(trigger: number, evt?: IActionEvent): void;
  79952. /** @hidden */
  79953. _getEffectiveTarget(target: any, propertyPath: string): any;
  79954. /** @hidden */
  79955. _getProperty(propertyPath: string): string;
  79956. /**
  79957. * Serialize this manager to a JSON object
  79958. * @param name defines the property name to store this manager
  79959. * @returns a JSON representation of this manager
  79960. */
  79961. serialize(name: string): any;
  79962. /**
  79963. * Creates a new ActionManager from a JSON data
  79964. * @param parsedActions defines the JSON data to read from
  79965. * @param object defines the hosting mesh
  79966. * @param scene defines the hosting scene
  79967. */
  79968. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79969. /**
  79970. * Get a trigger name by index
  79971. * @param trigger defines the trigger index
  79972. * @returns a trigger name
  79973. */
  79974. static GetTriggerName(trigger: number): string;
  79975. }
  79976. }
  79977. declare module BABYLON {
  79978. /**
  79979. * Class representing a ray with position and direction
  79980. */
  79981. export class Ray {
  79982. /** origin point */
  79983. origin: Vector3;
  79984. /** direction */
  79985. direction: Vector3;
  79986. /** length of the ray */
  79987. length: number;
  79988. private static readonly TmpVector3;
  79989. private _tmpRay;
  79990. /**
  79991. * Creates a new ray
  79992. * @param origin origin point
  79993. * @param direction direction
  79994. * @param length length of the ray
  79995. */
  79996. constructor(
  79997. /** origin point */
  79998. origin: Vector3,
  79999. /** direction */
  80000. direction: Vector3,
  80001. /** length of the ray */
  80002. length?: number);
  80003. /**
  80004. * Checks if the ray intersects a box
  80005. * @param minimum bound of the box
  80006. * @param maximum bound of the box
  80007. * @param intersectionTreshold extra extend to be added to the box in all direction
  80008. * @returns if the box was hit
  80009. */
  80010. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  80011. /**
  80012. * Checks if the ray intersects a box
  80013. * @param box the bounding box to check
  80014. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  80015. * @returns if the box was hit
  80016. */
  80017. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  80018. /**
  80019. * If the ray hits a sphere
  80020. * @param sphere the bounding sphere to check
  80021. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80022. * @returns true if it hits the sphere
  80023. */
  80024. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80025. /**
  80026. * If the ray hits a triange
  80027. * @param vertex0 triangle vertex
  80028. * @param vertex1 triangle vertex
  80029. * @param vertex2 triangle vertex
  80030. * @returns intersection information if hit
  80031. */
  80032. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80033. /**
  80034. * Checks if ray intersects a plane
  80035. * @param plane the plane to check
  80036. * @returns the distance away it was hit
  80037. */
  80038. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80039. /**
  80040. * Calculate the intercept of a ray on a given axis
  80041. * @param axis to check 'x' | 'y' | 'z'
  80042. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80043. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80044. */
  80045. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80046. /**
  80047. * Checks if ray intersects a mesh
  80048. * @param mesh the mesh to check
  80049. * @param fastCheck if only the bounding box should checked
  80050. * @returns picking info of the intersecton
  80051. */
  80052. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80053. /**
  80054. * Checks if ray intersects a mesh
  80055. * @param meshes the meshes to check
  80056. * @param fastCheck if only the bounding box should checked
  80057. * @param results array to store result in
  80058. * @returns Array of picking infos
  80059. */
  80060. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80061. private _comparePickingInfo;
  80062. private static smallnum;
  80063. private static rayl;
  80064. /**
  80065. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80066. * @param sega the first point of the segment to test the intersection against
  80067. * @param segb the second point of the segment to test the intersection against
  80068. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80069. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80070. */
  80071. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80072. /**
  80073. * Update the ray from viewport position
  80074. * @param x position
  80075. * @param y y position
  80076. * @param viewportWidth viewport width
  80077. * @param viewportHeight viewport height
  80078. * @param world world matrix
  80079. * @param view view matrix
  80080. * @param projection projection matrix
  80081. * @returns this ray updated
  80082. */
  80083. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80084. /**
  80085. * Creates a ray with origin and direction of 0,0,0
  80086. * @returns the new ray
  80087. */
  80088. static Zero(): Ray;
  80089. /**
  80090. * Creates a new ray from screen space and viewport
  80091. * @param x position
  80092. * @param y y position
  80093. * @param viewportWidth viewport width
  80094. * @param viewportHeight viewport height
  80095. * @param world world matrix
  80096. * @param view view matrix
  80097. * @param projection projection matrix
  80098. * @returns new ray
  80099. */
  80100. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80101. /**
  80102. * 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
  80103. * transformed to the given world matrix.
  80104. * @param origin The origin point
  80105. * @param end The end point
  80106. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80107. * @returns the new ray
  80108. */
  80109. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80110. /**
  80111. * Transforms a ray by a matrix
  80112. * @param ray ray to transform
  80113. * @param matrix matrix to apply
  80114. * @returns the resulting new ray
  80115. */
  80116. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80117. /**
  80118. * Transforms a ray by a matrix
  80119. * @param ray ray to transform
  80120. * @param matrix matrix to apply
  80121. * @param result ray to store result in
  80122. */
  80123. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80124. /**
  80125. * Unproject a ray from screen space to object space
  80126. * @param sourceX defines the screen space x coordinate to use
  80127. * @param sourceY defines the screen space y coordinate to use
  80128. * @param viewportWidth defines the current width of the viewport
  80129. * @param viewportHeight defines the current height of the viewport
  80130. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80131. * @param view defines the view matrix to use
  80132. * @param projection defines the projection matrix to use
  80133. */
  80134. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80135. }
  80136. /**
  80137. * Type used to define predicate used to select faces when a mesh intersection is detected
  80138. */
  80139. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80140. interface Scene {
  80141. /** @hidden */
  80142. _tempPickingRay: Nullable<Ray>;
  80143. /** @hidden */
  80144. _cachedRayForTransform: Ray;
  80145. /** @hidden */
  80146. _pickWithRayInverseMatrix: Matrix;
  80147. /** @hidden */
  80148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80149. /** @hidden */
  80150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80151. }
  80152. }
  80153. declare module BABYLON {
  80154. /**
  80155. * Groups all the scene component constants in one place to ease maintenance.
  80156. * @hidden
  80157. */
  80158. export class SceneComponentConstants {
  80159. static readonly NAME_EFFECTLAYER: string;
  80160. static readonly NAME_LAYER: string;
  80161. static readonly NAME_LENSFLARESYSTEM: string;
  80162. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80163. static readonly NAME_PARTICLESYSTEM: string;
  80164. static readonly NAME_GAMEPAD: string;
  80165. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80166. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80167. static readonly NAME_DEPTHRENDERER: string;
  80168. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80169. static readonly NAME_SPRITE: string;
  80170. static readonly NAME_OUTLINERENDERER: string;
  80171. static readonly NAME_PROCEDURALTEXTURE: string;
  80172. static readonly NAME_SHADOWGENERATOR: string;
  80173. static readonly NAME_OCTREE: string;
  80174. static readonly NAME_PHYSICSENGINE: string;
  80175. static readonly NAME_AUDIO: string;
  80176. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80177. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80178. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80179. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80180. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80181. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80182. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80183. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80184. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80185. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80186. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80187. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80188. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80189. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80190. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80191. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80192. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80193. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80194. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80195. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80196. static readonly STEP_AFTERRENDER_AUDIO: number;
  80197. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80198. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80199. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80200. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80201. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80202. static readonly STEP_POINTERMOVE_SPRITE: number;
  80203. static readonly STEP_POINTERDOWN_SPRITE: number;
  80204. static readonly STEP_POINTERUP_SPRITE: number;
  80205. }
  80206. /**
  80207. * This represents a scene component.
  80208. *
  80209. * This is used to decouple the dependency the scene is having on the different workloads like
  80210. * layers, post processes...
  80211. */
  80212. export interface ISceneComponent {
  80213. /**
  80214. * The name of the component. Each component must have a unique name.
  80215. */
  80216. name: string;
  80217. /**
  80218. * The scene the component belongs to.
  80219. */
  80220. scene: Scene;
  80221. /**
  80222. * Register the component to one instance of a scene.
  80223. */
  80224. register(): void;
  80225. /**
  80226. * Rebuilds the elements related to this component in case of
  80227. * context lost for instance.
  80228. */
  80229. rebuild(): void;
  80230. /**
  80231. * Disposes the component and the associated ressources.
  80232. */
  80233. dispose(): void;
  80234. }
  80235. /**
  80236. * This represents a SERIALIZABLE scene component.
  80237. *
  80238. * This extends Scene Component to add Serialization methods on top.
  80239. */
  80240. export interface ISceneSerializableComponent extends ISceneComponent {
  80241. /**
  80242. * Adds all the elements from the container to the scene
  80243. * @param container the container holding the elements
  80244. */
  80245. addFromContainer(container: AbstractScene): void;
  80246. /**
  80247. * Removes all the elements in the container from the scene
  80248. * @param container contains the elements to remove
  80249. * @param dispose if the removed element should be disposed (default: false)
  80250. */
  80251. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80252. /**
  80253. * Serializes the component data to the specified json object
  80254. * @param serializationObject The object to serialize to
  80255. */
  80256. serialize(serializationObject: any): void;
  80257. }
  80258. /**
  80259. * Strong typing of a Mesh related stage step action
  80260. */
  80261. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80262. /**
  80263. * Strong typing of a Evaluate Sub Mesh related stage step action
  80264. */
  80265. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80266. /**
  80267. * Strong typing of a Active Mesh related stage step action
  80268. */
  80269. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80270. /**
  80271. * Strong typing of a Camera related stage step action
  80272. */
  80273. export type CameraStageAction = (camera: Camera) => void;
  80274. /**
  80275. * Strong typing of a Camera Frame buffer related stage step action
  80276. */
  80277. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80278. /**
  80279. * Strong typing of a Render Target related stage step action
  80280. */
  80281. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80282. /**
  80283. * Strong typing of a RenderingGroup related stage step action
  80284. */
  80285. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80286. /**
  80287. * Strong typing of a Mesh Render related stage step action
  80288. */
  80289. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80290. /**
  80291. * Strong typing of a simple stage step action
  80292. */
  80293. export type SimpleStageAction = () => void;
  80294. /**
  80295. * Strong typing of a render target action.
  80296. */
  80297. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80298. /**
  80299. * Strong typing of a pointer move action.
  80300. */
  80301. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80302. /**
  80303. * Strong typing of a pointer up/down action.
  80304. */
  80305. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80306. /**
  80307. * Representation of a stage in the scene (Basically a list of ordered steps)
  80308. * @hidden
  80309. */
  80310. export class Stage<T extends Function> extends Array<{
  80311. index: number;
  80312. component: ISceneComponent;
  80313. action: T;
  80314. }> {
  80315. /**
  80316. * Hide ctor from the rest of the world.
  80317. * @param items The items to add.
  80318. */
  80319. private constructor();
  80320. /**
  80321. * Creates a new Stage.
  80322. * @returns A new instance of a Stage
  80323. */
  80324. static Create<T extends Function>(): Stage<T>;
  80325. /**
  80326. * Registers a step in an ordered way in the targeted stage.
  80327. * @param index Defines the position to register the step in
  80328. * @param component Defines the component attached to the step
  80329. * @param action Defines the action to launch during the step
  80330. */
  80331. registerStep(index: number, component: ISceneComponent, action: T): void;
  80332. /**
  80333. * Clears all the steps from the stage.
  80334. */
  80335. clear(): void;
  80336. }
  80337. }
  80338. declare module BABYLON {
  80339. interface Scene {
  80340. /** @hidden */
  80341. _pointerOverSprite: Nullable<Sprite>;
  80342. /** @hidden */
  80343. _pickedDownSprite: Nullable<Sprite>;
  80344. /** @hidden */
  80345. _tempSpritePickingRay: Nullable<Ray>;
  80346. /**
  80347. * All of the sprite managers added to this scene
  80348. * @see http://doc.babylonjs.com/babylon101/sprites
  80349. */
  80350. spriteManagers: Array<ISpriteManager>;
  80351. /**
  80352. * An event triggered when sprites rendering is about to start
  80353. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80354. */
  80355. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80356. /**
  80357. * An event triggered when sprites rendering is done
  80358. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80359. */
  80360. onAfterSpritesRenderingObservable: Observable<Scene>;
  80361. /** @hidden */
  80362. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80363. /** Launch a ray to try to pick a sprite in the scene
  80364. * @param x position on screen
  80365. * @param y position on screen
  80366. * @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
  80367. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80368. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80369. * @returns a PickingInfo
  80370. */
  80371. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80372. /** Use the given ray to pick a sprite in the scene
  80373. * @param ray The ray (in world space) to use to pick meshes
  80374. * @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
  80375. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80376. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80377. * @returns a PickingInfo
  80378. */
  80379. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80380. /** @hidden */
  80381. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80382. /** Launch a ray to try to pick sprites in the scene
  80383. * @param x position on screen
  80384. * @param y position on screen
  80385. * @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
  80386. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80387. * @returns a PickingInfo array
  80388. */
  80389. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80390. /** Use the given ray to pick sprites in the scene
  80391. * @param ray The ray (in world space) to use to pick meshes
  80392. * @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
  80393. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80394. * @returns a PickingInfo array
  80395. */
  80396. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80397. /**
  80398. * Force the sprite under the pointer
  80399. * @param sprite defines the sprite to use
  80400. */
  80401. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80402. /**
  80403. * Gets the sprite under the pointer
  80404. * @returns a Sprite or null if no sprite is under the pointer
  80405. */
  80406. getPointerOverSprite(): Nullable<Sprite>;
  80407. }
  80408. /**
  80409. * Defines the sprite scene component responsible to manage sprites
  80410. * in a given scene.
  80411. */
  80412. export class SpriteSceneComponent implements ISceneComponent {
  80413. /**
  80414. * The component name helpfull to identify the component in the list of scene components.
  80415. */
  80416. readonly name: string;
  80417. /**
  80418. * The scene the component belongs to.
  80419. */
  80420. scene: Scene;
  80421. /** @hidden */
  80422. private _spritePredicate;
  80423. /**
  80424. * Creates a new instance of the component for the given scene
  80425. * @param scene Defines the scene to register the component in
  80426. */
  80427. constructor(scene: Scene);
  80428. /**
  80429. * Registers the component in a given scene
  80430. */
  80431. register(): void;
  80432. /**
  80433. * Rebuilds the elements related to this component in case of
  80434. * context lost for instance.
  80435. */
  80436. rebuild(): void;
  80437. /**
  80438. * Disposes the component and the associated ressources.
  80439. */
  80440. dispose(): void;
  80441. private _pickSpriteButKeepRay;
  80442. private _pointerMove;
  80443. private _pointerDown;
  80444. private _pointerUp;
  80445. }
  80446. }
  80447. declare module BABYLON {
  80448. /** @hidden */
  80449. export var fogFragmentDeclaration: {
  80450. name: string;
  80451. shader: string;
  80452. };
  80453. }
  80454. declare module BABYLON {
  80455. /** @hidden */
  80456. export var fogFragment: {
  80457. name: string;
  80458. shader: string;
  80459. };
  80460. }
  80461. declare module BABYLON {
  80462. /** @hidden */
  80463. export var spritesPixelShader: {
  80464. name: string;
  80465. shader: string;
  80466. };
  80467. }
  80468. declare module BABYLON {
  80469. /** @hidden */
  80470. export var fogVertexDeclaration: {
  80471. name: string;
  80472. shader: string;
  80473. };
  80474. }
  80475. declare module BABYLON {
  80476. /** @hidden */
  80477. export var spritesVertexShader: {
  80478. name: string;
  80479. shader: string;
  80480. };
  80481. }
  80482. declare module BABYLON {
  80483. /**
  80484. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80485. */
  80486. export interface ISpriteManager extends IDisposable {
  80487. /**
  80488. * Restricts the camera to viewing objects with the same layerMask.
  80489. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80490. */
  80491. layerMask: number;
  80492. /**
  80493. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80494. */
  80495. isPickable: boolean;
  80496. /**
  80497. * Specifies the rendering group id for this mesh (0 by default)
  80498. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80499. */
  80500. renderingGroupId: number;
  80501. /**
  80502. * Defines the list of sprites managed by the manager.
  80503. */
  80504. sprites: Array<Sprite>;
  80505. /**
  80506. * Tests the intersection of a sprite with a specific ray.
  80507. * @param ray The ray we are sending to test the collision
  80508. * @param camera The camera space we are sending rays in
  80509. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80510. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80511. * @returns picking info or null.
  80512. */
  80513. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80514. /**
  80515. * Intersects the sprites with a ray
  80516. * @param ray defines the ray to intersect with
  80517. * @param camera defines the current active camera
  80518. * @param predicate defines a predicate used to select candidate sprites
  80519. * @returns null if no hit or a PickingInfo array
  80520. */
  80521. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80522. /**
  80523. * Renders the list of sprites on screen.
  80524. */
  80525. render(): void;
  80526. }
  80527. /**
  80528. * Class used to manage multiple sprites on the same spritesheet
  80529. * @see http://doc.babylonjs.com/babylon101/sprites
  80530. */
  80531. export class SpriteManager implements ISpriteManager {
  80532. /** defines the manager's name */
  80533. name: string;
  80534. /** Gets the list of sprites */
  80535. sprites: Sprite[];
  80536. /** Gets or sets the rendering group id (0 by default) */
  80537. renderingGroupId: number;
  80538. /** Gets or sets camera layer mask */
  80539. layerMask: number;
  80540. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80541. fogEnabled: boolean;
  80542. /** Gets or sets a boolean indicating if the sprites are pickable */
  80543. isPickable: boolean;
  80544. /** Defines the default width of a cell in the spritesheet */
  80545. cellWidth: number;
  80546. /** Defines the default height of a cell in the spritesheet */
  80547. cellHeight: number;
  80548. /** Associative array from JSON sprite data file */
  80549. private _cellData;
  80550. /** Array of sprite names from JSON sprite data file */
  80551. private _spriteMap;
  80552. /** True when packed cell data from JSON file is ready*/
  80553. private _packedAndReady;
  80554. /**
  80555. * An event triggered when the manager is disposed.
  80556. */
  80557. onDisposeObservable: Observable<SpriteManager>;
  80558. private _onDisposeObserver;
  80559. /**
  80560. * Callback called when the manager is disposed
  80561. */
  80562. onDispose: () => void;
  80563. private _capacity;
  80564. private _fromPacked;
  80565. private _spriteTexture;
  80566. private _epsilon;
  80567. private _scene;
  80568. private _vertexData;
  80569. private _buffer;
  80570. private _vertexBuffers;
  80571. private _indexBuffer;
  80572. private _effectBase;
  80573. private _effectFog;
  80574. /**
  80575. * Gets or sets the spritesheet texture
  80576. */
  80577. texture: Texture;
  80578. /**
  80579. * Creates a new sprite manager
  80580. * @param name defines the manager's name
  80581. * @param imgUrl defines the sprite sheet url
  80582. * @param capacity defines the maximum allowed number of sprites
  80583. * @param cellSize defines the size of a sprite cell
  80584. * @param scene defines the hosting scene
  80585. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80586. * @param samplingMode defines the smapling mode to use with spritesheet
  80587. * @param fromPacked set to false; do not alter
  80588. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80589. */
  80590. constructor(
  80591. /** defines the manager's name */
  80592. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80593. private _makePacked;
  80594. private _appendSpriteVertex;
  80595. /**
  80596. * Intersects the sprites with a ray
  80597. * @param ray defines the ray to intersect with
  80598. * @param camera defines the current active camera
  80599. * @param predicate defines a predicate used to select candidate sprites
  80600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80601. * @returns null if no hit or a PickingInfo
  80602. */
  80603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80604. /**
  80605. * Intersects the sprites with a ray
  80606. * @param ray defines the ray to intersect with
  80607. * @param camera defines the current active camera
  80608. * @param predicate defines a predicate used to select candidate sprites
  80609. * @returns null if no hit or a PickingInfo array
  80610. */
  80611. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80612. /**
  80613. * Render all child sprites
  80614. */
  80615. render(): void;
  80616. /**
  80617. * Release associated resources
  80618. */
  80619. dispose(): void;
  80620. }
  80621. }
  80622. declare module BABYLON {
  80623. /**
  80624. * Class used to represent a sprite
  80625. * @see http://doc.babylonjs.com/babylon101/sprites
  80626. */
  80627. export class Sprite {
  80628. /** defines the name */
  80629. name: string;
  80630. /** Gets or sets the current world position */
  80631. position: Vector3;
  80632. /** Gets or sets the main color */
  80633. color: Color4;
  80634. /** Gets or sets the width */
  80635. width: number;
  80636. /** Gets or sets the height */
  80637. height: number;
  80638. /** Gets or sets rotation angle */
  80639. angle: number;
  80640. /** Gets or sets the cell index in the sprite sheet */
  80641. cellIndex: number;
  80642. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80643. cellRef: string;
  80644. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80645. invertU: number;
  80646. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80647. invertV: number;
  80648. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80649. disposeWhenFinishedAnimating: boolean;
  80650. /** Gets the list of attached animations */
  80651. animations: Animation[];
  80652. /** Gets or sets a boolean indicating if the sprite can be picked */
  80653. isPickable: boolean;
  80654. /**
  80655. * Gets or sets the associated action manager
  80656. */
  80657. actionManager: Nullable<ActionManager>;
  80658. private _animationStarted;
  80659. private _loopAnimation;
  80660. private _fromIndex;
  80661. private _toIndex;
  80662. private _delay;
  80663. private _direction;
  80664. private _manager;
  80665. private _time;
  80666. private _onAnimationEnd;
  80667. /**
  80668. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80669. */
  80670. isVisible: boolean;
  80671. /**
  80672. * Gets or sets the sprite size
  80673. */
  80674. size: number;
  80675. /**
  80676. * Creates a new Sprite
  80677. * @param name defines the name
  80678. * @param manager defines the manager
  80679. */
  80680. constructor(
  80681. /** defines the name */
  80682. name: string, manager: ISpriteManager);
  80683. /**
  80684. * Starts an animation
  80685. * @param from defines the initial key
  80686. * @param to defines the end key
  80687. * @param loop defines if the animation must loop
  80688. * @param delay defines the start delay (in ms)
  80689. * @param onAnimationEnd defines a callback to call when animation ends
  80690. */
  80691. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80692. /** Stops current animation (if any) */
  80693. stopAnimation(): void;
  80694. /** @hidden */
  80695. _animate(deltaTime: number): void;
  80696. /** Release associated resources */
  80697. dispose(): void;
  80698. }
  80699. }
  80700. declare module BABYLON {
  80701. /**
  80702. * Information about the result of picking within a scene
  80703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80704. */
  80705. export class PickingInfo {
  80706. /** @hidden */
  80707. _pickingUnavailable: boolean;
  80708. /**
  80709. * If the pick collided with an object
  80710. */
  80711. hit: boolean;
  80712. /**
  80713. * Distance away where the pick collided
  80714. */
  80715. distance: number;
  80716. /**
  80717. * The location of pick collision
  80718. */
  80719. pickedPoint: Nullable<Vector3>;
  80720. /**
  80721. * The mesh corresponding the the pick collision
  80722. */
  80723. pickedMesh: Nullable<AbstractMesh>;
  80724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80725. bu: number;
  80726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80727. bv: number;
  80728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80729. faceId: number;
  80730. /** Id of the the submesh that was picked */
  80731. subMeshId: number;
  80732. /** If a sprite was picked, this will be the sprite the pick collided with */
  80733. pickedSprite: Nullable<Sprite>;
  80734. /**
  80735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80736. */
  80737. originMesh: Nullable<AbstractMesh>;
  80738. /**
  80739. * The ray that was used to perform the picking.
  80740. */
  80741. ray: Nullable<Ray>;
  80742. /**
  80743. * Gets the normal correspodning to the face the pick collided with
  80744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80746. * @returns The normal correspodning to the face the pick collided with
  80747. */
  80748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80749. /**
  80750. * Gets the texture coordinates of where the pick occured
  80751. * @returns the vector containing the coordnates of the texture
  80752. */
  80753. getTextureCoordinates(): Nullable<Vector2>;
  80754. }
  80755. }
  80756. declare module BABYLON {
  80757. /**
  80758. * Gather the list of pointer event types as constants.
  80759. */
  80760. export class PointerEventTypes {
  80761. /**
  80762. * 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.
  80763. */
  80764. static readonly POINTERDOWN: number;
  80765. /**
  80766. * The pointerup event is fired when a pointer is no longer active.
  80767. */
  80768. static readonly POINTERUP: number;
  80769. /**
  80770. * The pointermove event is fired when a pointer changes coordinates.
  80771. */
  80772. static readonly POINTERMOVE: number;
  80773. /**
  80774. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80775. */
  80776. static readonly POINTERWHEEL: number;
  80777. /**
  80778. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80779. */
  80780. static readonly POINTERPICK: number;
  80781. /**
  80782. * The pointertap event is fired when a the object has been touched and released without drag.
  80783. */
  80784. static readonly POINTERTAP: number;
  80785. /**
  80786. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80787. */
  80788. static readonly POINTERDOUBLETAP: number;
  80789. }
  80790. /**
  80791. * Base class of pointer info types.
  80792. */
  80793. export class PointerInfoBase {
  80794. /**
  80795. * Defines the type of event (PointerEventTypes)
  80796. */
  80797. type: number;
  80798. /**
  80799. * Defines the related dom event
  80800. */
  80801. event: PointerEvent | MouseWheelEvent;
  80802. /**
  80803. * Instantiates the base class of pointers info.
  80804. * @param type Defines the type of event (PointerEventTypes)
  80805. * @param event Defines the related dom event
  80806. */
  80807. constructor(
  80808. /**
  80809. * Defines the type of event (PointerEventTypes)
  80810. */
  80811. type: number,
  80812. /**
  80813. * Defines the related dom event
  80814. */
  80815. event: PointerEvent | MouseWheelEvent);
  80816. }
  80817. /**
  80818. * This class is used to store pointer related info for the onPrePointerObservable event.
  80819. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80820. */
  80821. export class PointerInfoPre extends PointerInfoBase {
  80822. /**
  80823. * Ray from a pointer if availible (eg. 6dof controller)
  80824. */
  80825. ray: Nullable<Ray>;
  80826. /**
  80827. * Defines the local position of the pointer on the canvas.
  80828. */
  80829. localPosition: Vector2;
  80830. /**
  80831. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80832. */
  80833. skipOnPointerObservable: boolean;
  80834. /**
  80835. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80836. * @param type Defines the type of event (PointerEventTypes)
  80837. * @param event Defines the related dom event
  80838. * @param localX Defines the local x coordinates of the pointer when the event occured
  80839. * @param localY Defines the local y coordinates of the pointer when the event occured
  80840. */
  80841. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80842. }
  80843. /**
  80844. * This type contains all the data related to a pointer event in Babylon.js.
  80845. * 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.
  80846. */
  80847. export class PointerInfo extends PointerInfoBase {
  80848. /**
  80849. * Defines the picking info associated to the info (if any)\
  80850. */
  80851. pickInfo: Nullable<PickingInfo>;
  80852. /**
  80853. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80854. * @param type Defines the type of event (PointerEventTypes)
  80855. * @param event Defines the related dom event
  80856. * @param pickInfo Defines the picking info associated to the info (if any)\
  80857. */
  80858. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80859. /**
  80860. * Defines the picking info associated to the info (if any)\
  80861. */
  80862. pickInfo: Nullable<PickingInfo>);
  80863. }
  80864. /**
  80865. * Data relating to a touch event on the screen.
  80866. */
  80867. export interface PointerTouch {
  80868. /**
  80869. * X coordinate of touch.
  80870. */
  80871. x: number;
  80872. /**
  80873. * Y coordinate of touch.
  80874. */
  80875. y: number;
  80876. /**
  80877. * Id of touch. Unique for each finger.
  80878. */
  80879. pointerId: number;
  80880. /**
  80881. * Event type passed from DOM.
  80882. */
  80883. type: any;
  80884. }
  80885. }
  80886. declare module BABYLON {
  80887. /**
  80888. * Manage the mouse inputs to control the movement of a free camera.
  80889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80890. */
  80891. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80892. /**
  80893. * Define if touch is enabled in the mouse input
  80894. */
  80895. touchEnabled: boolean;
  80896. /**
  80897. * Defines the camera the input is attached to.
  80898. */
  80899. camera: FreeCamera;
  80900. /**
  80901. * Defines the buttons associated with the input to handle camera move.
  80902. */
  80903. buttons: number[];
  80904. /**
  80905. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80906. */
  80907. angularSensibility: number;
  80908. private _pointerInput;
  80909. private _onMouseMove;
  80910. private _observer;
  80911. private previousPosition;
  80912. /**
  80913. * Observable for when a pointer move event occurs containing the move offset
  80914. */
  80915. onPointerMovedObservable: Observable<{
  80916. offsetX: number;
  80917. offsetY: number;
  80918. }>;
  80919. /**
  80920. * @hidden
  80921. * If the camera should be rotated automatically based on pointer movement
  80922. */
  80923. _allowCameraRotation: boolean;
  80924. /**
  80925. * Manage the mouse inputs to control the movement of a free camera.
  80926. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80927. * @param touchEnabled Defines if touch is enabled or not
  80928. */
  80929. constructor(
  80930. /**
  80931. * Define if touch is enabled in the mouse input
  80932. */
  80933. touchEnabled?: boolean);
  80934. /**
  80935. * Attach the input controls to a specific dom element to get the input from.
  80936. * @param element Defines the element the controls should be listened from
  80937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80938. */
  80939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80940. /**
  80941. * Called on JS contextmenu event.
  80942. * Override this method to provide functionality.
  80943. */
  80944. protected onContextMenu(evt: PointerEvent): void;
  80945. /**
  80946. * Detach the current controls from the specified dom element.
  80947. * @param element Defines the element to stop listening the inputs from
  80948. */
  80949. detachControl(element: Nullable<HTMLElement>): void;
  80950. /**
  80951. * Gets the class name of the current intput.
  80952. * @returns the class name
  80953. */
  80954. getClassName(): string;
  80955. /**
  80956. * Get the friendly name associated with the input class.
  80957. * @returns the input friendly name
  80958. */
  80959. getSimpleName(): string;
  80960. }
  80961. }
  80962. declare module BABYLON {
  80963. /**
  80964. * Manage the touch inputs to control the movement of a free camera.
  80965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80966. */
  80967. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80968. /**
  80969. * Defines the camera the input is attached to.
  80970. */
  80971. camera: FreeCamera;
  80972. /**
  80973. * Defines the touch sensibility for rotation.
  80974. * The higher the faster.
  80975. */
  80976. touchAngularSensibility: number;
  80977. /**
  80978. * Defines the touch sensibility for move.
  80979. * The higher the faster.
  80980. */
  80981. touchMoveSensibility: number;
  80982. private _offsetX;
  80983. private _offsetY;
  80984. private _pointerPressed;
  80985. private _pointerInput;
  80986. private _observer;
  80987. private _onLostFocus;
  80988. /**
  80989. * Attach the input controls to a specific dom element to get the input from.
  80990. * @param element Defines the element the controls should be listened from
  80991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80992. */
  80993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80994. /**
  80995. * Detach the current controls from the specified dom element.
  80996. * @param element Defines the element to stop listening the inputs from
  80997. */
  80998. detachControl(element: Nullable<HTMLElement>): void;
  80999. /**
  81000. * Update the current camera state depending on the inputs that have been used this frame.
  81001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81002. */
  81003. checkInputs(): void;
  81004. /**
  81005. * Gets the class name of the current intput.
  81006. * @returns the class name
  81007. */
  81008. getClassName(): string;
  81009. /**
  81010. * Get the friendly name associated with the input class.
  81011. * @returns the input friendly name
  81012. */
  81013. getSimpleName(): string;
  81014. }
  81015. }
  81016. declare module BABYLON {
  81017. /**
  81018. * Default Inputs manager for the FreeCamera.
  81019. * It groups all the default supported inputs for ease of use.
  81020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81021. */
  81022. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81023. /**
  81024. * @hidden
  81025. */
  81026. _mouseInput: Nullable<FreeCameraMouseInput>;
  81027. /**
  81028. * Instantiates a new FreeCameraInputsManager.
  81029. * @param camera Defines the camera the inputs belong to
  81030. */
  81031. constructor(camera: FreeCamera);
  81032. /**
  81033. * Add keyboard input support to the input manager.
  81034. * @returns the current input manager
  81035. */
  81036. addKeyboard(): FreeCameraInputsManager;
  81037. /**
  81038. * Add mouse input support to the input manager.
  81039. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81040. * @returns the current input manager
  81041. */
  81042. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81043. /**
  81044. * Removes the mouse input support from the manager
  81045. * @returns the current input manager
  81046. */
  81047. removeMouse(): FreeCameraInputsManager;
  81048. /**
  81049. * Add touch input support to the input manager.
  81050. * @returns the current input manager
  81051. */
  81052. addTouch(): FreeCameraInputsManager;
  81053. /**
  81054. * Remove all attached input methods from a camera
  81055. */
  81056. clear(): void;
  81057. }
  81058. }
  81059. declare module BABYLON {
  81060. /**
  81061. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81062. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81063. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81064. */
  81065. export class FreeCamera extends TargetCamera {
  81066. /**
  81067. * Define the collision ellipsoid of the camera.
  81068. * This is helpful to simulate a camera body like the player body around the camera
  81069. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81070. */
  81071. ellipsoid: Vector3;
  81072. /**
  81073. * Define an offset for the position of the ellipsoid around the camera.
  81074. * This can be helpful to determine the center of the body near the gravity center of the body
  81075. * instead of its head.
  81076. */
  81077. ellipsoidOffset: Vector3;
  81078. /**
  81079. * Enable or disable collisions of the camera with the rest of the scene objects.
  81080. */
  81081. checkCollisions: boolean;
  81082. /**
  81083. * Enable or disable gravity on the camera.
  81084. */
  81085. applyGravity: boolean;
  81086. /**
  81087. * Define the input manager associated to the camera.
  81088. */
  81089. inputs: FreeCameraInputsManager;
  81090. /**
  81091. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81092. * Higher values reduce sensitivity.
  81093. */
  81094. /**
  81095. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81096. * Higher values reduce sensitivity.
  81097. */
  81098. angularSensibility: number;
  81099. /**
  81100. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81101. */
  81102. keysUp: number[];
  81103. /**
  81104. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81105. */
  81106. keysDown: number[];
  81107. /**
  81108. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81109. */
  81110. keysLeft: number[];
  81111. /**
  81112. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81113. */
  81114. keysRight: number[];
  81115. /**
  81116. * Event raised when the camera collide with a mesh in the scene.
  81117. */
  81118. onCollide: (collidedMesh: AbstractMesh) => void;
  81119. private _collider;
  81120. private _needMoveForGravity;
  81121. private _oldPosition;
  81122. private _diffPosition;
  81123. private _newPosition;
  81124. /** @hidden */
  81125. _localDirection: Vector3;
  81126. /** @hidden */
  81127. _transformedDirection: Vector3;
  81128. /**
  81129. * Instantiates a Free Camera.
  81130. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81131. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81132. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81133. * @param name Define the name of the camera in the scene
  81134. * @param position Define the start position of the camera in the scene
  81135. * @param scene Define the scene the camera belongs to
  81136. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81137. */
  81138. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81139. /**
  81140. * Attached controls to the current camera.
  81141. * @param element Defines the element the controls should be listened from
  81142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81143. */
  81144. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81145. /**
  81146. * Detach the current controls from the camera.
  81147. * The camera will stop reacting to inputs.
  81148. * @param element Defines the element to stop listening the inputs from
  81149. */
  81150. detachControl(element: HTMLElement): void;
  81151. private _collisionMask;
  81152. /**
  81153. * Define a collision mask to limit the list of object the camera can collide with
  81154. */
  81155. collisionMask: number;
  81156. /** @hidden */
  81157. _collideWithWorld(displacement: Vector3): void;
  81158. private _onCollisionPositionChange;
  81159. /** @hidden */
  81160. _checkInputs(): void;
  81161. /** @hidden */
  81162. _decideIfNeedsToMove(): boolean;
  81163. /** @hidden */
  81164. _updatePosition(): void;
  81165. /**
  81166. * Destroy the camera and release the current resources hold by it.
  81167. */
  81168. dispose(): void;
  81169. /**
  81170. * Gets the current object class name.
  81171. * @return the class name
  81172. */
  81173. getClassName(): string;
  81174. }
  81175. }
  81176. declare module BABYLON {
  81177. /**
  81178. * Represents a gamepad control stick position
  81179. */
  81180. export class StickValues {
  81181. /**
  81182. * The x component of the control stick
  81183. */
  81184. x: number;
  81185. /**
  81186. * The y component of the control stick
  81187. */
  81188. y: number;
  81189. /**
  81190. * Initializes the gamepad x and y control stick values
  81191. * @param x The x component of the gamepad control stick value
  81192. * @param y The y component of the gamepad control stick value
  81193. */
  81194. constructor(
  81195. /**
  81196. * The x component of the control stick
  81197. */
  81198. x: number,
  81199. /**
  81200. * The y component of the control stick
  81201. */
  81202. y: number);
  81203. }
  81204. /**
  81205. * An interface which manages callbacks for gamepad button changes
  81206. */
  81207. export interface GamepadButtonChanges {
  81208. /**
  81209. * Called when a gamepad has been changed
  81210. */
  81211. changed: boolean;
  81212. /**
  81213. * Called when a gamepad press event has been triggered
  81214. */
  81215. pressChanged: boolean;
  81216. /**
  81217. * Called when a touch event has been triggered
  81218. */
  81219. touchChanged: boolean;
  81220. /**
  81221. * Called when a value has changed
  81222. */
  81223. valueChanged: boolean;
  81224. }
  81225. /**
  81226. * Represents a gamepad
  81227. */
  81228. export class Gamepad {
  81229. /**
  81230. * The id of the gamepad
  81231. */
  81232. id: string;
  81233. /**
  81234. * The index of the gamepad
  81235. */
  81236. index: number;
  81237. /**
  81238. * The browser gamepad
  81239. */
  81240. browserGamepad: any;
  81241. /**
  81242. * Specifies what type of gamepad this represents
  81243. */
  81244. type: number;
  81245. private _leftStick;
  81246. private _rightStick;
  81247. /** @hidden */
  81248. _isConnected: boolean;
  81249. private _leftStickAxisX;
  81250. private _leftStickAxisY;
  81251. private _rightStickAxisX;
  81252. private _rightStickAxisY;
  81253. /**
  81254. * Triggered when the left control stick has been changed
  81255. */
  81256. private _onleftstickchanged;
  81257. /**
  81258. * Triggered when the right control stick has been changed
  81259. */
  81260. private _onrightstickchanged;
  81261. /**
  81262. * Represents a gamepad controller
  81263. */
  81264. static GAMEPAD: number;
  81265. /**
  81266. * Represents a generic controller
  81267. */
  81268. static GENERIC: number;
  81269. /**
  81270. * Represents an XBox controller
  81271. */
  81272. static XBOX: number;
  81273. /**
  81274. * Represents a pose-enabled controller
  81275. */
  81276. static POSE_ENABLED: number;
  81277. /**
  81278. * Represents an Dual Shock controller
  81279. */
  81280. static DUALSHOCK: number;
  81281. /**
  81282. * Specifies whether the left control stick should be Y-inverted
  81283. */
  81284. protected _invertLeftStickY: boolean;
  81285. /**
  81286. * Specifies if the gamepad has been connected
  81287. */
  81288. readonly isConnected: boolean;
  81289. /**
  81290. * Initializes the gamepad
  81291. * @param id The id of the gamepad
  81292. * @param index The index of the gamepad
  81293. * @param browserGamepad The browser gamepad
  81294. * @param leftStickX The x component of the left joystick
  81295. * @param leftStickY The y component of the left joystick
  81296. * @param rightStickX The x component of the right joystick
  81297. * @param rightStickY The y component of the right joystick
  81298. */
  81299. constructor(
  81300. /**
  81301. * The id of the gamepad
  81302. */
  81303. id: string,
  81304. /**
  81305. * The index of the gamepad
  81306. */
  81307. index: number,
  81308. /**
  81309. * The browser gamepad
  81310. */
  81311. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81312. /**
  81313. * Callback triggered when the left joystick has changed
  81314. * @param callback
  81315. */
  81316. onleftstickchanged(callback: (values: StickValues) => void): void;
  81317. /**
  81318. * Callback triggered when the right joystick has changed
  81319. * @param callback
  81320. */
  81321. onrightstickchanged(callback: (values: StickValues) => void): void;
  81322. /**
  81323. * Gets the left joystick
  81324. */
  81325. /**
  81326. * Sets the left joystick values
  81327. */
  81328. leftStick: StickValues;
  81329. /**
  81330. * Gets the right joystick
  81331. */
  81332. /**
  81333. * Sets the right joystick value
  81334. */
  81335. rightStick: StickValues;
  81336. /**
  81337. * Updates the gamepad joystick positions
  81338. */
  81339. update(): void;
  81340. /**
  81341. * Disposes the gamepad
  81342. */
  81343. dispose(): void;
  81344. }
  81345. /**
  81346. * Represents a generic gamepad
  81347. */
  81348. export class GenericPad extends Gamepad {
  81349. private _buttons;
  81350. private _onbuttondown;
  81351. private _onbuttonup;
  81352. /**
  81353. * Observable triggered when a button has been pressed
  81354. */
  81355. onButtonDownObservable: Observable<number>;
  81356. /**
  81357. * Observable triggered when a button has been released
  81358. */
  81359. onButtonUpObservable: Observable<number>;
  81360. /**
  81361. * Callback triggered when a button has been pressed
  81362. * @param callback Called when a button has been pressed
  81363. */
  81364. onbuttondown(callback: (buttonPressed: number) => void): void;
  81365. /**
  81366. * Callback triggered when a button has been released
  81367. * @param callback Called when a button has been released
  81368. */
  81369. onbuttonup(callback: (buttonReleased: number) => void): void;
  81370. /**
  81371. * Initializes the generic gamepad
  81372. * @param id The id of the generic gamepad
  81373. * @param index The index of the generic gamepad
  81374. * @param browserGamepad The browser gamepad
  81375. */
  81376. constructor(id: string, index: number, browserGamepad: any);
  81377. private _setButtonValue;
  81378. /**
  81379. * Updates the generic gamepad
  81380. */
  81381. update(): void;
  81382. /**
  81383. * Disposes the generic gamepad
  81384. */
  81385. dispose(): void;
  81386. }
  81387. }
  81388. declare module BABYLON {
  81389. interface Engine {
  81390. /**
  81391. * Creates a raw texture
  81392. * @param data defines the data to store in the texture
  81393. * @param width defines the width of the texture
  81394. * @param height defines the height of the texture
  81395. * @param format defines the format of the data
  81396. * @param generateMipMaps defines if the engine should generate the mip levels
  81397. * @param invertY defines if data must be stored with Y axis inverted
  81398. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81399. * @param compression defines the compression used (null by default)
  81400. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81401. * @returns the raw texture inside an InternalTexture
  81402. */
  81403. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81404. /**
  81405. * Update a raw texture
  81406. * @param texture defines the texture to update
  81407. * @param data defines the data to store in the texture
  81408. * @param format defines the format of the data
  81409. * @param invertY defines if data must be stored with Y axis inverted
  81410. */
  81411. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81412. /**
  81413. * Update a raw texture
  81414. * @param texture defines the texture to update
  81415. * @param data defines the data to store in the texture
  81416. * @param format defines the format of the data
  81417. * @param invertY defines if data must be stored with Y axis inverted
  81418. * @param compression defines the compression used (null by default)
  81419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81420. */
  81421. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81422. /**
  81423. * Creates a new raw cube texture
  81424. * @param data defines the array of data to use to create each face
  81425. * @param size defines the size of the textures
  81426. * @param format defines the format of the data
  81427. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81428. * @param generateMipMaps defines if the engine should generate the mip levels
  81429. * @param invertY defines if data must be stored with Y axis inverted
  81430. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81431. * @param compression defines the compression used (null by default)
  81432. * @returns the cube texture as an InternalTexture
  81433. */
  81434. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81435. /**
  81436. * Update a raw cube texture
  81437. * @param texture defines the texture to udpdate
  81438. * @param data defines the data to store
  81439. * @param format defines the data format
  81440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81441. * @param invertY defines if data must be stored with Y axis inverted
  81442. */
  81443. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81444. /**
  81445. * Update a raw cube texture
  81446. * @param texture defines the texture to udpdate
  81447. * @param data defines the data to store
  81448. * @param format defines the data format
  81449. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81450. * @param invertY defines if data must be stored with Y axis inverted
  81451. * @param compression defines the compression used (null by default)
  81452. */
  81453. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81454. /**
  81455. * Update a raw cube texture
  81456. * @param texture defines the texture to udpdate
  81457. * @param data defines the data to store
  81458. * @param format defines the data format
  81459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81460. * @param invertY defines if data must be stored with Y axis inverted
  81461. * @param compression defines the compression used (null by default)
  81462. * @param level defines which level of the texture to update
  81463. */
  81464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81465. /**
  81466. * Creates a new raw cube texture from a specified url
  81467. * @param url defines the url where the data is located
  81468. * @param scene defines the current scene
  81469. * @param size defines the size of the textures
  81470. * @param format defines the format of the data
  81471. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81472. * @param noMipmap defines if the engine should avoid generating the mip levels
  81473. * @param callback defines a callback used to extract texture data from loaded data
  81474. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81475. * @param onLoad defines a callback called when texture is loaded
  81476. * @param onError defines a callback called if there is an error
  81477. * @returns the cube texture as an InternalTexture
  81478. */
  81479. 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;
  81480. /**
  81481. * Creates a new raw cube texture from a specified url
  81482. * @param url defines the url where the data is located
  81483. * @param scene defines the current scene
  81484. * @param size defines the size of the textures
  81485. * @param format defines the format of the data
  81486. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81487. * @param noMipmap defines if the engine should avoid generating the mip levels
  81488. * @param callback defines a callback used to extract texture data from loaded data
  81489. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81490. * @param onLoad defines a callback called when texture is loaded
  81491. * @param onError defines a callback called if there is an error
  81492. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81493. * @param invertY defines if data must be stored with Y axis inverted
  81494. * @returns the cube texture as an InternalTexture
  81495. */
  81496. 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;
  81497. /**
  81498. * Creates a new raw 3D texture
  81499. * @param data defines the data used to create the texture
  81500. * @param width defines the width of the texture
  81501. * @param height defines the height of the texture
  81502. * @param depth defines the depth of the texture
  81503. * @param format defines the format of the texture
  81504. * @param generateMipMaps defines if the engine must generate mip levels
  81505. * @param invertY defines if data must be stored with Y axis inverted
  81506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81507. * @param compression defines the compressed used (can be null)
  81508. * @param textureType defines the compressed used (can be null)
  81509. * @returns a new raw 3D texture (stored in an InternalTexture)
  81510. */
  81511. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81512. /**
  81513. * Update a raw 3D texture
  81514. * @param texture defines the texture to update
  81515. * @param data defines the data to store
  81516. * @param format defines the data format
  81517. * @param invertY defines if data must be stored with Y axis inverted
  81518. */
  81519. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81520. /**
  81521. * Update a raw 3D texture
  81522. * @param texture defines the texture to update
  81523. * @param data defines the data to store
  81524. * @param format defines the data format
  81525. * @param invertY defines if data must be stored with Y axis inverted
  81526. * @param compression defines the used compression (can be null)
  81527. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81528. */
  81529. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81530. /**
  81531. * Creates a new raw 2D array texture
  81532. * @param data defines the data used to create the texture
  81533. * @param width defines the width of the texture
  81534. * @param height defines the height of the texture
  81535. * @param depth defines the number of layers of the texture
  81536. * @param format defines the format of the texture
  81537. * @param generateMipMaps defines if the engine must generate mip levels
  81538. * @param invertY defines if data must be stored with Y axis inverted
  81539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81540. * @param compression defines the compressed used (can be null)
  81541. * @param textureType defines the compressed used (can be null)
  81542. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81543. */
  81544. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81545. /**
  81546. * Update a raw 2D array texture
  81547. * @param texture defines the texture to update
  81548. * @param data defines the data to store
  81549. * @param format defines the data format
  81550. * @param invertY defines if data must be stored with Y axis inverted
  81551. */
  81552. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81553. /**
  81554. * Update a raw 2D array texture
  81555. * @param texture defines the texture to update
  81556. * @param data defines the data to store
  81557. * @param format defines the data format
  81558. * @param invertY defines if data must be stored with Y axis inverted
  81559. * @param compression defines the used compression (can be null)
  81560. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81561. */
  81562. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81563. }
  81564. }
  81565. declare module BABYLON {
  81566. /**
  81567. * Raw texture can help creating a texture directly from an array of data.
  81568. * This can be super useful if you either get the data from an uncompressed source or
  81569. * if you wish to create your texture pixel by pixel.
  81570. */
  81571. export class RawTexture extends Texture {
  81572. /**
  81573. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81574. */
  81575. format: number;
  81576. private _engine;
  81577. /**
  81578. * Instantiates a new RawTexture.
  81579. * Raw texture can help creating a texture directly from an array of data.
  81580. * This can be super useful if you either get the data from an uncompressed source or
  81581. * if you wish to create your texture pixel by pixel.
  81582. * @param data define the array of data to use to create the texture
  81583. * @param width define the width of the texture
  81584. * @param height define the height of the texture
  81585. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81586. * @param scene define the scene the texture belongs to
  81587. * @param generateMipMaps define whether mip maps should be generated or not
  81588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81590. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81591. */
  81592. constructor(data: ArrayBufferView, width: number, height: number,
  81593. /**
  81594. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81595. */
  81596. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81597. /**
  81598. * Updates the texture underlying data.
  81599. * @param data Define the new data of the texture
  81600. */
  81601. update(data: ArrayBufferView): void;
  81602. /**
  81603. * Creates a luminance texture from some data.
  81604. * @param data Define the texture data
  81605. * @param width Define the width of the texture
  81606. * @param height Define the height of the texture
  81607. * @param scene Define the scene the texture belongs to
  81608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81611. * @returns the luminance texture
  81612. */
  81613. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81614. /**
  81615. * Creates a luminance alpha texture from some data.
  81616. * @param data Define the texture data
  81617. * @param width Define the width of the texture
  81618. * @param height Define the height of the texture
  81619. * @param scene Define the scene the texture belongs to
  81620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81623. * @returns the luminance alpha texture
  81624. */
  81625. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81626. /**
  81627. * Creates an alpha texture from some data.
  81628. * @param data Define the texture data
  81629. * @param width Define the width of the texture
  81630. * @param height Define the height of the texture
  81631. * @param scene Define the scene the texture belongs to
  81632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81635. * @returns the alpha texture
  81636. */
  81637. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81638. /**
  81639. * Creates a RGB texture from some data.
  81640. * @param data Define the texture data
  81641. * @param width Define the width of the texture
  81642. * @param height Define the height of the texture
  81643. * @param scene Define the scene the texture belongs to
  81644. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81645. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81646. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81647. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81648. * @returns the RGB alpha texture
  81649. */
  81650. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81651. /**
  81652. * Creates a RGBA texture from some data.
  81653. * @param data Define the texture data
  81654. * @param width Define the width of the texture
  81655. * @param height Define the height of the texture
  81656. * @param scene Define the scene the texture belongs to
  81657. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81658. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81659. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81660. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81661. * @returns the RGBA texture
  81662. */
  81663. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81664. /**
  81665. * Creates a R texture from some data.
  81666. * @param data Define the texture data
  81667. * @param width Define the width of the texture
  81668. * @param height Define the height of the texture
  81669. * @param scene Define the scene the texture belongs to
  81670. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81673. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81674. * @returns the R texture
  81675. */
  81676. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81677. }
  81678. }
  81679. declare module BABYLON {
  81680. /**
  81681. * Interface for the size containing width and height
  81682. */
  81683. export interface ISize {
  81684. /**
  81685. * Width
  81686. */
  81687. width: number;
  81688. /**
  81689. * Heighht
  81690. */
  81691. height: number;
  81692. }
  81693. /**
  81694. * Size containing widht and height
  81695. */
  81696. export class Size implements ISize {
  81697. /**
  81698. * Width
  81699. */
  81700. width: number;
  81701. /**
  81702. * Height
  81703. */
  81704. height: number;
  81705. /**
  81706. * Creates a Size object from the given width and height (floats).
  81707. * @param width width of the new size
  81708. * @param height height of the new size
  81709. */
  81710. constructor(width: number, height: number);
  81711. /**
  81712. * Returns a string with the Size width and height
  81713. * @returns a string with the Size width and height
  81714. */
  81715. toString(): string;
  81716. /**
  81717. * "Size"
  81718. * @returns the string "Size"
  81719. */
  81720. getClassName(): string;
  81721. /**
  81722. * Returns the Size hash code.
  81723. * @returns a hash code for a unique width and height
  81724. */
  81725. getHashCode(): number;
  81726. /**
  81727. * Updates the current size from the given one.
  81728. * @param src the given size
  81729. */
  81730. copyFrom(src: Size): void;
  81731. /**
  81732. * Updates in place the current Size from the given floats.
  81733. * @param width width of the new size
  81734. * @param height height of the new size
  81735. * @returns the updated Size.
  81736. */
  81737. copyFromFloats(width: number, height: number): Size;
  81738. /**
  81739. * Updates in place the current Size from the given floats.
  81740. * @param width width to set
  81741. * @param height height to set
  81742. * @returns the updated Size.
  81743. */
  81744. set(width: number, height: number): Size;
  81745. /**
  81746. * Multiplies the width and height by numbers
  81747. * @param w factor to multiple the width by
  81748. * @param h factor to multiple the height by
  81749. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81750. */
  81751. multiplyByFloats(w: number, h: number): Size;
  81752. /**
  81753. * Clones the size
  81754. * @returns a new Size copied from the given one.
  81755. */
  81756. clone(): Size;
  81757. /**
  81758. * True if the current Size and the given one width and height are strictly equal.
  81759. * @param other the other size to compare against
  81760. * @returns True if the current Size and the given one width and height are strictly equal.
  81761. */
  81762. equals(other: Size): boolean;
  81763. /**
  81764. * The surface of the Size : width * height (float).
  81765. */
  81766. readonly surface: number;
  81767. /**
  81768. * Create a new size of zero
  81769. * @returns a new Size set to (0.0, 0.0)
  81770. */
  81771. static Zero(): Size;
  81772. /**
  81773. * Sums the width and height of two sizes
  81774. * @param otherSize size to add to this size
  81775. * @returns a new Size set as the addition result of the current Size and the given one.
  81776. */
  81777. add(otherSize: Size): Size;
  81778. /**
  81779. * Subtracts the width and height of two
  81780. * @param otherSize size to subtract to this size
  81781. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81782. */
  81783. subtract(otherSize: Size): Size;
  81784. /**
  81785. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81786. * @param start starting size to lerp between
  81787. * @param end end size to lerp between
  81788. * @param amount amount to lerp between the start and end values
  81789. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81790. */
  81791. static Lerp(start: Size, end: Size, amount: number): Size;
  81792. }
  81793. }
  81794. declare module BABYLON {
  81795. /**
  81796. * Defines a runtime animation
  81797. */
  81798. export class RuntimeAnimation {
  81799. private _events;
  81800. /**
  81801. * The current frame of the runtime animation
  81802. */
  81803. private _currentFrame;
  81804. /**
  81805. * The animation used by the runtime animation
  81806. */
  81807. private _animation;
  81808. /**
  81809. * The target of the runtime animation
  81810. */
  81811. private _target;
  81812. /**
  81813. * The initiating animatable
  81814. */
  81815. private _host;
  81816. /**
  81817. * The original value of the runtime animation
  81818. */
  81819. private _originalValue;
  81820. /**
  81821. * The original blend value of the runtime animation
  81822. */
  81823. private _originalBlendValue;
  81824. /**
  81825. * The offsets cache of the runtime animation
  81826. */
  81827. private _offsetsCache;
  81828. /**
  81829. * The high limits cache of the runtime animation
  81830. */
  81831. private _highLimitsCache;
  81832. /**
  81833. * Specifies if the runtime animation has been stopped
  81834. */
  81835. private _stopped;
  81836. /**
  81837. * The blending factor of the runtime animation
  81838. */
  81839. private _blendingFactor;
  81840. /**
  81841. * The BabylonJS scene
  81842. */
  81843. private _scene;
  81844. /**
  81845. * The current value of the runtime animation
  81846. */
  81847. private _currentValue;
  81848. /** @hidden */
  81849. _animationState: _IAnimationState;
  81850. /**
  81851. * The active target of the runtime animation
  81852. */
  81853. private _activeTargets;
  81854. private _currentActiveTarget;
  81855. private _directTarget;
  81856. /**
  81857. * The target path of the runtime animation
  81858. */
  81859. private _targetPath;
  81860. /**
  81861. * The weight of the runtime animation
  81862. */
  81863. private _weight;
  81864. /**
  81865. * The ratio offset of the runtime animation
  81866. */
  81867. private _ratioOffset;
  81868. /**
  81869. * The previous delay of the runtime animation
  81870. */
  81871. private _previousDelay;
  81872. /**
  81873. * The previous ratio of the runtime animation
  81874. */
  81875. private _previousRatio;
  81876. private _enableBlending;
  81877. private _keys;
  81878. private _minFrame;
  81879. private _maxFrame;
  81880. private _minValue;
  81881. private _maxValue;
  81882. private _targetIsArray;
  81883. /**
  81884. * Gets the current frame of the runtime animation
  81885. */
  81886. readonly currentFrame: number;
  81887. /**
  81888. * Gets the weight of the runtime animation
  81889. */
  81890. readonly weight: number;
  81891. /**
  81892. * Gets the current value of the runtime animation
  81893. */
  81894. readonly currentValue: any;
  81895. /**
  81896. * Gets the target path of the runtime animation
  81897. */
  81898. readonly targetPath: string;
  81899. /**
  81900. * Gets the actual target of the runtime animation
  81901. */
  81902. readonly target: any;
  81903. /** @hidden */
  81904. _onLoop: () => void;
  81905. /**
  81906. * Create a new RuntimeAnimation object
  81907. * @param target defines the target of the animation
  81908. * @param animation defines the source animation object
  81909. * @param scene defines the hosting scene
  81910. * @param host defines the initiating Animatable
  81911. */
  81912. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81913. private _preparePath;
  81914. /**
  81915. * Gets the animation from the runtime animation
  81916. */
  81917. readonly animation: Animation;
  81918. /**
  81919. * Resets the runtime animation to the beginning
  81920. * @param restoreOriginal defines whether to restore the target property to the original value
  81921. */
  81922. reset(restoreOriginal?: boolean): void;
  81923. /**
  81924. * Specifies if the runtime animation is stopped
  81925. * @returns Boolean specifying if the runtime animation is stopped
  81926. */
  81927. isStopped(): boolean;
  81928. /**
  81929. * Disposes of the runtime animation
  81930. */
  81931. dispose(): void;
  81932. /**
  81933. * Apply the interpolated value to the target
  81934. * @param currentValue defines the value computed by the animation
  81935. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81936. */
  81937. setValue(currentValue: any, weight: number): void;
  81938. private _getOriginalValues;
  81939. private _setValue;
  81940. /**
  81941. * Gets the loop pmode of the runtime animation
  81942. * @returns Loop Mode
  81943. */
  81944. private _getCorrectLoopMode;
  81945. /**
  81946. * Move the current animation to a given frame
  81947. * @param frame defines the frame to move to
  81948. */
  81949. goToFrame(frame: number): void;
  81950. /**
  81951. * @hidden Internal use only
  81952. */
  81953. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81954. /**
  81955. * Execute the current animation
  81956. * @param delay defines the delay to add to the current frame
  81957. * @param from defines the lower bound of the animation range
  81958. * @param to defines the upper bound of the animation range
  81959. * @param loop defines if the current animation must loop
  81960. * @param speedRatio defines the current speed ratio
  81961. * @param weight defines the weight of the animation (default is -1 so no weight)
  81962. * @param onLoop optional callback called when animation loops
  81963. * @returns a boolean indicating if the animation is running
  81964. */
  81965. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81966. }
  81967. }
  81968. declare module BABYLON {
  81969. /**
  81970. * Class used to store an actual running animation
  81971. */
  81972. export class Animatable {
  81973. /** defines the target object */
  81974. target: any;
  81975. /** defines the starting frame number (default is 0) */
  81976. fromFrame: number;
  81977. /** defines the ending frame number (default is 100) */
  81978. toFrame: number;
  81979. /** defines if the animation must loop (default is false) */
  81980. loopAnimation: boolean;
  81981. /** defines a callback to call when animation ends if it is not looping */
  81982. onAnimationEnd?: (() => void) | null | undefined;
  81983. /** defines a callback to call when animation loops */
  81984. onAnimationLoop?: (() => void) | null | undefined;
  81985. private _localDelayOffset;
  81986. private _pausedDelay;
  81987. private _runtimeAnimations;
  81988. private _paused;
  81989. private _scene;
  81990. private _speedRatio;
  81991. private _weight;
  81992. private _syncRoot;
  81993. /**
  81994. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81995. * This will only apply for non looping animation (default is true)
  81996. */
  81997. disposeOnEnd: boolean;
  81998. /**
  81999. * Gets a boolean indicating if the animation has started
  82000. */
  82001. animationStarted: boolean;
  82002. /**
  82003. * Observer raised when the animation ends
  82004. */
  82005. onAnimationEndObservable: Observable<Animatable>;
  82006. /**
  82007. * Observer raised when the animation loops
  82008. */
  82009. onAnimationLoopObservable: Observable<Animatable>;
  82010. /**
  82011. * Gets the root Animatable used to synchronize and normalize animations
  82012. */
  82013. readonly syncRoot: Nullable<Animatable>;
  82014. /**
  82015. * Gets the current frame of the first RuntimeAnimation
  82016. * Used to synchronize Animatables
  82017. */
  82018. readonly masterFrame: number;
  82019. /**
  82020. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82021. */
  82022. weight: number;
  82023. /**
  82024. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82025. */
  82026. speedRatio: number;
  82027. /**
  82028. * Creates a new Animatable
  82029. * @param scene defines the hosting scene
  82030. * @param target defines the target object
  82031. * @param fromFrame defines the starting frame number (default is 0)
  82032. * @param toFrame defines the ending frame number (default is 100)
  82033. * @param loopAnimation defines if the animation must loop (default is false)
  82034. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82035. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82036. * @param animations defines a group of animation to add to the new Animatable
  82037. * @param onAnimationLoop defines a callback to call when animation loops
  82038. */
  82039. constructor(scene: Scene,
  82040. /** defines the target object */
  82041. target: any,
  82042. /** defines the starting frame number (default is 0) */
  82043. fromFrame?: number,
  82044. /** defines the ending frame number (default is 100) */
  82045. toFrame?: number,
  82046. /** defines if the animation must loop (default is false) */
  82047. loopAnimation?: boolean, speedRatio?: number,
  82048. /** defines a callback to call when animation ends if it is not looping */
  82049. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82050. /** defines a callback to call when animation loops */
  82051. onAnimationLoop?: (() => void) | null | undefined);
  82052. /**
  82053. * Synchronize and normalize current Animatable with a source Animatable
  82054. * This is useful when using animation weights and when animations are not of the same length
  82055. * @param root defines the root Animatable to synchronize with
  82056. * @returns the current Animatable
  82057. */
  82058. syncWith(root: Animatable): Animatable;
  82059. /**
  82060. * Gets the list of runtime animations
  82061. * @returns an array of RuntimeAnimation
  82062. */
  82063. getAnimations(): RuntimeAnimation[];
  82064. /**
  82065. * Adds more animations to the current animatable
  82066. * @param target defines the target of the animations
  82067. * @param animations defines the new animations to add
  82068. */
  82069. appendAnimations(target: any, animations: Animation[]): void;
  82070. /**
  82071. * Gets the source animation for a specific property
  82072. * @param property defines the propertyu to look for
  82073. * @returns null or the source animation for the given property
  82074. */
  82075. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82076. /**
  82077. * Gets the runtime animation for a specific property
  82078. * @param property defines the propertyu to look for
  82079. * @returns null or the runtime animation for the given property
  82080. */
  82081. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82082. /**
  82083. * Resets the animatable to its original state
  82084. */
  82085. reset(): void;
  82086. /**
  82087. * Allows the animatable to blend with current running animations
  82088. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82089. * @param blendingSpeed defines the blending speed to use
  82090. */
  82091. enableBlending(blendingSpeed: number): void;
  82092. /**
  82093. * Disable animation blending
  82094. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82095. */
  82096. disableBlending(): void;
  82097. /**
  82098. * Jump directly to a given frame
  82099. * @param frame defines the frame to jump to
  82100. */
  82101. goToFrame(frame: number): void;
  82102. /**
  82103. * Pause the animation
  82104. */
  82105. pause(): void;
  82106. /**
  82107. * Restart the animation
  82108. */
  82109. restart(): void;
  82110. private _raiseOnAnimationEnd;
  82111. /**
  82112. * Stop and delete the current animation
  82113. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82114. * @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)
  82115. */
  82116. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82117. /**
  82118. * Wait asynchronously for the animation to end
  82119. * @returns a promise which will be fullfilled when the animation ends
  82120. */
  82121. waitAsync(): Promise<Animatable>;
  82122. /** @hidden */
  82123. _animate(delay: number): boolean;
  82124. }
  82125. interface Scene {
  82126. /** @hidden */
  82127. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82128. /** @hidden */
  82129. _processLateAnimationBindingsForMatrices(holder: {
  82130. totalWeight: number;
  82131. animations: RuntimeAnimation[];
  82132. originalValue: Matrix;
  82133. }): any;
  82134. /** @hidden */
  82135. _processLateAnimationBindingsForQuaternions(holder: {
  82136. totalWeight: number;
  82137. animations: RuntimeAnimation[];
  82138. originalValue: Quaternion;
  82139. }, refQuaternion: Quaternion): Quaternion;
  82140. /** @hidden */
  82141. _processLateAnimationBindings(): void;
  82142. /**
  82143. * Will start the animation sequence of a given target
  82144. * @param target defines the target
  82145. * @param from defines from which frame should animation start
  82146. * @param to defines until which frame should animation run.
  82147. * @param weight defines the weight to apply to the animation (1.0 by default)
  82148. * @param loop defines if the animation loops
  82149. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82150. * @param onAnimationEnd defines the function to be executed when the animation ends
  82151. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82152. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82153. * @param onAnimationLoop defines the callback to call when an animation loops
  82154. * @returns the animatable object created for this animation
  82155. */
  82156. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82157. /**
  82158. * Will start the animation sequence of a given target
  82159. * @param target defines the target
  82160. * @param from defines from which frame should animation start
  82161. * @param to defines until which frame should animation run.
  82162. * @param loop defines if the animation loops
  82163. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82164. * @param onAnimationEnd defines the function to be executed when the animation ends
  82165. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82166. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82167. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82168. * @param onAnimationLoop defines the callback to call when an animation loops
  82169. * @returns the animatable object created for this animation
  82170. */
  82171. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82172. /**
  82173. * Will start the animation sequence of a given target and its hierarchy
  82174. * @param target defines the target
  82175. * @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.
  82176. * @param from defines from which frame should animation start
  82177. * @param to defines until which frame should animation run.
  82178. * @param loop defines if the animation loops
  82179. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82180. * @param onAnimationEnd defines the function to be executed when the animation ends
  82181. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82182. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82183. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82184. * @param onAnimationLoop defines the callback to call when an animation loops
  82185. * @returns the list of created animatables
  82186. */
  82187. 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[];
  82188. /**
  82189. * Begin a new animation on a given node
  82190. * @param target defines the target where the animation will take place
  82191. * @param animations defines the list of animations to start
  82192. * @param from defines the initial value
  82193. * @param to defines the final value
  82194. * @param loop defines if you want animation to loop (off by default)
  82195. * @param speedRatio defines the speed ratio to apply to all animations
  82196. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82197. * @param onAnimationLoop defines the callback to call when an animation loops
  82198. * @returns the list of created animatables
  82199. */
  82200. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82201. /**
  82202. * Begin a new animation on a given node and its hierarchy
  82203. * @param target defines the root node where the animation will take place
  82204. * @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.
  82205. * @param animations defines the list of animations to start
  82206. * @param from defines the initial value
  82207. * @param to defines the final value
  82208. * @param loop defines if you want animation to loop (off by default)
  82209. * @param speedRatio defines the speed ratio to apply to all animations
  82210. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82211. * @param onAnimationLoop defines the callback to call when an animation loops
  82212. * @returns the list of animatables created for all nodes
  82213. */
  82214. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82215. /**
  82216. * Gets the animatable associated with a specific target
  82217. * @param target defines the target of the animatable
  82218. * @returns the required animatable if found
  82219. */
  82220. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82221. /**
  82222. * Gets all animatables associated with a given target
  82223. * @param target defines the target to look animatables for
  82224. * @returns an array of Animatables
  82225. */
  82226. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82227. /**
  82228. * Stops and removes all animations that have been applied to the scene
  82229. */
  82230. stopAllAnimations(): void;
  82231. /**
  82232. * Gets the current delta time used by animation engine
  82233. */
  82234. deltaTime: number;
  82235. }
  82236. interface Bone {
  82237. /**
  82238. * Copy an animation range from another bone
  82239. * @param source defines the source bone
  82240. * @param rangeName defines the range name to copy
  82241. * @param frameOffset defines the frame offset
  82242. * @param rescaleAsRequired defines if rescaling must be applied if required
  82243. * @param skelDimensionsRatio defines the scaling ratio
  82244. * @returns true if operation was successful
  82245. */
  82246. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82247. }
  82248. }
  82249. declare module BABYLON {
  82250. /**
  82251. * Class used to override all child animations of a given target
  82252. */
  82253. export class AnimationPropertiesOverride {
  82254. /**
  82255. * Gets or sets a value indicating if animation blending must be used
  82256. */
  82257. enableBlending: boolean;
  82258. /**
  82259. * Gets or sets the blending speed to use when enableBlending is true
  82260. */
  82261. blendingSpeed: number;
  82262. /**
  82263. * Gets or sets the default loop mode to use
  82264. */
  82265. loopMode: number;
  82266. }
  82267. }
  82268. declare module BABYLON {
  82269. /**
  82270. * Class used to handle skinning animations
  82271. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82272. */
  82273. export class Skeleton implements IAnimatable {
  82274. /** defines the skeleton name */
  82275. name: string;
  82276. /** defines the skeleton Id */
  82277. id: string;
  82278. /**
  82279. * Defines the list of child bones
  82280. */
  82281. bones: Bone[];
  82282. /**
  82283. * Defines an estimate of the dimension of the skeleton at rest
  82284. */
  82285. dimensionsAtRest: Vector3;
  82286. /**
  82287. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82288. */
  82289. needInitialSkinMatrix: boolean;
  82290. /**
  82291. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82292. */
  82293. overrideMesh: Nullable<AbstractMesh>;
  82294. /**
  82295. * Gets the list of animations attached to this skeleton
  82296. */
  82297. animations: Array<Animation>;
  82298. private _scene;
  82299. private _isDirty;
  82300. private _transformMatrices;
  82301. private _transformMatrixTexture;
  82302. private _meshesWithPoseMatrix;
  82303. private _animatables;
  82304. private _identity;
  82305. private _synchronizedWithMesh;
  82306. private _ranges;
  82307. private _lastAbsoluteTransformsUpdateId;
  82308. private _canUseTextureForBones;
  82309. private _uniqueId;
  82310. /** @hidden */
  82311. _numBonesWithLinkedTransformNode: number;
  82312. /** @hidden */
  82313. _hasWaitingData: Nullable<boolean>;
  82314. /**
  82315. * Specifies if the skeleton should be serialized
  82316. */
  82317. doNotSerialize: boolean;
  82318. private _useTextureToStoreBoneMatrices;
  82319. /**
  82320. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82321. * Please note that this option is not available if the hardware does not support it
  82322. */
  82323. useTextureToStoreBoneMatrices: boolean;
  82324. private _animationPropertiesOverride;
  82325. /**
  82326. * Gets or sets the animation properties override
  82327. */
  82328. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82329. /**
  82330. * List of inspectable custom properties (used by the Inspector)
  82331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82332. */
  82333. inspectableCustomProperties: IInspectable[];
  82334. /**
  82335. * An observable triggered before computing the skeleton's matrices
  82336. */
  82337. onBeforeComputeObservable: Observable<Skeleton>;
  82338. /**
  82339. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82340. */
  82341. readonly isUsingTextureForMatrices: boolean;
  82342. /**
  82343. * Gets the unique ID of this skeleton
  82344. */
  82345. readonly uniqueId: number;
  82346. /**
  82347. * Creates a new skeleton
  82348. * @param name defines the skeleton name
  82349. * @param id defines the skeleton Id
  82350. * @param scene defines the hosting scene
  82351. */
  82352. constructor(
  82353. /** defines the skeleton name */
  82354. name: string,
  82355. /** defines the skeleton Id */
  82356. id: string, scene: Scene);
  82357. /**
  82358. * Gets the current object class name.
  82359. * @return the class name
  82360. */
  82361. getClassName(): string;
  82362. /**
  82363. * Returns an array containing the root bones
  82364. * @returns an array containing the root bones
  82365. */
  82366. getChildren(): Array<Bone>;
  82367. /**
  82368. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82369. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82370. * @returns a Float32Array containing matrices data
  82371. */
  82372. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82373. /**
  82374. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82375. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82376. * @returns a raw texture containing the data
  82377. */
  82378. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82379. /**
  82380. * Gets the current hosting scene
  82381. * @returns a scene object
  82382. */
  82383. getScene(): Scene;
  82384. /**
  82385. * Gets a string representing the current skeleton data
  82386. * @param fullDetails defines a boolean indicating if we want a verbose version
  82387. * @returns a string representing the current skeleton data
  82388. */
  82389. toString(fullDetails?: boolean): string;
  82390. /**
  82391. * Get bone's index searching by name
  82392. * @param name defines bone's name to search for
  82393. * @return the indice of the bone. Returns -1 if not found
  82394. */
  82395. getBoneIndexByName(name: string): number;
  82396. /**
  82397. * Creater a new animation range
  82398. * @param name defines the name of the range
  82399. * @param from defines the start key
  82400. * @param to defines the end key
  82401. */
  82402. createAnimationRange(name: string, from: number, to: number): void;
  82403. /**
  82404. * Delete a specific animation range
  82405. * @param name defines the name of the range
  82406. * @param deleteFrames defines if frames must be removed as well
  82407. */
  82408. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82409. /**
  82410. * Gets a specific animation range
  82411. * @param name defines the name of the range to look for
  82412. * @returns the requested animation range or null if not found
  82413. */
  82414. getAnimationRange(name: string): Nullable<AnimationRange>;
  82415. /**
  82416. * Gets the list of all animation ranges defined on this skeleton
  82417. * @returns an array
  82418. */
  82419. getAnimationRanges(): Nullable<AnimationRange>[];
  82420. /**
  82421. * Copy animation range from a source skeleton.
  82422. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82423. * @param source defines the source skeleton
  82424. * @param name defines the name of the range to copy
  82425. * @param rescaleAsRequired defines if rescaling must be applied if required
  82426. * @returns true if operation was successful
  82427. */
  82428. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82429. /**
  82430. * Forces the skeleton to go to rest pose
  82431. */
  82432. returnToRest(): void;
  82433. private _getHighestAnimationFrame;
  82434. /**
  82435. * Begin a specific animation range
  82436. * @param name defines the name of the range to start
  82437. * @param loop defines if looping must be turned on (false by default)
  82438. * @param speedRatio defines the speed ratio to apply (1 by default)
  82439. * @param onAnimationEnd defines a callback which will be called when animation will end
  82440. * @returns a new animatable
  82441. */
  82442. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82443. /** @hidden */
  82444. _markAsDirty(): void;
  82445. /** @hidden */
  82446. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82447. /** @hidden */
  82448. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82449. private _computeTransformMatrices;
  82450. /**
  82451. * Build all resources required to render a skeleton
  82452. */
  82453. prepare(): void;
  82454. /**
  82455. * Gets the list of animatables currently running for this skeleton
  82456. * @returns an array of animatables
  82457. */
  82458. getAnimatables(): IAnimatable[];
  82459. /**
  82460. * Clone the current skeleton
  82461. * @param name defines the name of the new skeleton
  82462. * @param id defines the id of the new skeleton
  82463. * @returns the new skeleton
  82464. */
  82465. clone(name: string, id?: string): Skeleton;
  82466. /**
  82467. * Enable animation blending for this skeleton
  82468. * @param blendingSpeed defines the blending speed to apply
  82469. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82470. */
  82471. enableBlending(blendingSpeed?: number): void;
  82472. /**
  82473. * Releases all resources associated with the current skeleton
  82474. */
  82475. dispose(): void;
  82476. /**
  82477. * Serialize the skeleton in a JSON object
  82478. * @returns a JSON object
  82479. */
  82480. serialize(): any;
  82481. /**
  82482. * Creates a new skeleton from serialized data
  82483. * @param parsedSkeleton defines the serialized data
  82484. * @param scene defines the hosting scene
  82485. * @returns a new skeleton
  82486. */
  82487. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82488. /**
  82489. * Compute all node absolute transforms
  82490. * @param forceUpdate defines if computation must be done even if cache is up to date
  82491. */
  82492. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82493. /**
  82494. * Gets the root pose matrix
  82495. * @returns a matrix
  82496. */
  82497. getPoseMatrix(): Nullable<Matrix>;
  82498. /**
  82499. * Sorts bones per internal index
  82500. */
  82501. sortBones(): void;
  82502. private _sortBones;
  82503. }
  82504. }
  82505. declare module BABYLON {
  82506. /**
  82507. * Class used to store bone information
  82508. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82509. */
  82510. export class Bone extends Node {
  82511. /**
  82512. * defines the bone name
  82513. */
  82514. name: string;
  82515. private static _tmpVecs;
  82516. private static _tmpQuat;
  82517. private static _tmpMats;
  82518. /**
  82519. * Gets the list of child bones
  82520. */
  82521. children: Bone[];
  82522. /** Gets the animations associated with this bone */
  82523. animations: Animation[];
  82524. /**
  82525. * Gets or sets bone length
  82526. */
  82527. length: number;
  82528. /**
  82529. * @hidden Internal only
  82530. * Set this value to map this bone to a different index in the transform matrices
  82531. * Set this value to -1 to exclude the bone from the transform matrices
  82532. */
  82533. _index: Nullable<number>;
  82534. private _skeleton;
  82535. private _localMatrix;
  82536. private _restPose;
  82537. private _baseMatrix;
  82538. private _absoluteTransform;
  82539. private _invertedAbsoluteTransform;
  82540. private _parent;
  82541. private _scalingDeterminant;
  82542. private _worldTransform;
  82543. private _localScaling;
  82544. private _localRotation;
  82545. private _localPosition;
  82546. private _needToDecompose;
  82547. private _needToCompose;
  82548. /** @hidden */
  82549. _linkedTransformNode: Nullable<TransformNode>;
  82550. /** @hidden */
  82551. _waitingTransformNodeId: Nullable<string>;
  82552. /** @hidden */
  82553. /** @hidden */
  82554. _matrix: Matrix;
  82555. /**
  82556. * Create a new bone
  82557. * @param name defines the bone name
  82558. * @param skeleton defines the parent skeleton
  82559. * @param parentBone defines the parent (can be null if the bone is the root)
  82560. * @param localMatrix defines the local matrix
  82561. * @param restPose defines the rest pose matrix
  82562. * @param baseMatrix defines the base matrix
  82563. * @param index defines index of the bone in the hiearchy
  82564. */
  82565. constructor(
  82566. /**
  82567. * defines the bone name
  82568. */
  82569. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82570. /**
  82571. * Gets the current object class name.
  82572. * @return the class name
  82573. */
  82574. getClassName(): string;
  82575. /**
  82576. * Gets the parent skeleton
  82577. * @returns a skeleton
  82578. */
  82579. getSkeleton(): Skeleton;
  82580. /**
  82581. * Gets parent bone
  82582. * @returns a bone or null if the bone is the root of the bone hierarchy
  82583. */
  82584. getParent(): Nullable<Bone>;
  82585. /**
  82586. * Returns an array containing the root bones
  82587. * @returns an array containing the root bones
  82588. */
  82589. getChildren(): Array<Bone>;
  82590. /**
  82591. * Gets the node index in matrix array generated for rendering
  82592. * @returns the node index
  82593. */
  82594. getIndex(): number;
  82595. /**
  82596. * Sets the parent bone
  82597. * @param parent defines the parent (can be null if the bone is the root)
  82598. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82599. */
  82600. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82601. /**
  82602. * Gets the local matrix
  82603. * @returns a matrix
  82604. */
  82605. getLocalMatrix(): Matrix;
  82606. /**
  82607. * Gets the base matrix (initial matrix which remains unchanged)
  82608. * @returns a matrix
  82609. */
  82610. getBaseMatrix(): Matrix;
  82611. /**
  82612. * Gets the rest pose matrix
  82613. * @returns a matrix
  82614. */
  82615. getRestPose(): Matrix;
  82616. /**
  82617. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82618. */
  82619. getWorldMatrix(): Matrix;
  82620. /**
  82621. * Sets the local matrix to rest pose matrix
  82622. */
  82623. returnToRest(): void;
  82624. /**
  82625. * Gets the inverse of the absolute transform matrix.
  82626. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82627. * @returns a matrix
  82628. */
  82629. getInvertedAbsoluteTransform(): Matrix;
  82630. /**
  82631. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82632. * @returns a matrix
  82633. */
  82634. getAbsoluteTransform(): Matrix;
  82635. /**
  82636. * Links with the given transform node.
  82637. * The local matrix of this bone is copied from the transform node every frame.
  82638. * @param transformNode defines the transform node to link to
  82639. */
  82640. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82641. /**
  82642. * Gets the node used to drive the bone's transformation
  82643. * @returns a transform node or null
  82644. */
  82645. getTransformNode(): Nullable<TransformNode>;
  82646. /** Gets or sets current position (in local space) */
  82647. position: Vector3;
  82648. /** Gets or sets current rotation (in local space) */
  82649. rotation: Vector3;
  82650. /** Gets or sets current rotation quaternion (in local space) */
  82651. rotationQuaternion: Quaternion;
  82652. /** Gets or sets current scaling (in local space) */
  82653. scaling: Vector3;
  82654. /**
  82655. * Gets the animation properties override
  82656. */
  82657. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82658. private _decompose;
  82659. private _compose;
  82660. /**
  82661. * Update the base and local matrices
  82662. * @param matrix defines the new base or local matrix
  82663. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82664. * @param updateLocalMatrix defines if the local matrix should be updated
  82665. */
  82666. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82667. /** @hidden */
  82668. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82669. /**
  82670. * Flag the bone as dirty (Forcing it to update everything)
  82671. */
  82672. markAsDirty(): void;
  82673. /** @hidden */
  82674. _markAsDirtyAndCompose(): void;
  82675. private _markAsDirtyAndDecompose;
  82676. /**
  82677. * Translate the bone in local or world space
  82678. * @param vec The amount to translate the bone
  82679. * @param space The space that the translation is in
  82680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82681. */
  82682. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82683. /**
  82684. * Set the postion of the bone in local or world space
  82685. * @param position The position to set the bone
  82686. * @param space The space that the position is in
  82687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82688. */
  82689. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82690. /**
  82691. * Set the absolute position of the bone (world space)
  82692. * @param position The position to set the bone
  82693. * @param mesh The mesh that this bone is attached to
  82694. */
  82695. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82696. /**
  82697. * Scale the bone on the x, y and z axes (in local space)
  82698. * @param x The amount to scale the bone on the x axis
  82699. * @param y The amount to scale the bone on the y axis
  82700. * @param z The amount to scale the bone on the z axis
  82701. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82702. */
  82703. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82704. /**
  82705. * Set the bone scaling in local space
  82706. * @param scale defines the scaling vector
  82707. */
  82708. setScale(scale: Vector3): void;
  82709. /**
  82710. * Gets the current scaling in local space
  82711. * @returns the current scaling vector
  82712. */
  82713. getScale(): Vector3;
  82714. /**
  82715. * Gets the current scaling in local space and stores it in a target vector
  82716. * @param result defines the target vector
  82717. */
  82718. getScaleToRef(result: Vector3): void;
  82719. /**
  82720. * Set the yaw, pitch, and roll of the bone in local or world space
  82721. * @param yaw The rotation of the bone on the y axis
  82722. * @param pitch The rotation of the bone on the x axis
  82723. * @param roll The rotation of the bone on the z axis
  82724. * @param space The space that the axes of rotation are in
  82725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82726. */
  82727. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82728. /**
  82729. * Add a rotation to the bone on an axis in local or world space
  82730. * @param axis The axis to rotate the bone on
  82731. * @param amount The amount to rotate the bone
  82732. * @param space The space that the axis is in
  82733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82734. */
  82735. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82736. /**
  82737. * Set the rotation of the bone to a particular axis angle in local or world space
  82738. * @param axis The axis to rotate the bone on
  82739. * @param angle The angle that the bone should be rotated to
  82740. * @param space The space that the axis is in
  82741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82742. */
  82743. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82744. /**
  82745. * Set the euler rotation of the bone in local of world space
  82746. * @param rotation The euler rotation that the bone should be set to
  82747. * @param space The space that the rotation is in
  82748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82749. */
  82750. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82751. /**
  82752. * Set the quaternion rotation of the bone in local of world space
  82753. * @param quat The quaternion rotation that the bone should be set to
  82754. * @param space The space that the rotation is in
  82755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82756. */
  82757. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82758. /**
  82759. * Set the rotation matrix of the bone in local of world space
  82760. * @param rotMat The rotation matrix that the bone should be set to
  82761. * @param space The space that the rotation is in
  82762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82763. */
  82764. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82765. private _rotateWithMatrix;
  82766. private _getNegativeRotationToRef;
  82767. /**
  82768. * Get the position of the bone in local or world space
  82769. * @param space The space that the returned position is in
  82770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82771. * @returns The position of the bone
  82772. */
  82773. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82774. /**
  82775. * Copy the position of the bone to a vector3 in local or world space
  82776. * @param space The space that the returned position is in
  82777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82778. * @param result The vector3 to copy the position to
  82779. */
  82780. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82781. /**
  82782. * Get the absolute position of the bone (world space)
  82783. * @param mesh The mesh that this bone is attached to
  82784. * @returns The absolute position of the bone
  82785. */
  82786. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82787. /**
  82788. * Copy the absolute position of the bone (world space) to the result param
  82789. * @param mesh The mesh that this bone is attached to
  82790. * @param result The vector3 to copy the absolute position to
  82791. */
  82792. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82793. /**
  82794. * Compute the absolute transforms of this bone and its children
  82795. */
  82796. computeAbsoluteTransforms(): void;
  82797. /**
  82798. * Get the world direction from an axis that is in the local space of the bone
  82799. * @param localAxis The local direction that is used to compute the world direction
  82800. * @param mesh The mesh that this bone is attached to
  82801. * @returns The world direction
  82802. */
  82803. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82804. /**
  82805. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82806. * @param localAxis The local direction that is used to compute the world direction
  82807. * @param mesh The mesh that this bone is attached to
  82808. * @param result The vector3 that the world direction will be copied to
  82809. */
  82810. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82811. /**
  82812. * Get the euler rotation of the bone in local or world space
  82813. * @param space The space that the rotation should be in
  82814. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82815. * @returns The euler rotation
  82816. */
  82817. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82818. /**
  82819. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82820. * @param space The space that the rotation should be in
  82821. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82822. * @param result The vector3 that the rotation should be copied to
  82823. */
  82824. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82825. /**
  82826. * Get the quaternion rotation of the bone in either local or world space
  82827. * @param space The space that the rotation should be in
  82828. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82829. * @returns The quaternion rotation
  82830. */
  82831. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82832. /**
  82833. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82834. * @param space The space that the rotation should be in
  82835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82836. * @param result The quaternion that the rotation should be copied to
  82837. */
  82838. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82839. /**
  82840. * Get the rotation matrix of the bone in local or world space
  82841. * @param space The space that the rotation should be in
  82842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82843. * @returns The rotation matrix
  82844. */
  82845. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82846. /**
  82847. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82848. * @param space The space that the rotation should be in
  82849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82850. * @param result The quaternion that the rotation should be copied to
  82851. */
  82852. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82853. /**
  82854. * Get the world position of a point that is in the local space of the bone
  82855. * @param position The local position
  82856. * @param mesh The mesh that this bone is attached to
  82857. * @returns The world position
  82858. */
  82859. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82860. /**
  82861. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82862. * @param position The local position
  82863. * @param mesh The mesh that this bone is attached to
  82864. * @param result The vector3 that the world position should be copied to
  82865. */
  82866. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82867. /**
  82868. * Get the local position of a point that is in world space
  82869. * @param position The world position
  82870. * @param mesh The mesh that this bone is attached to
  82871. * @returns The local position
  82872. */
  82873. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82874. /**
  82875. * Get the local position of a point that is in world space and copy it to the result param
  82876. * @param position The world position
  82877. * @param mesh The mesh that this bone is attached to
  82878. * @param result The vector3 that the local position should be copied to
  82879. */
  82880. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82881. }
  82882. }
  82883. declare module BABYLON {
  82884. /**
  82885. * 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.
  82886. * @see https://doc.babylonjs.com/how_to/transformnode
  82887. */
  82888. export class TransformNode extends Node {
  82889. /**
  82890. * Object will not rotate to face the camera
  82891. */
  82892. static BILLBOARDMODE_NONE: number;
  82893. /**
  82894. * Object will rotate to face the camera but only on the x axis
  82895. */
  82896. static BILLBOARDMODE_X: number;
  82897. /**
  82898. * Object will rotate to face the camera but only on the y axis
  82899. */
  82900. static BILLBOARDMODE_Y: number;
  82901. /**
  82902. * Object will rotate to face the camera but only on the z axis
  82903. */
  82904. static BILLBOARDMODE_Z: number;
  82905. /**
  82906. * Object will rotate to face the camera
  82907. */
  82908. static BILLBOARDMODE_ALL: number;
  82909. /**
  82910. * Object will rotate to face the camera's position instead of orientation
  82911. */
  82912. static BILLBOARDMODE_USE_POSITION: number;
  82913. private _forward;
  82914. private _forwardInverted;
  82915. private _up;
  82916. private _right;
  82917. private _rightInverted;
  82918. private _position;
  82919. private _rotation;
  82920. private _rotationQuaternion;
  82921. protected _scaling: Vector3;
  82922. protected _isDirty: boolean;
  82923. private _transformToBoneReferal;
  82924. private _isAbsoluteSynced;
  82925. private _billboardMode;
  82926. /**
  82927. * Gets or sets the billboard mode. Default is 0.
  82928. *
  82929. * | Value | Type | Description |
  82930. * | --- | --- | --- |
  82931. * | 0 | BILLBOARDMODE_NONE | |
  82932. * | 1 | BILLBOARDMODE_X | |
  82933. * | 2 | BILLBOARDMODE_Y | |
  82934. * | 4 | BILLBOARDMODE_Z | |
  82935. * | 7 | BILLBOARDMODE_ALL | |
  82936. *
  82937. */
  82938. billboardMode: number;
  82939. private _preserveParentRotationForBillboard;
  82940. /**
  82941. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82942. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82943. */
  82944. preserveParentRotationForBillboard: boolean;
  82945. /**
  82946. * 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
  82947. */
  82948. scalingDeterminant: number;
  82949. private _infiniteDistance;
  82950. /**
  82951. * Gets or sets the distance of the object to max, often used by skybox
  82952. */
  82953. infiniteDistance: boolean;
  82954. /**
  82955. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82956. * By default the system will update normals to compensate
  82957. */
  82958. ignoreNonUniformScaling: boolean;
  82959. /**
  82960. * 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
  82961. */
  82962. reIntegrateRotationIntoRotationQuaternion: boolean;
  82963. /** @hidden */
  82964. _poseMatrix: Nullable<Matrix>;
  82965. /** @hidden */
  82966. _localMatrix: Matrix;
  82967. private _usePivotMatrix;
  82968. private _absolutePosition;
  82969. private _absoluteScaling;
  82970. private _absoluteRotationQuaternion;
  82971. private _pivotMatrix;
  82972. private _pivotMatrixInverse;
  82973. protected _postMultiplyPivotMatrix: boolean;
  82974. protected _isWorldMatrixFrozen: boolean;
  82975. /** @hidden */
  82976. _indexInSceneTransformNodesArray: number;
  82977. /**
  82978. * An event triggered after the world matrix is updated
  82979. */
  82980. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82981. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82982. /**
  82983. * Gets a string identifying the name of the class
  82984. * @returns "TransformNode" string
  82985. */
  82986. getClassName(): string;
  82987. /**
  82988. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82989. */
  82990. position: Vector3;
  82991. /**
  82992. * 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)).
  82993. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82994. */
  82995. rotation: Vector3;
  82996. /**
  82997. * 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)).
  82998. */
  82999. scaling: Vector3;
  83000. /**
  83001. * 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).
  83002. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  83003. */
  83004. rotationQuaternion: Nullable<Quaternion>;
  83005. /**
  83006. * The forward direction of that transform in world space.
  83007. */
  83008. readonly forward: Vector3;
  83009. /**
  83010. * The up direction of that transform in world space.
  83011. */
  83012. readonly up: Vector3;
  83013. /**
  83014. * The right direction of that transform in world space.
  83015. */
  83016. readonly right: Vector3;
  83017. /**
  83018. * Copies the parameter passed Matrix into the mesh Pose matrix.
  83019. * @param matrix the matrix to copy the pose from
  83020. * @returns this TransformNode.
  83021. */
  83022. updatePoseMatrix(matrix: Matrix): TransformNode;
  83023. /**
  83024. * Returns the mesh Pose matrix.
  83025. * @returns the pose matrix
  83026. */
  83027. getPoseMatrix(): Matrix;
  83028. /** @hidden */
  83029. _isSynchronized(): boolean;
  83030. /** @hidden */
  83031. _initCache(): void;
  83032. /**
  83033. * Flag the transform node as dirty (Forcing it to update everything)
  83034. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83035. * @returns this transform node
  83036. */
  83037. markAsDirty(property: string): TransformNode;
  83038. /**
  83039. * Returns the current mesh absolute position.
  83040. * Returns a Vector3.
  83041. */
  83042. readonly absolutePosition: Vector3;
  83043. /**
  83044. * Returns the current mesh absolute scaling.
  83045. * Returns a Vector3.
  83046. */
  83047. readonly absoluteScaling: Vector3;
  83048. /**
  83049. * Returns the current mesh absolute rotation.
  83050. * Returns a Quaternion.
  83051. */
  83052. readonly absoluteRotationQuaternion: Quaternion;
  83053. /**
  83054. * Sets a new matrix to apply before all other transformation
  83055. * @param matrix defines the transform matrix
  83056. * @returns the current TransformNode
  83057. */
  83058. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83059. /**
  83060. * Sets a new pivot matrix to the current node
  83061. * @param matrix defines the new pivot matrix to use
  83062. * @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
  83063. * @returns the current TransformNode
  83064. */
  83065. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83066. /**
  83067. * Returns the mesh pivot matrix.
  83068. * Default : Identity.
  83069. * @returns the matrix
  83070. */
  83071. getPivotMatrix(): Matrix;
  83072. /**
  83073. * Instantiate (when possible) or clone that node with its hierarchy
  83074. * @param newParent defines the new parent to use for the instance (or clone)
  83075. * @param options defines options to configure how copy is done
  83076. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83077. * @returns an instance (or a clone) of the current node with its hiearchy
  83078. */
  83079. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83080. doNotInstantiate: boolean;
  83081. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83082. /**
  83083. * Prevents the World matrix to be computed any longer
  83084. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83085. * @returns the TransformNode.
  83086. */
  83087. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83088. /**
  83089. * Allows back the World matrix computation.
  83090. * @returns the TransformNode.
  83091. */
  83092. unfreezeWorldMatrix(): this;
  83093. /**
  83094. * True if the World matrix has been frozen.
  83095. */
  83096. readonly isWorldMatrixFrozen: boolean;
  83097. /**
  83098. * Retuns the mesh absolute position in the World.
  83099. * @returns a Vector3.
  83100. */
  83101. getAbsolutePosition(): Vector3;
  83102. /**
  83103. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83104. * @param absolutePosition the absolute position to set
  83105. * @returns the TransformNode.
  83106. */
  83107. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83108. /**
  83109. * Sets the mesh position in its local space.
  83110. * @param vector3 the position to set in localspace
  83111. * @returns the TransformNode.
  83112. */
  83113. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83114. /**
  83115. * Returns the mesh position in the local space from the current World matrix values.
  83116. * @returns a new Vector3.
  83117. */
  83118. getPositionExpressedInLocalSpace(): Vector3;
  83119. /**
  83120. * Translates the mesh along the passed Vector3 in its local space.
  83121. * @param vector3 the distance to translate in localspace
  83122. * @returns the TransformNode.
  83123. */
  83124. locallyTranslate(vector3: Vector3): TransformNode;
  83125. private static _lookAtVectorCache;
  83126. /**
  83127. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83128. * @param targetPoint the position (must be in same space as current mesh) to look at
  83129. * @param yawCor optional yaw (y-axis) correction in radians
  83130. * @param pitchCor optional pitch (x-axis) correction in radians
  83131. * @param rollCor optional roll (z-axis) correction in radians
  83132. * @param space the choosen space of the target
  83133. * @returns the TransformNode.
  83134. */
  83135. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83136. /**
  83137. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83138. * This Vector3 is expressed in the World space.
  83139. * @param localAxis axis to rotate
  83140. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83141. */
  83142. getDirection(localAxis: Vector3): Vector3;
  83143. /**
  83144. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83145. * localAxis is expressed in the mesh local space.
  83146. * result is computed in the Wordl space from the mesh World matrix.
  83147. * @param localAxis axis to rotate
  83148. * @param result the resulting transformnode
  83149. * @returns this TransformNode.
  83150. */
  83151. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83152. /**
  83153. * Sets this transform node rotation to the given local axis.
  83154. * @param localAxis the axis in local space
  83155. * @param yawCor optional yaw (y-axis) correction in radians
  83156. * @param pitchCor optional pitch (x-axis) correction in radians
  83157. * @param rollCor optional roll (z-axis) correction in radians
  83158. * @returns this TransformNode
  83159. */
  83160. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83161. /**
  83162. * Sets a new pivot point to the current node
  83163. * @param point defines the new pivot point to use
  83164. * @param space defines if the point is in world or local space (local by default)
  83165. * @returns the current TransformNode
  83166. */
  83167. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83168. /**
  83169. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83170. * @returns the pivot point
  83171. */
  83172. getPivotPoint(): Vector3;
  83173. /**
  83174. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83175. * @param result the vector3 to store the result
  83176. * @returns this TransformNode.
  83177. */
  83178. getPivotPointToRef(result: Vector3): TransformNode;
  83179. /**
  83180. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83181. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83182. */
  83183. getAbsolutePivotPoint(): Vector3;
  83184. /**
  83185. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83186. * @param result vector3 to store the result
  83187. * @returns this TransformNode.
  83188. */
  83189. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83190. /**
  83191. * Defines the passed node as the parent of the current node.
  83192. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83193. * @see https://doc.babylonjs.com/how_to/parenting
  83194. * @param node the node ot set as the parent
  83195. * @returns this TransformNode.
  83196. */
  83197. setParent(node: Nullable<Node>): TransformNode;
  83198. private _nonUniformScaling;
  83199. /**
  83200. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83201. */
  83202. readonly nonUniformScaling: boolean;
  83203. /** @hidden */
  83204. _updateNonUniformScalingState(value: boolean): boolean;
  83205. /**
  83206. * Attach the current TransformNode to another TransformNode associated with a bone
  83207. * @param bone Bone affecting the TransformNode
  83208. * @param affectedTransformNode TransformNode associated with the bone
  83209. * @returns this object
  83210. */
  83211. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83212. /**
  83213. * Detach the transform node if its associated with a bone
  83214. * @returns this object
  83215. */
  83216. detachFromBone(): TransformNode;
  83217. private static _rotationAxisCache;
  83218. /**
  83219. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83220. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83221. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83222. * The passed axis is also normalized.
  83223. * @param axis the axis to rotate around
  83224. * @param amount the amount to rotate in radians
  83225. * @param space Space to rotate in (Default: local)
  83226. * @returns the TransformNode.
  83227. */
  83228. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83229. /**
  83230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83231. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83232. * The passed axis is also normalized. .
  83233. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83234. * @param point the point to rotate around
  83235. * @param axis the axis to rotate around
  83236. * @param amount the amount to rotate in radians
  83237. * @returns the TransformNode
  83238. */
  83239. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83240. /**
  83241. * Translates the mesh along the axis vector for the passed distance in the given space.
  83242. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83243. * @param axis the axis to translate in
  83244. * @param distance the distance to translate
  83245. * @param space Space to rotate in (Default: local)
  83246. * @returns the TransformNode.
  83247. */
  83248. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83249. /**
  83250. * Adds a rotation step to the mesh current rotation.
  83251. * x, y, z are Euler angles expressed in radians.
  83252. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83253. * This means this rotation is made in the mesh local space only.
  83254. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83255. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83256. * ```javascript
  83257. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83258. * ```
  83259. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83260. * 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.
  83261. * @param x Rotation to add
  83262. * @param y Rotation to add
  83263. * @param z Rotation to add
  83264. * @returns the TransformNode.
  83265. */
  83266. addRotation(x: number, y: number, z: number): TransformNode;
  83267. /**
  83268. * @hidden
  83269. */
  83270. protected _getEffectiveParent(): Nullable<Node>;
  83271. /**
  83272. * Computes the world matrix of the node
  83273. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83274. * @returns the world matrix
  83275. */
  83276. computeWorldMatrix(force?: boolean): Matrix;
  83277. protected _afterComputeWorldMatrix(): void;
  83278. /**
  83279. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83280. * @param func callback function to add
  83281. *
  83282. * @returns the TransformNode.
  83283. */
  83284. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83285. /**
  83286. * Removes a registered callback function.
  83287. * @param func callback function to remove
  83288. * @returns the TransformNode.
  83289. */
  83290. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83291. /**
  83292. * Gets the position of the current mesh in camera space
  83293. * @param camera defines the camera to use
  83294. * @returns a position
  83295. */
  83296. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83297. /**
  83298. * Returns the distance from the mesh to the active camera
  83299. * @param camera defines the camera to use
  83300. * @returns the distance
  83301. */
  83302. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83303. /**
  83304. * Clone the current transform node
  83305. * @param name Name of the new clone
  83306. * @param newParent New parent for the clone
  83307. * @param doNotCloneChildren Do not clone children hierarchy
  83308. * @returns the new transform node
  83309. */
  83310. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83311. /**
  83312. * Serializes the objects information.
  83313. * @param currentSerializationObject defines the object to serialize in
  83314. * @returns the serialized object
  83315. */
  83316. serialize(currentSerializationObject?: any): any;
  83317. /**
  83318. * Returns a new TransformNode object parsed from the source provided.
  83319. * @param parsedTransformNode is the source.
  83320. * @param scene the scne the object belongs to
  83321. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83322. * @returns a new TransformNode object parsed from the source provided.
  83323. */
  83324. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83325. /**
  83326. * Get all child-transformNodes of this node
  83327. * @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
  83328. * @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
  83329. * @returns an array of TransformNode
  83330. */
  83331. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83332. /**
  83333. * Releases resources associated with this transform node.
  83334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83336. */
  83337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83338. /**
  83339. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83340. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83341. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83342. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83343. * @returns the current mesh
  83344. */
  83345. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83346. private _syncAbsoluteScalingAndRotation;
  83347. }
  83348. }
  83349. declare module BABYLON {
  83350. /**
  83351. * Defines the types of pose enabled controllers that are supported
  83352. */
  83353. export enum PoseEnabledControllerType {
  83354. /**
  83355. * HTC Vive
  83356. */
  83357. VIVE = 0,
  83358. /**
  83359. * Oculus Rift
  83360. */
  83361. OCULUS = 1,
  83362. /**
  83363. * Windows mixed reality
  83364. */
  83365. WINDOWS = 2,
  83366. /**
  83367. * Samsung gear VR
  83368. */
  83369. GEAR_VR = 3,
  83370. /**
  83371. * Google Daydream
  83372. */
  83373. DAYDREAM = 4,
  83374. /**
  83375. * Generic
  83376. */
  83377. GENERIC = 5
  83378. }
  83379. /**
  83380. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83381. */
  83382. export interface MutableGamepadButton {
  83383. /**
  83384. * Value of the button/trigger
  83385. */
  83386. value: number;
  83387. /**
  83388. * If the button/trigger is currently touched
  83389. */
  83390. touched: boolean;
  83391. /**
  83392. * If the button/trigger is currently pressed
  83393. */
  83394. pressed: boolean;
  83395. }
  83396. /**
  83397. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83398. * @hidden
  83399. */
  83400. export interface ExtendedGamepadButton extends GamepadButton {
  83401. /**
  83402. * If the button/trigger is currently pressed
  83403. */
  83404. readonly pressed: boolean;
  83405. /**
  83406. * If the button/trigger is currently touched
  83407. */
  83408. readonly touched: boolean;
  83409. /**
  83410. * Value of the button/trigger
  83411. */
  83412. readonly value: number;
  83413. }
  83414. /** @hidden */
  83415. export interface _GamePadFactory {
  83416. /**
  83417. * Returns wether or not the current gamepad can be created for this type of controller.
  83418. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83419. * @returns true if it can be created, otherwise false
  83420. */
  83421. canCreate(gamepadInfo: any): boolean;
  83422. /**
  83423. * Creates a new instance of the Gamepad.
  83424. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83425. * @returns the new gamepad instance
  83426. */
  83427. create(gamepadInfo: any): Gamepad;
  83428. }
  83429. /**
  83430. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83431. */
  83432. export class PoseEnabledControllerHelper {
  83433. /** @hidden */
  83434. static _ControllerFactories: _GamePadFactory[];
  83435. /** @hidden */
  83436. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83437. /**
  83438. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83439. * @param vrGamepad the gamepad to initialized
  83440. * @returns a vr controller of the type the gamepad identified as
  83441. */
  83442. static InitiateController(vrGamepad: any): Gamepad;
  83443. }
  83444. /**
  83445. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83446. */
  83447. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83448. /**
  83449. * If the controller is used in a webXR session
  83450. */
  83451. isXR: boolean;
  83452. private _deviceRoomPosition;
  83453. private _deviceRoomRotationQuaternion;
  83454. /**
  83455. * The device position in babylon space
  83456. */
  83457. devicePosition: Vector3;
  83458. /**
  83459. * The device rotation in babylon space
  83460. */
  83461. deviceRotationQuaternion: Quaternion;
  83462. /**
  83463. * The scale factor of the device in babylon space
  83464. */
  83465. deviceScaleFactor: number;
  83466. /**
  83467. * (Likely devicePosition should be used instead) The device position in its room space
  83468. */
  83469. position: Vector3;
  83470. /**
  83471. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83472. */
  83473. rotationQuaternion: Quaternion;
  83474. /**
  83475. * The type of controller (Eg. Windows mixed reality)
  83476. */
  83477. controllerType: PoseEnabledControllerType;
  83478. protected _calculatedPosition: Vector3;
  83479. private _calculatedRotation;
  83480. /**
  83481. * The raw pose from the device
  83482. */
  83483. rawPose: DevicePose;
  83484. private _trackPosition;
  83485. private _maxRotationDistFromHeadset;
  83486. private _draggedRoomRotation;
  83487. /**
  83488. * @hidden
  83489. */
  83490. _disableTrackPosition(fixedPosition: Vector3): void;
  83491. /**
  83492. * Internal, the mesh attached to the controller
  83493. * @hidden
  83494. */
  83495. _mesh: Nullable<AbstractMesh>;
  83496. private _poseControlledCamera;
  83497. private _leftHandSystemQuaternion;
  83498. /**
  83499. * Internal, matrix used to convert room space to babylon space
  83500. * @hidden
  83501. */
  83502. _deviceToWorld: Matrix;
  83503. /**
  83504. * Node to be used when casting a ray from the controller
  83505. * @hidden
  83506. */
  83507. _pointingPoseNode: Nullable<TransformNode>;
  83508. /**
  83509. * Name of the child mesh that can be used to cast a ray from the controller
  83510. */
  83511. static readonly POINTING_POSE: string;
  83512. /**
  83513. * Creates a new PoseEnabledController from a gamepad
  83514. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83515. */
  83516. constructor(browserGamepad: any);
  83517. private _workingMatrix;
  83518. /**
  83519. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83520. */
  83521. update(): void;
  83522. /**
  83523. * Updates only the pose device and mesh without doing any button event checking
  83524. */
  83525. protected _updatePoseAndMesh(): void;
  83526. /**
  83527. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83528. * @param poseData raw pose fromthe device
  83529. */
  83530. updateFromDevice(poseData: DevicePose): void;
  83531. /**
  83532. * @hidden
  83533. */
  83534. _meshAttachedObservable: Observable<AbstractMesh>;
  83535. /**
  83536. * Attaches a mesh to the controller
  83537. * @param mesh the mesh to be attached
  83538. */
  83539. attachToMesh(mesh: AbstractMesh): void;
  83540. /**
  83541. * Attaches the controllers mesh to a camera
  83542. * @param camera the camera the mesh should be attached to
  83543. */
  83544. attachToPoseControlledCamera(camera: TargetCamera): void;
  83545. /**
  83546. * Disposes of the controller
  83547. */
  83548. dispose(): void;
  83549. /**
  83550. * The mesh that is attached to the controller
  83551. */
  83552. readonly mesh: Nullable<AbstractMesh>;
  83553. /**
  83554. * Gets the ray of the controller in the direction the controller is pointing
  83555. * @param length the length the resulting ray should be
  83556. * @returns a ray in the direction the controller is pointing
  83557. */
  83558. getForwardRay(length?: number): Ray;
  83559. }
  83560. }
  83561. declare module BABYLON {
  83562. /**
  83563. * Defines the WebVRController object that represents controllers tracked in 3D space
  83564. */
  83565. export abstract class WebVRController extends PoseEnabledController {
  83566. /**
  83567. * Internal, the default controller model for the controller
  83568. */
  83569. protected _defaultModel: Nullable<AbstractMesh>;
  83570. /**
  83571. * Fired when the trigger state has changed
  83572. */
  83573. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83574. /**
  83575. * Fired when the main button state has changed
  83576. */
  83577. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83578. /**
  83579. * Fired when the secondary button state has changed
  83580. */
  83581. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83582. /**
  83583. * Fired when the pad state has changed
  83584. */
  83585. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83586. /**
  83587. * Fired when controllers stick values have changed
  83588. */
  83589. onPadValuesChangedObservable: Observable<StickValues>;
  83590. /**
  83591. * Array of button availible on the controller
  83592. */
  83593. protected _buttons: Array<MutableGamepadButton>;
  83594. private _onButtonStateChange;
  83595. /**
  83596. * Fired when a controller button's state has changed
  83597. * @param callback the callback containing the button that was modified
  83598. */
  83599. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83600. /**
  83601. * X and Y axis corresponding to the controllers joystick
  83602. */
  83603. pad: StickValues;
  83604. /**
  83605. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83606. */
  83607. hand: string;
  83608. /**
  83609. * The default controller model for the controller
  83610. */
  83611. readonly defaultModel: Nullable<AbstractMesh>;
  83612. /**
  83613. * Creates a new WebVRController from a gamepad
  83614. * @param vrGamepad the gamepad that the WebVRController should be created from
  83615. */
  83616. constructor(vrGamepad: any);
  83617. /**
  83618. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83619. */
  83620. update(): void;
  83621. /**
  83622. * Function to be called when a button is modified
  83623. */
  83624. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83625. /**
  83626. * Loads a mesh and attaches it to the controller
  83627. * @param scene the scene the mesh should be added to
  83628. * @param meshLoaded callback for when the mesh has been loaded
  83629. */
  83630. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83631. private _setButtonValue;
  83632. private _changes;
  83633. private _checkChanges;
  83634. /**
  83635. * Disposes of th webVRCOntroller
  83636. */
  83637. dispose(): void;
  83638. }
  83639. }
  83640. declare module BABYLON {
  83641. /**
  83642. * The HemisphericLight simulates the ambient environment light,
  83643. * so the passed direction is the light reflection direction, not the incoming direction.
  83644. */
  83645. export class HemisphericLight extends Light {
  83646. /**
  83647. * The groundColor is the light in the opposite direction to the one specified during creation.
  83648. * 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.
  83649. */
  83650. groundColor: Color3;
  83651. /**
  83652. * The light reflection direction, not the incoming direction.
  83653. */
  83654. direction: Vector3;
  83655. /**
  83656. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83657. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83658. * The HemisphericLight can't cast shadows.
  83659. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83660. * @param name The friendly name of the light
  83661. * @param direction The direction of the light reflection
  83662. * @param scene The scene the light belongs to
  83663. */
  83664. constructor(name: string, direction: Vector3, scene: Scene);
  83665. protected _buildUniformLayout(): void;
  83666. /**
  83667. * Returns the string "HemisphericLight".
  83668. * @return The class name
  83669. */
  83670. getClassName(): string;
  83671. /**
  83672. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83673. * Returns the updated direction.
  83674. * @param target The target the direction should point to
  83675. * @return The computed direction
  83676. */
  83677. setDirectionToTarget(target: Vector3): Vector3;
  83678. /**
  83679. * Returns the shadow generator associated to the light.
  83680. * @returns Always null for hemispheric lights because it does not support shadows.
  83681. */
  83682. getShadowGenerator(): Nullable<IShadowGenerator>;
  83683. /**
  83684. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83685. * @param effect The effect to update
  83686. * @param lightIndex The index of the light in the effect to update
  83687. * @returns The hemispheric light
  83688. */
  83689. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83690. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83691. /**
  83692. * Computes the world matrix of the node
  83693. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83694. * @param useWasUpdatedFlag defines a reserved property
  83695. * @returns the world matrix
  83696. */
  83697. computeWorldMatrix(): Matrix;
  83698. /**
  83699. * Returns the integer 3.
  83700. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83701. */
  83702. getTypeID(): number;
  83703. /**
  83704. * Prepares the list of defines specific to the light type.
  83705. * @param defines the list of defines
  83706. * @param lightIndex defines the index of the light for the effect
  83707. */
  83708. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83709. }
  83710. }
  83711. declare module BABYLON {
  83712. /** @hidden */
  83713. export var vrMultiviewToSingleviewPixelShader: {
  83714. name: string;
  83715. shader: string;
  83716. };
  83717. }
  83718. declare module BABYLON {
  83719. /**
  83720. * Renders to multiple views with a single draw call
  83721. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83722. */
  83723. export class MultiviewRenderTarget extends RenderTargetTexture {
  83724. /**
  83725. * Creates a multiview render target
  83726. * @param scene scene used with the render target
  83727. * @param size the size of the render target (used for each view)
  83728. */
  83729. constructor(scene: Scene, size?: number | {
  83730. width: number;
  83731. height: number;
  83732. } | {
  83733. ratio: number;
  83734. });
  83735. /**
  83736. * @hidden
  83737. * @param faceIndex the face index, if its a cube texture
  83738. */
  83739. _bindFrameBuffer(faceIndex?: number): void;
  83740. /**
  83741. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83742. * @returns the view count
  83743. */
  83744. getViewCount(): number;
  83745. }
  83746. }
  83747. declare module BABYLON {
  83748. /**
  83749. * Represents a camera frustum
  83750. */
  83751. export class Frustum {
  83752. /**
  83753. * Gets the planes representing the frustum
  83754. * @param transform matrix to be applied to the returned planes
  83755. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83756. */
  83757. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83758. /**
  83759. * Gets the near frustum plane transformed by the transform matrix
  83760. * @param transform transformation matrix to be applied to the resulting frustum plane
  83761. * @param frustumPlane the resuling frustum plane
  83762. */
  83763. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83764. /**
  83765. * Gets the far frustum plane transformed by the transform matrix
  83766. * @param transform transformation matrix to be applied to the resulting frustum plane
  83767. * @param frustumPlane the resuling frustum plane
  83768. */
  83769. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83770. /**
  83771. * Gets the left frustum plane transformed by the transform matrix
  83772. * @param transform transformation matrix to be applied to the resulting frustum plane
  83773. * @param frustumPlane the resuling frustum plane
  83774. */
  83775. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83776. /**
  83777. * Gets the right frustum plane transformed by the transform matrix
  83778. * @param transform transformation matrix to be applied to the resulting frustum plane
  83779. * @param frustumPlane the resuling frustum plane
  83780. */
  83781. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83782. /**
  83783. * Gets the top frustum plane transformed by the transform matrix
  83784. * @param transform transformation matrix to be applied to the resulting frustum plane
  83785. * @param frustumPlane the resuling frustum plane
  83786. */
  83787. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83788. /**
  83789. * Gets the bottom frustum plane transformed by the transform matrix
  83790. * @param transform transformation matrix to be applied to the resulting frustum plane
  83791. * @param frustumPlane the resuling frustum plane
  83792. */
  83793. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83794. /**
  83795. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83796. * @param transform transformation matrix to be applied to the resulting frustum planes
  83797. * @param frustumPlanes the resuling frustum planes
  83798. */
  83799. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83800. }
  83801. }
  83802. declare module BABYLON {
  83803. interface Engine {
  83804. /**
  83805. * Creates a new multiview render target
  83806. * @param width defines the width of the texture
  83807. * @param height defines the height of the texture
  83808. * @returns the created multiview texture
  83809. */
  83810. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83811. /**
  83812. * Binds a multiview framebuffer to be drawn to
  83813. * @param multiviewTexture texture to bind
  83814. */
  83815. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83816. }
  83817. interface Camera {
  83818. /**
  83819. * @hidden
  83820. * 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)
  83821. */
  83822. _useMultiviewToSingleView: boolean;
  83823. /**
  83824. * @hidden
  83825. * 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)
  83826. */
  83827. _multiviewTexture: Nullable<RenderTargetTexture>;
  83828. /**
  83829. * @hidden
  83830. * ensures the multiview texture of the camera exists and has the specified width/height
  83831. * @param width height to set on the multiview texture
  83832. * @param height width to set on the multiview texture
  83833. */
  83834. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83835. }
  83836. interface Scene {
  83837. /** @hidden */
  83838. _transformMatrixR: Matrix;
  83839. /** @hidden */
  83840. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83841. /** @hidden */
  83842. _createMultiviewUbo(): void;
  83843. /** @hidden */
  83844. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83845. /** @hidden */
  83846. _renderMultiviewToSingleView(camera: Camera): void;
  83847. }
  83848. }
  83849. declare module BABYLON {
  83850. /**
  83851. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83852. * This will not be used for webXR as it supports displaying texture arrays directly
  83853. */
  83854. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83855. /**
  83856. * Initializes a VRMultiviewToSingleview
  83857. * @param name name of the post process
  83858. * @param camera camera to be applied to
  83859. * @param scaleFactor scaling factor to the size of the output texture
  83860. */
  83861. constructor(name: string, camera: Camera, scaleFactor: number);
  83862. }
  83863. }
  83864. declare module BABYLON {
  83865. /**
  83866. * Interface used to define additional presentation attributes
  83867. */
  83868. export interface IVRPresentationAttributes {
  83869. /**
  83870. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83871. */
  83872. highRefreshRate: boolean;
  83873. /**
  83874. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83875. */
  83876. foveationLevel: number;
  83877. }
  83878. interface Engine {
  83879. /** @hidden */
  83880. _vrDisplay: any;
  83881. /** @hidden */
  83882. _vrSupported: boolean;
  83883. /** @hidden */
  83884. _oldSize: Size;
  83885. /** @hidden */
  83886. _oldHardwareScaleFactor: number;
  83887. /** @hidden */
  83888. _vrExclusivePointerMode: boolean;
  83889. /** @hidden */
  83890. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83891. /** @hidden */
  83892. _onVRDisplayPointerRestricted: () => void;
  83893. /** @hidden */
  83894. _onVRDisplayPointerUnrestricted: () => void;
  83895. /** @hidden */
  83896. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83897. /** @hidden */
  83898. _onVrDisplayDisconnect: Nullable<() => void>;
  83899. /** @hidden */
  83900. _onVrDisplayPresentChange: Nullable<() => void>;
  83901. /**
  83902. * Observable signaled when VR display mode changes
  83903. */
  83904. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83905. /**
  83906. * Observable signaled when VR request present is complete
  83907. */
  83908. onVRRequestPresentComplete: Observable<boolean>;
  83909. /**
  83910. * Observable signaled when VR request present starts
  83911. */
  83912. onVRRequestPresentStart: Observable<Engine>;
  83913. /**
  83914. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83915. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83916. */
  83917. isInVRExclusivePointerMode: boolean;
  83918. /**
  83919. * Gets a boolean indicating if a webVR device was detected
  83920. * @returns true if a webVR device was detected
  83921. */
  83922. isVRDevicePresent(): boolean;
  83923. /**
  83924. * Gets the current webVR device
  83925. * @returns the current webVR device (or null)
  83926. */
  83927. getVRDevice(): any;
  83928. /**
  83929. * Initializes a webVR display and starts listening to display change events
  83930. * The onVRDisplayChangedObservable will be notified upon these changes
  83931. * @returns A promise containing a VRDisplay and if vr is supported
  83932. */
  83933. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83934. /** @hidden */
  83935. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83936. /**
  83937. * Gets or sets the presentation attributes used to configure VR rendering
  83938. */
  83939. vrPresentationAttributes?: IVRPresentationAttributes;
  83940. /**
  83941. * Call this function to switch to webVR mode
  83942. * Will do nothing if webVR is not supported or if there is no webVR device
  83943. * @param options the webvr options provided to the camera. mainly used for multiview
  83944. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83945. */
  83946. enableVR(options: WebVROptions): void;
  83947. /** @hidden */
  83948. _onVRFullScreenTriggered(): void;
  83949. }
  83950. }
  83951. declare module BABYLON {
  83952. /**
  83953. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83954. * IMPORTANT!! The data is right-hand data.
  83955. * @export
  83956. * @interface DevicePose
  83957. */
  83958. export interface DevicePose {
  83959. /**
  83960. * The position of the device, values in array are [x,y,z].
  83961. */
  83962. readonly position: Nullable<Float32Array>;
  83963. /**
  83964. * The linearVelocity of the device, values in array are [x,y,z].
  83965. */
  83966. readonly linearVelocity: Nullable<Float32Array>;
  83967. /**
  83968. * The linearAcceleration of the device, values in array are [x,y,z].
  83969. */
  83970. readonly linearAcceleration: Nullable<Float32Array>;
  83971. /**
  83972. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83973. */
  83974. readonly orientation: Nullable<Float32Array>;
  83975. /**
  83976. * The angularVelocity of the device, values in array are [x,y,z].
  83977. */
  83978. readonly angularVelocity: Nullable<Float32Array>;
  83979. /**
  83980. * The angularAcceleration of the device, values in array are [x,y,z].
  83981. */
  83982. readonly angularAcceleration: Nullable<Float32Array>;
  83983. }
  83984. /**
  83985. * Interface representing a pose controlled object in Babylon.
  83986. * A pose controlled object has both regular pose values as well as pose values
  83987. * from an external device such as a VR head mounted display
  83988. */
  83989. export interface PoseControlled {
  83990. /**
  83991. * The position of the object in babylon space.
  83992. */
  83993. position: Vector3;
  83994. /**
  83995. * The rotation quaternion of the object in babylon space.
  83996. */
  83997. rotationQuaternion: Quaternion;
  83998. /**
  83999. * The position of the device in babylon space.
  84000. */
  84001. devicePosition?: Vector3;
  84002. /**
  84003. * The rotation quaternion of the device in babylon space.
  84004. */
  84005. deviceRotationQuaternion: Quaternion;
  84006. /**
  84007. * The raw pose coming from the device.
  84008. */
  84009. rawPose: Nullable<DevicePose>;
  84010. /**
  84011. * The scale of the device to be used when translating from device space to babylon space.
  84012. */
  84013. deviceScaleFactor: number;
  84014. /**
  84015. * Updates the poseControlled values based on the input device pose.
  84016. * @param poseData the pose data to update the object with
  84017. */
  84018. updateFromDevice(poseData: DevicePose): void;
  84019. }
  84020. /**
  84021. * Set of options to customize the webVRCamera
  84022. */
  84023. export interface WebVROptions {
  84024. /**
  84025. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84026. */
  84027. trackPosition?: boolean;
  84028. /**
  84029. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84030. */
  84031. positionScale?: number;
  84032. /**
  84033. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84034. */
  84035. displayName?: string;
  84036. /**
  84037. * Should the native controller meshes be initialized. (default: true)
  84038. */
  84039. controllerMeshes?: boolean;
  84040. /**
  84041. * Creating a default HemiLight only on controllers. (default: true)
  84042. */
  84043. defaultLightingOnControllers?: boolean;
  84044. /**
  84045. * If you don't want to use the default VR button of the helper. (default: false)
  84046. */
  84047. useCustomVRButton?: boolean;
  84048. /**
  84049. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84050. */
  84051. customVRButton?: HTMLButtonElement;
  84052. /**
  84053. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84054. */
  84055. rayLength?: number;
  84056. /**
  84057. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84058. */
  84059. defaultHeight?: number;
  84060. /**
  84061. * If multiview should be used if availible (default: false)
  84062. */
  84063. useMultiview?: boolean;
  84064. }
  84065. /**
  84066. * This represents a WebVR camera.
  84067. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84068. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84069. */
  84070. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84071. private webVROptions;
  84072. /**
  84073. * @hidden
  84074. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84075. */
  84076. _vrDevice: any;
  84077. /**
  84078. * The rawPose of the vrDevice.
  84079. */
  84080. rawPose: Nullable<DevicePose>;
  84081. private _onVREnabled;
  84082. private _specsVersion;
  84083. private _attached;
  84084. private _frameData;
  84085. protected _descendants: Array<Node>;
  84086. private _deviceRoomPosition;
  84087. /** @hidden */
  84088. _deviceRoomRotationQuaternion: Quaternion;
  84089. private _standingMatrix;
  84090. /**
  84091. * Represents device position in babylon space.
  84092. */
  84093. devicePosition: Vector3;
  84094. /**
  84095. * Represents device rotation in babylon space.
  84096. */
  84097. deviceRotationQuaternion: Quaternion;
  84098. /**
  84099. * The scale of the device to be used when translating from device space to babylon space.
  84100. */
  84101. deviceScaleFactor: number;
  84102. private _deviceToWorld;
  84103. private _worldToDevice;
  84104. /**
  84105. * References to the webVR controllers for the vrDevice.
  84106. */
  84107. controllers: Array<WebVRController>;
  84108. /**
  84109. * Emits an event when a controller is attached.
  84110. */
  84111. onControllersAttachedObservable: Observable<WebVRController[]>;
  84112. /**
  84113. * Emits an event when a controller's mesh has been loaded;
  84114. */
  84115. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84116. /**
  84117. * Emits an event when the HMD's pose has been updated.
  84118. */
  84119. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84120. private _poseSet;
  84121. /**
  84122. * If the rig cameras be used as parent instead of this camera.
  84123. */
  84124. rigParenting: boolean;
  84125. private _lightOnControllers;
  84126. private _defaultHeight?;
  84127. /**
  84128. * Instantiates a WebVRFreeCamera.
  84129. * @param name The name of the WebVRFreeCamera
  84130. * @param position The starting anchor position for the camera
  84131. * @param scene The scene the camera belongs to
  84132. * @param webVROptions a set of customizable options for the webVRCamera
  84133. */
  84134. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84135. /**
  84136. * Gets the device distance from the ground in meters.
  84137. * @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.
  84138. */
  84139. deviceDistanceToRoomGround(): number;
  84140. /**
  84141. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84142. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84143. */
  84144. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84145. /**
  84146. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84147. * @returns A promise with a boolean set to if the standing matrix is supported.
  84148. */
  84149. useStandingMatrixAsync(): Promise<boolean>;
  84150. /**
  84151. * Disposes the camera
  84152. */
  84153. dispose(): void;
  84154. /**
  84155. * Gets a vrController by name.
  84156. * @param name The name of the controller to retreive
  84157. * @returns the controller matching the name specified or null if not found
  84158. */
  84159. getControllerByName(name: string): Nullable<WebVRController>;
  84160. private _leftController;
  84161. /**
  84162. * The controller corresponding to the users left hand.
  84163. */
  84164. readonly leftController: Nullable<WebVRController>;
  84165. private _rightController;
  84166. /**
  84167. * The controller corresponding to the users right hand.
  84168. */
  84169. readonly rightController: Nullable<WebVRController>;
  84170. /**
  84171. * Casts a ray forward from the vrCamera's gaze.
  84172. * @param length Length of the ray (default: 100)
  84173. * @returns the ray corresponding to the gaze
  84174. */
  84175. getForwardRay(length?: number): Ray;
  84176. /**
  84177. * @hidden
  84178. * Updates the camera based on device's frame data
  84179. */
  84180. _checkInputs(): void;
  84181. /**
  84182. * Updates the poseControlled values based on the input device pose.
  84183. * @param poseData Pose coming from the device
  84184. */
  84185. updateFromDevice(poseData: DevicePose): void;
  84186. private _htmlElementAttached;
  84187. private _detachIfAttached;
  84188. /**
  84189. * WebVR's attach control will start broadcasting frames to the device.
  84190. * Note that in certain browsers (chrome for example) this function must be called
  84191. * within a user-interaction callback. Example:
  84192. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84193. *
  84194. * @param element html element to attach the vrDevice to
  84195. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84196. */
  84197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84198. /**
  84199. * Detaches the camera from the html element and disables VR
  84200. *
  84201. * @param element html element to detach from
  84202. */
  84203. detachControl(element: HTMLElement): void;
  84204. /**
  84205. * @returns the name of this class
  84206. */
  84207. getClassName(): string;
  84208. /**
  84209. * Calls resetPose on the vrDisplay
  84210. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84211. */
  84212. resetToCurrentRotation(): void;
  84213. /**
  84214. * @hidden
  84215. * Updates the rig cameras (left and right eye)
  84216. */
  84217. _updateRigCameras(): void;
  84218. private _workingVector;
  84219. private _oneVector;
  84220. private _workingMatrix;
  84221. private updateCacheCalled;
  84222. private _correctPositionIfNotTrackPosition;
  84223. /**
  84224. * @hidden
  84225. * Updates the cached values of the camera
  84226. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84227. */
  84228. _updateCache(ignoreParentClass?: boolean): void;
  84229. /**
  84230. * @hidden
  84231. * Get current device position in babylon world
  84232. */
  84233. _computeDevicePosition(): void;
  84234. /**
  84235. * Updates the current device position and rotation in the babylon world
  84236. */
  84237. update(): void;
  84238. /**
  84239. * @hidden
  84240. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84241. * @returns an identity matrix
  84242. */
  84243. _getViewMatrix(): Matrix;
  84244. private _tmpMatrix;
  84245. /**
  84246. * This function is called by the two RIG cameras.
  84247. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84248. * @hidden
  84249. */
  84250. _getWebVRViewMatrix(): Matrix;
  84251. /** @hidden */
  84252. _getWebVRProjectionMatrix(): Matrix;
  84253. private _onGamepadConnectedObserver;
  84254. private _onGamepadDisconnectedObserver;
  84255. private _updateCacheWhenTrackingDisabledObserver;
  84256. /**
  84257. * Initializes the controllers and their meshes
  84258. */
  84259. initControllers(): void;
  84260. }
  84261. }
  84262. declare module BABYLON {
  84263. /**
  84264. * Size options for a post process
  84265. */
  84266. export type PostProcessOptions = {
  84267. width: number;
  84268. height: number;
  84269. };
  84270. /**
  84271. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84272. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84273. */
  84274. export class PostProcess {
  84275. /** Name of the PostProcess. */
  84276. name: string;
  84277. /**
  84278. * Gets or sets the unique id of the post process
  84279. */
  84280. uniqueId: number;
  84281. /**
  84282. * Width of the texture to apply the post process on
  84283. */
  84284. width: number;
  84285. /**
  84286. * Height of the texture to apply the post process on
  84287. */
  84288. height: number;
  84289. /**
  84290. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84291. * @hidden
  84292. */
  84293. _outputTexture: Nullable<InternalTexture>;
  84294. /**
  84295. * Sampling mode used by the shader
  84296. * See https://doc.babylonjs.com/classes/3.1/texture
  84297. */
  84298. renderTargetSamplingMode: number;
  84299. /**
  84300. * Clear color to use when screen clearing
  84301. */
  84302. clearColor: Color4;
  84303. /**
  84304. * If the buffer needs to be cleared before applying the post process. (default: true)
  84305. * Should be set to false if shader will overwrite all previous pixels.
  84306. */
  84307. autoClear: boolean;
  84308. /**
  84309. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84310. */
  84311. alphaMode: number;
  84312. /**
  84313. * Sets the setAlphaBlendConstants of the babylon engine
  84314. */
  84315. alphaConstants: Color4;
  84316. /**
  84317. * Animations to be used for the post processing
  84318. */
  84319. animations: Animation[];
  84320. /**
  84321. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84322. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84323. */
  84324. enablePixelPerfectMode: boolean;
  84325. /**
  84326. * Force the postprocess to be applied without taking in account viewport
  84327. */
  84328. forceFullscreenViewport: boolean;
  84329. /**
  84330. * List of inspectable custom properties (used by the Inspector)
  84331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84332. */
  84333. inspectableCustomProperties: IInspectable[];
  84334. /**
  84335. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84336. *
  84337. * | Value | Type | Description |
  84338. * | ----- | ----------------------------------- | ----------- |
  84339. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84340. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84341. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84342. *
  84343. */
  84344. scaleMode: number;
  84345. /**
  84346. * Force textures to be a power of two (default: false)
  84347. */
  84348. alwaysForcePOT: boolean;
  84349. private _samples;
  84350. /**
  84351. * Number of sample textures (default: 1)
  84352. */
  84353. samples: number;
  84354. /**
  84355. * Modify the scale of the post process to be the same as the viewport (default: false)
  84356. */
  84357. adaptScaleToCurrentViewport: boolean;
  84358. private _camera;
  84359. private _scene;
  84360. private _engine;
  84361. private _options;
  84362. private _reusable;
  84363. private _textureType;
  84364. /**
  84365. * Smart array of input and output textures for the post process.
  84366. * @hidden
  84367. */
  84368. _textures: SmartArray<InternalTexture>;
  84369. /**
  84370. * The index in _textures that corresponds to the output texture.
  84371. * @hidden
  84372. */
  84373. _currentRenderTextureInd: number;
  84374. private _effect;
  84375. private _samplers;
  84376. private _fragmentUrl;
  84377. private _vertexUrl;
  84378. private _parameters;
  84379. private _scaleRatio;
  84380. protected _indexParameters: any;
  84381. private _shareOutputWithPostProcess;
  84382. private _texelSize;
  84383. private _forcedOutputTexture;
  84384. /**
  84385. * Returns the fragment url or shader name used in the post process.
  84386. * @returns the fragment url or name in the shader store.
  84387. */
  84388. getEffectName(): string;
  84389. /**
  84390. * An event triggered when the postprocess is activated.
  84391. */
  84392. onActivateObservable: Observable<Camera>;
  84393. private _onActivateObserver;
  84394. /**
  84395. * A function that is added to the onActivateObservable
  84396. */
  84397. onActivate: Nullable<(camera: Camera) => void>;
  84398. /**
  84399. * An event triggered when the postprocess changes its size.
  84400. */
  84401. onSizeChangedObservable: Observable<PostProcess>;
  84402. private _onSizeChangedObserver;
  84403. /**
  84404. * A function that is added to the onSizeChangedObservable
  84405. */
  84406. onSizeChanged: (postProcess: PostProcess) => void;
  84407. /**
  84408. * An event triggered when the postprocess applies its effect.
  84409. */
  84410. onApplyObservable: Observable<Effect>;
  84411. private _onApplyObserver;
  84412. /**
  84413. * A function that is added to the onApplyObservable
  84414. */
  84415. onApply: (effect: Effect) => void;
  84416. /**
  84417. * An event triggered before rendering the postprocess
  84418. */
  84419. onBeforeRenderObservable: Observable<Effect>;
  84420. private _onBeforeRenderObserver;
  84421. /**
  84422. * A function that is added to the onBeforeRenderObservable
  84423. */
  84424. onBeforeRender: (effect: Effect) => void;
  84425. /**
  84426. * An event triggered after rendering the postprocess
  84427. */
  84428. onAfterRenderObservable: Observable<Effect>;
  84429. private _onAfterRenderObserver;
  84430. /**
  84431. * A function that is added to the onAfterRenderObservable
  84432. */
  84433. onAfterRender: (efect: Effect) => void;
  84434. /**
  84435. * 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
  84436. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84437. */
  84438. inputTexture: InternalTexture;
  84439. /**
  84440. * Gets the camera which post process is applied to.
  84441. * @returns The camera the post process is applied to.
  84442. */
  84443. getCamera(): Camera;
  84444. /**
  84445. * Gets the texel size of the postprocess.
  84446. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84447. */
  84448. readonly texelSize: Vector2;
  84449. /**
  84450. * Creates a new instance PostProcess
  84451. * @param name The name of the PostProcess.
  84452. * @param fragmentUrl The url of the fragment shader to be used.
  84453. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84454. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84455. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84456. * @param camera The camera to apply the render pass to.
  84457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84458. * @param engine The engine which the post process will be applied. (default: current engine)
  84459. * @param reusable If the post process can be reused on the same frame. (default: false)
  84460. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84461. * @param textureType Type of textures used when performing the post process. (default: 0)
  84462. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84463. * @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
  84464. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84465. */
  84466. constructor(
  84467. /** Name of the PostProcess. */
  84468. 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);
  84469. /**
  84470. * Gets a string idenfifying the name of the class
  84471. * @returns "PostProcess" string
  84472. */
  84473. getClassName(): string;
  84474. /**
  84475. * Gets the engine which this post process belongs to.
  84476. * @returns The engine the post process was enabled with.
  84477. */
  84478. getEngine(): Engine;
  84479. /**
  84480. * The effect that is created when initializing the post process.
  84481. * @returns The created effect corresponding the the postprocess.
  84482. */
  84483. getEffect(): Effect;
  84484. /**
  84485. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84486. * @param postProcess The post process to share the output with.
  84487. * @returns This post process.
  84488. */
  84489. shareOutputWith(postProcess: PostProcess): PostProcess;
  84490. /**
  84491. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84492. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84493. */
  84494. useOwnOutput(): void;
  84495. /**
  84496. * Updates the effect with the current post process compile time values and recompiles the shader.
  84497. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84498. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84499. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84500. * @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
  84501. * @param onCompiled Called when the shader has been compiled.
  84502. * @param onError Called if there is an error when compiling a shader.
  84503. */
  84504. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84505. /**
  84506. * The post process is reusable if it can be used multiple times within one frame.
  84507. * @returns If the post process is reusable
  84508. */
  84509. isReusable(): boolean;
  84510. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84511. markTextureDirty(): void;
  84512. /**
  84513. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84514. * 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.
  84515. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84516. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84517. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84518. * @returns The target texture that was bound to be written to.
  84519. */
  84520. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84521. /**
  84522. * If the post process is supported.
  84523. */
  84524. readonly isSupported: boolean;
  84525. /**
  84526. * The aspect ratio of the output texture.
  84527. */
  84528. readonly aspectRatio: number;
  84529. /**
  84530. * Get a value indicating if the post-process is ready to be used
  84531. * @returns true if the post-process is ready (shader is compiled)
  84532. */
  84533. isReady(): boolean;
  84534. /**
  84535. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84536. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84537. */
  84538. apply(): Nullable<Effect>;
  84539. private _disposeTextures;
  84540. /**
  84541. * Disposes the post process.
  84542. * @param camera The camera to dispose the post process on.
  84543. */
  84544. dispose(camera?: Camera): void;
  84545. }
  84546. }
  84547. declare module BABYLON {
  84548. /** @hidden */
  84549. export var kernelBlurVaryingDeclaration: {
  84550. name: string;
  84551. shader: string;
  84552. };
  84553. }
  84554. declare module BABYLON {
  84555. /** @hidden */
  84556. export var kernelBlurFragment: {
  84557. name: string;
  84558. shader: string;
  84559. };
  84560. }
  84561. declare module BABYLON {
  84562. /** @hidden */
  84563. export var kernelBlurFragment2: {
  84564. name: string;
  84565. shader: string;
  84566. };
  84567. }
  84568. declare module BABYLON {
  84569. /** @hidden */
  84570. export var kernelBlurPixelShader: {
  84571. name: string;
  84572. shader: string;
  84573. };
  84574. }
  84575. declare module BABYLON {
  84576. /** @hidden */
  84577. export var kernelBlurVertex: {
  84578. name: string;
  84579. shader: string;
  84580. };
  84581. }
  84582. declare module BABYLON {
  84583. /** @hidden */
  84584. export var kernelBlurVertexShader: {
  84585. name: string;
  84586. shader: string;
  84587. };
  84588. }
  84589. declare module BABYLON {
  84590. /**
  84591. * The Blur Post Process which blurs an image based on a kernel and direction.
  84592. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84593. */
  84594. export class BlurPostProcess extends PostProcess {
  84595. /** The direction in which to blur the image. */
  84596. direction: Vector2;
  84597. private blockCompilation;
  84598. protected _kernel: number;
  84599. protected _idealKernel: number;
  84600. protected _packedFloat: boolean;
  84601. private _staticDefines;
  84602. /**
  84603. * Sets the length in pixels of the blur sample region
  84604. */
  84605. /**
  84606. * Gets the length in pixels of the blur sample region
  84607. */
  84608. kernel: number;
  84609. /**
  84610. * Sets wether or not the blur needs to unpack/repack floats
  84611. */
  84612. /**
  84613. * Gets wether or not the blur is unpacking/repacking floats
  84614. */
  84615. packedFloat: boolean;
  84616. /**
  84617. * Creates a new instance BlurPostProcess
  84618. * @param name The name of the effect.
  84619. * @param direction The direction in which to blur the image.
  84620. * @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.
  84621. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84622. * @param camera The camera to apply the render pass to.
  84623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84624. * @param engine The engine which the post process will be applied. (default: current engine)
  84625. * @param reusable If the post process can be reused on the same frame. (default: false)
  84626. * @param textureType Type of textures used when performing the post process. (default: 0)
  84627. * @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)
  84628. */
  84629. constructor(name: string,
  84630. /** The direction in which to blur the image. */
  84631. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84632. /**
  84633. * Updates the effect with the current post process compile time values and recompiles the shader.
  84634. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84635. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84636. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84637. * @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
  84638. * @param onCompiled Called when the shader has been compiled.
  84639. * @param onError Called if there is an error when compiling a shader.
  84640. */
  84641. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84642. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84643. /**
  84644. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84645. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84646. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84647. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84648. * The gaps between physical kernels are compensated for in the weighting of the samples
  84649. * @param idealKernel Ideal blur kernel.
  84650. * @return Nearest best kernel.
  84651. */
  84652. protected _nearestBestKernel(idealKernel: number): number;
  84653. /**
  84654. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84655. * @param x The point on the Gaussian distribution to sample.
  84656. * @return the value of the Gaussian function at x.
  84657. */
  84658. protected _gaussianWeight(x: number): number;
  84659. /**
  84660. * Generates a string that can be used as a floating point number in GLSL.
  84661. * @param x Value to print.
  84662. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84663. * @return GLSL float string.
  84664. */
  84665. protected _glslFloat(x: number, decimalFigures?: number): string;
  84666. }
  84667. }
  84668. declare module BABYLON {
  84669. /**
  84670. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84671. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84672. * You can then easily use it as a reflectionTexture on a flat surface.
  84673. * In case the surface is not a plane, please consider relying on reflection probes.
  84674. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84675. */
  84676. export class MirrorTexture extends RenderTargetTexture {
  84677. private scene;
  84678. /**
  84679. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84680. * 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.
  84681. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84682. */
  84683. mirrorPlane: Plane;
  84684. /**
  84685. * Define the blur ratio used to blur the reflection if needed.
  84686. */
  84687. blurRatio: number;
  84688. /**
  84689. * Define the adaptive blur kernel used to blur the reflection if needed.
  84690. * This will autocompute the closest best match for the `blurKernel`
  84691. */
  84692. adaptiveBlurKernel: number;
  84693. /**
  84694. * Define the blur kernel used to blur the reflection if needed.
  84695. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84696. */
  84697. blurKernel: number;
  84698. /**
  84699. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84700. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84701. */
  84702. blurKernelX: number;
  84703. /**
  84704. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84705. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84706. */
  84707. blurKernelY: number;
  84708. private _autoComputeBlurKernel;
  84709. protected _onRatioRescale(): void;
  84710. private _updateGammaSpace;
  84711. private _imageProcessingConfigChangeObserver;
  84712. private _transformMatrix;
  84713. private _mirrorMatrix;
  84714. private _savedViewMatrix;
  84715. private _blurX;
  84716. private _blurY;
  84717. private _adaptiveBlurKernel;
  84718. private _blurKernelX;
  84719. private _blurKernelY;
  84720. private _blurRatio;
  84721. /**
  84722. * Instantiates a Mirror Texture.
  84723. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84724. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84725. * You can then easily use it as a reflectionTexture on a flat surface.
  84726. * In case the surface is not a plane, please consider relying on reflection probes.
  84727. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84728. * @param name
  84729. * @param size
  84730. * @param scene
  84731. * @param generateMipMaps
  84732. * @param type
  84733. * @param samplingMode
  84734. * @param generateDepthBuffer
  84735. */
  84736. constructor(name: string, size: number | {
  84737. width: number;
  84738. height: number;
  84739. } | {
  84740. ratio: number;
  84741. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84742. private _preparePostProcesses;
  84743. /**
  84744. * Clone the mirror texture.
  84745. * @returns the cloned texture
  84746. */
  84747. clone(): MirrorTexture;
  84748. /**
  84749. * Serialize the texture to a JSON representation you could use in Parse later on
  84750. * @returns the serialized JSON representation
  84751. */
  84752. serialize(): any;
  84753. /**
  84754. * Dispose the texture and release its associated resources.
  84755. */
  84756. dispose(): void;
  84757. }
  84758. }
  84759. declare module BABYLON {
  84760. /**
  84761. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84762. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84763. */
  84764. export class Texture extends BaseTexture {
  84765. /**
  84766. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84767. */
  84768. static SerializeBuffers: boolean;
  84769. /** @hidden */
  84770. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84771. /** @hidden */
  84772. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84773. /** @hidden */
  84774. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84775. /** nearest is mag = nearest and min = nearest and mip = linear */
  84776. static readonly NEAREST_SAMPLINGMODE: number;
  84777. /** nearest is mag = nearest and min = nearest and mip = linear */
  84778. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84779. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84780. static readonly BILINEAR_SAMPLINGMODE: number;
  84781. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84782. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84783. /** Trilinear is mag = linear and min = linear and mip = linear */
  84784. static readonly TRILINEAR_SAMPLINGMODE: number;
  84785. /** Trilinear is mag = linear and min = linear and mip = linear */
  84786. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84787. /** mag = nearest and min = nearest and mip = nearest */
  84788. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84789. /** mag = nearest and min = linear and mip = nearest */
  84790. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84791. /** mag = nearest and min = linear and mip = linear */
  84792. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84793. /** mag = nearest and min = linear and mip = none */
  84794. static readonly NEAREST_LINEAR: number;
  84795. /** mag = nearest and min = nearest and mip = none */
  84796. static readonly NEAREST_NEAREST: number;
  84797. /** mag = linear and min = nearest and mip = nearest */
  84798. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84799. /** mag = linear and min = nearest and mip = linear */
  84800. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84801. /** mag = linear and min = linear and mip = none */
  84802. static readonly LINEAR_LINEAR: number;
  84803. /** mag = linear and min = nearest and mip = none */
  84804. static readonly LINEAR_NEAREST: number;
  84805. /** Explicit coordinates mode */
  84806. static readonly EXPLICIT_MODE: number;
  84807. /** Spherical coordinates mode */
  84808. static readonly SPHERICAL_MODE: number;
  84809. /** Planar coordinates mode */
  84810. static readonly PLANAR_MODE: number;
  84811. /** Cubic coordinates mode */
  84812. static readonly CUBIC_MODE: number;
  84813. /** Projection coordinates mode */
  84814. static readonly PROJECTION_MODE: number;
  84815. /** Inverse Cubic coordinates mode */
  84816. static readonly SKYBOX_MODE: number;
  84817. /** Inverse Cubic coordinates mode */
  84818. static readonly INVCUBIC_MODE: number;
  84819. /** Equirectangular coordinates mode */
  84820. static readonly EQUIRECTANGULAR_MODE: number;
  84821. /** Equirectangular Fixed coordinates mode */
  84822. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84823. /** Equirectangular Fixed Mirrored coordinates mode */
  84824. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84825. /** Texture is not repeating outside of 0..1 UVs */
  84826. static readonly CLAMP_ADDRESSMODE: number;
  84827. /** Texture is repeating outside of 0..1 UVs */
  84828. static readonly WRAP_ADDRESSMODE: number;
  84829. /** Texture is repeating and mirrored */
  84830. static readonly MIRROR_ADDRESSMODE: number;
  84831. /**
  84832. * 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
  84833. */
  84834. static UseSerializedUrlIfAny: boolean;
  84835. /**
  84836. * Define the url of the texture.
  84837. */
  84838. url: Nullable<string>;
  84839. /**
  84840. * Define an offset on the texture to offset the u coordinates of the UVs
  84841. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84842. */
  84843. uOffset: number;
  84844. /**
  84845. * Define an offset on the texture to offset the v coordinates of the UVs
  84846. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84847. */
  84848. vOffset: number;
  84849. /**
  84850. * Define an offset on the texture to scale the u coordinates of the UVs
  84851. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84852. */
  84853. uScale: number;
  84854. /**
  84855. * Define an offset on the texture to scale the v coordinates of the UVs
  84856. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84857. */
  84858. vScale: number;
  84859. /**
  84860. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84861. * @see http://doc.babylonjs.com/how_to/more_materials
  84862. */
  84863. uAng: number;
  84864. /**
  84865. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84866. * @see http://doc.babylonjs.com/how_to/more_materials
  84867. */
  84868. vAng: number;
  84869. /**
  84870. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84871. * @see http://doc.babylonjs.com/how_to/more_materials
  84872. */
  84873. wAng: number;
  84874. /**
  84875. * Defines the center of rotation (U)
  84876. */
  84877. uRotationCenter: number;
  84878. /**
  84879. * Defines the center of rotation (V)
  84880. */
  84881. vRotationCenter: number;
  84882. /**
  84883. * Defines the center of rotation (W)
  84884. */
  84885. wRotationCenter: number;
  84886. /**
  84887. * Are mip maps generated for this texture or not.
  84888. */
  84889. readonly noMipmap: boolean;
  84890. /**
  84891. * List of inspectable custom properties (used by the Inspector)
  84892. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84893. */
  84894. inspectableCustomProperties: Nullable<IInspectable[]>;
  84895. private _noMipmap;
  84896. /** @hidden */
  84897. _invertY: boolean;
  84898. private _rowGenerationMatrix;
  84899. private _cachedTextureMatrix;
  84900. private _projectionModeMatrix;
  84901. private _t0;
  84902. private _t1;
  84903. private _t2;
  84904. private _cachedUOffset;
  84905. private _cachedVOffset;
  84906. private _cachedUScale;
  84907. private _cachedVScale;
  84908. private _cachedUAng;
  84909. private _cachedVAng;
  84910. private _cachedWAng;
  84911. private _cachedProjectionMatrixId;
  84912. private _cachedCoordinatesMode;
  84913. /** @hidden */
  84914. protected _initialSamplingMode: number;
  84915. /** @hidden */
  84916. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84917. private _deleteBuffer;
  84918. protected _format: Nullable<number>;
  84919. private _delayedOnLoad;
  84920. private _delayedOnError;
  84921. private _mimeType?;
  84922. /**
  84923. * Observable triggered once the texture has been loaded.
  84924. */
  84925. onLoadObservable: Observable<Texture>;
  84926. protected _isBlocking: boolean;
  84927. /**
  84928. * Is the texture preventing material to render while loading.
  84929. * If false, a default texture will be used instead of the loading one during the preparation step.
  84930. */
  84931. isBlocking: boolean;
  84932. /**
  84933. * Get the current sampling mode associated with the texture.
  84934. */
  84935. readonly samplingMode: number;
  84936. /**
  84937. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84938. */
  84939. readonly invertY: boolean;
  84940. /**
  84941. * Instantiates a new texture.
  84942. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84943. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84944. * @param url defines the url of the picture to load as a texture
  84945. * @param scene defines the scene or engine the texture will belong to
  84946. * @param noMipmap defines if the texture will require mip maps or not
  84947. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84948. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84949. * @param onLoad defines a callback triggered when the texture has been loaded
  84950. * @param onError defines a callback triggered when an error occurred during the loading session
  84951. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84952. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84953. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84954. * @param mimeType defines an optional mime type information
  84955. */
  84956. 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);
  84957. /**
  84958. * Update the url (and optional buffer) of this texture if url was null during construction.
  84959. * @param url the url of the texture
  84960. * @param buffer the buffer of the texture (defaults to null)
  84961. * @param onLoad callback called when the texture is loaded (defaults to null)
  84962. */
  84963. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84964. /**
  84965. * Finish the loading sequence of a texture flagged as delayed load.
  84966. * @hidden
  84967. */
  84968. delayLoad(): void;
  84969. private _prepareRowForTextureGeneration;
  84970. /**
  84971. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84972. * @returns the transform matrix of the texture.
  84973. */
  84974. getTextureMatrix(uBase?: number): Matrix;
  84975. /**
  84976. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84977. * @returns The reflection texture transform
  84978. */
  84979. getReflectionTextureMatrix(): Matrix;
  84980. /**
  84981. * Clones the texture.
  84982. * @returns the cloned texture
  84983. */
  84984. clone(): Texture;
  84985. /**
  84986. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84987. * @returns The JSON representation of the texture
  84988. */
  84989. serialize(): any;
  84990. /**
  84991. * Get the current class name of the texture useful for serialization or dynamic coding.
  84992. * @returns "Texture"
  84993. */
  84994. getClassName(): string;
  84995. /**
  84996. * Dispose the texture and release its associated resources.
  84997. */
  84998. dispose(): void;
  84999. /**
  85000. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  85001. * @param parsedTexture Define the JSON representation of the texture
  85002. * @param scene Define the scene the parsed texture should be instantiated in
  85003. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  85004. * @returns The parsed texture if successful
  85005. */
  85006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  85007. /**
  85008. * Creates a texture from its base 64 representation.
  85009. * @param data Define the base64 payload without the data: prefix
  85010. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85011. * @param scene Define the scene the texture should belong to
  85012. * @param noMipmap Forces the texture to not create mip map information if true
  85013. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85014. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85015. * @param onLoad define a callback triggered when the texture has been loaded
  85016. * @param onError define a callback triggered when an error occurred during the loading session
  85017. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85018. * @returns the created texture
  85019. */
  85020. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85021. /**
  85022. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85023. * @param data Define the base64 payload without the data: prefix
  85024. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85025. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85026. * @param scene Define the scene the texture should belong to
  85027. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85028. * @param noMipmap Forces the texture to not create mip map information if true
  85029. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85030. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85031. * @param onLoad define a callback triggered when the texture has been loaded
  85032. * @param onError define a callback triggered when an error occurred during the loading session
  85033. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85034. * @returns the created texture
  85035. */
  85036. 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;
  85037. }
  85038. }
  85039. declare module BABYLON {
  85040. /**
  85041. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85042. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85043. */
  85044. export class PostProcessManager {
  85045. private _scene;
  85046. private _indexBuffer;
  85047. private _vertexBuffers;
  85048. /**
  85049. * Creates a new instance PostProcess
  85050. * @param scene The scene that the post process is associated with.
  85051. */
  85052. constructor(scene: Scene);
  85053. private _prepareBuffers;
  85054. private _buildIndexBuffer;
  85055. /**
  85056. * Rebuilds the vertex buffers of the manager.
  85057. * @hidden
  85058. */
  85059. _rebuild(): void;
  85060. /**
  85061. * Prepares a frame to be run through a post process.
  85062. * @param sourceTexture The input texture to the post procesess. (default: null)
  85063. * @param postProcesses An array of post processes to be run. (default: null)
  85064. * @returns True if the post processes were able to be run.
  85065. * @hidden
  85066. */
  85067. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85068. /**
  85069. * Manually render a set of post processes to a texture.
  85070. * @param postProcesses An array of post processes to be run.
  85071. * @param targetTexture The target texture to render to.
  85072. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85073. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85074. * @param lodLevel defines which lod of the texture to render to
  85075. */
  85076. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85077. /**
  85078. * Finalize the result of the output of the postprocesses.
  85079. * @param doNotPresent If true the result will not be displayed to the screen.
  85080. * @param targetTexture The target texture to render to.
  85081. * @param faceIndex The index of the face to bind the target texture to.
  85082. * @param postProcesses The array of post processes to render.
  85083. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85084. * @hidden
  85085. */
  85086. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85087. /**
  85088. * Disposes of the post process manager.
  85089. */
  85090. dispose(): void;
  85091. }
  85092. }
  85093. declare module BABYLON {
  85094. /** Interface used by value gradients (color, factor, ...) */
  85095. export interface IValueGradient {
  85096. /**
  85097. * Gets or sets the gradient value (between 0 and 1)
  85098. */
  85099. gradient: number;
  85100. }
  85101. /** Class used to store color4 gradient */
  85102. export class ColorGradient implements IValueGradient {
  85103. /**
  85104. * Gets or sets the gradient value (between 0 and 1)
  85105. */
  85106. gradient: number;
  85107. /**
  85108. * Gets or sets first associated color
  85109. */
  85110. color1: Color4;
  85111. /**
  85112. * Gets or sets second associated color
  85113. */
  85114. color2?: Color4;
  85115. /**
  85116. * Will get a color picked randomly between color1 and color2.
  85117. * If color2 is undefined then color1 will be used
  85118. * @param result defines the target Color4 to store the result in
  85119. */
  85120. getColorToRef(result: Color4): void;
  85121. }
  85122. /** Class used to store color 3 gradient */
  85123. export class Color3Gradient implements IValueGradient {
  85124. /**
  85125. * Gets or sets the gradient value (between 0 and 1)
  85126. */
  85127. gradient: number;
  85128. /**
  85129. * Gets or sets the associated color
  85130. */
  85131. color: Color3;
  85132. }
  85133. /** Class used to store factor gradient */
  85134. export class FactorGradient implements IValueGradient {
  85135. /**
  85136. * Gets or sets the gradient value (between 0 and 1)
  85137. */
  85138. gradient: number;
  85139. /**
  85140. * Gets or sets first associated factor
  85141. */
  85142. factor1: number;
  85143. /**
  85144. * Gets or sets second associated factor
  85145. */
  85146. factor2?: number;
  85147. /**
  85148. * Will get a number picked randomly between factor1 and factor2.
  85149. * If factor2 is undefined then factor1 will be used
  85150. * @returns the picked number
  85151. */
  85152. getFactor(): number;
  85153. }
  85154. /**
  85155. * Helper used to simplify some generic gradient tasks
  85156. */
  85157. export class GradientHelper {
  85158. /**
  85159. * Gets the current gradient from an array of IValueGradient
  85160. * @param ratio defines the current ratio to get
  85161. * @param gradients defines the array of IValueGradient
  85162. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85163. */
  85164. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85165. }
  85166. }
  85167. declare module BABYLON {
  85168. interface ThinEngine {
  85169. /**
  85170. * Creates a dynamic texture
  85171. * @param width defines the width of the texture
  85172. * @param height defines the height of the texture
  85173. * @param generateMipMaps defines if the engine should generate the mip levels
  85174. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85175. * @returns the dynamic texture inside an InternalTexture
  85176. */
  85177. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85178. /**
  85179. * Update the content of a dynamic texture
  85180. * @param texture defines the texture to update
  85181. * @param canvas defines the canvas containing the source
  85182. * @param invertY defines if data must be stored with Y axis inverted
  85183. * @param premulAlpha defines if alpha is stored as premultiplied
  85184. * @param format defines the format of the data
  85185. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85186. */
  85187. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85188. }
  85189. }
  85190. declare module BABYLON {
  85191. /**
  85192. * Helper class used to generate a canvas to manipulate images
  85193. */
  85194. export class CanvasGenerator {
  85195. /**
  85196. * Create a new canvas (or offscreen canvas depending on the context)
  85197. * @param width defines the expected width
  85198. * @param height defines the expected height
  85199. * @return a new canvas or offscreen canvas
  85200. */
  85201. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85202. }
  85203. }
  85204. declare module BABYLON {
  85205. /**
  85206. * A class extending Texture allowing drawing on a texture
  85207. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85208. */
  85209. export class DynamicTexture extends Texture {
  85210. private _generateMipMaps;
  85211. private _canvas;
  85212. private _context;
  85213. private _engine;
  85214. /**
  85215. * Creates a DynamicTexture
  85216. * @param name defines the name of the texture
  85217. * @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
  85218. * @param scene defines the scene where you want the texture
  85219. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85220. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85221. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85222. */
  85223. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85224. /**
  85225. * Get the current class name of the texture useful for serialization or dynamic coding.
  85226. * @returns "DynamicTexture"
  85227. */
  85228. getClassName(): string;
  85229. /**
  85230. * Gets the current state of canRescale
  85231. */
  85232. readonly canRescale: boolean;
  85233. private _recreate;
  85234. /**
  85235. * Scales the texture
  85236. * @param ratio the scale factor to apply to both width and height
  85237. */
  85238. scale(ratio: number): void;
  85239. /**
  85240. * Resizes the texture
  85241. * @param width the new width
  85242. * @param height the new height
  85243. */
  85244. scaleTo(width: number, height: number): void;
  85245. /**
  85246. * Gets the context of the canvas used by the texture
  85247. * @returns the canvas context of the dynamic texture
  85248. */
  85249. getContext(): CanvasRenderingContext2D;
  85250. /**
  85251. * Clears the texture
  85252. */
  85253. clear(): void;
  85254. /**
  85255. * Updates the texture
  85256. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85257. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85258. */
  85259. update(invertY?: boolean, premulAlpha?: boolean): void;
  85260. /**
  85261. * Draws text onto the texture
  85262. * @param text defines the text to be drawn
  85263. * @param x defines the placement of the text from the left
  85264. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85265. * @param font defines the font to be used with font-style, font-size, font-name
  85266. * @param color defines the color used for the text
  85267. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85268. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85269. * @param update defines whether texture is immediately update (default is true)
  85270. */
  85271. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85272. /**
  85273. * Clones the texture
  85274. * @returns the clone of the texture.
  85275. */
  85276. clone(): DynamicTexture;
  85277. /**
  85278. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85279. * @returns a serialized dynamic texture object
  85280. */
  85281. serialize(): any;
  85282. /** @hidden */
  85283. _rebuild(): void;
  85284. }
  85285. }
  85286. declare module BABYLON {
  85287. interface AbstractScene {
  85288. /**
  85289. * The list of procedural textures added to the scene
  85290. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85291. */
  85292. proceduralTextures: Array<ProceduralTexture>;
  85293. }
  85294. /**
  85295. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85296. * in a given scene.
  85297. */
  85298. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85299. /**
  85300. * The component name helpfull to identify the component in the list of scene components.
  85301. */
  85302. readonly name: string;
  85303. /**
  85304. * The scene the component belongs to.
  85305. */
  85306. scene: Scene;
  85307. /**
  85308. * Creates a new instance of the component for the given scene
  85309. * @param scene Defines the scene to register the component in
  85310. */
  85311. constructor(scene: Scene);
  85312. /**
  85313. * Registers the component in a given scene
  85314. */
  85315. register(): void;
  85316. /**
  85317. * Rebuilds the elements related to this component in case of
  85318. * context lost for instance.
  85319. */
  85320. rebuild(): void;
  85321. /**
  85322. * Disposes the component and the associated ressources.
  85323. */
  85324. dispose(): void;
  85325. private _beforeClear;
  85326. }
  85327. }
  85328. declare module BABYLON {
  85329. interface ThinEngine {
  85330. /**
  85331. * Creates a new render target cube texture
  85332. * @param size defines the size of the texture
  85333. * @param options defines the options used to create the texture
  85334. * @returns a new render target cube texture stored in an InternalTexture
  85335. */
  85336. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85337. }
  85338. }
  85339. declare module BABYLON {
  85340. /** @hidden */
  85341. export var proceduralVertexShader: {
  85342. name: string;
  85343. shader: string;
  85344. };
  85345. }
  85346. declare module BABYLON {
  85347. /**
  85348. * 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.
  85349. * This is the base class of any Procedural texture and contains most of the shareable code.
  85350. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85351. */
  85352. export class ProceduralTexture extends Texture {
  85353. isCube: boolean;
  85354. /**
  85355. * Define if the texture is enabled or not (disabled texture will not render)
  85356. */
  85357. isEnabled: boolean;
  85358. /**
  85359. * Define if the texture must be cleared before rendering (default is true)
  85360. */
  85361. autoClear: boolean;
  85362. /**
  85363. * Callback called when the texture is generated
  85364. */
  85365. onGenerated: () => void;
  85366. /**
  85367. * Event raised when the texture is generated
  85368. */
  85369. onGeneratedObservable: Observable<ProceduralTexture>;
  85370. /** @hidden */
  85371. _generateMipMaps: boolean;
  85372. /** @hidden **/
  85373. _effect: Effect;
  85374. /** @hidden */
  85375. _textures: {
  85376. [key: string]: Texture;
  85377. };
  85378. private _size;
  85379. private _currentRefreshId;
  85380. private _refreshRate;
  85381. private _vertexBuffers;
  85382. private _indexBuffer;
  85383. private _uniforms;
  85384. private _samplers;
  85385. private _fragment;
  85386. private _floats;
  85387. private _ints;
  85388. private _floatsArrays;
  85389. private _colors3;
  85390. private _colors4;
  85391. private _vectors2;
  85392. private _vectors3;
  85393. private _matrices;
  85394. private _fallbackTexture;
  85395. private _fallbackTextureUsed;
  85396. private _engine;
  85397. private _cachedDefines;
  85398. private _contentUpdateId;
  85399. private _contentData;
  85400. /**
  85401. * Instantiates a new procedural texture.
  85402. * 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.
  85403. * This is the base class of any Procedural texture and contains most of the shareable code.
  85404. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85405. * @param name Define the name of the texture
  85406. * @param size Define the size of the texture to create
  85407. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85408. * @param scene Define the scene the texture belongs to
  85409. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85410. * @param generateMipMaps Define if the texture should creates mip maps or not
  85411. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85412. */
  85413. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85414. /**
  85415. * The effect that is created when initializing the post process.
  85416. * @returns The created effect corresponding the the postprocess.
  85417. */
  85418. getEffect(): Effect;
  85419. /**
  85420. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85421. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85422. */
  85423. getContent(): Nullable<ArrayBufferView>;
  85424. private _createIndexBuffer;
  85425. /** @hidden */
  85426. _rebuild(): void;
  85427. /**
  85428. * Resets the texture in order to recreate its associated resources.
  85429. * This can be called in case of context loss
  85430. */
  85431. reset(): void;
  85432. protected _getDefines(): string;
  85433. /**
  85434. * Is the texture ready to be used ? (rendered at least once)
  85435. * @returns true if ready, otherwise, false.
  85436. */
  85437. isReady(): boolean;
  85438. /**
  85439. * Resets the refresh counter of the texture and start bak from scratch.
  85440. * Could be useful to regenerate the texture if it is setup to render only once.
  85441. */
  85442. resetRefreshCounter(): void;
  85443. /**
  85444. * Set the fragment shader to use in order to render the texture.
  85445. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85446. */
  85447. setFragment(fragment: any): void;
  85448. /**
  85449. * Define the refresh rate of the texture or the rendering frequency.
  85450. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85451. */
  85452. refreshRate: number;
  85453. /** @hidden */
  85454. _shouldRender(): boolean;
  85455. /**
  85456. * Get the size the texture is rendering at.
  85457. * @returns the size (texture is always squared)
  85458. */
  85459. getRenderSize(): number;
  85460. /**
  85461. * Resize the texture to new value.
  85462. * @param size Define the new size the texture should have
  85463. * @param generateMipMaps Define whether the new texture should create mip maps
  85464. */
  85465. resize(size: number, generateMipMaps: boolean): void;
  85466. private _checkUniform;
  85467. /**
  85468. * Set a texture in the shader program used to render.
  85469. * @param name Define the name of the uniform samplers as defined in the shader
  85470. * @param texture Define the texture to bind to this sampler
  85471. * @return the texture itself allowing "fluent" like uniform updates
  85472. */
  85473. setTexture(name: string, texture: Texture): ProceduralTexture;
  85474. /**
  85475. * Set a float in the shader.
  85476. * @param name Define the name of the uniform as defined in the shader
  85477. * @param value Define the value to give to the uniform
  85478. * @return the texture itself allowing "fluent" like uniform updates
  85479. */
  85480. setFloat(name: string, value: number): ProceduralTexture;
  85481. /**
  85482. * Set a int in the shader.
  85483. * @param name Define the name of the uniform as defined in the shader
  85484. * @param value Define the value to give to the uniform
  85485. * @return the texture itself allowing "fluent" like uniform updates
  85486. */
  85487. setInt(name: string, value: number): ProceduralTexture;
  85488. /**
  85489. * Set an array of floats in the shader.
  85490. * @param name Define the name of the uniform as defined in the shader
  85491. * @param value Define the value to give to the uniform
  85492. * @return the texture itself allowing "fluent" like uniform updates
  85493. */
  85494. setFloats(name: string, value: number[]): ProceduralTexture;
  85495. /**
  85496. * Set a vec3 in the shader from a Color3.
  85497. * @param name Define the name of the uniform as defined in the shader
  85498. * @param value Define the value to give to the uniform
  85499. * @return the texture itself allowing "fluent" like uniform updates
  85500. */
  85501. setColor3(name: string, value: Color3): ProceduralTexture;
  85502. /**
  85503. * Set a vec4 in the shader from a Color4.
  85504. * @param name Define the name of the uniform as defined in the shader
  85505. * @param value Define the value to give to the uniform
  85506. * @return the texture itself allowing "fluent" like uniform updates
  85507. */
  85508. setColor4(name: string, value: Color4): ProceduralTexture;
  85509. /**
  85510. * Set a vec2 in the shader from a Vector2.
  85511. * @param name Define the name of the uniform as defined in the shader
  85512. * @param value Define the value to give to the uniform
  85513. * @return the texture itself allowing "fluent" like uniform updates
  85514. */
  85515. setVector2(name: string, value: Vector2): ProceduralTexture;
  85516. /**
  85517. * Set a vec3 in the shader from a Vector3.
  85518. * @param name Define the name of the uniform as defined in the shader
  85519. * @param value Define the value to give to the uniform
  85520. * @return the texture itself allowing "fluent" like uniform updates
  85521. */
  85522. setVector3(name: string, value: Vector3): ProceduralTexture;
  85523. /**
  85524. * Set a mat4 in the shader from a MAtrix.
  85525. * @param name Define the name of the uniform as defined in the shader
  85526. * @param value Define the value to give to the uniform
  85527. * @return the texture itself allowing "fluent" like uniform updates
  85528. */
  85529. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85530. /**
  85531. * Render the texture to its associated render target.
  85532. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85533. */
  85534. render(useCameraPostProcess?: boolean): void;
  85535. /**
  85536. * Clone the texture.
  85537. * @returns the cloned texture
  85538. */
  85539. clone(): ProceduralTexture;
  85540. /**
  85541. * Dispose the texture and release its asoociated resources.
  85542. */
  85543. dispose(): void;
  85544. }
  85545. }
  85546. declare module BABYLON {
  85547. /**
  85548. * This represents the base class for particle system in Babylon.
  85549. * 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.
  85550. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85551. * @example https://doc.babylonjs.com/babylon101/particles
  85552. */
  85553. export class BaseParticleSystem {
  85554. /**
  85555. * Source color is added to the destination color without alpha affecting the result
  85556. */
  85557. static BLENDMODE_ONEONE: number;
  85558. /**
  85559. * Blend current color and particle color using particle’s alpha
  85560. */
  85561. static BLENDMODE_STANDARD: number;
  85562. /**
  85563. * Add current color and particle color multiplied by particle’s alpha
  85564. */
  85565. static BLENDMODE_ADD: number;
  85566. /**
  85567. * Multiply current color with particle color
  85568. */
  85569. static BLENDMODE_MULTIPLY: number;
  85570. /**
  85571. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85572. */
  85573. static BLENDMODE_MULTIPLYADD: number;
  85574. /**
  85575. * List of animations used by the particle system.
  85576. */
  85577. animations: Animation[];
  85578. /**
  85579. * The id of the Particle system.
  85580. */
  85581. id: string;
  85582. /**
  85583. * The friendly name of the Particle system.
  85584. */
  85585. name: string;
  85586. /**
  85587. * The rendering group used by the Particle system to chose when to render.
  85588. */
  85589. renderingGroupId: number;
  85590. /**
  85591. * The emitter represents the Mesh or position we are attaching the particle system to.
  85592. */
  85593. emitter: Nullable<AbstractMesh | Vector3>;
  85594. /**
  85595. * The maximum number of particles to emit per frame
  85596. */
  85597. emitRate: number;
  85598. /**
  85599. * If you want to launch only a few particles at once, that can be done, as well.
  85600. */
  85601. manualEmitCount: number;
  85602. /**
  85603. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85604. */
  85605. updateSpeed: number;
  85606. /**
  85607. * The amount of time the particle system is running (depends of the overall update speed).
  85608. */
  85609. targetStopDuration: number;
  85610. /**
  85611. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85612. */
  85613. disposeOnStop: boolean;
  85614. /**
  85615. * Minimum power of emitting particles.
  85616. */
  85617. minEmitPower: number;
  85618. /**
  85619. * Maximum power of emitting particles.
  85620. */
  85621. maxEmitPower: number;
  85622. /**
  85623. * Minimum life time of emitting particles.
  85624. */
  85625. minLifeTime: number;
  85626. /**
  85627. * Maximum life time of emitting particles.
  85628. */
  85629. maxLifeTime: number;
  85630. /**
  85631. * Minimum Size of emitting particles.
  85632. */
  85633. minSize: number;
  85634. /**
  85635. * Maximum Size of emitting particles.
  85636. */
  85637. maxSize: number;
  85638. /**
  85639. * Minimum scale of emitting particles on X axis.
  85640. */
  85641. minScaleX: number;
  85642. /**
  85643. * Maximum scale of emitting particles on X axis.
  85644. */
  85645. maxScaleX: number;
  85646. /**
  85647. * Minimum scale of emitting particles on Y axis.
  85648. */
  85649. minScaleY: number;
  85650. /**
  85651. * Maximum scale of emitting particles on Y axis.
  85652. */
  85653. maxScaleY: number;
  85654. /**
  85655. * Gets or sets the minimal initial rotation in radians.
  85656. */
  85657. minInitialRotation: number;
  85658. /**
  85659. * Gets or sets the maximal initial rotation in radians.
  85660. */
  85661. maxInitialRotation: number;
  85662. /**
  85663. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85664. */
  85665. minAngularSpeed: number;
  85666. /**
  85667. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85668. */
  85669. maxAngularSpeed: number;
  85670. /**
  85671. * The texture used to render each particle. (this can be a spritesheet)
  85672. */
  85673. particleTexture: Nullable<Texture>;
  85674. /**
  85675. * The layer mask we are rendering the particles through.
  85676. */
  85677. layerMask: number;
  85678. /**
  85679. * This can help using your own shader to render the particle system.
  85680. * The according effect will be created
  85681. */
  85682. customShader: any;
  85683. /**
  85684. * By default particle system starts as soon as they are created. This prevents the
  85685. * automatic start to happen and let you decide when to start emitting particles.
  85686. */
  85687. preventAutoStart: boolean;
  85688. private _noiseTexture;
  85689. /**
  85690. * Gets or sets a texture used to add random noise to particle positions
  85691. */
  85692. noiseTexture: Nullable<ProceduralTexture>;
  85693. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85694. noiseStrength: Vector3;
  85695. /**
  85696. * Callback triggered when the particle animation is ending.
  85697. */
  85698. onAnimationEnd: Nullable<() => void>;
  85699. /**
  85700. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85701. */
  85702. blendMode: number;
  85703. /**
  85704. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85705. * to override the particles.
  85706. */
  85707. forceDepthWrite: boolean;
  85708. /** 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 */
  85709. preWarmCycles: number;
  85710. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85711. preWarmStepOffset: number;
  85712. /**
  85713. * 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)
  85714. */
  85715. spriteCellChangeSpeed: number;
  85716. /**
  85717. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85718. */
  85719. startSpriteCellID: number;
  85720. /**
  85721. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85722. */
  85723. endSpriteCellID: number;
  85724. /**
  85725. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85726. */
  85727. spriteCellWidth: number;
  85728. /**
  85729. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85730. */
  85731. spriteCellHeight: number;
  85732. /**
  85733. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85734. */
  85735. spriteRandomStartCell: boolean;
  85736. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85737. translationPivot: Vector2;
  85738. /** @hidden */
  85739. protected _isAnimationSheetEnabled: boolean;
  85740. /**
  85741. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85742. */
  85743. beginAnimationOnStart: boolean;
  85744. /**
  85745. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85746. */
  85747. beginAnimationFrom: number;
  85748. /**
  85749. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85750. */
  85751. beginAnimationTo: number;
  85752. /**
  85753. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85754. */
  85755. beginAnimationLoop: boolean;
  85756. /**
  85757. * Gets or sets a world offset applied to all particles
  85758. */
  85759. worldOffset: Vector3;
  85760. /**
  85761. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85762. */
  85763. isAnimationSheetEnabled: boolean;
  85764. /**
  85765. * Get hosting scene
  85766. * @returns the scene
  85767. */
  85768. getScene(): Scene;
  85769. /**
  85770. * You can use gravity if you want to give an orientation to your particles.
  85771. */
  85772. gravity: Vector3;
  85773. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85774. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85775. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85776. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85777. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85778. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85779. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85780. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85781. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85782. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85783. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85784. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85785. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85786. /**
  85787. * Defines the delay in milliseconds before starting the system (0 by default)
  85788. */
  85789. startDelay: number;
  85790. /**
  85791. * Gets the current list of drag gradients.
  85792. * You must use addDragGradient and removeDragGradient to udpate this list
  85793. * @returns the list of drag gradients
  85794. */
  85795. getDragGradients(): Nullable<Array<FactorGradient>>;
  85796. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85797. limitVelocityDamping: number;
  85798. /**
  85799. * Gets the current list of limit velocity gradients.
  85800. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85801. * @returns the list of limit velocity gradients
  85802. */
  85803. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85804. /**
  85805. * Gets the current list of color gradients.
  85806. * You must use addColorGradient and removeColorGradient to udpate this list
  85807. * @returns the list of color gradients
  85808. */
  85809. getColorGradients(): Nullable<Array<ColorGradient>>;
  85810. /**
  85811. * Gets the current list of size gradients.
  85812. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85813. * @returns the list of size gradients
  85814. */
  85815. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85816. /**
  85817. * Gets the current list of color remap gradients.
  85818. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85819. * @returns the list of color remap gradients
  85820. */
  85821. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85822. /**
  85823. * Gets the current list of alpha remap gradients.
  85824. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85825. * @returns the list of alpha remap gradients
  85826. */
  85827. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85828. /**
  85829. * Gets the current list of life time gradients.
  85830. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85831. * @returns the list of life time gradients
  85832. */
  85833. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85834. /**
  85835. * Gets the current list of angular speed gradients.
  85836. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85837. * @returns the list of angular speed gradients
  85838. */
  85839. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85840. /**
  85841. * Gets the current list of velocity gradients.
  85842. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85843. * @returns the list of velocity gradients
  85844. */
  85845. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85846. /**
  85847. * Gets the current list of start size gradients.
  85848. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85849. * @returns the list of start size gradients
  85850. */
  85851. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85852. /**
  85853. * Gets the current list of emit rate gradients.
  85854. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85855. * @returns the list of emit rate gradients
  85856. */
  85857. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85858. /**
  85859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85860. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85861. */
  85862. direction1: Vector3;
  85863. /**
  85864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85865. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85866. */
  85867. direction2: Vector3;
  85868. /**
  85869. * 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.
  85870. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85871. */
  85872. minEmitBox: Vector3;
  85873. /**
  85874. * 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.
  85875. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85876. */
  85877. maxEmitBox: Vector3;
  85878. /**
  85879. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85880. */
  85881. color1: Color4;
  85882. /**
  85883. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85884. */
  85885. color2: Color4;
  85886. /**
  85887. * Color the particle will have at the end of its lifetime
  85888. */
  85889. colorDead: Color4;
  85890. /**
  85891. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85892. */
  85893. textureMask: Color4;
  85894. /**
  85895. * The particle emitter type defines the emitter used by the particle system.
  85896. * It can be for example box, sphere, or cone...
  85897. */
  85898. particleEmitterType: IParticleEmitterType;
  85899. /** @hidden */
  85900. _isSubEmitter: boolean;
  85901. /**
  85902. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85903. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85904. */
  85905. billboardMode: number;
  85906. protected _isBillboardBased: boolean;
  85907. /**
  85908. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85909. */
  85910. isBillboardBased: boolean;
  85911. /**
  85912. * The scene the particle system belongs to.
  85913. */
  85914. protected _scene: Scene;
  85915. /**
  85916. * Local cache of defines for image processing.
  85917. */
  85918. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85919. /**
  85920. * Default configuration related to image processing available in the standard Material.
  85921. */
  85922. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85923. /**
  85924. * Gets the image processing configuration used either in this material.
  85925. */
  85926. /**
  85927. * Sets the Default image processing configuration used either in the this material.
  85928. *
  85929. * If sets to null, the scene one is in use.
  85930. */
  85931. imageProcessingConfiguration: ImageProcessingConfiguration;
  85932. /**
  85933. * Attaches a new image processing configuration to the Standard Material.
  85934. * @param configuration
  85935. */
  85936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85937. /** @hidden */
  85938. protected _reset(): void;
  85939. /** @hidden */
  85940. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85941. /**
  85942. * Instantiates a particle system.
  85943. * 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.
  85944. * @param name The name of the particle system
  85945. */
  85946. constructor(name: string);
  85947. /**
  85948. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85949. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85950. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85951. * @returns the emitter
  85952. */
  85953. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85954. /**
  85955. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85956. * @param radius The radius of the hemisphere to emit from
  85957. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85958. * @returns the emitter
  85959. */
  85960. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85961. /**
  85962. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85963. * @param radius The radius of the sphere to emit from
  85964. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85965. * @returns the emitter
  85966. */
  85967. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85968. /**
  85969. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85970. * @param radius The radius of the sphere to emit from
  85971. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85972. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85973. * @returns the emitter
  85974. */
  85975. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85976. /**
  85977. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85978. * @param radius The radius of the emission cylinder
  85979. * @param height The height of the emission cylinder
  85980. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85981. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85982. * @returns the emitter
  85983. */
  85984. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85985. /**
  85986. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85987. * @param radius The radius of the cylinder to emit from
  85988. * @param height The height of the emission cylinder
  85989. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85992. * @returns the emitter
  85993. */
  85994. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85995. /**
  85996. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85997. * @param radius The radius of the cone to emit from
  85998. * @param angle The base angle of the cone
  85999. * @returns the emitter
  86000. */
  86001. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86002. /**
  86003. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86004. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86005. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86006. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86007. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86008. * @returns the emitter
  86009. */
  86010. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86011. }
  86012. }
  86013. declare module BABYLON {
  86014. /**
  86015. * Type of sub emitter
  86016. */
  86017. export enum SubEmitterType {
  86018. /**
  86019. * Attached to the particle over it's lifetime
  86020. */
  86021. ATTACHED = 0,
  86022. /**
  86023. * Created when the particle dies
  86024. */
  86025. END = 1
  86026. }
  86027. /**
  86028. * Sub emitter class used to emit particles from an existing particle
  86029. */
  86030. export class SubEmitter {
  86031. /**
  86032. * the particle system to be used by the sub emitter
  86033. */
  86034. particleSystem: ParticleSystem;
  86035. /**
  86036. * Type of the submitter (Default: END)
  86037. */
  86038. type: SubEmitterType;
  86039. /**
  86040. * 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)
  86041. * Note: This only is supported when using an emitter of type Mesh
  86042. */
  86043. inheritDirection: boolean;
  86044. /**
  86045. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86046. */
  86047. inheritedVelocityAmount: number;
  86048. /**
  86049. * Creates a sub emitter
  86050. * @param particleSystem the particle system to be used by the sub emitter
  86051. */
  86052. constructor(
  86053. /**
  86054. * the particle system to be used by the sub emitter
  86055. */
  86056. particleSystem: ParticleSystem);
  86057. /**
  86058. * Clones the sub emitter
  86059. * @returns the cloned sub emitter
  86060. */
  86061. clone(): SubEmitter;
  86062. /**
  86063. * Serialize current object to a JSON object
  86064. * @returns the serialized object
  86065. */
  86066. serialize(): any;
  86067. /** @hidden */
  86068. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86069. /**
  86070. * Creates a new SubEmitter from a serialized JSON version
  86071. * @param serializationObject defines the JSON object to read from
  86072. * @param scene defines the hosting scene
  86073. * @param rootUrl defines the rootUrl for data loading
  86074. * @returns a new SubEmitter
  86075. */
  86076. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86077. /** Release associated resources */
  86078. dispose(): void;
  86079. }
  86080. }
  86081. declare module BABYLON {
  86082. /** @hidden */
  86083. export var clipPlaneFragmentDeclaration: {
  86084. name: string;
  86085. shader: string;
  86086. };
  86087. }
  86088. declare module BABYLON {
  86089. /** @hidden */
  86090. export var imageProcessingDeclaration: {
  86091. name: string;
  86092. shader: string;
  86093. };
  86094. }
  86095. declare module BABYLON {
  86096. /** @hidden */
  86097. export var imageProcessingFunctions: {
  86098. name: string;
  86099. shader: string;
  86100. };
  86101. }
  86102. declare module BABYLON {
  86103. /** @hidden */
  86104. export var clipPlaneFragment: {
  86105. name: string;
  86106. shader: string;
  86107. };
  86108. }
  86109. declare module BABYLON {
  86110. /** @hidden */
  86111. export var particlesPixelShader: {
  86112. name: string;
  86113. shader: string;
  86114. };
  86115. }
  86116. declare module BABYLON {
  86117. /** @hidden */
  86118. export var clipPlaneVertexDeclaration: {
  86119. name: string;
  86120. shader: string;
  86121. };
  86122. }
  86123. declare module BABYLON {
  86124. /** @hidden */
  86125. export var clipPlaneVertex: {
  86126. name: string;
  86127. shader: string;
  86128. };
  86129. }
  86130. declare module BABYLON {
  86131. /** @hidden */
  86132. export var particlesVertexShader: {
  86133. name: string;
  86134. shader: string;
  86135. };
  86136. }
  86137. declare module BABYLON {
  86138. /**
  86139. * This represents a particle system in Babylon.
  86140. * 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.
  86141. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86142. * @example https://doc.babylonjs.com/babylon101/particles
  86143. */
  86144. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86145. /**
  86146. * Billboard mode will only apply to Y axis
  86147. */
  86148. static readonly BILLBOARDMODE_Y: number;
  86149. /**
  86150. * Billboard mode will apply to all axes
  86151. */
  86152. static readonly BILLBOARDMODE_ALL: number;
  86153. /**
  86154. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86155. */
  86156. static readonly BILLBOARDMODE_STRETCHED: number;
  86157. /**
  86158. * This function can be defined to provide custom update for active particles.
  86159. * This function will be called instead of regular update (age, position, color, etc.).
  86160. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86161. */
  86162. updateFunction: (particles: Particle[]) => void;
  86163. private _emitterWorldMatrix;
  86164. /**
  86165. * This function can be defined to specify initial direction for every new particle.
  86166. * It by default use the emitterType defined function
  86167. */
  86168. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86169. /**
  86170. * This function can be defined to specify initial position for every new particle.
  86171. * It by default use the emitterType defined function
  86172. */
  86173. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86174. /**
  86175. * @hidden
  86176. */
  86177. _inheritedVelocityOffset: Vector3;
  86178. /**
  86179. * An event triggered when the system is disposed
  86180. */
  86181. onDisposeObservable: Observable<ParticleSystem>;
  86182. private _onDisposeObserver;
  86183. /**
  86184. * Sets a callback that will be triggered when the system is disposed
  86185. */
  86186. onDispose: () => void;
  86187. private _particles;
  86188. private _epsilon;
  86189. private _capacity;
  86190. private _stockParticles;
  86191. private _newPartsExcess;
  86192. private _vertexData;
  86193. private _vertexBuffer;
  86194. private _vertexBuffers;
  86195. private _spriteBuffer;
  86196. private _indexBuffer;
  86197. private _effect;
  86198. private _customEffect;
  86199. private _cachedDefines;
  86200. private _scaledColorStep;
  86201. private _colorDiff;
  86202. private _scaledDirection;
  86203. private _scaledGravity;
  86204. private _currentRenderId;
  86205. private _alive;
  86206. private _useInstancing;
  86207. private _started;
  86208. private _stopped;
  86209. private _actualFrame;
  86210. private _scaledUpdateSpeed;
  86211. private _vertexBufferSize;
  86212. /** @hidden */
  86213. _currentEmitRateGradient: Nullable<FactorGradient>;
  86214. /** @hidden */
  86215. _currentEmitRate1: number;
  86216. /** @hidden */
  86217. _currentEmitRate2: number;
  86218. /** @hidden */
  86219. _currentStartSizeGradient: Nullable<FactorGradient>;
  86220. /** @hidden */
  86221. _currentStartSize1: number;
  86222. /** @hidden */
  86223. _currentStartSize2: number;
  86224. private readonly _rawTextureWidth;
  86225. private _rampGradientsTexture;
  86226. private _useRampGradients;
  86227. /** Gets or sets a boolean indicating that ramp gradients must be used
  86228. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86229. */
  86230. useRampGradients: boolean;
  86231. /**
  86232. * 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.
  86233. * 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: [])
  86234. */
  86235. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86236. private _subEmitters;
  86237. /**
  86238. * @hidden
  86239. * If the particle systems emitter should be disposed when the particle system is disposed
  86240. */
  86241. _disposeEmitterOnDispose: boolean;
  86242. /**
  86243. * The current active Sub-systems, this property is used by the root particle system only.
  86244. */
  86245. activeSubSystems: Array<ParticleSystem>;
  86246. private _rootParticleSystem;
  86247. /**
  86248. * Gets the current list of active particles
  86249. */
  86250. readonly particles: Particle[];
  86251. /**
  86252. * Returns the string "ParticleSystem"
  86253. * @returns a string containing the class name
  86254. */
  86255. getClassName(): string;
  86256. /**
  86257. * Instantiates a particle system.
  86258. * 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.
  86259. * @param name The name of the particle system
  86260. * @param capacity The max number of particles alive at the same time
  86261. * @param scene The scene the particle system belongs to
  86262. * @param customEffect a custom effect used to change the way particles are rendered by default
  86263. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86264. * @param epsilon Offset used to render the particles
  86265. */
  86266. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86267. private _addFactorGradient;
  86268. private _removeFactorGradient;
  86269. /**
  86270. * Adds a new life time gradient
  86271. * @param gradient defines the gradient to use (between 0 and 1)
  86272. * @param factor defines the life time factor to affect to the specified gradient
  86273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86274. * @returns the current particle system
  86275. */
  86276. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86277. /**
  86278. * Remove a specific life time gradient
  86279. * @param gradient defines the gradient to remove
  86280. * @returns the current particle system
  86281. */
  86282. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86283. /**
  86284. * Adds a new size gradient
  86285. * @param gradient defines the gradient to use (between 0 and 1)
  86286. * @param factor defines the size factor to affect to the specified gradient
  86287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86288. * @returns the current particle system
  86289. */
  86290. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86291. /**
  86292. * Remove a specific size gradient
  86293. * @param gradient defines the gradient to remove
  86294. * @returns the current particle system
  86295. */
  86296. removeSizeGradient(gradient: number): IParticleSystem;
  86297. /**
  86298. * Adds a new color remap gradient
  86299. * @param gradient defines the gradient to use (between 0 and 1)
  86300. * @param min defines the color remap minimal range
  86301. * @param max defines the color remap maximal range
  86302. * @returns the current particle system
  86303. */
  86304. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86305. /**
  86306. * Remove a specific color remap gradient
  86307. * @param gradient defines the gradient to remove
  86308. * @returns the current particle system
  86309. */
  86310. removeColorRemapGradient(gradient: number): IParticleSystem;
  86311. /**
  86312. * Adds a new alpha remap gradient
  86313. * @param gradient defines the gradient to use (between 0 and 1)
  86314. * @param min defines the alpha remap minimal range
  86315. * @param max defines the alpha remap maximal range
  86316. * @returns the current particle system
  86317. */
  86318. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86319. /**
  86320. * Remove a specific alpha remap gradient
  86321. * @param gradient defines the gradient to remove
  86322. * @returns the current particle system
  86323. */
  86324. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86325. /**
  86326. * Adds a new angular speed gradient
  86327. * @param gradient defines the gradient to use (between 0 and 1)
  86328. * @param factor defines the angular speed to affect to the specified gradient
  86329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86330. * @returns the current particle system
  86331. */
  86332. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86333. /**
  86334. * Remove a specific angular speed gradient
  86335. * @param gradient defines the gradient to remove
  86336. * @returns the current particle system
  86337. */
  86338. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86339. /**
  86340. * Adds a new velocity gradient
  86341. * @param gradient defines the gradient to use (between 0 and 1)
  86342. * @param factor defines the velocity to affect to the specified gradient
  86343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86344. * @returns the current particle system
  86345. */
  86346. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86347. /**
  86348. * Remove a specific velocity gradient
  86349. * @param gradient defines the gradient to remove
  86350. * @returns the current particle system
  86351. */
  86352. removeVelocityGradient(gradient: number): IParticleSystem;
  86353. /**
  86354. * Adds a new limit velocity gradient
  86355. * @param gradient defines the gradient to use (between 0 and 1)
  86356. * @param factor defines the limit velocity value to affect to the specified gradient
  86357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86358. * @returns the current particle system
  86359. */
  86360. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86361. /**
  86362. * Remove a specific limit velocity gradient
  86363. * @param gradient defines the gradient to remove
  86364. * @returns the current particle system
  86365. */
  86366. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86367. /**
  86368. * Adds a new drag gradient
  86369. * @param gradient defines the gradient to use (between 0 and 1)
  86370. * @param factor defines the drag value to affect to the specified gradient
  86371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86372. * @returns the current particle system
  86373. */
  86374. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86375. /**
  86376. * Remove a specific drag gradient
  86377. * @param gradient defines the gradient to remove
  86378. * @returns the current particle system
  86379. */
  86380. removeDragGradient(gradient: number): IParticleSystem;
  86381. /**
  86382. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86383. * @param gradient defines the gradient to use (between 0 and 1)
  86384. * @param factor defines the emit rate value to affect to the specified gradient
  86385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86386. * @returns the current particle system
  86387. */
  86388. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86389. /**
  86390. * Remove a specific emit rate gradient
  86391. * @param gradient defines the gradient to remove
  86392. * @returns the current particle system
  86393. */
  86394. removeEmitRateGradient(gradient: number): IParticleSystem;
  86395. /**
  86396. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86397. * @param gradient defines the gradient to use (between 0 and 1)
  86398. * @param factor defines the start size value to affect to the specified gradient
  86399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86400. * @returns the current particle system
  86401. */
  86402. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86403. /**
  86404. * Remove a specific start size gradient
  86405. * @param gradient defines the gradient to remove
  86406. * @returns the current particle system
  86407. */
  86408. removeStartSizeGradient(gradient: number): IParticleSystem;
  86409. private _createRampGradientTexture;
  86410. /**
  86411. * Gets the current list of ramp gradients.
  86412. * You must use addRampGradient and removeRampGradient to udpate this list
  86413. * @returns the list of ramp gradients
  86414. */
  86415. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86416. /**
  86417. * Adds a new ramp gradient used to remap particle colors
  86418. * @param gradient defines the gradient to use (between 0 and 1)
  86419. * @param color defines the color to affect to the specified gradient
  86420. * @returns the current particle system
  86421. */
  86422. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86423. /**
  86424. * Remove a specific ramp gradient
  86425. * @param gradient defines the gradient to remove
  86426. * @returns the current particle system
  86427. */
  86428. removeRampGradient(gradient: number): ParticleSystem;
  86429. /**
  86430. * Adds a new color gradient
  86431. * @param gradient defines the gradient to use (between 0 and 1)
  86432. * @param color1 defines the color to affect to the specified gradient
  86433. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86434. * @returns this particle system
  86435. */
  86436. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86437. /**
  86438. * Remove a specific color gradient
  86439. * @param gradient defines the gradient to remove
  86440. * @returns this particle system
  86441. */
  86442. removeColorGradient(gradient: number): IParticleSystem;
  86443. private _fetchR;
  86444. protected _reset(): void;
  86445. private _resetEffect;
  86446. private _createVertexBuffers;
  86447. private _createIndexBuffer;
  86448. /**
  86449. * Gets the maximum number of particles active at the same time.
  86450. * @returns The max number of active particles.
  86451. */
  86452. getCapacity(): number;
  86453. /**
  86454. * Gets whether there are still active particles in the system.
  86455. * @returns True if it is alive, otherwise false.
  86456. */
  86457. isAlive(): boolean;
  86458. /**
  86459. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86460. * @returns True if it has been started, otherwise false.
  86461. */
  86462. isStarted(): boolean;
  86463. private _prepareSubEmitterInternalArray;
  86464. /**
  86465. * Starts the particle system and begins to emit
  86466. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86467. */
  86468. start(delay?: number): void;
  86469. /**
  86470. * Stops the particle system.
  86471. * @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.
  86472. */
  86473. stop(stopSubEmitters?: boolean): void;
  86474. /**
  86475. * Remove all active particles
  86476. */
  86477. reset(): void;
  86478. /**
  86479. * @hidden (for internal use only)
  86480. */
  86481. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86482. /**
  86483. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86484. * Its lifetime will start back at 0.
  86485. */
  86486. recycleParticle: (particle: Particle) => void;
  86487. private _stopSubEmitters;
  86488. private _createParticle;
  86489. private _removeFromRoot;
  86490. private _emitFromParticle;
  86491. private _update;
  86492. /** @hidden */
  86493. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86494. /** @hidden */
  86495. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86496. /** @hidden */
  86497. private _getEffect;
  86498. /**
  86499. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86500. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86501. */
  86502. animate(preWarmOnly?: boolean): void;
  86503. private _appendParticleVertices;
  86504. /**
  86505. * Rebuilds the particle system.
  86506. */
  86507. rebuild(): void;
  86508. /**
  86509. * Is this system ready to be used/rendered
  86510. * @return true if the system is ready
  86511. */
  86512. isReady(): boolean;
  86513. private _render;
  86514. /**
  86515. * Renders the particle system in its current state.
  86516. * @returns the current number of particles
  86517. */
  86518. render(): number;
  86519. /**
  86520. * Disposes the particle system and free the associated resources
  86521. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86522. */
  86523. dispose(disposeTexture?: boolean): void;
  86524. /**
  86525. * Clones the particle system.
  86526. * @param name The name of the cloned object
  86527. * @param newEmitter The new emitter to use
  86528. * @returns the cloned particle system
  86529. */
  86530. clone(name: string, newEmitter: any): ParticleSystem;
  86531. /**
  86532. * Serializes the particle system to a JSON object.
  86533. * @returns the JSON object
  86534. */
  86535. serialize(): any;
  86536. /** @hidden */
  86537. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86538. /** @hidden */
  86539. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86540. /**
  86541. * Parses a JSON object to create a particle system.
  86542. * @param parsedParticleSystem The JSON object to parse
  86543. * @param scene The scene to create the particle system in
  86544. * @param rootUrl The root url to use to load external dependencies like texture
  86545. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86546. * @returns the Parsed particle system
  86547. */
  86548. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86549. }
  86550. }
  86551. declare module BABYLON {
  86552. /**
  86553. * A particle represents one of the element emitted by a particle system.
  86554. * This is mainly define by its coordinates, direction, velocity and age.
  86555. */
  86556. export class Particle {
  86557. /**
  86558. * The particle system the particle belongs to.
  86559. */
  86560. particleSystem: ParticleSystem;
  86561. private static _Count;
  86562. /**
  86563. * Unique ID of the particle
  86564. */
  86565. id: number;
  86566. /**
  86567. * The world position of the particle in the scene.
  86568. */
  86569. position: Vector3;
  86570. /**
  86571. * The world direction of the particle in the scene.
  86572. */
  86573. direction: Vector3;
  86574. /**
  86575. * The color of the particle.
  86576. */
  86577. color: Color4;
  86578. /**
  86579. * The color change of the particle per step.
  86580. */
  86581. colorStep: Color4;
  86582. /**
  86583. * Defines how long will the life of the particle be.
  86584. */
  86585. lifeTime: number;
  86586. /**
  86587. * The current age of the particle.
  86588. */
  86589. age: number;
  86590. /**
  86591. * The current size of the particle.
  86592. */
  86593. size: number;
  86594. /**
  86595. * The current scale of the particle.
  86596. */
  86597. scale: Vector2;
  86598. /**
  86599. * The current angle of the particle.
  86600. */
  86601. angle: number;
  86602. /**
  86603. * Defines how fast is the angle changing.
  86604. */
  86605. angularSpeed: number;
  86606. /**
  86607. * Defines the cell index used by the particle to be rendered from a sprite.
  86608. */
  86609. cellIndex: number;
  86610. /**
  86611. * The information required to support color remapping
  86612. */
  86613. remapData: Vector4;
  86614. /** @hidden */
  86615. _randomCellOffset?: number;
  86616. /** @hidden */
  86617. _initialDirection: Nullable<Vector3>;
  86618. /** @hidden */
  86619. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86620. /** @hidden */
  86621. _initialStartSpriteCellID: number;
  86622. /** @hidden */
  86623. _initialEndSpriteCellID: number;
  86624. /** @hidden */
  86625. _currentColorGradient: Nullable<ColorGradient>;
  86626. /** @hidden */
  86627. _currentColor1: Color4;
  86628. /** @hidden */
  86629. _currentColor2: Color4;
  86630. /** @hidden */
  86631. _currentSizeGradient: Nullable<FactorGradient>;
  86632. /** @hidden */
  86633. _currentSize1: number;
  86634. /** @hidden */
  86635. _currentSize2: number;
  86636. /** @hidden */
  86637. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86638. /** @hidden */
  86639. _currentAngularSpeed1: number;
  86640. /** @hidden */
  86641. _currentAngularSpeed2: number;
  86642. /** @hidden */
  86643. _currentVelocityGradient: Nullable<FactorGradient>;
  86644. /** @hidden */
  86645. _currentVelocity1: number;
  86646. /** @hidden */
  86647. _currentVelocity2: number;
  86648. /** @hidden */
  86649. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86650. /** @hidden */
  86651. _currentLimitVelocity1: number;
  86652. /** @hidden */
  86653. _currentLimitVelocity2: number;
  86654. /** @hidden */
  86655. _currentDragGradient: Nullable<FactorGradient>;
  86656. /** @hidden */
  86657. _currentDrag1: number;
  86658. /** @hidden */
  86659. _currentDrag2: number;
  86660. /** @hidden */
  86661. _randomNoiseCoordinates1: Vector3;
  86662. /** @hidden */
  86663. _randomNoiseCoordinates2: Vector3;
  86664. /**
  86665. * Creates a new instance Particle
  86666. * @param particleSystem the particle system the particle belongs to
  86667. */
  86668. constructor(
  86669. /**
  86670. * The particle system the particle belongs to.
  86671. */
  86672. particleSystem: ParticleSystem);
  86673. private updateCellInfoFromSystem;
  86674. /**
  86675. * Defines how the sprite cell index is updated for the particle
  86676. */
  86677. updateCellIndex(): void;
  86678. /** @hidden */
  86679. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86680. /** @hidden */
  86681. _inheritParticleInfoToSubEmitters(): void;
  86682. /** @hidden */
  86683. _reset(): void;
  86684. /**
  86685. * Copy the properties of particle to another one.
  86686. * @param other the particle to copy the information to.
  86687. */
  86688. copyTo(other: Particle): void;
  86689. }
  86690. }
  86691. declare module BABYLON {
  86692. /**
  86693. * Particle emitter represents a volume emitting particles.
  86694. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86695. */
  86696. export interface IParticleEmitterType {
  86697. /**
  86698. * Called by the particle System when the direction is computed for the created particle.
  86699. * @param worldMatrix is the world matrix of the particle system
  86700. * @param directionToUpdate is the direction vector to update with the result
  86701. * @param particle is the particle we are computed the direction for
  86702. */
  86703. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86704. /**
  86705. * Called by the particle System when the position is computed for the created particle.
  86706. * @param worldMatrix is the world matrix of the particle system
  86707. * @param positionToUpdate is the position vector to update with the result
  86708. * @param particle is the particle we are computed the position for
  86709. */
  86710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86711. /**
  86712. * Clones the current emitter and returns a copy of it
  86713. * @returns the new emitter
  86714. */
  86715. clone(): IParticleEmitterType;
  86716. /**
  86717. * Called by the GPUParticleSystem to setup the update shader
  86718. * @param effect defines the update shader
  86719. */
  86720. applyToShader(effect: Effect): void;
  86721. /**
  86722. * Returns a string to use to update the GPU particles update shader
  86723. * @returns the effect defines string
  86724. */
  86725. getEffectDefines(): string;
  86726. /**
  86727. * Returns a string representing the class name
  86728. * @returns a string containing the class name
  86729. */
  86730. getClassName(): string;
  86731. /**
  86732. * Serializes the particle system to a JSON object.
  86733. * @returns the JSON object
  86734. */
  86735. serialize(): any;
  86736. /**
  86737. * Parse properties from a JSON object
  86738. * @param serializationObject defines the JSON object
  86739. */
  86740. parse(serializationObject: any): void;
  86741. }
  86742. }
  86743. declare module BABYLON {
  86744. /**
  86745. * Particle emitter emitting particles from the inside of a box.
  86746. * It emits the particles randomly between 2 given directions.
  86747. */
  86748. export class BoxParticleEmitter implements IParticleEmitterType {
  86749. /**
  86750. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86751. */
  86752. direction1: Vector3;
  86753. /**
  86754. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86755. */
  86756. direction2: Vector3;
  86757. /**
  86758. * 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.
  86759. */
  86760. minEmitBox: Vector3;
  86761. /**
  86762. * 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.
  86763. */
  86764. maxEmitBox: Vector3;
  86765. /**
  86766. * Creates a new instance BoxParticleEmitter
  86767. */
  86768. constructor();
  86769. /**
  86770. * Called by the particle System when the direction is computed for the created particle.
  86771. * @param worldMatrix is the world matrix of the particle system
  86772. * @param directionToUpdate is the direction vector to update with the result
  86773. * @param particle is the particle we are computed the direction for
  86774. */
  86775. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86776. /**
  86777. * Called by the particle System when the position is computed for the created particle.
  86778. * @param worldMatrix is the world matrix of the particle system
  86779. * @param positionToUpdate is the position vector to update with the result
  86780. * @param particle is the particle we are computed the position for
  86781. */
  86782. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86783. /**
  86784. * Clones the current emitter and returns a copy of it
  86785. * @returns the new emitter
  86786. */
  86787. clone(): BoxParticleEmitter;
  86788. /**
  86789. * Called by the GPUParticleSystem to setup the update shader
  86790. * @param effect defines the update shader
  86791. */
  86792. applyToShader(effect: Effect): void;
  86793. /**
  86794. * Returns a string to use to update the GPU particles update shader
  86795. * @returns a string containng the defines string
  86796. */
  86797. getEffectDefines(): string;
  86798. /**
  86799. * Returns the string "BoxParticleEmitter"
  86800. * @returns a string containing the class name
  86801. */
  86802. getClassName(): string;
  86803. /**
  86804. * Serializes the particle system to a JSON object.
  86805. * @returns the JSON object
  86806. */
  86807. serialize(): any;
  86808. /**
  86809. * Parse properties from a JSON object
  86810. * @param serializationObject defines the JSON object
  86811. */
  86812. parse(serializationObject: any): void;
  86813. }
  86814. }
  86815. declare module BABYLON {
  86816. /**
  86817. * Particle emitter emitting particles from the inside of a cone.
  86818. * It emits the particles alongside the cone volume from the base to the particle.
  86819. * The emission direction might be randomized.
  86820. */
  86821. export class ConeParticleEmitter implements IParticleEmitterType {
  86822. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86823. directionRandomizer: number;
  86824. private _radius;
  86825. private _angle;
  86826. private _height;
  86827. /**
  86828. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86829. */
  86830. radiusRange: number;
  86831. /**
  86832. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86833. */
  86834. heightRange: number;
  86835. /**
  86836. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86837. */
  86838. emitFromSpawnPointOnly: boolean;
  86839. /**
  86840. * Gets or sets the radius of the emission cone
  86841. */
  86842. radius: number;
  86843. /**
  86844. * Gets or sets the angle of the emission cone
  86845. */
  86846. angle: number;
  86847. private _buildHeight;
  86848. /**
  86849. * Creates a new instance ConeParticleEmitter
  86850. * @param radius the radius of the emission cone (1 by default)
  86851. * @param angle the cone base angle (PI by default)
  86852. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86853. */
  86854. constructor(radius?: number, angle?: number,
  86855. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86856. directionRandomizer?: number);
  86857. /**
  86858. * Called by the particle System when the direction is computed for the created particle.
  86859. * @param worldMatrix is the world matrix of the particle system
  86860. * @param directionToUpdate is the direction vector to update with the result
  86861. * @param particle is the particle we are computed the direction for
  86862. */
  86863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86864. /**
  86865. * Called by the particle System when the position is computed for the created particle.
  86866. * @param worldMatrix is the world matrix of the particle system
  86867. * @param positionToUpdate is the position vector to update with the result
  86868. * @param particle is the particle we are computed the position for
  86869. */
  86870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86871. /**
  86872. * Clones the current emitter and returns a copy of it
  86873. * @returns the new emitter
  86874. */
  86875. clone(): ConeParticleEmitter;
  86876. /**
  86877. * Called by the GPUParticleSystem to setup the update shader
  86878. * @param effect defines the update shader
  86879. */
  86880. applyToShader(effect: Effect): void;
  86881. /**
  86882. * Returns a string to use to update the GPU particles update shader
  86883. * @returns a string containng the defines string
  86884. */
  86885. getEffectDefines(): string;
  86886. /**
  86887. * Returns the string "ConeParticleEmitter"
  86888. * @returns a string containing the class name
  86889. */
  86890. getClassName(): string;
  86891. /**
  86892. * Serializes the particle system to a JSON object.
  86893. * @returns the JSON object
  86894. */
  86895. serialize(): any;
  86896. /**
  86897. * Parse properties from a JSON object
  86898. * @param serializationObject defines the JSON object
  86899. */
  86900. parse(serializationObject: any): void;
  86901. }
  86902. }
  86903. declare module BABYLON {
  86904. /**
  86905. * Particle emitter emitting particles from the inside of a cylinder.
  86906. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86907. */
  86908. export class CylinderParticleEmitter implements IParticleEmitterType {
  86909. /**
  86910. * The radius of the emission cylinder.
  86911. */
  86912. radius: number;
  86913. /**
  86914. * The height of the emission cylinder.
  86915. */
  86916. height: number;
  86917. /**
  86918. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86919. */
  86920. radiusRange: number;
  86921. /**
  86922. * How much to randomize the particle direction [0-1].
  86923. */
  86924. directionRandomizer: number;
  86925. /**
  86926. * Creates a new instance CylinderParticleEmitter
  86927. * @param radius the radius of the emission cylinder (1 by default)
  86928. * @param height the height of the emission cylinder (1 by default)
  86929. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86930. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86931. */
  86932. constructor(
  86933. /**
  86934. * The radius of the emission cylinder.
  86935. */
  86936. radius?: number,
  86937. /**
  86938. * The height of the emission cylinder.
  86939. */
  86940. height?: number,
  86941. /**
  86942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86943. */
  86944. radiusRange?: number,
  86945. /**
  86946. * How much to randomize the particle direction [0-1].
  86947. */
  86948. directionRandomizer?: number);
  86949. /**
  86950. * Called by the particle System when the direction is computed for the created particle.
  86951. * @param worldMatrix is the world matrix of the particle system
  86952. * @param directionToUpdate is the direction vector to update with the result
  86953. * @param particle is the particle we are computed the direction for
  86954. */
  86955. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86956. /**
  86957. * Called by the particle System when the position is computed for the created particle.
  86958. * @param worldMatrix is the world matrix of the particle system
  86959. * @param positionToUpdate is the position vector to update with the result
  86960. * @param particle is the particle we are computed the position for
  86961. */
  86962. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86963. /**
  86964. * Clones the current emitter and returns a copy of it
  86965. * @returns the new emitter
  86966. */
  86967. clone(): CylinderParticleEmitter;
  86968. /**
  86969. * Called by the GPUParticleSystem to setup the update shader
  86970. * @param effect defines the update shader
  86971. */
  86972. applyToShader(effect: Effect): void;
  86973. /**
  86974. * Returns a string to use to update the GPU particles update shader
  86975. * @returns a string containng the defines string
  86976. */
  86977. getEffectDefines(): string;
  86978. /**
  86979. * Returns the string "CylinderParticleEmitter"
  86980. * @returns a string containing the class name
  86981. */
  86982. getClassName(): string;
  86983. /**
  86984. * Serializes the particle system to a JSON object.
  86985. * @returns the JSON object
  86986. */
  86987. serialize(): any;
  86988. /**
  86989. * Parse properties from a JSON object
  86990. * @param serializationObject defines the JSON object
  86991. */
  86992. parse(serializationObject: any): void;
  86993. }
  86994. /**
  86995. * Particle emitter emitting particles from the inside of a cylinder.
  86996. * It emits the particles randomly between two vectors.
  86997. */
  86998. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86999. /**
  87000. * The min limit of the emission direction.
  87001. */
  87002. direction1: Vector3;
  87003. /**
  87004. * The max limit of the emission direction.
  87005. */
  87006. direction2: Vector3;
  87007. /**
  87008. * Creates a new instance CylinderDirectedParticleEmitter
  87009. * @param radius the radius of the emission cylinder (1 by default)
  87010. * @param height the height of the emission cylinder (1 by default)
  87011. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87012. * @param direction1 the min limit of the emission direction (up vector by default)
  87013. * @param direction2 the max limit of the emission direction (up vector by default)
  87014. */
  87015. constructor(radius?: number, height?: number, radiusRange?: number,
  87016. /**
  87017. * The min limit of the emission direction.
  87018. */
  87019. direction1?: Vector3,
  87020. /**
  87021. * The max limit of the emission direction.
  87022. */
  87023. direction2?: Vector3);
  87024. /**
  87025. * Called by the particle System when the direction is computed for the created particle.
  87026. * @param worldMatrix is the world matrix of the particle system
  87027. * @param directionToUpdate is the direction vector to update with the result
  87028. * @param particle is the particle we are computed the direction for
  87029. */
  87030. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87031. /**
  87032. * Clones the current emitter and returns a copy of it
  87033. * @returns the new emitter
  87034. */
  87035. clone(): CylinderDirectedParticleEmitter;
  87036. /**
  87037. * Called by the GPUParticleSystem to setup the update shader
  87038. * @param effect defines the update shader
  87039. */
  87040. applyToShader(effect: Effect): void;
  87041. /**
  87042. * Returns a string to use to update the GPU particles update shader
  87043. * @returns a string containng the defines string
  87044. */
  87045. getEffectDefines(): string;
  87046. /**
  87047. * Returns the string "CylinderDirectedParticleEmitter"
  87048. * @returns a string containing the class name
  87049. */
  87050. getClassName(): string;
  87051. /**
  87052. * Serializes the particle system to a JSON object.
  87053. * @returns the JSON object
  87054. */
  87055. serialize(): any;
  87056. /**
  87057. * Parse properties from a JSON object
  87058. * @param serializationObject defines the JSON object
  87059. */
  87060. parse(serializationObject: any): void;
  87061. }
  87062. }
  87063. declare module BABYLON {
  87064. /**
  87065. * Particle emitter emitting particles from the inside of a hemisphere.
  87066. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87067. */
  87068. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87069. /**
  87070. * The radius of the emission hemisphere.
  87071. */
  87072. radius: number;
  87073. /**
  87074. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87075. */
  87076. radiusRange: number;
  87077. /**
  87078. * How much to randomize the particle direction [0-1].
  87079. */
  87080. directionRandomizer: number;
  87081. /**
  87082. * Creates a new instance HemisphericParticleEmitter
  87083. * @param radius the radius of the emission hemisphere (1 by default)
  87084. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87085. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87086. */
  87087. constructor(
  87088. /**
  87089. * The radius of the emission hemisphere.
  87090. */
  87091. radius?: number,
  87092. /**
  87093. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87094. */
  87095. radiusRange?: number,
  87096. /**
  87097. * How much to randomize the particle direction [0-1].
  87098. */
  87099. directionRandomizer?: number);
  87100. /**
  87101. * Called by the particle System when the direction is computed for the created particle.
  87102. * @param worldMatrix is the world matrix of the particle system
  87103. * @param directionToUpdate is the direction vector to update with the result
  87104. * @param particle is the particle we are computed the direction for
  87105. */
  87106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87107. /**
  87108. * Called by the particle System when the position is computed for the created particle.
  87109. * @param worldMatrix is the world matrix of the particle system
  87110. * @param positionToUpdate is the position vector to update with the result
  87111. * @param particle is the particle we are computed the position for
  87112. */
  87113. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87114. /**
  87115. * Clones the current emitter and returns a copy of it
  87116. * @returns the new emitter
  87117. */
  87118. clone(): HemisphericParticleEmitter;
  87119. /**
  87120. * Called by the GPUParticleSystem to setup the update shader
  87121. * @param effect defines the update shader
  87122. */
  87123. applyToShader(effect: Effect): void;
  87124. /**
  87125. * Returns a string to use to update the GPU particles update shader
  87126. * @returns a string containng the defines string
  87127. */
  87128. getEffectDefines(): string;
  87129. /**
  87130. * Returns the string "HemisphericParticleEmitter"
  87131. * @returns a string containing the class name
  87132. */
  87133. getClassName(): string;
  87134. /**
  87135. * Serializes the particle system to a JSON object.
  87136. * @returns the JSON object
  87137. */
  87138. serialize(): any;
  87139. /**
  87140. * Parse properties from a JSON object
  87141. * @param serializationObject defines the JSON object
  87142. */
  87143. parse(serializationObject: any): void;
  87144. }
  87145. }
  87146. declare module BABYLON {
  87147. /**
  87148. * Particle emitter emitting particles from a point.
  87149. * It emits the particles randomly between 2 given directions.
  87150. */
  87151. export class PointParticleEmitter implements IParticleEmitterType {
  87152. /**
  87153. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87154. */
  87155. direction1: Vector3;
  87156. /**
  87157. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87158. */
  87159. direction2: Vector3;
  87160. /**
  87161. * Creates a new instance PointParticleEmitter
  87162. */
  87163. constructor();
  87164. /**
  87165. * Called by the particle System when the direction is computed for the created particle.
  87166. * @param worldMatrix is the world matrix of the particle system
  87167. * @param directionToUpdate is the direction vector to update with the result
  87168. * @param particle is the particle we are computed the direction for
  87169. */
  87170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87171. /**
  87172. * Called by the particle System when the position is computed for the created particle.
  87173. * @param worldMatrix is the world matrix of the particle system
  87174. * @param positionToUpdate is the position vector to update with the result
  87175. * @param particle is the particle we are computed the position for
  87176. */
  87177. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87178. /**
  87179. * Clones the current emitter and returns a copy of it
  87180. * @returns the new emitter
  87181. */
  87182. clone(): PointParticleEmitter;
  87183. /**
  87184. * Called by the GPUParticleSystem to setup the update shader
  87185. * @param effect defines the update shader
  87186. */
  87187. applyToShader(effect: Effect): void;
  87188. /**
  87189. * Returns a string to use to update the GPU particles update shader
  87190. * @returns a string containng the defines string
  87191. */
  87192. getEffectDefines(): string;
  87193. /**
  87194. * Returns the string "PointParticleEmitter"
  87195. * @returns a string containing the class name
  87196. */
  87197. getClassName(): string;
  87198. /**
  87199. * Serializes the particle system to a JSON object.
  87200. * @returns the JSON object
  87201. */
  87202. serialize(): any;
  87203. /**
  87204. * Parse properties from a JSON object
  87205. * @param serializationObject defines the JSON object
  87206. */
  87207. parse(serializationObject: any): void;
  87208. }
  87209. }
  87210. declare module BABYLON {
  87211. /**
  87212. * Particle emitter emitting particles from the inside of a sphere.
  87213. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87214. */
  87215. export class SphereParticleEmitter implements IParticleEmitterType {
  87216. /**
  87217. * The radius of the emission sphere.
  87218. */
  87219. radius: number;
  87220. /**
  87221. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87222. */
  87223. radiusRange: number;
  87224. /**
  87225. * How much to randomize the particle direction [0-1].
  87226. */
  87227. directionRandomizer: number;
  87228. /**
  87229. * Creates a new instance SphereParticleEmitter
  87230. * @param radius the radius of the emission sphere (1 by default)
  87231. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87232. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87233. */
  87234. constructor(
  87235. /**
  87236. * The radius of the emission sphere.
  87237. */
  87238. radius?: number,
  87239. /**
  87240. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87241. */
  87242. radiusRange?: number,
  87243. /**
  87244. * How much to randomize the particle direction [0-1].
  87245. */
  87246. directionRandomizer?: number);
  87247. /**
  87248. * Called by the particle System when the direction is computed for the created particle.
  87249. * @param worldMatrix is the world matrix of the particle system
  87250. * @param directionToUpdate is the direction vector to update with the result
  87251. * @param particle is the particle we are computed the direction for
  87252. */
  87253. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87254. /**
  87255. * Called by the particle System when the position is computed for the created particle.
  87256. * @param worldMatrix is the world matrix of the particle system
  87257. * @param positionToUpdate is the position vector to update with the result
  87258. * @param particle is the particle we are computed the position for
  87259. */
  87260. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87261. /**
  87262. * Clones the current emitter and returns a copy of it
  87263. * @returns the new emitter
  87264. */
  87265. clone(): SphereParticleEmitter;
  87266. /**
  87267. * Called by the GPUParticleSystem to setup the update shader
  87268. * @param effect defines the update shader
  87269. */
  87270. applyToShader(effect: Effect): void;
  87271. /**
  87272. * Returns a string to use to update the GPU particles update shader
  87273. * @returns a string containng the defines string
  87274. */
  87275. getEffectDefines(): string;
  87276. /**
  87277. * Returns the string "SphereParticleEmitter"
  87278. * @returns a string containing the class name
  87279. */
  87280. getClassName(): string;
  87281. /**
  87282. * Serializes the particle system to a JSON object.
  87283. * @returns the JSON object
  87284. */
  87285. serialize(): any;
  87286. /**
  87287. * Parse properties from a JSON object
  87288. * @param serializationObject defines the JSON object
  87289. */
  87290. parse(serializationObject: any): void;
  87291. }
  87292. /**
  87293. * Particle emitter emitting particles from the inside of a sphere.
  87294. * It emits the particles randomly between two vectors.
  87295. */
  87296. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87297. /**
  87298. * The min limit of the emission direction.
  87299. */
  87300. direction1: Vector3;
  87301. /**
  87302. * The max limit of the emission direction.
  87303. */
  87304. direction2: Vector3;
  87305. /**
  87306. * Creates a new instance SphereDirectedParticleEmitter
  87307. * @param radius the radius of the emission sphere (1 by default)
  87308. * @param direction1 the min limit of the emission direction (up vector by default)
  87309. * @param direction2 the max limit of the emission direction (up vector by default)
  87310. */
  87311. constructor(radius?: number,
  87312. /**
  87313. * The min limit of the emission direction.
  87314. */
  87315. direction1?: Vector3,
  87316. /**
  87317. * The max limit of the emission direction.
  87318. */
  87319. direction2?: Vector3);
  87320. /**
  87321. * Called by the particle System when the direction is computed for the created particle.
  87322. * @param worldMatrix is the world matrix of the particle system
  87323. * @param directionToUpdate is the direction vector to update with the result
  87324. * @param particle is the particle we are computed the direction for
  87325. */
  87326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87327. /**
  87328. * Clones the current emitter and returns a copy of it
  87329. * @returns the new emitter
  87330. */
  87331. clone(): SphereDirectedParticleEmitter;
  87332. /**
  87333. * Called by the GPUParticleSystem to setup the update shader
  87334. * @param effect defines the update shader
  87335. */
  87336. applyToShader(effect: Effect): void;
  87337. /**
  87338. * Returns a string to use to update the GPU particles update shader
  87339. * @returns a string containng the defines string
  87340. */
  87341. getEffectDefines(): string;
  87342. /**
  87343. * Returns the string "SphereDirectedParticleEmitter"
  87344. * @returns a string containing the class name
  87345. */
  87346. getClassName(): string;
  87347. /**
  87348. * Serializes the particle system to a JSON object.
  87349. * @returns the JSON object
  87350. */
  87351. serialize(): any;
  87352. /**
  87353. * Parse properties from a JSON object
  87354. * @param serializationObject defines the JSON object
  87355. */
  87356. parse(serializationObject: any): void;
  87357. }
  87358. }
  87359. declare module BABYLON {
  87360. /**
  87361. * Interface representing a particle system in Babylon.js.
  87362. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87363. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87364. */
  87365. export interface IParticleSystem {
  87366. /**
  87367. * List of animations used by the particle system.
  87368. */
  87369. animations: Animation[];
  87370. /**
  87371. * The id of the Particle system.
  87372. */
  87373. id: string;
  87374. /**
  87375. * The name of the Particle system.
  87376. */
  87377. name: string;
  87378. /**
  87379. * The emitter represents the Mesh or position we are attaching the particle system to.
  87380. */
  87381. emitter: Nullable<AbstractMesh | Vector3>;
  87382. /**
  87383. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87384. */
  87385. isBillboardBased: boolean;
  87386. /**
  87387. * The rendering group used by the Particle system to chose when to render.
  87388. */
  87389. renderingGroupId: number;
  87390. /**
  87391. * The layer mask we are rendering the particles through.
  87392. */
  87393. layerMask: number;
  87394. /**
  87395. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87396. */
  87397. updateSpeed: number;
  87398. /**
  87399. * The amount of time the particle system is running (depends of the overall update speed).
  87400. */
  87401. targetStopDuration: number;
  87402. /**
  87403. * The texture used to render each particle. (this can be a spritesheet)
  87404. */
  87405. particleTexture: Nullable<Texture>;
  87406. /**
  87407. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87408. */
  87409. blendMode: number;
  87410. /**
  87411. * Minimum life time of emitting particles.
  87412. */
  87413. minLifeTime: number;
  87414. /**
  87415. * Maximum life time of emitting particles.
  87416. */
  87417. maxLifeTime: number;
  87418. /**
  87419. * Minimum Size of emitting particles.
  87420. */
  87421. minSize: number;
  87422. /**
  87423. * Maximum Size of emitting particles.
  87424. */
  87425. maxSize: number;
  87426. /**
  87427. * Minimum scale of emitting particles on X axis.
  87428. */
  87429. minScaleX: number;
  87430. /**
  87431. * Maximum scale of emitting particles on X axis.
  87432. */
  87433. maxScaleX: number;
  87434. /**
  87435. * Minimum scale of emitting particles on Y axis.
  87436. */
  87437. minScaleY: number;
  87438. /**
  87439. * Maximum scale of emitting particles on Y axis.
  87440. */
  87441. maxScaleY: number;
  87442. /**
  87443. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87444. */
  87445. color1: Color4;
  87446. /**
  87447. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87448. */
  87449. color2: Color4;
  87450. /**
  87451. * Color the particle will have at the end of its lifetime.
  87452. */
  87453. colorDead: Color4;
  87454. /**
  87455. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87456. */
  87457. emitRate: number;
  87458. /**
  87459. * You can use gravity if you want to give an orientation to your particles.
  87460. */
  87461. gravity: Vector3;
  87462. /**
  87463. * Minimum power of emitting particles.
  87464. */
  87465. minEmitPower: number;
  87466. /**
  87467. * Maximum power of emitting particles.
  87468. */
  87469. maxEmitPower: number;
  87470. /**
  87471. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87472. */
  87473. minAngularSpeed: number;
  87474. /**
  87475. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87476. */
  87477. maxAngularSpeed: number;
  87478. /**
  87479. * Gets or sets the minimal initial rotation in radians.
  87480. */
  87481. minInitialRotation: number;
  87482. /**
  87483. * Gets or sets the maximal initial rotation in radians.
  87484. */
  87485. maxInitialRotation: number;
  87486. /**
  87487. * The particle emitter type defines the emitter used by the particle system.
  87488. * It can be for example box, sphere, or cone...
  87489. */
  87490. particleEmitterType: Nullable<IParticleEmitterType>;
  87491. /**
  87492. * Defines the delay in milliseconds before starting the system (0 by default)
  87493. */
  87494. startDelay: number;
  87495. /**
  87496. * 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
  87497. */
  87498. preWarmCycles: number;
  87499. /**
  87500. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87501. */
  87502. preWarmStepOffset: number;
  87503. /**
  87504. * 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)
  87505. */
  87506. spriteCellChangeSpeed: number;
  87507. /**
  87508. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87509. */
  87510. startSpriteCellID: number;
  87511. /**
  87512. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87513. */
  87514. endSpriteCellID: number;
  87515. /**
  87516. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87517. */
  87518. spriteCellWidth: number;
  87519. /**
  87520. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87521. */
  87522. spriteCellHeight: number;
  87523. /**
  87524. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87525. */
  87526. spriteRandomStartCell: boolean;
  87527. /**
  87528. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87529. */
  87530. isAnimationSheetEnabled: boolean;
  87531. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87532. translationPivot: Vector2;
  87533. /**
  87534. * Gets or sets a texture used to add random noise to particle positions
  87535. */
  87536. noiseTexture: Nullable<BaseTexture>;
  87537. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87538. noiseStrength: Vector3;
  87539. /**
  87540. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87541. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87542. */
  87543. billboardMode: number;
  87544. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87545. limitVelocityDamping: number;
  87546. /**
  87547. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87548. */
  87549. beginAnimationOnStart: boolean;
  87550. /**
  87551. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87552. */
  87553. beginAnimationFrom: number;
  87554. /**
  87555. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87556. */
  87557. beginAnimationTo: number;
  87558. /**
  87559. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87560. */
  87561. beginAnimationLoop: boolean;
  87562. /**
  87563. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87564. */
  87565. disposeOnStop: boolean;
  87566. /**
  87567. * Gets the maximum number of particles active at the same time.
  87568. * @returns The max number of active particles.
  87569. */
  87570. getCapacity(): number;
  87571. /**
  87572. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87573. * @returns True if it has been started, otherwise false.
  87574. */
  87575. isStarted(): boolean;
  87576. /**
  87577. * Animates the particle system for this frame.
  87578. */
  87579. animate(): void;
  87580. /**
  87581. * Renders the particle system in its current state.
  87582. * @returns the current number of particles
  87583. */
  87584. render(): number;
  87585. /**
  87586. * Dispose the particle system and frees its associated resources.
  87587. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87588. */
  87589. dispose(disposeTexture?: boolean): void;
  87590. /**
  87591. * Clones the particle system.
  87592. * @param name The name of the cloned object
  87593. * @param newEmitter The new emitter to use
  87594. * @returns the cloned particle system
  87595. */
  87596. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87597. /**
  87598. * Serializes the particle system to a JSON object.
  87599. * @returns the JSON object
  87600. */
  87601. serialize(): any;
  87602. /**
  87603. * Rebuild the particle system
  87604. */
  87605. rebuild(): void;
  87606. /**
  87607. * Starts the particle system and begins to emit
  87608. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87609. */
  87610. start(delay?: number): void;
  87611. /**
  87612. * Stops the particle system.
  87613. */
  87614. stop(): void;
  87615. /**
  87616. * Remove all active particles
  87617. */
  87618. reset(): void;
  87619. /**
  87620. * Is this system ready to be used/rendered
  87621. * @return true if the system is ready
  87622. */
  87623. isReady(): boolean;
  87624. /**
  87625. * Adds a new color gradient
  87626. * @param gradient defines the gradient to use (between 0 and 1)
  87627. * @param color1 defines the color to affect to the specified gradient
  87628. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87629. * @returns the current particle system
  87630. */
  87631. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87632. /**
  87633. * Remove a specific color gradient
  87634. * @param gradient defines the gradient to remove
  87635. * @returns the current particle system
  87636. */
  87637. removeColorGradient(gradient: number): IParticleSystem;
  87638. /**
  87639. * Adds a new size gradient
  87640. * @param gradient defines the gradient to use (between 0 and 1)
  87641. * @param factor defines the size factor to affect to the specified gradient
  87642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87643. * @returns the current particle system
  87644. */
  87645. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87646. /**
  87647. * Remove a specific size gradient
  87648. * @param gradient defines the gradient to remove
  87649. * @returns the current particle system
  87650. */
  87651. removeSizeGradient(gradient: number): IParticleSystem;
  87652. /**
  87653. * Gets the current list of color gradients.
  87654. * You must use addColorGradient and removeColorGradient to udpate this list
  87655. * @returns the list of color gradients
  87656. */
  87657. getColorGradients(): Nullable<Array<ColorGradient>>;
  87658. /**
  87659. * Gets the current list of size gradients.
  87660. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87661. * @returns the list of size gradients
  87662. */
  87663. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87664. /**
  87665. * Gets the current list of angular speed gradients.
  87666. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87667. * @returns the list of angular speed gradients
  87668. */
  87669. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87670. /**
  87671. * Adds a new angular speed gradient
  87672. * @param gradient defines the gradient to use (between 0 and 1)
  87673. * @param factor defines the angular speed to affect to the specified gradient
  87674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87675. * @returns the current particle system
  87676. */
  87677. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87678. /**
  87679. * Remove a specific angular speed gradient
  87680. * @param gradient defines the gradient to remove
  87681. * @returns the current particle system
  87682. */
  87683. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87684. /**
  87685. * Gets the current list of velocity gradients.
  87686. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87687. * @returns the list of velocity gradients
  87688. */
  87689. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87690. /**
  87691. * Adds a new velocity gradient
  87692. * @param gradient defines the gradient to use (between 0 and 1)
  87693. * @param factor defines the velocity to affect to the specified gradient
  87694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87695. * @returns the current particle system
  87696. */
  87697. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87698. /**
  87699. * Remove a specific velocity gradient
  87700. * @param gradient defines the gradient to remove
  87701. * @returns the current particle system
  87702. */
  87703. removeVelocityGradient(gradient: number): IParticleSystem;
  87704. /**
  87705. * Gets the current list of limit velocity gradients.
  87706. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87707. * @returns the list of limit velocity gradients
  87708. */
  87709. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87710. /**
  87711. * Adds a new limit velocity gradient
  87712. * @param gradient defines the gradient to use (between 0 and 1)
  87713. * @param factor defines the limit velocity to affect to the specified gradient
  87714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87715. * @returns the current particle system
  87716. */
  87717. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87718. /**
  87719. * Remove a specific limit velocity gradient
  87720. * @param gradient defines the gradient to remove
  87721. * @returns the current particle system
  87722. */
  87723. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87724. /**
  87725. * Adds a new drag gradient
  87726. * @param gradient defines the gradient to use (between 0 and 1)
  87727. * @param factor defines the drag to affect to the specified gradient
  87728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87729. * @returns the current particle system
  87730. */
  87731. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87732. /**
  87733. * Remove a specific drag gradient
  87734. * @param gradient defines the gradient to remove
  87735. * @returns the current particle system
  87736. */
  87737. removeDragGradient(gradient: number): IParticleSystem;
  87738. /**
  87739. * Gets the current list of drag gradients.
  87740. * You must use addDragGradient and removeDragGradient to udpate this list
  87741. * @returns the list of drag gradients
  87742. */
  87743. getDragGradients(): Nullable<Array<FactorGradient>>;
  87744. /**
  87745. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87746. * @param gradient defines the gradient to use (between 0 and 1)
  87747. * @param factor defines the emit rate to affect to the specified gradient
  87748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87749. * @returns the current particle system
  87750. */
  87751. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87752. /**
  87753. * Remove a specific emit rate gradient
  87754. * @param gradient defines the gradient to remove
  87755. * @returns the current particle system
  87756. */
  87757. removeEmitRateGradient(gradient: number): IParticleSystem;
  87758. /**
  87759. * Gets the current list of emit rate gradients.
  87760. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87761. * @returns the list of emit rate gradients
  87762. */
  87763. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87764. /**
  87765. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87766. * @param gradient defines the gradient to use (between 0 and 1)
  87767. * @param factor defines the start size to affect to the specified gradient
  87768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87769. * @returns the current particle system
  87770. */
  87771. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87772. /**
  87773. * Remove a specific start size gradient
  87774. * @param gradient defines the gradient to remove
  87775. * @returns the current particle system
  87776. */
  87777. removeStartSizeGradient(gradient: number): IParticleSystem;
  87778. /**
  87779. * Gets the current list of start size gradients.
  87780. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87781. * @returns the list of start size gradients
  87782. */
  87783. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87784. /**
  87785. * Adds a new life time gradient
  87786. * @param gradient defines the gradient to use (between 0 and 1)
  87787. * @param factor defines the life time factor to affect to the specified gradient
  87788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87789. * @returns the current particle system
  87790. */
  87791. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87792. /**
  87793. * Remove a specific life time gradient
  87794. * @param gradient defines the gradient to remove
  87795. * @returns the current particle system
  87796. */
  87797. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87798. /**
  87799. * Gets the current list of life time gradients.
  87800. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87801. * @returns the list of life time gradients
  87802. */
  87803. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87804. /**
  87805. * Gets the current list of color gradients.
  87806. * You must use addColorGradient and removeColorGradient to udpate this list
  87807. * @returns the list of color gradients
  87808. */
  87809. getColorGradients(): Nullable<Array<ColorGradient>>;
  87810. /**
  87811. * Adds a new ramp gradient used to remap particle colors
  87812. * @param gradient defines the gradient to use (between 0 and 1)
  87813. * @param color defines the color to affect to the specified gradient
  87814. * @returns the current particle system
  87815. */
  87816. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87817. /**
  87818. * Gets the current list of ramp gradients.
  87819. * You must use addRampGradient and removeRampGradient to udpate this list
  87820. * @returns the list of ramp gradients
  87821. */
  87822. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87823. /** Gets or sets a boolean indicating that ramp gradients must be used
  87824. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87825. */
  87826. useRampGradients: boolean;
  87827. /**
  87828. * Adds a new color remap gradient
  87829. * @param gradient defines the gradient to use (between 0 and 1)
  87830. * @param min defines the color remap minimal range
  87831. * @param max defines the color remap maximal range
  87832. * @returns the current particle system
  87833. */
  87834. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87835. /**
  87836. * Gets the current list of color remap gradients.
  87837. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87838. * @returns the list of color remap gradients
  87839. */
  87840. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87841. /**
  87842. * Adds a new alpha remap gradient
  87843. * @param gradient defines the gradient to use (between 0 and 1)
  87844. * @param min defines the alpha remap minimal range
  87845. * @param max defines the alpha remap maximal range
  87846. * @returns the current particle system
  87847. */
  87848. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87849. /**
  87850. * Gets the current list of alpha remap gradients.
  87851. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87852. * @returns the list of alpha remap gradients
  87853. */
  87854. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87855. /**
  87856. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87857. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87858. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87859. * @returns the emitter
  87860. */
  87861. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87862. /**
  87863. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87864. * @param radius The radius of the hemisphere to emit from
  87865. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87866. * @returns the emitter
  87867. */
  87868. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87869. /**
  87870. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87871. * @param radius The radius of the sphere to emit from
  87872. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87873. * @returns the emitter
  87874. */
  87875. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87876. /**
  87877. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87878. * @param radius The radius of the sphere to emit from
  87879. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87880. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87881. * @returns the emitter
  87882. */
  87883. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87884. /**
  87885. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87886. * @param radius The radius of the emission cylinder
  87887. * @param height The height of the emission cylinder
  87888. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87889. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87890. * @returns the emitter
  87891. */
  87892. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87893. /**
  87894. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87895. * @param radius The radius of the cylinder to emit from
  87896. * @param height The height of the emission cylinder
  87897. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87898. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87899. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87900. * @returns the emitter
  87901. */
  87902. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87903. /**
  87904. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87905. * @param radius The radius of the cone to emit from
  87906. * @param angle The base angle of the cone
  87907. * @returns the emitter
  87908. */
  87909. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87910. /**
  87911. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87914. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87915. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87916. * @returns the emitter
  87917. */
  87918. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87919. /**
  87920. * Get hosting scene
  87921. * @returns the scene
  87922. */
  87923. getScene(): Scene;
  87924. }
  87925. }
  87926. declare module BABYLON {
  87927. /**
  87928. * Creates an instance based on a source mesh.
  87929. */
  87930. export class InstancedMesh extends AbstractMesh {
  87931. private _sourceMesh;
  87932. private _currentLOD;
  87933. /** @hidden */
  87934. _indexInSourceMeshInstanceArray: number;
  87935. constructor(name: string, source: Mesh);
  87936. /**
  87937. * Returns the string "InstancedMesh".
  87938. */
  87939. getClassName(): string;
  87940. /** Gets the list of lights affecting that mesh */
  87941. readonly lightSources: Light[];
  87942. _resyncLightSources(): void;
  87943. _resyncLightSource(light: Light): void;
  87944. _removeLightSource(light: Light, dispose: boolean): void;
  87945. /**
  87946. * If the source mesh receives shadows
  87947. */
  87948. readonly receiveShadows: boolean;
  87949. /**
  87950. * The material of the source mesh
  87951. */
  87952. readonly material: Nullable<Material>;
  87953. /**
  87954. * Visibility of the source mesh
  87955. */
  87956. readonly visibility: number;
  87957. /**
  87958. * Skeleton of the source mesh
  87959. */
  87960. readonly skeleton: Nullable<Skeleton>;
  87961. /**
  87962. * Rendering ground id of the source mesh
  87963. */
  87964. renderingGroupId: number;
  87965. /**
  87966. * Returns the total number of vertices (integer).
  87967. */
  87968. getTotalVertices(): number;
  87969. /**
  87970. * Returns a positive integer : the total number of indices in this mesh geometry.
  87971. * @returns the numner of indices or zero if the mesh has no geometry.
  87972. */
  87973. getTotalIndices(): number;
  87974. /**
  87975. * The source mesh of the instance
  87976. */
  87977. readonly sourceMesh: Mesh;
  87978. /**
  87979. * Is this node ready to be used/rendered
  87980. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87981. * @return {boolean} is it ready
  87982. */
  87983. isReady(completeCheck?: boolean): boolean;
  87984. /**
  87985. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87986. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87987. * @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.
  87988. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87989. */
  87990. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87991. /**
  87992. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87993. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87994. * The `data` are either a numeric array either a Float32Array.
  87995. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87996. * 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).
  87997. * Note that a new underlying VertexBuffer object is created each call.
  87998. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87999. *
  88000. * Possible `kind` values :
  88001. * - VertexBuffer.PositionKind
  88002. * - VertexBuffer.UVKind
  88003. * - VertexBuffer.UV2Kind
  88004. * - VertexBuffer.UV3Kind
  88005. * - VertexBuffer.UV4Kind
  88006. * - VertexBuffer.UV5Kind
  88007. * - VertexBuffer.UV6Kind
  88008. * - VertexBuffer.ColorKind
  88009. * - VertexBuffer.MatricesIndicesKind
  88010. * - VertexBuffer.MatricesIndicesExtraKind
  88011. * - VertexBuffer.MatricesWeightsKind
  88012. * - VertexBuffer.MatricesWeightsExtraKind
  88013. *
  88014. * Returns the Mesh.
  88015. */
  88016. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88017. /**
  88018. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88019. * If the mesh has no geometry, it is simply returned as it is.
  88020. * The `data` are either a numeric array either a Float32Array.
  88021. * No new underlying VertexBuffer object is created.
  88022. * 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.
  88023. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88024. *
  88025. * Possible `kind` values :
  88026. * - VertexBuffer.PositionKind
  88027. * - VertexBuffer.UVKind
  88028. * - VertexBuffer.UV2Kind
  88029. * - VertexBuffer.UV3Kind
  88030. * - VertexBuffer.UV4Kind
  88031. * - VertexBuffer.UV5Kind
  88032. * - VertexBuffer.UV6Kind
  88033. * - VertexBuffer.ColorKind
  88034. * - VertexBuffer.MatricesIndicesKind
  88035. * - VertexBuffer.MatricesIndicesExtraKind
  88036. * - VertexBuffer.MatricesWeightsKind
  88037. * - VertexBuffer.MatricesWeightsExtraKind
  88038. *
  88039. * Returns the Mesh.
  88040. */
  88041. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88042. /**
  88043. * Sets the mesh indices.
  88044. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88045. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88046. * This method creates a new index buffer each call.
  88047. * Returns the Mesh.
  88048. */
  88049. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88050. /**
  88051. * Boolean : True if the mesh owns the requested kind of data.
  88052. */
  88053. isVerticesDataPresent(kind: string): boolean;
  88054. /**
  88055. * Returns an array of indices (IndicesArray).
  88056. */
  88057. getIndices(): Nullable<IndicesArray>;
  88058. readonly _positions: Nullable<Vector3[]>;
  88059. /**
  88060. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88061. * This means the mesh underlying bounding box and sphere are recomputed.
  88062. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88063. * @returns the current mesh
  88064. */
  88065. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88066. /** @hidden */
  88067. _preActivate(): InstancedMesh;
  88068. /** @hidden */
  88069. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88070. /** @hidden */
  88071. _postActivate(): void;
  88072. getWorldMatrix(): Matrix;
  88073. readonly isAnInstance: boolean;
  88074. /**
  88075. * Returns the current associated LOD AbstractMesh.
  88076. */
  88077. getLOD(camera: Camera): AbstractMesh;
  88078. /** @hidden */
  88079. _syncSubMeshes(): InstancedMesh;
  88080. /** @hidden */
  88081. _generatePointsArray(): boolean;
  88082. /**
  88083. * Creates a new InstancedMesh from the current mesh.
  88084. * - name (string) : the cloned mesh name
  88085. * - newParent (optional Node) : the optional Node to parent the clone to.
  88086. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88087. *
  88088. * Returns the clone.
  88089. */
  88090. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88091. /**
  88092. * Disposes the InstancedMesh.
  88093. * Returns nothing.
  88094. */
  88095. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88096. }
  88097. interface Mesh {
  88098. /**
  88099. * Register a custom buffer that will be instanced
  88100. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88101. * @param kind defines the buffer kind
  88102. * @param stride defines the stride in floats
  88103. */
  88104. registerInstancedBuffer(kind: string, stride: number): void;
  88105. /** @hidden */
  88106. _userInstancedBuffersStorage: {
  88107. data: {
  88108. [key: string]: Float32Array;
  88109. };
  88110. sizes: {
  88111. [key: string]: number;
  88112. };
  88113. vertexBuffers: {
  88114. [key: string]: Nullable<VertexBuffer>;
  88115. };
  88116. strides: {
  88117. [key: string]: number;
  88118. };
  88119. };
  88120. }
  88121. interface AbstractMesh {
  88122. /**
  88123. * Object used to store instanced buffers defined by user
  88124. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88125. */
  88126. instancedBuffers: {
  88127. [key: string]: any;
  88128. };
  88129. }
  88130. }
  88131. declare module BABYLON {
  88132. /**
  88133. * Defines the options associated with the creation of a shader material.
  88134. */
  88135. export interface IShaderMaterialOptions {
  88136. /**
  88137. * Does the material work in alpha blend mode
  88138. */
  88139. needAlphaBlending: boolean;
  88140. /**
  88141. * Does the material work in alpha test mode
  88142. */
  88143. needAlphaTesting: boolean;
  88144. /**
  88145. * The list of attribute names used in the shader
  88146. */
  88147. attributes: string[];
  88148. /**
  88149. * The list of unifrom names used in the shader
  88150. */
  88151. uniforms: string[];
  88152. /**
  88153. * The list of UBO names used in the shader
  88154. */
  88155. uniformBuffers: string[];
  88156. /**
  88157. * The list of sampler names used in the shader
  88158. */
  88159. samplers: string[];
  88160. /**
  88161. * The list of defines used in the shader
  88162. */
  88163. defines: string[];
  88164. }
  88165. /**
  88166. * 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.
  88167. *
  88168. * This returned material effects how the mesh will look based on the code in the shaders.
  88169. *
  88170. * @see http://doc.babylonjs.com/how_to/shader_material
  88171. */
  88172. export class ShaderMaterial extends Material {
  88173. private _shaderPath;
  88174. private _options;
  88175. private _textures;
  88176. private _textureArrays;
  88177. private _floats;
  88178. private _ints;
  88179. private _floatsArrays;
  88180. private _colors3;
  88181. private _colors3Arrays;
  88182. private _colors4;
  88183. private _colors4Arrays;
  88184. private _vectors2;
  88185. private _vectors3;
  88186. private _vectors4;
  88187. private _matrices;
  88188. private _matrixArrays;
  88189. private _matrices3x3;
  88190. private _matrices2x2;
  88191. private _vectors2Arrays;
  88192. private _vectors3Arrays;
  88193. private _vectors4Arrays;
  88194. private _cachedWorldViewMatrix;
  88195. private _cachedWorldViewProjectionMatrix;
  88196. private _renderId;
  88197. private _multiview;
  88198. /**
  88199. * Instantiate a new shader material.
  88200. * 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.
  88201. * This returned material effects how the mesh will look based on the code in the shaders.
  88202. * @see http://doc.babylonjs.com/how_to/shader_material
  88203. * @param name Define the name of the material in the scene
  88204. * @param scene Define the scene the material belongs to
  88205. * @param shaderPath Defines the route to the shader code in one of three ways:
  88206. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88207. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88208. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88209. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88210. * @param options Define the options used to create the shader
  88211. */
  88212. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88213. /**
  88214. * Gets the shader path used to define the shader code
  88215. * It can be modified to trigger a new compilation
  88216. */
  88217. /**
  88218. * Sets the shader path used to define the shader code
  88219. * It can be modified to trigger a new compilation
  88220. */
  88221. shaderPath: any;
  88222. /**
  88223. * Gets the options used to compile the shader.
  88224. * They can be modified to trigger a new compilation
  88225. */
  88226. readonly options: IShaderMaterialOptions;
  88227. /**
  88228. * Gets the current class name of the material e.g. "ShaderMaterial"
  88229. * Mainly use in serialization.
  88230. * @returns the class name
  88231. */
  88232. getClassName(): string;
  88233. /**
  88234. * Specifies if the material will require alpha blending
  88235. * @returns a boolean specifying if alpha blending is needed
  88236. */
  88237. needAlphaBlending(): boolean;
  88238. /**
  88239. * Specifies if this material should be rendered in alpha test mode
  88240. * @returns a boolean specifying if an alpha test is needed.
  88241. */
  88242. needAlphaTesting(): boolean;
  88243. private _checkUniform;
  88244. /**
  88245. * Set a texture in the shader.
  88246. * @param name Define the name of the uniform samplers as defined in the shader
  88247. * @param texture Define the texture to bind to this sampler
  88248. * @return the material itself allowing "fluent" like uniform updates
  88249. */
  88250. setTexture(name: string, texture: Texture): ShaderMaterial;
  88251. /**
  88252. * Set a texture array in the shader.
  88253. * @param name Define the name of the uniform sampler array as defined in the shader
  88254. * @param textures Define the list of textures to bind to this sampler
  88255. * @return the material itself allowing "fluent" like uniform updates
  88256. */
  88257. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88258. /**
  88259. * Set a float in the shader.
  88260. * @param name Define the name of the uniform as defined in the shader
  88261. * @param value Define the value to give to the uniform
  88262. * @return the material itself allowing "fluent" like uniform updates
  88263. */
  88264. setFloat(name: string, value: number): ShaderMaterial;
  88265. /**
  88266. * Set a int in the shader.
  88267. * @param name Define the name of the uniform as defined in the shader
  88268. * @param value Define the value to give to the uniform
  88269. * @return the material itself allowing "fluent" like uniform updates
  88270. */
  88271. setInt(name: string, value: number): ShaderMaterial;
  88272. /**
  88273. * Set an array of floats in the shader.
  88274. * @param name Define the name of the uniform as defined in the shader
  88275. * @param value Define the value to give to the uniform
  88276. * @return the material itself allowing "fluent" like uniform updates
  88277. */
  88278. setFloats(name: string, value: number[]): ShaderMaterial;
  88279. /**
  88280. * Set a vec3 in the shader from a Color3.
  88281. * @param name Define the name of the uniform as defined in the shader
  88282. * @param value Define the value to give to the uniform
  88283. * @return the material itself allowing "fluent" like uniform updates
  88284. */
  88285. setColor3(name: string, value: Color3): ShaderMaterial;
  88286. /**
  88287. * Set a vec3 array in the shader from a Color3 array.
  88288. * @param name Define the name of the uniform as defined in the shader
  88289. * @param value Define the value to give to the uniform
  88290. * @return the material itself allowing "fluent" like uniform updates
  88291. */
  88292. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88293. /**
  88294. * Set a vec4 in the shader from a Color4.
  88295. * @param name Define the name of the uniform as defined in the shader
  88296. * @param value Define the value to give to the uniform
  88297. * @return the material itself allowing "fluent" like uniform updates
  88298. */
  88299. setColor4(name: string, value: Color4): ShaderMaterial;
  88300. /**
  88301. * Set a vec4 array in the shader from a Color4 array.
  88302. * @param name Define the name of the uniform as defined in the shader
  88303. * @param value Define the value to give to the uniform
  88304. * @return the material itself allowing "fluent" like uniform updates
  88305. */
  88306. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88307. /**
  88308. * Set a vec2 in the shader from a Vector2.
  88309. * @param name Define the name of the uniform as defined in the shader
  88310. * @param value Define the value to give to the uniform
  88311. * @return the material itself allowing "fluent" like uniform updates
  88312. */
  88313. setVector2(name: string, value: Vector2): ShaderMaterial;
  88314. /**
  88315. * Set a vec3 in the shader from a Vector3.
  88316. * @param name Define the name of the uniform as defined in the shader
  88317. * @param value Define the value to give to the uniform
  88318. * @return the material itself allowing "fluent" like uniform updates
  88319. */
  88320. setVector3(name: string, value: Vector3): ShaderMaterial;
  88321. /**
  88322. * Set a vec4 in the shader from a Vector4.
  88323. * @param name Define the name of the uniform as defined in the shader
  88324. * @param value Define the value to give to the uniform
  88325. * @return the material itself allowing "fluent" like uniform updates
  88326. */
  88327. setVector4(name: string, value: Vector4): ShaderMaterial;
  88328. /**
  88329. * Set a mat4 in the shader from a Matrix.
  88330. * @param name Define the name of the uniform as defined in the shader
  88331. * @param value Define the value to give to the uniform
  88332. * @return the material itself allowing "fluent" like uniform updates
  88333. */
  88334. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88335. /**
  88336. * Set a float32Array in the shader from a matrix array.
  88337. * @param name Define the name of the uniform as defined in the shader
  88338. * @param value Define the value to give to the uniform
  88339. * @return the material itself allowing "fluent" like uniform updates
  88340. */
  88341. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88342. /**
  88343. * Set a mat3 in the shader from a Float32Array.
  88344. * @param name Define the name of the uniform as defined in the shader
  88345. * @param value Define the value to give to the uniform
  88346. * @return the material itself allowing "fluent" like uniform updates
  88347. */
  88348. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88349. /**
  88350. * Set a mat2 in the shader from a Float32Array.
  88351. * @param name Define the name of the uniform as defined in the shader
  88352. * @param value Define the value to give to the uniform
  88353. * @return the material itself allowing "fluent" like uniform updates
  88354. */
  88355. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88356. /**
  88357. * Set a vec2 array in the shader from a number array.
  88358. * @param name Define the name of the uniform as defined in the shader
  88359. * @param value Define the value to give to the uniform
  88360. * @return the material itself allowing "fluent" like uniform updates
  88361. */
  88362. setArray2(name: string, value: number[]): ShaderMaterial;
  88363. /**
  88364. * Set a vec3 array in the shader from a number array.
  88365. * @param name Define the name of the uniform as defined in the shader
  88366. * @param value Define the value to give to the uniform
  88367. * @return the material itself allowing "fluent" like uniform updates
  88368. */
  88369. setArray3(name: string, value: number[]): ShaderMaterial;
  88370. /**
  88371. * Set a vec4 array in the shader from a number array.
  88372. * @param name Define the name of the uniform as defined in the shader
  88373. * @param value Define the value to give to the uniform
  88374. * @return the material itself allowing "fluent" like uniform updates
  88375. */
  88376. setArray4(name: string, value: number[]): ShaderMaterial;
  88377. private _checkCache;
  88378. /**
  88379. * Specifies that the submesh is ready to be used
  88380. * @param mesh defines the mesh to check
  88381. * @param subMesh defines which submesh to check
  88382. * @param useInstances specifies that instances should be used
  88383. * @returns a boolean indicating that the submesh is ready or not
  88384. */
  88385. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88386. /**
  88387. * Checks if the material is ready to render the requested mesh
  88388. * @param mesh Define the mesh to render
  88389. * @param useInstances Define whether or not the material is used with instances
  88390. * @returns true if ready, otherwise false
  88391. */
  88392. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88393. /**
  88394. * Binds the world matrix to the material
  88395. * @param world defines the world transformation matrix
  88396. */
  88397. bindOnlyWorldMatrix(world: Matrix): void;
  88398. /**
  88399. * Binds the material to the mesh
  88400. * @param world defines the world transformation matrix
  88401. * @param mesh defines the mesh to bind the material to
  88402. */
  88403. bind(world: Matrix, mesh?: Mesh): void;
  88404. /**
  88405. * Gets the active textures from the material
  88406. * @returns an array of textures
  88407. */
  88408. getActiveTextures(): BaseTexture[];
  88409. /**
  88410. * Specifies if the material uses a texture
  88411. * @param texture defines the texture to check against the material
  88412. * @returns a boolean specifying if the material uses the texture
  88413. */
  88414. hasTexture(texture: BaseTexture): boolean;
  88415. /**
  88416. * Makes a duplicate of the material, and gives it a new name
  88417. * @param name defines the new name for the duplicated material
  88418. * @returns the cloned material
  88419. */
  88420. clone(name: string): ShaderMaterial;
  88421. /**
  88422. * Disposes the material
  88423. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88424. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88425. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88426. */
  88427. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88428. /**
  88429. * Serializes this material in a JSON representation
  88430. * @returns the serialized material object
  88431. */
  88432. serialize(): any;
  88433. /**
  88434. * Creates a shader material from parsed shader material data
  88435. * @param source defines the JSON represnetation of the material
  88436. * @param scene defines the hosting scene
  88437. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88438. * @returns a new material
  88439. */
  88440. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88441. }
  88442. }
  88443. declare module BABYLON {
  88444. /** @hidden */
  88445. export var colorPixelShader: {
  88446. name: string;
  88447. shader: string;
  88448. };
  88449. }
  88450. declare module BABYLON {
  88451. /** @hidden */
  88452. export var colorVertexShader: {
  88453. name: string;
  88454. shader: string;
  88455. };
  88456. }
  88457. declare module BABYLON {
  88458. /**
  88459. * Line mesh
  88460. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88461. */
  88462. export class LinesMesh extends Mesh {
  88463. /**
  88464. * If vertex color should be applied to the mesh
  88465. */
  88466. readonly useVertexColor?: boolean | undefined;
  88467. /**
  88468. * If vertex alpha should be applied to the mesh
  88469. */
  88470. readonly useVertexAlpha?: boolean | undefined;
  88471. /**
  88472. * Color of the line (Default: White)
  88473. */
  88474. color: Color3;
  88475. /**
  88476. * Alpha of the line (Default: 1)
  88477. */
  88478. alpha: number;
  88479. /**
  88480. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88481. * This margin is expressed in world space coordinates, so its value may vary.
  88482. * Default value is 0.1
  88483. */
  88484. intersectionThreshold: number;
  88485. private _colorShader;
  88486. private color4;
  88487. /**
  88488. * Creates a new LinesMesh
  88489. * @param name defines the name
  88490. * @param scene defines the hosting scene
  88491. * @param parent defines the parent mesh if any
  88492. * @param source defines the optional source LinesMesh used to clone data from
  88493. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88494. * When false, achieved by calling a clone(), also passing False.
  88495. * This will make creation of children, recursive.
  88496. * @param useVertexColor defines if this LinesMesh supports vertex color
  88497. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88498. */
  88499. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88500. /**
  88501. * If vertex color should be applied to the mesh
  88502. */
  88503. useVertexColor?: boolean | undefined,
  88504. /**
  88505. * If vertex alpha should be applied to the mesh
  88506. */
  88507. useVertexAlpha?: boolean | undefined);
  88508. private _addClipPlaneDefine;
  88509. private _removeClipPlaneDefine;
  88510. isReady(): boolean;
  88511. /**
  88512. * Returns the string "LineMesh"
  88513. */
  88514. getClassName(): string;
  88515. /**
  88516. * @hidden
  88517. */
  88518. /**
  88519. * @hidden
  88520. */
  88521. material: Material;
  88522. /**
  88523. * @hidden
  88524. */
  88525. readonly checkCollisions: boolean;
  88526. /** @hidden */
  88527. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88528. /** @hidden */
  88529. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88530. /**
  88531. * Disposes of the line mesh
  88532. * @param doNotRecurse If children should be disposed
  88533. */
  88534. dispose(doNotRecurse?: boolean): void;
  88535. /**
  88536. * Returns a new LineMesh object cloned from the current one.
  88537. */
  88538. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88539. /**
  88540. * Creates a new InstancedLinesMesh object from the mesh model.
  88541. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88542. * @param name defines the name of the new instance
  88543. * @returns a new InstancedLinesMesh
  88544. */
  88545. createInstance(name: string): InstancedLinesMesh;
  88546. }
  88547. /**
  88548. * Creates an instance based on a source LinesMesh
  88549. */
  88550. export class InstancedLinesMesh extends InstancedMesh {
  88551. /**
  88552. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88553. * This margin is expressed in world space coordinates, so its value may vary.
  88554. * Initilized with the intersectionThreshold value of the source LinesMesh
  88555. */
  88556. intersectionThreshold: number;
  88557. constructor(name: string, source: LinesMesh);
  88558. /**
  88559. * Returns the string "InstancedLinesMesh".
  88560. */
  88561. getClassName(): string;
  88562. }
  88563. }
  88564. declare module BABYLON {
  88565. /** @hidden */
  88566. export var linePixelShader: {
  88567. name: string;
  88568. shader: string;
  88569. };
  88570. }
  88571. declare module BABYLON {
  88572. /** @hidden */
  88573. export var lineVertexShader: {
  88574. name: string;
  88575. shader: string;
  88576. };
  88577. }
  88578. declare module BABYLON {
  88579. interface AbstractMesh {
  88580. /**
  88581. * Gets the edgesRenderer associated with the mesh
  88582. */
  88583. edgesRenderer: Nullable<EdgesRenderer>;
  88584. }
  88585. interface LinesMesh {
  88586. /**
  88587. * Enables the edge rendering mode on the mesh.
  88588. * This mode makes the mesh edges visible
  88589. * @param epsilon defines the maximal distance between two angles to detect a face
  88590. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88591. * @returns the currentAbstractMesh
  88592. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88593. */
  88594. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88595. }
  88596. interface InstancedLinesMesh {
  88597. /**
  88598. * Enables the edge rendering mode on the mesh.
  88599. * This mode makes the mesh edges visible
  88600. * @param epsilon defines the maximal distance between two angles to detect a face
  88601. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88602. * @returns the current InstancedLinesMesh
  88603. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88604. */
  88605. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88606. }
  88607. /**
  88608. * Defines the minimum contract an Edges renderer should follow.
  88609. */
  88610. export interface IEdgesRenderer extends IDisposable {
  88611. /**
  88612. * Gets or sets a boolean indicating if the edgesRenderer is active
  88613. */
  88614. isEnabled: boolean;
  88615. /**
  88616. * Renders the edges of the attached mesh,
  88617. */
  88618. render(): void;
  88619. /**
  88620. * Checks wether or not the edges renderer is ready to render.
  88621. * @return true if ready, otherwise false.
  88622. */
  88623. isReady(): boolean;
  88624. }
  88625. /**
  88626. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88627. */
  88628. export class EdgesRenderer implements IEdgesRenderer {
  88629. /**
  88630. * Define the size of the edges with an orthographic camera
  88631. */
  88632. edgesWidthScalerForOrthographic: number;
  88633. /**
  88634. * Define the size of the edges with a perspective camera
  88635. */
  88636. edgesWidthScalerForPerspective: number;
  88637. protected _source: AbstractMesh;
  88638. protected _linesPositions: number[];
  88639. protected _linesNormals: number[];
  88640. protected _linesIndices: number[];
  88641. protected _epsilon: number;
  88642. protected _indicesCount: number;
  88643. protected _lineShader: ShaderMaterial;
  88644. protected _ib: DataBuffer;
  88645. protected _buffers: {
  88646. [key: string]: Nullable<VertexBuffer>;
  88647. };
  88648. protected _checkVerticesInsteadOfIndices: boolean;
  88649. private _meshRebuildObserver;
  88650. private _meshDisposeObserver;
  88651. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88652. isEnabled: boolean;
  88653. /**
  88654. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88655. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88656. * @param source Mesh used to create edges
  88657. * @param epsilon sum of angles in adjacency to check for edge
  88658. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88659. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88660. */
  88661. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88662. protected _prepareRessources(): void;
  88663. /** @hidden */
  88664. _rebuild(): void;
  88665. /**
  88666. * Releases the required resources for the edges renderer
  88667. */
  88668. dispose(): void;
  88669. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88670. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88671. /**
  88672. * Checks if the pair of p0 and p1 is en edge
  88673. * @param faceIndex
  88674. * @param edge
  88675. * @param faceNormals
  88676. * @param p0
  88677. * @param p1
  88678. * @private
  88679. */
  88680. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88681. /**
  88682. * push line into the position, normal and index buffer
  88683. * @protected
  88684. */
  88685. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88686. /**
  88687. * Generates lines edges from adjacencjes
  88688. * @private
  88689. */
  88690. _generateEdgesLines(): void;
  88691. /**
  88692. * Checks wether or not the edges renderer is ready to render.
  88693. * @return true if ready, otherwise false.
  88694. */
  88695. isReady(): boolean;
  88696. /**
  88697. * Renders the edges of the attached mesh,
  88698. */
  88699. render(): void;
  88700. }
  88701. /**
  88702. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88703. */
  88704. export class LineEdgesRenderer extends EdgesRenderer {
  88705. /**
  88706. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88707. * @param source LineMesh used to generate edges
  88708. * @param epsilon not important (specified angle for edge detection)
  88709. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88710. */
  88711. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88712. /**
  88713. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88714. */
  88715. _generateEdgesLines(): void;
  88716. }
  88717. }
  88718. declare module BABYLON {
  88719. /**
  88720. * This represents the object necessary to create a rendering group.
  88721. * This is exclusively used and created by the rendering manager.
  88722. * To modify the behavior, you use the available helpers in your scene or meshes.
  88723. * @hidden
  88724. */
  88725. export class RenderingGroup {
  88726. index: number;
  88727. private static _zeroVector;
  88728. private _scene;
  88729. private _opaqueSubMeshes;
  88730. private _transparentSubMeshes;
  88731. private _alphaTestSubMeshes;
  88732. private _depthOnlySubMeshes;
  88733. private _particleSystems;
  88734. private _spriteManagers;
  88735. private _opaqueSortCompareFn;
  88736. private _alphaTestSortCompareFn;
  88737. private _transparentSortCompareFn;
  88738. private _renderOpaque;
  88739. private _renderAlphaTest;
  88740. private _renderTransparent;
  88741. /** @hidden */
  88742. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88743. onBeforeTransparentRendering: () => void;
  88744. /**
  88745. * Set the opaque sort comparison function.
  88746. * If null the sub meshes will be render in the order they were created
  88747. */
  88748. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88749. /**
  88750. * Set the alpha test sort comparison function.
  88751. * If null the sub meshes will be render in the order they were created
  88752. */
  88753. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88754. /**
  88755. * Set the transparent sort comparison function.
  88756. * If null the sub meshes will be render in the order they were created
  88757. */
  88758. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88759. /**
  88760. * Creates a new rendering group.
  88761. * @param index The rendering group index
  88762. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88763. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88764. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88765. */
  88766. 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>);
  88767. /**
  88768. * Render all the sub meshes contained in the group.
  88769. * @param customRenderFunction Used to override the default render behaviour of the group.
  88770. * @returns true if rendered some submeshes.
  88771. */
  88772. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88773. /**
  88774. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88775. * @param subMeshes The submeshes to render
  88776. */
  88777. private renderOpaqueSorted;
  88778. /**
  88779. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88780. * @param subMeshes The submeshes to render
  88781. */
  88782. private renderAlphaTestSorted;
  88783. /**
  88784. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88785. * @param subMeshes The submeshes to render
  88786. */
  88787. private renderTransparentSorted;
  88788. /**
  88789. * Renders the submeshes in a specified order.
  88790. * @param subMeshes The submeshes to sort before render
  88791. * @param sortCompareFn The comparison function use to sort
  88792. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88793. * @param transparent Specifies to activate blending if true
  88794. */
  88795. private static renderSorted;
  88796. /**
  88797. * Renders the submeshes in the order they were dispatched (no sort applied).
  88798. * @param subMeshes The submeshes to render
  88799. */
  88800. private static renderUnsorted;
  88801. /**
  88802. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88803. * are rendered back to front if in the same alpha index.
  88804. *
  88805. * @param a The first submesh
  88806. * @param b The second submesh
  88807. * @returns The result of the comparison
  88808. */
  88809. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88810. /**
  88811. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88812. * are rendered back to front.
  88813. *
  88814. * @param a The first submesh
  88815. * @param b The second submesh
  88816. * @returns The result of the comparison
  88817. */
  88818. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88819. /**
  88820. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88821. * are rendered front to back (prevent overdraw).
  88822. *
  88823. * @param a The first submesh
  88824. * @param b The second submesh
  88825. * @returns The result of the comparison
  88826. */
  88827. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88828. /**
  88829. * Resets the different lists of submeshes to prepare a new frame.
  88830. */
  88831. prepare(): void;
  88832. dispose(): void;
  88833. /**
  88834. * Inserts the submesh in its correct queue depending on its material.
  88835. * @param subMesh The submesh to dispatch
  88836. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88837. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88838. */
  88839. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88840. dispatchSprites(spriteManager: ISpriteManager): void;
  88841. dispatchParticles(particleSystem: IParticleSystem): void;
  88842. private _renderParticles;
  88843. private _renderSprites;
  88844. }
  88845. }
  88846. declare module BABYLON {
  88847. /**
  88848. * Interface describing the different options available in the rendering manager
  88849. * regarding Auto Clear between groups.
  88850. */
  88851. export interface IRenderingManagerAutoClearSetup {
  88852. /**
  88853. * Defines whether or not autoclear is enable.
  88854. */
  88855. autoClear: boolean;
  88856. /**
  88857. * Defines whether or not to autoclear the depth buffer.
  88858. */
  88859. depth: boolean;
  88860. /**
  88861. * Defines whether or not to autoclear the stencil buffer.
  88862. */
  88863. stencil: boolean;
  88864. }
  88865. /**
  88866. * This class is used by the onRenderingGroupObservable
  88867. */
  88868. export class RenderingGroupInfo {
  88869. /**
  88870. * The Scene that being rendered
  88871. */
  88872. scene: Scene;
  88873. /**
  88874. * The camera currently used for the rendering pass
  88875. */
  88876. camera: Nullable<Camera>;
  88877. /**
  88878. * The ID of the renderingGroup being processed
  88879. */
  88880. renderingGroupId: number;
  88881. }
  88882. /**
  88883. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88884. * It is enable to manage the different groups as well as the different necessary sort functions.
  88885. * This should not be used directly aside of the few static configurations
  88886. */
  88887. export class RenderingManager {
  88888. /**
  88889. * The max id used for rendering groups (not included)
  88890. */
  88891. static MAX_RENDERINGGROUPS: number;
  88892. /**
  88893. * The min id used for rendering groups (included)
  88894. */
  88895. static MIN_RENDERINGGROUPS: number;
  88896. /**
  88897. * Used to globally prevent autoclearing scenes.
  88898. */
  88899. static AUTOCLEAR: boolean;
  88900. /**
  88901. * @hidden
  88902. */
  88903. _useSceneAutoClearSetup: boolean;
  88904. private _scene;
  88905. private _renderingGroups;
  88906. private _depthStencilBufferAlreadyCleaned;
  88907. private _autoClearDepthStencil;
  88908. private _customOpaqueSortCompareFn;
  88909. private _customAlphaTestSortCompareFn;
  88910. private _customTransparentSortCompareFn;
  88911. private _renderingGroupInfo;
  88912. /**
  88913. * Instantiates a new rendering group for a particular scene
  88914. * @param scene Defines the scene the groups belongs to
  88915. */
  88916. constructor(scene: Scene);
  88917. private _clearDepthStencilBuffer;
  88918. /**
  88919. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88920. * @hidden
  88921. */
  88922. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88923. /**
  88924. * Resets the different information of the group to prepare a new frame
  88925. * @hidden
  88926. */
  88927. reset(): void;
  88928. /**
  88929. * Dispose and release the group and its associated resources.
  88930. * @hidden
  88931. */
  88932. dispose(): void;
  88933. /**
  88934. * Clear the info related to rendering groups preventing retention points during dispose.
  88935. */
  88936. freeRenderingGroups(): void;
  88937. private _prepareRenderingGroup;
  88938. /**
  88939. * Add a sprite manager to the rendering manager in order to render it this frame.
  88940. * @param spriteManager Define the sprite manager to render
  88941. */
  88942. dispatchSprites(spriteManager: ISpriteManager): void;
  88943. /**
  88944. * Add a particle system to the rendering manager in order to render it this frame.
  88945. * @param particleSystem Define the particle system to render
  88946. */
  88947. dispatchParticles(particleSystem: IParticleSystem): void;
  88948. /**
  88949. * Add a submesh to the manager in order to render it this frame
  88950. * @param subMesh The submesh to dispatch
  88951. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88952. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88953. */
  88954. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88955. /**
  88956. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88957. * This allowed control for front to back rendering or reversly depending of the special needs.
  88958. *
  88959. * @param renderingGroupId The rendering group id corresponding to its index
  88960. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88961. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88962. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88963. */
  88964. 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;
  88965. /**
  88966. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88967. *
  88968. * @param renderingGroupId The rendering group id corresponding to its index
  88969. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88970. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88971. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88972. */
  88973. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88974. /**
  88975. * Gets the current auto clear configuration for one rendering group of the rendering
  88976. * manager.
  88977. * @param index the rendering group index to get the information for
  88978. * @returns The auto clear setup for the requested rendering group
  88979. */
  88980. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88981. }
  88982. }
  88983. declare module BABYLON {
  88984. /**
  88985. * This Helps creating a texture that will be created from a camera in your scene.
  88986. * It is basically a dynamic texture that could be used to create special effects for instance.
  88987. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88988. */
  88989. export class RenderTargetTexture extends Texture {
  88990. isCube: boolean;
  88991. /**
  88992. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88993. */
  88994. static readonly REFRESHRATE_RENDER_ONCE: number;
  88995. /**
  88996. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88997. */
  88998. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88999. /**
  89000. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  89001. * the central point of your effect and can save a lot of performances.
  89002. */
  89003. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  89004. /**
  89005. * Use this predicate to dynamically define the list of mesh you want to render.
  89006. * If set, the renderList property will be overwritten.
  89007. */
  89008. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  89009. private _renderList;
  89010. /**
  89011. * Use this list to define the list of mesh you want to render.
  89012. */
  89013. renderList: Nullable<Array<AbstractMesh>>;
  89014. private _hookArray;
  89015. /**
  89016. * Define if particles should be rendered in your texture.
  89017. */
  89018. renderParticles: boolean;
  89019. /**
  89020. * Define if sprites should be rendered in your texture.
  89021. */
  89022. renderSprites: boolean;
  89023. /**
  89024. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89025. */
  89026. coordinatesMode: number;
  89027. /**
  89028. * Define the camera used to render the texture.
  89029. */
  89030. activeCamera: Nullable<Camera>;
  89031. /**
  89032. * Override the render function of the texture with your own one.
  89033. */
  89034. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89035. /**
  89036. * Define if camera post processes should be use while rendering the texture.
  89037. */
  89038. useCameraPostProcesses: boolean;
  89039. /**
  89040. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89041. */
  89042. ignoreCameraViewport: boolean;
  89043. private _postProcessManager;
  89044. private _postProcesses;
  89045. private _resizeObserver;
  89046. /**
  89047. * An event triggered when the texture is unbind.
  89048. */
  89049. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89050. /**
  89051. * An event triggered when the texture is unbind.
  89052. */
  89053. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89054. private _onAfterUnbindObserver;
  89055. /**
  89056. * Set a after unbind callback in the texture.
  89057. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89058. */
  89059. onAfterUnbind: () => void;
  89060. /**
  89061. * An event triggered before rendering the texture
  89062. */
  89063. onBeforeRenderObservable: Observable<number>;
  89064. private _onBeforeRenderObserver;
  89065. /**
  89066. * Set a before render callback in the texture.
  89067. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89068. */
  89069. onBeforeRender: (faceIndex: number) => void;
  89070. /**
  89071. * An event triggered after rendering the texture
  89072. */
  89073. onAfterRenderObservable: Observable<number>;
  89074. private _onAfterRenderObserver;
  89075. /**
  89076. * Set a after render callback in the texture.
  89077. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89078. */
  89079. onAfterRender: (faceIndex: number) => void;
  89080. /**
  89081. * An event triggered after the texture clear
  89082. */
  89083. onClearObservable: Observable<Engine>;
  89084. private _onClearObserver;
  89085. /**
  89086. * Set a clear callback in the texture.
  89087. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89088. */
  89089. onClear: (Engine: Engine) => void;
  89090. /**
  89091. * An event triggered when the texture is resized.
  89092. */
  89093. onResizeObservable: Observable<RenderTargetTexture>;
  89094. /**
  89095. * Define the clear color of the Render Target if it should be different from the scene.
  89096. */
  89097. clearColor: Color4;
  89098. protected _size: number | {
  89099. width: number;
  89100. height: number;
  89101. };
  89102. protected _initialSizeParameter: number | {
  89103. width: number;
  89104. height: number;
  89105. } | {
  89106. ratio: number;
  89107. };
  89108. protected _sizeRatio: Nullable<number>;
  89109. /** @hidden */
  89110. _generateMipMaps: boolean;
  89111. protected _renderingManager: RenderingManager;
  89112. /** @hidden */
  89113. _waitingRenderList: string[];
  89114. protected _doNotChangeAspectRatio: boolean;
  89115. protected _currentRefreshId: number;
  89116. protected _refreshRate: number;
  89117. protected _textureMatrix: Matrix;
  89118. protected _samples: number;
  89119. protected _renderTargetOptions: RenderTargetCreationOptions;
  89120. /**
  89121. * Gets render target creation options that were used.
  89122. */
  89123. readonly renderTargetOptions: RenderTargetCreationOptions;
  89124. protected _engine: Engine;
  89125. protected _onRatioRescale(): void;
  89126. /**
  89127. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89128. * It must define where the camera used to render the texture is set
  89129. */
  89130. boundingBoxPosition: Vector3;
  89131. private _boundingBoxSize;
  89132. /**
  89133. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89134. * When defined, the cubemap will switch to local mode
  89135. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89136. * @example https://www.babylonjs-playground.com/#RNASML
  89137. */
  89138. boundingBoxSize: Vector3;
  89139. /**
  89140. * In case the RTT has been created with a depth texture, get the associated
  89141. * depth texture.
  89142. * Otherwise, return null.
  89143. */
  89144. depthStencilTexture: Nullable<InternalTexture>;
  89145. /**
  89146. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89147. * or used a shadow, depth texture...
  89148. * @param name The friendly name of the texture
  89149. * @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)
  89150. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89151. * @param generateMipMaps True if mip maps need to be generated after render.
  89152. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89153. * @param type The type of the buffer in the RTT (int, half float, float...)
  89154. * @param isCube True if a cube texture needs to be created
  89155. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89156. * @param generateDepthBuffer True to generate a depth buffer
  89157. * @param generateStencilBuffer True to generate a stencil buffer
  89158. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89159. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89160. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89161. */
  89162. constructor(name: string, size: number | {
  89163. width: number;
  89164. height: number;
  89165. } | {
  89166. ratio: number;
  89167. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89168. /**
  89169. * Creates a depth stencil texture.
  89170. * This is only available in WebGL 2 or with the depth texture extension available.
  89171. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89172. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89173. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89174. */
  89175. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89176. private _processSizeParameter;
  89177. /**
  89178. * Define the number of samples to use in case of MSAA.
  89179. * It defaults to one meaning no MSAA has been enabled.
  89180. */
  89181. samples: number;
  89182. /**
  89183. * Resets the refresh counter of the texture and start bak from scratch.
  89184. * Could be useful to regenerate the texture if it is setup to render only once.
  89185. */
  89186. resetRefreshCounter(): void;
  89187. /**
  89188. * Define the refresh rate of the texture or the rendering frequency.
  89189. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89190. */
  89191. refreshRate: number;
  89192. /**
  89193. * Adds a post process to the render target rendering passes.
  89194. * @param postProcess define the post process to add
  89195. */
  89196. addPostProcess(postProcess: PostProcess): void;
  89197. /**
  89198. * Clear all the post processes attached to the render target
  89199. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89200. */
  89201. clearPostProcesses(dispose?: boolean): void;
  89202. /**
  89203. * Remove one of the post process from the list of attached post processes to the texture
  89204. * @param postProcess define the post process to remove from the list
  89205. */
  89206. removePostProcess(postProcess: PostProcess): void;
  89207. /** @hidden */
  89208. _shouldRender(): boolean;
  89209. /**
  89210. * Gets the actual render size of the texture.
  89211. * @returns the width of the render size
  89212. */
  89213. getRenderSize(): number;
  89214. /**
  89215. * Gets the actual render width of the texture.
  89216. * @returns the width of the render size
  89217. */
  89218. getRenderWidth(): number;
  89219. /**
  89220. * Gets the actual render height of the texture.
  89221. * @returns the height of the render size
  89222. */
  89223. getRenderHeight(): number;
  89224. /**
  89225. * Get if the texture can be rescaled or not.
  89226. */
  89227. readonly canRescale: boolean;
  89228. /**
  89229. * Resize the texture using a ratio.
  89230. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89231. */
  89232. scale(ratio: number): void;
  89233. /**
  89234. * Get the texture reflection matrix used to rotate/transform the reflection.
  89235. * @returns the reflection matrix
  89236. */
  89237. getReflectionTextureMatrix(): Matrix;
  89238. /**
  89239. * Resize the texture to a new desired size.
  89240. * Be carrefull as it will recreate all the data in the new texture.
  89241. * @param size Define the new size. It can be:
  89242. * - a number for squared texture,
  89243. * - an object containing { width: number, height: number }
  89244. * - or an object containing a ratio { ratio: number }
  89245. */
  89246. resize(size: number | {
  89247. width: number;
  89248. height: number;
  89249. } | {
  89250. ratio: number;
  89251. }): void;
  89252. /**
  89253. * Renders all the objects from the render list into the texture.
  89254. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89255. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89256. */
  89257. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89258. private _bestReflectionRenderTargetDimension;
  89259. /**
  89260. * @hidden
  89261. * @param faceIndex face index to bind to if this is a cubetexture
  89262. */
  89263. _bindFrameBuffer(faceIndex?: number): void;
  89264. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89265. private renderToTarget;
  89266. /**
  89267. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89268. * This allowed control for front to back rendering or reversly depending of the special needs.
  89269. *
  89270. * @param renderingGroupId The rendering group id corresponding to its index
  89271. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89272. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89273. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89274. */
  89275. 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;
  89276. /**
  89277. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89278. *
  89279. * @param renderingGroupId The rendering group id corresponding to its index
  89280. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89281. */
  89282. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89283. /**
  89284. * Clones the texture.
  89285. * @returns the cloned texture
  89286. */
  89287. clone(): RenderTargetTexture;
  89288. /**
  89289. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89290. * @returns The JSON representation of the texture
  89291. */
  89292. serialize(): any;
  89293. /**
  89294. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89295. */
  89296. disposeFramebufferObjects(): void;
  89297. /**
  89298. * Dispose the texture and release its associated resources.
  89299. */
  89300. dispose(): void;
  89301. /** @hidden */
  89302. _rebuild(): void;
  89303. /**
  89304. * Clear the info related to rendering groups preventing retention point in material dispose.
  89305. */
  89306. freeRenderingGroups(): void;
  89307. /**
  89308. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89309. * @returns the view count
  89310. */
  89311. getViewCount(): number;
  89312. }
  89313. }
  89314. declare module BABYLON {
  89315. /**
  89316. * Options for compiling materials.
  89317. */
  89318. export interface IMaterialCompilationOptions {
  89319. /**
  89320. * Defines whether clip planes are enabled.
  89321. */
  89322. clipPlane: boolean;
  89323. /**
  89324. * Defines whether instances are enabled.
  89325. */
  89326. useInstances: boolean;
  89327. }
  89328. /**
  89329. * Base class for the main features of a material in Babylon.js
  89330. */
  89331. export class Material implements IAnimatable {
  89332. /**
  89333. * Returns the triangle fill mode
  89334. */
  89335. static readonly TriangleFillMode: number;
  89336. /**
  89337. * Returns the wireframe mode
  89338. */
  89339. static readonly WireFrameFillMode: number;
  89340. /**
  89341. * Returns the point fill mode
  89342. */
  89343. static readonly PointFillMode: number;
  89344. /**
  89345. * Returns the point list draw mode
  89346. */
  89347. static readonly PointListDrawMode: number;
  89348. /**
  89349. * Returns the line list draw mode
  89350. */
  89351. static readonly LineListDrawMode: number;
  89352. /**
  89353. * Returns the line loop draw mode
  89354. */
  89355. static readonly LineLoopDrawMode: number;
  89356. /**
  89357. * Returns the line strip draw mode
  89358. */
  89359. static readonly LineStripDrawMode: number;
  89360. /**
  89361. * Returns the triangle strip draw mode
  89362. */
  89363. static readonly TriangleStripDrawMode: number;
  89364. /**
  89365. * Returns the triangle fan draw mode
  89366. */
  89367. static readonly TriangleFanDrawMode: number;
  89368. /**
  89369. * Stores the clock-wise side orientation
  89370. */
  89371. static readonly ClockWiseSideOrientation: number;
  89372. /**
  89373. * Stores the counter clock-wise side orientation
  89374. */
  89375. static readonly CounterClockWiseSideOrientation: number;
  89376. /**
  89377. * The dirty texture flag value
  89378. */
  89379. static readonly TextureDirtyFlag: number;
  89380. /**
  89381. * The dirty light flag value
  89382. */
  89383. static readonly LightDirtyFlag: number;
  89384. /**
  89385. * The dirty fresnel flag value
  89386. */
  89387. static readonly FresnelDirtyFlag: number;
  89388. /**
  89389. * The dirty attribute flag value
  89390. */
  89391. static readonly AttributesDirtyFlag: number;
  89392. /**
  89393. * The dirty misc flag value
  89394. */
  89395. static readonly MiscDirtyFlag: number;
  89396. /**
  89397. * The all dirty flag value
  89398. */
  89399. static readonly AllDirtyFlag: number;
  89400. /**
  89401. * The ID of the material
  89402. */
  89403. id: string;
  89404. /**
  89405. * Gets or sets the unique id of the material
  89406. */
  89407. uniqueId: number;
  89408. /**
  89409. * The name of the material
  89410. */
  89411. name: string;
  89412. /**
  89413. * Gets or sets user defined metadata
  89414. */
  89415. metadata: any;
  89416. /**
  89417. * For internal use only. Please do not use.
  89418. */
  89419. reservedDataStore: any;
  89420. /**
  89421. * Specifies if the ready state should be checked on each call
  89422. */
  89423. checkReadyOnEveryCall: boolean;
  89424. /**
  89425. * Specifies if the ready state should be checked once
  89426. */
  89427. checkReadyOnlyOnce: boolean;
  89428. /**
  89429. * The state of the material
  89430. */
  89431. state: string;
  89432. /**
  89433. * The alpha value of the material
  89434. */
  89435. protected _alpha: number;
  89436. /**
  89437. * List of inspectable custom properties (used by the Inspector)
  89438. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89439. */
  89440. inspectableCustomProperties: IInspectable[];
  89441. /**
  89442. * Sets the alpha value of the material
  89443. */
  89444. /**
  89445. * Gets the alpha value of the material
  89446. */
  89447. alpha: number;
  89448. /**
  89449. * Specifies if back face culling is enabled
  89450. */
  89451. protected _backFaceCulling: boolean;
  89452. /**
  89453. * Sets the back-face culling state
  89454. */
  89455. /**
  89456. * Gets the back-face culling state
  89457. */
  89458. backFaceCulling: boolean;
  89459. /**
  89460. * Stores the value for side orientation
  89461. */
  89462. sideOrientation: number;
  89463. /**
  89464. * Callback triggered when the material is compiled
  89465. */
  89466. onCompiled: Nullable<(effect: Effect) => void>;
  89467. /**
  89468. * Callback triggered when an error occurs
  89469. */
  89470. onError: Nullable<(effect: Effect, errors: string) => void>;
  89471. /**
  89472. * Callback triggered to get the render target textures
  89473. */
  89474. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89475. /**
  89476. * Gets a boolean indicating that current material needs to register RTT
  89477. */
  89478. readonly hasRenderTargetTextures: boolean;
  89479. /**
  89480. * Specifies if the material should be serialized
  89481. */
  89482. doNotSerialize: boolean;
  89483. /**
  89484. * @hidden
  89485. */
  89486. _storeEffectOnSubMeshes: boolean;
  89487. /**
  89488. * Stores the animations for the material
  89489. */
  89490. animations: Nullable<Array<Animation>>;
  89491. /**
  89492. * An event triggered when the material is disposed
  89493. */
  89494. onDisposeObservable: Observable<Material>;
  89495. /**
  89496. * An observer which watches for dispose events
  89497. */
  89498. private _onDisposeObserver;
  89499. private _onUnBindObservable;
  89500. /**
  89501. * Called during a dispose event
  89502. */
  89503. onDispose: () => void;
  89504. private _onBindObservable;
  89505. /**
  89506. * An event triggered when the material is bound
  89507. */
  89508. readonly onBindObservable: Observable<AbstractMesh>;
  89509. /**
  89510. * An observer which watches for bind events
  89511. */
  89512. private _onBindObserver;
  89513. /**
  89514. * Called during a bind event
  89515. */
  89516. onBind: (Mesh: AbstractMesh) => void;
  89517. /**
  89518. * An event triggered when the material is unbound
  89519. */
  89520. readonly onUnBindObservable: Observable<Material>;
  89521. /**
  89522. * Stores the value of the alpha mode
  89523. */
  89524. private _alphaMode;
  89525. /**
  89526. * Sets the value of the alpha mode.
  89527. *
  89528. * | Value | Type | Description |
  89529. * | --- | --- | --- |
  89530. * | 0 | ALPHA_DISABLE | |
  89531. * | 1 | ALPHA_ADD | |
  89532. * | 2 | ALPHA_COMBINE | |
  89533. * | 3 | ALPHA_SUBTRACT | |
  89534. * | 4 | ALPHA_MULTIPLY | |
  89535. * | 5 | ALPHA_MAXIMIZED | |
  89536. * | 6 | ALPHA_ONEONE | |
  89537. * | 7 | ALPHA_PREMULTIPLIED | |
  89538. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89539. * | 9 | ALPHA_INTERPOLATE | |
  89540. * | 10 | ALPHA_SCREENMODE | |
  89541. *
  89542. */
  89543. /**
  89544. * Gets the value of the alpha mode
  89545. */
  89546. alphaMode: number;
  89547. /**
  89548. * Stores the state of the need depth pre-pass value
  89549. */
  89550. private _needDepthPrePass;
  89551. /**
  89552. * Sets the need depth pre-pass value
  89553. */
  89554. /**
  89555. * Gets the depth pre-pass value
  89556. */
  89557. needDepthPrePass: boolean;
  89558. /**
  89559. * Specifies if depth writing should be disabled
  89560. */
  89561. disableDepthWrite: boolean;
  89562. /**
  89563. * Specifies if depth writing should be forced
  89564. */
  89565. forceDepthWrite: boolean;
  89566. /**
  89567. * Specifies the depth function that should be used. 0 means the default engine function
  89568. */
  89569. depthFunction: number;
  89570. /**
  89571. * Specifies if there should be a separate pass for culling
  89572. */
  89573. separateCullingPass: boolean;
  89574. /**
  89575. * Stores the state specifing if fog should be enabled
  89576. */
  89577. private _fogEnabled;
  89578. /**
  89579. * Sets the state for enabling fog
  89580. */
  89581. /**
  89582. * Gets the value of the fog enabled state
  89583. */
  89584. fogEnabled: boolean;
  89585. /**
  89586. * Stores the size of points
  89587. */
  89588. pointSize: number;
  89589. /**
  89590. * Stores the z offset value
  89591. */
  89592. zOffset: number;
  89593. /**
  89594. * Gets a value specifying if wireframe mode is enabled
  89595. */
  89596. /**
  89597. * Sets the state of wireframe mode
  89598. */
  89599. wireframe: boolean;
  89600. /**
  89601. * Gets the value specifying if point clouds are enabled
  89602. */
  89603. /**
  89604. * Sets the state of point cloud mode
  89605. */
  89606. pointsCloud: boolean;
  89607. /**
  89608. * Gets the material fill mode
  89609. */
  89610. /**
  89611. * Sets the material fill mode
  89612. */
  89613. fillMode: number;
  89614. /**
  89615. * @hidden
  89616. * Stores the effects for the material
  89617. */
  89618. _effect: Nullable<Effect>;
  89619. /**
  89620. * @hidden
  89621. * Specifies if the material was previously ready
  89622. */
  89623. _wasPreviouslyReady: boolean;
  89624. /**
  89625. * Specifies if uniform buffers should be used
  89626. */
  89627. private _useUBO;
  89628. /**
  89629. * Stores a reference to the scene
  89630. */
  89631. private _scene;
  89632. /**
  89633. * Stores the fill mode state
  89634. */
  89635. private _fillMode;
  89636. /**
  89637. * Specifies if the depth write state should be cached
  89638. */
  89639. private _cachedDepthWriteState;
  89640. /**
  89641. * Specifies if the depth function state should be cached
  89642. */
  89643. private _cachedDepthFunctionState;
  89644. /**
  89645. * Stores the uniform buffer
  89646. */
  89647. protected _uniformBuffer: UniformBuffer;
  89648. /** @hidden */
  89649. _indexInSceneMaterialArray: number;
  89650. /** @hidden */
  89651. meshMap: Nullable<{
  89652. [id: string]: AbstractMesh | undefined;
  89653. }>;
  89654. /**
  89655. * Creates a material instance
  89656. * @param name defines the name of the material
  89657. * @param scene defines the scene to reference
  89658. * @param doNotAdd specifies if the material should be added to the scene
  89659. */
  89660. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89661. /**
  89662. * Returns a string representation of the current material
  89663. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89664. * @returns a string with material information
  89665. */
  89666. toString(fullDetails?: boolean): string;
  89667. /**
  89668. * Gets the class name of the material
  89669. * @returns a string with the class name of the material
  89670. */
  89671. getClassName(): string;
  89672. /**
  89673. * Specifies if updates for the material been locked
  89674. */
  89675. readonly isFrozen: boolean;
  89676. /**
  89677. * Locks updates for the material
  89678. */
  89679. freeze(): void;
  89680. /**
  89681. * Unlocks updates for the material
  89682. */
  89683. unfreeze(): void;
  89684. /**
  89685. * Specifies if the material is ready to be used
  89686. * @param mesh defines the mesh to check
  89687. * @param useInstances specifies if instances should be used
  89688. * @returns a boolean indicating if the material is ready to be used
  89689. */
  89690. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89691. /**
  89692. * Specifies that the submesh is ready to be used
  89693. * @param mesh defines the mesh to check
  89694. * @param subMesh defines which submesh to check
  89695. * @param useInstances specifies that instances should be used
  89696. * @returns a boolean indicating that the submesh is ready or not
  89697. */
  89698. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89699. /**
  89700. * Returns the material effect
  89701. * @returns the effect associated with the material
  89702. */
  89703. getEffect(): Nullable<Effect>;
  89704. /**
  89705. * Returns the current scene
  89706. * @returns a Scene
  89707. */
  89708. getScene(): Scene;
  89709. /**
  89710. * Specifies if the material will require alpha blending
  89711. * @returns a boolean specifying if alpha blending is needed
  89712. */
  89713. needAlphaBlending(): boolean;
  89714. /**
  89715. * Specifies if the mesh will require alpha blending
  89716. * @param mesh defines the mesh to check
  89717. * @returns a boolean specifying if alpha blending is needed for the mesh
  89718. */
  89719. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89720. /**
  89721. * Specifies if this material should be rendered in alpha test mode
  89722. * @returns a boolean specifying if an alpha test is needed.
  89723. */
  89724. needAlphaTesting(): boolean;
  89725. /**
  89726. * Gets the texture used for the alpha test
  89727. * @returns the texture to use for alpha testing
  89728. */
  89729. getAlphaTestTexture(): Nullable<BaseTexture>;
  89730. /**
  89731. * Marks the material to indicate that it needs to be re-calculated
  89732. */
  89733. markDirty(): void;
  89734. /** @hidden */
  89735. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89736. /**
  89737. * Binds the material to the mesh
  89738. * @param world defines the world transformation matrix
  89739. * @param mesh defines the mesh to bind the material to
  89740. */
  89741. bind(world: Matrix, mesh?: Mesh): void;
  89742. /**
  89743. * Binds the submesh to the material
  89744. * @param world defines the world transformation matrix
  89745. * @param mesh defines the mesh containing the submesh
  89746. * @param subMesh defines the submesh to bind the material to
  89747. */
  89748. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89749. /**
  89750. * Binds the world matrix to the material
  89751. * @param world defines the world transformation matrix
  89752. */
  89753. bindOnlyWorldMatrix(world: Matrix): void;
  89754. /**
  89755. * Binds the scene's uniform buffer to the effect.
  89756. * @param effect defines the effect to bind to the scene uniform buffer
  89757. * @param sceneUbo defines the uniform buffer storing scene data
  89758. */
  89759. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89760. /**
  89761. * Binds the view matrix to the effect
  89762. * @param effect defines the effect to bind the view matrix to
  89763. */
  89764. bindView(effect: Effect): void;
  89765. /**
  89766. * Binds the view projection matrix to the effect
  89767. * @param effect defines the effect to bind the view projection matrix to
  89768. */
  89769. bindViewProjection(effect: Effect): void;
  89770. /**
  89771. * Specifies if material alpha testing should be turned on for the mesh
  89772. * @param mesh defines the mesh to check
  89773. */
  89774. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89775. /**
  89776. * Processes to execute after binding the material to a mesh
  89777. * @param mesh defines the rendered mesh
  89778. */
  89779. protected _afterBind(mesh?: Mesh): void;
  89780. /**
  89781. * Unbinds the material from the mesh
  89782. */
  89783. unbind(): void;
  89784. /**
  89785. * Gets the active textures from the material
  89786. * @returns an array of textures
  89787. */
  89788. getActiveTextures(): BaseTexture[];
  89789. /**
  89790. * Specifies if the material uses a texture
  89791. * @param texture defines the texture to check against the material
  89792. * @returns a boolean specifying if the material uses the texture
  89793. */
  89794. hasTexture(texture: BaseTexture): boolean;
  89795. /**
  89796. * Makes a duplicate of the material, and gives it a new name
  89797. * @param name defines the new name for the duplicated material
  89798. * @returns the cloned material
  89799. */
  89800. clone(name: string): Nullable<Material>;
  89801. /**
  89802. * Gets the meshes bound to the material
  89803. * @returns an array of meshes bound to the material
  89804. */
  89805. getBindedMeshes(): AbstractMesh[];
  89806. /**
  89807. * Force shader compilation
  89808. * @param mesh defines the mesh associated with this material
  89809. * @param onCompiled defines a function to execute once the material is compiled
  89810. * @param options defines the options to configure the compilation
  89811. * @param onError defines a function to execute if the material fails compiling
  89812. */
  89813. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89814. /**
  89815. * Force shader compilation
  89816. * @param mesh defines the mesh that will use this material
  89817. * @param options defines additional options for compiling the shaders
  89818. * @returns a promise that resolves when the compilation completes
  89819. */
  89820. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89821. private static readonly _AllDirtyCallBack;
  89822. private static readonly _ImageProcessingDirtyCallBack;
  89823. private static readonly _TextureDirtyCallBack;
  89824. private static readonly _FresnelDirtyCallBack;
  89825. private static readonly _MiscDirtyCallBack;
  89826. private static readonly _LightsDirtyCallBack;
  89827. private static readonly _AttributeDirtyCallBack;
  89828. private static _FresnelAndMiscDirtyCallBack;
  89829. private static _TextureAndMiscDirtyCallBack;
  89830. private static readonly _DirtyCallbackArray;
  89831. private static readonly _RunDirtyCallBacks;
  89832. /**
  89833. * Marks a define in the material to indicate that it needs to be re-computed
  89834. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89835. */
  89836. markAsDirty(flag: number): void;
  89837. /**
  89838. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89839. * @param func defines a function which checks material defines against the submeshes
  89840. */
  89841. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89842. /**
  89843. * Indicates that we need to re-calculated for all submeshes
  89844. */
  89845. protected _markAllSubMeshesAsAllDirty(): void;
  89846. /**
  89847. * Indicates that image processing needs to be re-calculated for all submeshes
  89848. */
  89849. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89850. /**
  89851. * Indicates that textures need to be re-calculated for all submeshes
  89852. */
  89853. protected _markAllSubMeshesAsTexturesDirty(): void;
  89854. /**
  89855. * Indicates that fresnel needs to be re-calculated for all submeshes
  89856. */
  89857. protected _markAllSubMeshesAsFresnelDirty(): void;
  89858. /**
  89859. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89860. */
  89861. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89862. /**
  89863. * Indicates that lights need to be re-calculated for all submeshes
  89864. */
  89865. protected _markAllSubMeshesAsLightsDirty(): void;
  89866. /**
  89867. * Indicates that attributes need to be re-calculated for all submeshes
  89868. */
  89869. protected _markAllSubMeshesAsAttributesDirty(): void;
  89870. /**
  89871. * Indicates that misc needs to be re-calculated for all submeshes
  89872. */
  89873. protected _markAllSubMeshesAsMiscDirty(): void;
  89874. /**
  89875. * Indicates that textures and misc need to be re-calculated for all submeshes
  89876. */
  89877. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89878. /**
  89879. * Disposes the material
  89880. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89881. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89882. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89883. */
  89884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89885. /** @hidden */
  89886. private releaseVertexArrayObject;
  89887. /**
  89888. * Serializes this material
  89889. * @returns the serialized material object
  89890. */
  89891. serialize(): any;
  89892. /**
  89893. * Creates a material from parsed material data
  89894. * @param parsedMaterial defines parsed material data
  89895. * @param scene defines the hosting scene
  89896. * @param rootUrl defines the root URL to use to load textures
  89897. * @returns a new material
  89898. */
  89899. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89900. }
  89901. }
  89902. declare module BABYLON {
  89903. /**
  89904. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89905. * separate meshes. This can be use to improve performances.
  89906. * @see http://doc.babylonjs.com/how_to/multi_materials
  89907. */
  89908. export class MultiMaterial extends Material {
  89909. private _subMaterials;
  89910. /**
  89911. * Gets or Sets the list of Materials used within the multi material.
  89912. * They need to be ordered according to the submeshes order in the associated mesh
  89913. */
  89914. subMaterials: Nullable<Material>[];
  89915. /**
  89916. * Function used to align with Node.getChildren()
  89917. * @returns the list of Materials used within the multi material
  89918. */
  89919. getChildren(): Nullable<Material>[];
  89920. /**
  89921. * Instantiates a new Multi Material
  89922. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89923. * separate meshes. This can be use to improve performances.
  89924. * @see http://doc.babylonjs.com/how_to/multi_materials
  89925. * @param name Define the name in the scene
  89926. * @param scene Define the scene the material belongs to
  89927. */
  89928. constructor(name: string, scene: Scene);
  89929. private _hookArray;
  89930. /**
  89931. * Get one of the submaterial by its index in the submaterials array
  89932. * @param index The index to look the sub material at
  89933. * @returns The Material if the index has been defined
  89934. */
  89935. getSubMaterial(index: number): Nullable<Material>;
  89936. /**
  89937. * Get the list of active textures for the whole sub materials list.
  89938. * @returns All the textures that will be used during the rendering
  89939. */
  89940. getActiveTextures(): BaseTexture[];
  89941. /**
  89942. * Gets the current class name of the material e.g. "MultiMaterial"
  89943. * Mainly use in serialization.
  89944. * @returns the class name
  89945. */
  89946. getClassName(): string;
  89947. /**
  89948. * Checks if the material is ready to render the requested sub mesh
  89949. * @param mesh Define the mesh the submesh belongs to
  89950. * @param subMesh Define the sub mesh to look readyness for
  89951. * @param useInstances Define whether or not the material is used with instances
  89952. * @returns true if ready, otherwise false
  89953. */
  89954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89955. /**
  89956. * Clones the current material and its related sub materials
  89957. * @param name Define the name of the newly cloned material
  89958. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89959. * @returns the cloned material
  89960. */
  89961. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89962. /**
  89963. * Serializes the materials into a JSON representation.
  89964. * @returns the JSON representation
  89965. */
  89966. serialize(): any;
  89967. /**
  89968. * Dispose the material and release its associated resources
  89969. * @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)
  89970. * @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)
  89971. * @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)
  89972. */
  89973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89974. /**
  89975. * Creates a MultiMaterial from parsed MultiMaterial data.
  89976. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89977. * @param scene defines the hosting scene
  89978. * @returns a new MultiMaterial
  89979. */
  89980. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89981. }
  89982. }
  89983. declare module BABYLON {
  89984. /**
  89985. * Base class for submeshes
  89986. */
  89987. export class BaseSubMesh {
  89988. /** @hidden */
  89989. _materialDefines: Nullable<MaterialDefines>;
  89990. /** @hidden */
  89991. _materialEffect: Nullable<Effect>;
  89992. /**
  89993. * Gets material defines used by the effect associated to the sub mesh
  89994. */
  89995. /**
  89996. * Sets material defines used by the effect associated to the sub mesh
  89997. */
  89998. materialDefines: Nullable<MaterialDefines>;
  89999. /**
  90000. * Gets associated effect
  90001. */
  90002. readonly effect: Nullable<Effect>;
  90003. /**
  90004. * Sets associated effect (effect used to render this submesh)
  90005. * @param effect defines the effect to associate with
  90006. * @param defines defines the set of defines used to compile this effect
  90007. */
  90008. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  90009. }
  90010. /**
  90011. * Defines a subdivision inside a mesh
  90012. */
  90013. export class SubMesh extends BaseSubMesh implements ICullable {
  90014. /** the material index to use */
  90015. materialIndex: number;
  90016. /** vertex index start */
  90017. verticesStart: number;
  90018. /** vertices count */
  90019. verticesCount: number;
  90020. /** index start */
  90021. indexStart: number;
  90022. /** indices count */
  90023. indexCount: number;
  90024. /** @hidden */
  90025. _linesIndexCount: number;
  90026. private _mesh;
  90027. private _renderingMesh;
  90028. private _boundingInfo;
  90029. private _linesIndexBuffer;
  90030. /** @hidden */
  90031. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90032. /** @hidden */
  90033. _trianglePlanes: Plane[];
  90034. /** @hidden */
  90035. _lastColliderTransformMatrix: Nullable<Matrix>;
  90036. /** @hidden */
  90037. _renderId: number;
  90038. /** @hidden */
  90039. _alphaIndex: number;
  90040. /** @hidden */
  90041. _distanceToCamera: number;
  90042. /** @hidden */
  90043. _id: number;
  90044. private _currentMaterial;
  90045. /**
  90046. * Add a new submesh to a mesh
  90047. * @param materialIndex defines the material index to use
  90048. * @param verticesStart defines vertex index start
  90049. * @param verticesCount defines vertices count
  90050. * @param indexStart defines index start
  90051. * @param indexCount defines indices count
  90052. * @param mesh defines the parent mesh
  90053. * @param renderingMesh defines an optional rendering mesh
  90054. * @param createBoundingBox defines if bounding box should be created for this submesh
  90055. * @returns the new submesh
  90056. */
  90057. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90058. /**
  90059. * Creates a new submesh
  90060. * @param materialIndex defines the material index to use
  90061. * @param verticesStart defines vertex index start
  90062. * @param verticesCount defines vertices count
  90063. * @param indexStart defines index start
  90064. * @param indexCount defines indices count
  90065. * @param mesh defines the parent mesh
  90066. * @param renderingMesh defines an optional rendering mesh
  90067. * @param createBoundingBox defines if bounding box should be created for this submesh
  90068. */
  90069. constructor(
  90070. /** the material index to use */
  90071. materialIndex: number,
  90072. /** vertex index start */
  90073. verticesStart: number,
  90074. /** vertices count */
  90075. verticesCount: number,
  90076. /** index start */
  90077. indexStart: number,
  90078. /** indices count */
  90079. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90080. /**
  90081. * Returns true if this submesh covers the entire parent mesh
  90082. * @ignorenaming
  90083. */
  90084. readonly IsGlobal: boolean;
  90085. /**
  90086. * Returns the submesh BoudingInfo object
  90087. * @returns current bounding info (or mesh's one if the submesh is global)
  90088. */
  90089. getBoundingInfo(): BoundingInfo;
  90090. /**
  90091. * Sets the submesh BoundingInfo
  90092. * @param boundingInfo defines the new bounding info to use
  90093. * @returns the SubMesh
  90094. */
  90095. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90096. /**
  90097. * Returns the mesh of the current submesh
  90098. * @return the parent mesh
  90099. */
  90100. getMesh(): AbstractMesh;
  90101. /**
  90102. * Returns the rendering mesh of the submesh
  90103. * @returns the rendering mesh (could be different from parent mesh)
  90104. */
  90105. getRenderingMesh(): Mesh;
  90106. /**
  90107. * Returns the submesh material
  90108. * @returns null or the current material
  90109. */
  90110. getMaterial(): Nullable<Material>;
  90111. /**
  90112. * Sets a new updated BoundingInfo object to the submesh
  90113. * @param data defines an optional position array to use to determine the bounding info
  90114. * @returns the SubMesh
  90115. */
  90116. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90117. /** @hidden */
  90118. _checkCollision(collider: Collider): boolean;
  90119. /**
  90120. * Updates the submesh BoundingInfo
  90121. * @param world defines the world matrix to use to update the bounding info
  90122. * @returns the submesh
  90123. */
  90124. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90125. /**
  90126. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90127. * @param frustumPlanes defines the frustum planes
  90128. * @returns true if the submesh is intersecting with the frustum
  90129. */
  90130. isInFrustum(frustumPlanes: Plane[]): boolean;
  90131. /**
  90132. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90133. * @param frustumPlanes defines the frustum planes
  90134. * @returns true if the submesh is inside the frustum
  90135. */
  90136. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90137. /**
  90138. * Renders the submesh
  90139. * @param enableAlphaMode defines if alpha needs to be used
  90140. * @returns the submesh
  90141. */
  90142. render(enableAlphaMode: boolean): SubMesh;
  90143. /**
  90144. * @hidden
  90145. */
  90146. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90147. /**
  90148. * Checks if the submesh intersects with a ray
  90149. * @param ray defines the ray to test
  90150. * @returns true is the passed ray intersects the submesh bounding box
  90151. */
  90152. canIntersects(ray: Ray): boolean;
  90153. /**
  90154. * Intersects current submesh with a ray
  90155. * @param ray defines the ray to test
  90156. * @param positions defines mesh's positions array
  90157. * @param indices defines mesh's indices array
  90158. * @param fastCheck defines if only bounding info should be used
  90159. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90160. * @returns intersection info or null if no intersection
  90161. */
  90162. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90163. /** @hidden */
  90164. private _intersectLines;
  90165. /** @hidden */
  90166. private _intersectUnIndexedLines;
  90167. /** @hidden */
  90168. private _intersectTriangles;
  90169. /** @hidden */
  90170. private _intersectUnIndexedTriangles;
  90171. /** @hidden */
  90172. _rebuild(): void;
  90173. /**
  90174. * Creates a new submesh from the passed mesh
  90175. * @param newMesh defines the new hosting mesh
  90176. * @param newRenderingMesh defines an optional rendering mesh
  90177. * @returns the new submesh
  90178. */
  90179. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90180. /**
  90181. * Release associated resources
  90182. */
  90183. dispose(): void;
  90184. /**
  90185. * Gets the class name
  90186. * @returns the string "SubMesh".
  90187. */
  90188. getClassName(): string;
  90189. /**
  90190. * Creates a new submesh from indices data
  90191. * @param materialIndex the index of the main mesh material
  90192. * @param startIndex the index where to start the copy in the mesh indices array
  90193. * @param indexCount the number of indices to copy then from the startIndex
  90194. * @param mesh the main mesh to create the submesh from
  90195. * @param renderingMesh the optional rendering mesh
  90196. * @returns a new submesh
  90197. */
  90198. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90199. }
  90200. }
  90201. declare module BABYLON {
  90202. /**
  90203. * Class used to represent data loading progression
  90204. */
  90205. export class SceneLoaderFlags {
  90206. private static _ForceFullSceneLoadingForIncremental;
  90207. private static _ShowLoadingScreen;
  90208. private static _CleanBoneMatrixWeights;
  90209. private static _loggingLevel;
  90210. /**
  90211. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90212. */
  90213. static ForceFullSceneLoadingForIncremental: boolean;
  90214. /**
  90215. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90216. */
  90217. static ShowLoadingScreen: boolean;
  90218. /**
  90219. * Defines the current logging level (while loading the scene)
  90220. * @ignorenaming
  90221. */
  90222. static loggingLevel: number;
  90223. /**
  90224. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90225. */
  90226. static CleanBoneMatrixWeights: boolean;
  90227. }
  90228. }
  90229. declare module BABYLON {
  90230. /**
  90231. * Class used to store geometry data (vertex buffers + index buffer)
  90232. */
  90233. export class Geometry implements IGetSetVerticesData {
  90234. /**
  90235. * Gets or sets the ID of the geometry
  90236. */
  90237. id: string;
  90238. /**
  90239. * Gets or sets the unique ID of the geometry
  90240. */
  90241. uniqueId: number;
  90242. /**
  90243. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90244. */
  90245. delayLoadState: number;
  90246. /**
  90247. * Gets the file containing the data to load when running in delay load state
  90248. */
  90249. delayLoadingFile: Nullable<string>;
  90250. /**
  90251. * Callback called when the geometry is updated
  90252. */
  90253. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90254. private _scene;
  90255. private _engine;
  90256. private _meshes;
  90257. private _totalVertices;
  90258. /** @hidden */
  90259. _indices: IndicesArray;
  90260. /** @hidden */
  90261. _vertexBuffers: {
  90262. [key: string]: VertexBuffer;
  90263. };
  90264. private _isDisposed;
  90265. private _extend;
  90266. private _boundingBias;
  90267. /** @hidden */
  90268. _delayInfo: Array<string>;
  90269. private _indexBuffer;
  90270. private _indexBufferIsUpdatable;
  90271. /** @hidden */
  90272. _boundingInfo: Nullable<BoundingInfo>;
  90273. /** @hidden */
  90274. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90275. /** @hidden */
  90276. _softwareSkinningFrameId: number;
  90277. private _vertexArrayObjects;
  90278. private _updatable;
  90279. /** @hidden */
  90280. _positions: Nullable<Vector3[]>;
  90281. /**
  90282. * 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
  90283. */
  90284. /**
  90285. * 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
  90286. */
  90287. boundingBias: Vector2;
  90288. /**
  90289. * Static function used to attach a new empty geometry to a mesh
  90290. * @param mesh defines the mesh to attach the geometry to
  90291. * @returns the new Geometry
  90292. */
  90293. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90294. /**
  90295. * Creates a new geometry
  90296. * @param id defines the unique ID
  90297. * @param scene defines the hosting scene
  90298. * @param vertexData defines the VertexData used to get geometry data
  90299. * @param updatable defines if geometry must be updatable (false by default)
  90300. * @param mesh defines the mesh that will be associated with the geometry
  90301. */
  90302. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90303. /**
  90304. * Gets the current extend of the geometry
  90305. */
  90306. readonly extend: {
  90307. minimum: Vector3;
  90308. maximum: Vector3;
  90309. };
  90310. /**
  90311. * Gets the hosting scene
  90312. * @returns the hosting Scene
  90313. */
  90314. getScene(): Scene;
  90315. /**
  90316. * Gets the hosting engine
  90317. * @returns the hosting Engine
  90318. */
  90319. getEngine(): Engine;
  90320. /**
  90321. * Defines if the geometry is ready to use
  90322. * @returns true if the geometry is ready to be used
  90323. */
  90324. isReady(): boolean;
  90325. /**
  90326. * Gets a value indicating that the geometry should not be serialized
  90327. */
  90328. readonly doNotSerialize: boolean;
  90329. /** @hidden */
  90330. _rebuild(): void;
  90331. /**
  90332. * Affects all geometry data in one call
  90333. * @param vertexData defines the geometry data
  90334. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90335. */
  90336. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90337. /**
  90338. * Set specific vertex data
  90339. * @param kind defines the data kind (Position, normal, etc...)
  90340. * @param data defines the vertex data to use
  90341. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90342. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90343. */
  90344. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90345. /**
  90346. * Removes a specific vertex data
  90347. * @param kind defines the data kind (Position, normal, etc...)
  90348. */
  90349. removeVerticesData(kind: string): void;
  90350. /**
  90351. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90352. * @param buffer defines the vertex buffer to use
  90353. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90354. */
  90355. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90356. /**
  90357. * Update a specific vertex buffer
  90358. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90359. * It will do nothing if the buffer is not updatable
  90360. * @param kind defines the data kind (Position, normal, etc...)
  90361. * @param data defines the data to use
  90362. * @param offset defines the offset in the target buffer where to store the data
  90363. * @param useBytes set to true if the offset is in bytes
  90364. */
  90365. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90366. /**
  90367. * Update a specific vertex buffer
  90368. * This function will create a new buffer if the current one is not updatable
  90369. * @param kind defines the data kind (Position, normal, etc...)
  90370. * @param data defines the data to use
  90371. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90372. */
  90373. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90374. private _updateBoundingInfo;
  90375. /** @hidden */
  90376. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90377. /**
  90378. * Gets total number of vertices
  90379. * @returns the total number of vertices
  90380. */
  90381. getTotalVertices(): number;
  90382. /**
  90383. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90384. * @param kind defines the data kind (Position, normal, etc...)
  90385. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90386. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90387. * @returns a float array containing vertex data
  90388. */
  90389. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90390. /**
  90391. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90392. * @param kind defines the data kind (Position, normal, etc...)
  90393. * @returns true if the vertex buffer with the specified kind is updatable
  90394. */
  90395. isVertexBufferUpdatable(kind: string): boolean;
  90396. /**
  90397. * Gets a specific vertex buffer
  90398. * @param kind defines the data kind (Position, normal, etc...)
  90399. * @returns a VertexBuffer
  90400. */
  90401. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90402. /**
  90403. * Returns all vertex buffers
  90404. * @return an object holding all vertex buffers indexed by kind
  90405. */
  90406. getVertexBuffers(): Nullable<{
  90407. [key: string]: VertexBuffer;
  90408. }>;
  90409. /**
  90410. * Gets a boolean indicating if specific vertex buffer is present
  90411. * @param kind defines the data kind (Position, normal, etc...)
  90412. * @returns true if data is present
  90413. */
  90414. isVerticesDataPresent(kind: string): boolean;
  90415. /**
  90416. * Gets a list of all attached data kinds (Position, normal, etc...)
  90417. * @returns a list of string containing all kinds
  90418. */
  90419. getVerticesDataKinds(): string[];
  90420. /**
  90421. * Update index buffer
  90422. * @param indices defines the indices to store in the index buffer
  90423. * @param offset defines the offset in the target buffer where to store the data
  90424. * @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)
  90425. */
  90426. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90427. /**
  90428. * Creates a new index buffer
  90429. * @param indices defines the indices to store in the index buffer
  90430. * @param totalVertices defines the total number of vertices (could be null)
  90431. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90432. */
  90433. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90434. /**
  90435. * Return the total number of indices
  90436. * @returns the total number of indices
  90437. */
  90438. getTotalIndices(): number;
  90439. /**
  90440. * Gets the index buffer array
  90441. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90442. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90443. * @returns the index buffer array
  90444. */
  90445. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90446. /**
  90447. * Gets the index buffer
  90448. * @return the index buffer
  90449. */
  90450. getIndexBuffer(): Nullable<DataBuffer>;
  90451. /** @hidden */
  90452. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90453. /**
  90454. * Release the associated resources for a specific mesh
  90455. * @param mesh defines the source mesh
  90456. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90457. */
  90458. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90459. /**
  90460. * Apply current geometry to a given mesh
  90461. * @param mesh defines the mesh to apply geometry to
  90462. */
  90463. applyToMesh(mesh: Mesh): void;
  90464. private _updateExtend;
  90465. private _applyToMesh;
  90466. private notifyUpdate;
  90467. /**
  90468. * Load the geometry if it was flagged as delay loaded
  90469. * @param scene defines the hosting scene
  90470. * @param onLoaded defines a callback called when the geometry is loaded
  90471. */
  90472. load(scene: Scene, onLoaded?: () => void): void;
  90473. private _queueLoad;
  90474. /**
  90475. * Invert the geometry to move from a right handed system to a left handed one.
  90476. */
  90477. toLeftHanded(): void;
  90478. /** @hidden */
  90479. _resetPointsArrayCache(): void;
  90480. /** @hidden */
  90481. _generatePointsArray(): boolean;
  90482. /**
  90483. * Gets a value indicating if the geometry is disposed
  90484. * @returns true if the geometry was disposed
  90485. */
  90486. isDisposed(): boolean;
  90487. private _disposeVertexArrayObjects;
  90488. /**
  90489. * Free all associated resources
  90490. */
  90491. dispose(): void;
  90492. /**
  90493. * Clone the current geometry into a new geometry
  90494. * @param id defines the unique ID of the new geometry
  90495. * @returns a new geometry object
  90496. */
  90497. copy(id: string): Geometry;
  90498. /**
  90499. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90500. * @return a JSON representation of the current geometry data (without the vertices data)
  90501. */
  90502. serialize(): any;
  90503. private toNumberArray;
  90504. /**
  90505. * Serialize all vertices data into a JSON oject
  90506. * @returns a JSON representation of the current geometry data
  90507. */
  90508. serializeVerticeData(): any;
  90509. /**
  90510. * Extracts a clone of a mesh geometry
  90511. * @param mesh defines the source mesh
  90512. * @param id defines the unique ID of the new geometry object
  90513. * @returns the new geometry object
  90514. */
  90515. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90516. /**
  90517. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90518. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90519. * Be aware Math.random() could cause collisions, but:
  90520. * "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"
  90521. * @returns a string containing a new GUID
  90522. */
  90523. static RandomId(): string;
  90524. /** @hidden */
  90525. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90526. private static _CleanMatricesWeights;
  90527. /**
  90528. * Create a new geometry from persisted data (Using .babylon file format)
  90529. * @param parsedVertexData defines the persisted data
  90530. * @param scene defines the hosting scene
  90531. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90532. * @returns the new geometry object
  90533. */
  90534. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90535. }
  90536. }
  90537. declare module BABYLON {
  90538. /**
  90539. * Define an interface for all classes that will get and set the data on vertices
  90540. */
  90541. export interface IGetSetVerticesData {
  90542. /**
  90543. * Gets a boolean indicating if specific vertex data is present
  90544. * @param kind defines the vertex data kind to use
  90545. * @returns true is data kind is present
  90546. */
  90547. isVerticesDataPresent(kind: string): boolean;
  90548. /**
  90549. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90550. * @param kind defines the data kind (Position, normal, etc...)
  90551. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90553. * @returns a float array containing vertex data
  90554. */
  90555. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90556. /**
  90557. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90558. * @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.
  90559. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90560. * @returns the indices array or an empty array if the mesh has no geometry
  90561. */
  90562. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90563. /**
  90564. * Set specific vertex data
  90565. * @param kind defines the data kind (Position, normal, etc...)
  90566. * @param data defines the vertex data to use
  90567. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90568. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90569. */
  90570. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90571. /**
  90572. * Update a specific associated vertex buffer
  90573. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90574. * - VertexBuffer.PositionKind
  90575. * - VertexBuffer.UVKind
  90576. * - VertexBuffer.UV2Kind
  90577. * - VertexBuffer.UV3Kind
  90578. * - VertexBuffer.UV4Kind
  90579. * - VertexBuffer.UV5Kind
  90580. * - VertexBuffer.UV6Kind
  90581. * - VertexBuffer.ColorKind
  90582. * - VertexBuffer.MatricesIndicesKind
  90583. * - VertexBuffer.MatricesIndicesExtraKind
  90584. * - VertexBuffer.MatricesWeightsKind
  90585. * - VertexBuffer.MatricesWeightsExtraKind
  90586. * @param data defines the data source
  90587. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90588. * @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)
  90589. */
  90590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90591. /**
  90592. * Creates a new index buffer
  90593. * @param indices defines the indices to store in the index buffer
  90594. * @param totalVertices defines the total number of vertices (could be null)
  90595. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90596. */
  90597. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90598. }
  90599. /**
  90600. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90601. */
  90602. export class VertexData {
  90603. /**
  90604. * Mesh side orientation : usually the external or front surface
  90605. */
  90606. static readonly FRONTSIDE: number;
  90607. /**
  90608. * Mesh side orientation : usually the internal or back surface
  90609. */
  90610. static readonly BACKSIDE: number;
  90611. /**
  90612. * Mesh side orientation : both internal and external or front and back surfaces
  90613. */
  90614. static readonly DOUBLESIDE: number;
  90615. /**
  90616. * Mesh side orientation : by default, `FRONTSIDE`
  90617. */
  90618. static readonly DEFAULTSIDE: number;
  90619. /**
  90620. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90621. */
  90622. positions: Nullable<FloatArray>;
  90623. /**
  90624. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90625. */
  90626. normals: Nullable<FloatArray>;
  90627. /**
  90628. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90629. */
  90630. tangents: Nullable<FloatArray>;
  90631. /**
  90632. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90633. */
  90634. uvs: Nullable<FloatArray>;
  90635. /**
  90636. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90637. */
  90638. uvs2: Nullable<FloatArray>;
  90639. /**
  90640. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90641. */
  90642. uvs3: Nullable<FloatArray>;
  90643. /**
  90644. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90645. */
  90646. uvs4: Nullable<FloatArray>;
  90647. /**
  90648. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90649. */
  90650. uvs5: Nullable<FloatArray>;
  90651. /**
  90652. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90653. */
  90654. uvs6: Nullable<FloatArray>;
  90655. /**
  90656. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90657. */
  90658. colors: Nullable<FloatArray>;
  90659. /**
  90660. * 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).
  90661. */
  90662. matricesIndices: Nullable<FloatArray>;
  90663. /**
  90664. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90665. */
  90666. matricesWeights: Nullable<FloatArray>;
  90667. /**
  90668. * An array extending the number of possible indices
  90669. */
  90670. matricesIndicesExtra: Nullable<FloatArray>;
  90671. /**
  90672. * An array extending the number of possible weights when the number of indices is extended
  90673. */
  90674. matricesWeightsExtra: Nullable<FloatArray>;
  90675. /**
  90676. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90677. */
  90678. indices: Nullable<IndicesArray>;
  90679. /**
  90680. * Uses the passed data array to set the set the values for the specified kind of data
  90681. * @param data a linear array of floating numbers
  90682. * @param kind the type of data that is being set, eg positions, colors etc
  90683. */
  90684. set(data: FloatArray, kind: string): void;
  90685. /**
  90686. * Associates the vertexData to the passed Mesh.
  90687. * Sets it as updatable or not (default `false`)
  90688. * @param mesh the mesh the vertexData is applied to
  90689. * @param updatable when used and having the value true allows new data to update the vertexData
  90690. * @returns the VertexData
  90691. */
  90692. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90693. /**
  90694. * Associates the vertexData to the passed Geometry.
  90695. * Sets it as updatable or not (default `false`)
  90696. * @param geometry the geometry the vertexData is applied to
  90697. * @param updatable when used and having the value true allows new data to update the vertexData
  90698. * @returns VertexData
  90699. */
  90700. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90701. /**
  90702. * Updates the associated mesh
  90703. * @param mesh the mesh to be updated
  90704. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90705. * @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
  90706. * @returns VertexData
  90707. */
  90708. updateMesh(mesh: Mesh): VertexData;
  90709. /**
  90710. * Updates the associated geometry
  90711. * @param geometry the geometry to be updated
  90712. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90713. * @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
  90714. * @returns VertexData.
  90715. */
  90716. updateGeometry(geometry: Geometry): VertexData;
  90717. private _applyTo;
  90718. private _update;
  90719. /**
  90720. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90721. * @param matrix the transforming matrix
  90722. * @returns the VertexData
  90723. */
  90724. transform(matrix: Matrix): VertexData;
  90725. /**
  90726. * Merges the passed VertexData into the current one
  90727. * @param other the VertexData to be merged into the current one
  90728. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90729. * @returns the modified VertexData
  90730. */
  90731. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90732. private _mergeElement;
  90733. private _validate;
  90734. /**
  90735. * Serializes the VertexData
  90736. * @returns a serialized object
  90737. */
  90738. serialize(): any;
  90739. /**
  90740. * Extracts the vertexData from a mesh
  90741. * @param mesh the mesh from which to extract the VertexData
  90742. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90743. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90744. * @returns the object VertexData associated to the passed mesh
  90745. */
  90746. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90747. /**
  90748. * Extracts the vertexData from the geometry
  90749. * @param geometry the geometry from which to extract the VertexData
  90750. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90751. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90752. * @returns the object VertexData associated to the passed mesh
  90753. */
  90754. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90755. private static _ExtractFrom;
  90756. /**
  90757. * Creates the VertexData for a Ribbon
  90758. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90759. * * pathArray array of paths, each of which an array of successive Vector3
  90760. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90761. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90762. * * 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
  90763. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90764. * * 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)
  90765. * * 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)
  90766. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90767. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90768. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90769. * @returns the VertexData of the ribbon
  90770. */
  90771. static CreateRibbon(options: {
  90772. pathArray: Vector3[][];
  90773. closeArray?: boolean;
  90774. closePath?: boolean;
  90775. offset?: number;
  90776. sideOrientation?: number;
  90777. frontUVs?: Vector4;
  90778. backUVs?: Vector4;
  90779. invertUV?: boolean;
  90780. uvs?: Vector2[];
  90781. colors?: Color4[];
  90782. }): VertexData;
  90783. /**
  90784. * Creates the VertexData for a box
  90785. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90786. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90787. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90788. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90789. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90790. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90791. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90793. * * 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)
  90794. * * 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)
  90795. * @returns the VertexData of the box
  90796. */
  90797. static CreateBox(options: {
  90798. size?: number;
  90799. width?: number;
  90800. height?: number;
  90801. depth?: number;
  90802. faceUV?: Vector4[];
  90803. faceColors?: Color4[];
  90804. sideOrientation?: number;
  90805. frontUVs?: Vector4;
  90806. backUVs?: Vector4;
  90807. }): VertexData;
  90808. /**
  90809. * Creates the VertexData for a tiled box
  90810. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90811. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90812. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90813. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90815. * @returns the VertexData of the box
  90816. */
  90817. static CreateTiledBox(options: {
  90818. pattern?: number;
  90819. width?: number;
  90820. height?: number;
  90821. depth?: number;
  90822. tileSize?: number;
  90823. tileWidth?: number;
  90824. tileHeight?: number;
  90825. alignHorizontal?: number;
  90826. alignVertical?: number;
  90827. faceUV?: Vector4[];
  90828. faceColors?: Color4[];
  90829. sideOrientation?: number;
  90830. }): VertexData;
  90831. /**
  90832. * Creates the VertexData for a tiled plane
  90833. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90834. * * pattern a limited pattern arrangement depending on the number
  90835. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90836. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90837. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90838. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90839. * * 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)
  90840. * * 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)
  90841. * @returns the VertexData of the tiled plane
  90842. */
  90843. static CreateTiledPlane(options: {
  90844. pattern?: number;
  90845. tileSize?: number;
  90846. tileWidth?: number;
  90847. tileHeight?: number;
  90848. size?: number;
  90849. width?: number;
  90850. height?: number;
  90851. alignHorizontal?: number;
  90852. alignVertical?: number;
  90853. sideOrientation?: number;
  90854. frontUVs?: Vector4;
  90855. backUVs?: Vector4;
  90856. }): VertexData;
  90857. /**
  90858. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90859. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90860. * * segments sets the number of horizontal strips optional, default 32
  90861. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90862. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90863. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90864. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90865. * * 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
  90866. * * 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
  90867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90868. * * 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)
  90869. * * 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)
  90870. * @returns the VertexData of the ellipsoid
  90871. */
  90872. static CreateSphere(options: {
  90873. segments?: number;
  90874. diameter?: number;
  90875. diameterX?: number;
  90876. diameterY?: number;
  90877. diameterZ?: number;
  90878. arc?: number;
  90879. slice?: number;
  90880. sideOrientation?: number;
  90881. frontUVs?: Vector4;
  90882. backUVs?: Vector4;
  90883. }): VertexData;
  90884. /**
  90885. * Creates the VertexData for a cylinder, cone or prism
  90886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90887. * * height sets the height (y direction) of the cylinder, optional, default 2
  90888. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90889. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90890. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90891. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90892. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90893. * * 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
  90894. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90895. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90896. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90897. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90898. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90899. * * 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)
  90900. * * 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)
  90901. * @returns the VertexData of the cylinder, cone or prism
  90902. */
  90903. static CreateCylinder(options: {
  90904. height?: number;
  90905. diameterTop?: number;
  90906. diameterBottom?: number;
  90907. diameter?: number;
  90908. tessellation?: number;
  90909. subdivisions?: number;
  90910. arc?: number;
  90911. faceColors?: Color4[];
  90912. faceUV?: Vector4[];
  90913. hasRings?: boolean;
  90914. enclose?: boolean;
  90915. sideOrientation?: number;
  90916. frontUVs?: Vector4;
  90917. backUVs?: Vector4;
  90918. }): VertexData;
  90919. /**
  90920. * Creates the VertexData for a torus
  90921. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90922. * * diameter the diameter of the torus, optional default 1
  90923. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90924. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90926. * * 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)
  90927. * * 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)
  90928. * @returns the VertexData of the torus
  90929. */
  90930. static CreateTorus(options: {
  90931. diameter?: number;
  90932. thickness?: number;
  90933. tessellation?: number;
  90934. sideOrientation?: number;
  90935. frontUVs?: Vector4;
  90936. backUVs?: Vector4;
  90937. }): VertexData;
  90938. /**
  90939. * Creates the VertexData of the LineSystem
  90940. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90941. * - lines an array of lines, each line being an array of successive Vector3
  90942. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90943. * @returns the VertexData of the LineSystem
  90944. */
  90945. static CreateLineSystem(options: {
  90946. lines: Vector3[][];
  90947. colors?: Nullable<Color4[][]>;
  90948. }): VertexData;
  90949. /**
  90950. * Create the VertexData for a DashedLines
  90951. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90952. * - points an array successive Vector3
  90953. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90954. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90955. * - dashNb the intended total number of dashes, optional, default 200
  90956. * @returns the VertexData for the DashedLines
  90957. */
  90958. static CreateDashedLines(options: {
  90959. points: Vector3[];
  90960. dashSize?: number;
  90961. gapSize?: number;
  90962. dashNb?: number;
  90963. }): VertexData;
  90964. /**
  90965. * Creates the VertexData for a Ground
  90966. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90967. * - width the width (x direction) of the ground, optional, default 1
  90968. * - height the height (z direction) of the ground, optional, default 1
  90969. * - subdivisions the number of subdivisions per side, optional, default 1
  90970. * @returns the VertexData of the Ground
  90971. */
  90972. static CreateGround(options: {
  90973. width?: number;
  90974. height?: number;
  90975. subdivisions?: number;
  90976. subdivisionsX?: number;
  90977. subdivisionsY?: number;
  90978. }): VertexData;
  90979. /**
  90980. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90981. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90982. * * xmin the ground minimum X coordinate, optional, default -1
  90983. * * zmin the ground minimum Z coordinate, optional, default -1
  90984. * * xmax the ground maximum X coordinate, optional, default 1
  90985. * * zmax the ground maximum Z coordinate, optional, default 1
  90986. * * 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}
  90987. * * 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}
  90988. * @returns the VertexData of the TiledGround
  90989. */
  90990. static CreateTiledGround(options: {
  90991. xmin: number;
  90992. zmin: number;
  90993. xmax: number;
  90994. zmax: number;
  90995. subdivisions?: {
  90996. w: number;
  90997. h: number;
  90998. };
  90999. precision?: {
  91000. w: number;
  91001. h: number;
  91002. };
  91003. }): VertexData;
  91004. /**
  91005. * Creates the VertexData of the Ground designed from a heightmap
  91006. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91007. * * width the width (x direction) of the ground
  91008. * * height the height (z direction) of the ground
  91009. * * subdivisions the number of subdivisions per side
  91010. * * minHeight the minimum altitude on the ground, optional, default 0
  91011. * * maxHeight the maximum altitude on the ground, optional default 1
  91012. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91013. * * buffer the array holding the image color data
  91014. * * bufferWidth the width of image
  91015. * * bufferHeight the height of image
  91016. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91017. * @returns the VertexData of the Ground designed from a heightmap
  91018. */
  91019. static CreateGroundFromHeightMap(options: {
  91020. width: number;
  91021. height: number;
  91022. subdivisions: number;
  91023. minHeight: number;
  91024. maxHeight: number;
  91025. colorFilter: Color3;
  91026. buffer: Uint8Array;
  91027. bufferWidth: number;
  91028. bufferHeight: number;
  91029. alphaFilter: number;
  91030. }): VertexData;
  91031. /**
  91032. * Creates the VertexData for a Plane
  91033. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91034. * * size sets the width and height of the plane to the value of size, optional default 1
  91035. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91036. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91038. * * 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)
  91039. * * 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)
  91040. * @returns the VertexData of the box
  91041. */
  91042. static CreatePlane(options: {
  91043. size?: number;
  91044. width?: number;
  91045. height?: number;
  91046. sideOrientation?: number;
  91047. frontUVs?: Vector4;
  91048. backUVs?: Vector4;
  91049. }): VertexData;
  91050. /**
  91051. * Creates the VertexData of the Disc or regular Polygon
  91052. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91053. * * radius the radius of the disc, optional default 0.5
  91054. * * tessellation the number of polygon sides, optional, default 64
  91055. * * 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
  91056. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91057. * * 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)
  91058. * * 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)
  91059. * @returns the VertexData of the box
  91060. */
  91061. static CreateDisc(options: {
  91062. radius?: number;
  91063. tessellation?: number;
  91064. arc?: number;
  91065. sideOrientation?: number;
  91066. frontUVs?: Vector4;
  91067. backUVs?: Vector4;
  91068. }): VertexData;
  91069. /**
  91070. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91071. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91072. * @param polygon a mesh built from polygonTriangulation.build()
  91073. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91074. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91075. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91076. * @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)
  91077. * @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)
  91078. * @returns the VertexData of the Polygon
  91079. */
  91080. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91081. /**
  91082. * Creates the VertexData of the IcoSphere
  91083. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91084. * * radius the radius of the IcoSphere, optional default 1
  91085. * * radiusX allows stretching in the x direction, optional, default radius
  91086. * * radiusY allows stretching in the y direction, optional, default radius
  91087. * * radiusZ allows stretching in the z direction, optional, default radius
  91088. * * flat when true creates a flat shaded mesh, optional, default true
  91089. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91091. * * 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)
  91092. * * 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)
  91093. * @returns the VertexData of the IcoSphere
  91094. */
  91095. static CreateIcoSphere(options: {
  91096. radius?: number;
  91097. radiusX?: number;
  91098. radiusY?: number;
  91099. radiusZ?: number;
  91100. flat?: boolean;
  91101. subdivisions?: number;
  91102. sideOrientation?: number;
  91103. frontUVs?: Vector4;
  91104. backUVs?: Vector4;
  91105. }): VertexData;
  91106. /**
  91107. * Creates the VertexData for a Polyhedron
  91108. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91109. * * type provided types are:
  91110. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91111. * * 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)
  91112. * * size the size of the IcoSphere, optional default 1
  91113. * * sizeX allows stretching in the x direction, optional, default size
  91114. * * sizeY allows stretching in the y direction, optional, default size
  91115. * * sizeZ allows stretching in the z direction, optional, default size
  91116. * * 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
  91117. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91118. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91119. * * flat when true creates a flat shaded mesh, optional, default true
  91120. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91122. * * 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)
  91123. * * 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)
  91124. * @returns the VertexData of the Polyhedron
  91125. */
  91126. static CreatePolyhedron(options: {
  91127. type?: number;
  91128. size?: number;
  91129. sizeX?: number;
  91130. sizeY?: number;
  91131. sizeZ?: number;
  91132. custom?: any;
  91133. faceUV?: Vector4[];
  91134. faceColors?: Color4[];
  91135. flat?: boolean;
  91136. sideOrientation?: number;
  91137. frontUVs?: Vector4;
  91138. backUVs?: Vector4;
  91139. }): VertexData;
  91140. /**
  91141. * Creates the VertexData for a TorusKnot
  91142. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91143. * * radius the radius of the torus knot, optional, default 2
  91144. * * tube the thickness of the tube, optional, default 0.5
  91145. * * radialSegments the number of sides on each tube segments, optional, default 32
  91146. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91147. * * p the number of windings around the z axis, optional, default 2
  91148. * * q the number of windings around the x axis, optional, default 3
  91149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91150. * * 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)
  91151. * * 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)
  91152. * @returns the VertexData of the Torus Knot
  91153. */
  91154. static CreateTorusKnot(options: {
  91155. radius?: number;
  91156. tube?: number;
  91157. radialSegments?: number;
  91158. tubularSegments?: number;
  91159. p?: number;
  91160. q?: number;
  91161. sideOrientation?: number;
  91162. frontUVs?: Vector4;
  91163. backUVs?: Vector4;
  91164. }): VertexData;
  91165. /**
  91166. * Compute normals for given positions and indices
  91167. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91168. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91169. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91170. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91171. * * facetNormals : optional array of facet normals (vector3)
  91172. * * facetPositions : optional array of facet positions (vector3)
  91173. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91174. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91175. * * bInfo : optional bounding info, required for facetPartitioning computation
  91176. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91177. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91178. * * useRightHandedSystem: optional boolean to for right handed system computation
  91179. * * depthSort : optional boolean to enable the facet depth sort computation
  91180. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91181. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91182. */
  91183. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91184. facetNormals?: any;
  91185. facetPositions?: any;
  91186. facetPartitioning?: any;
  91187. ratio?: number;
  91188. bInfo?: any;
  91189. bbSize?: Vector3;
  91190. subDiv?: any;
  91191. useRightHandedSystem?: boolean;
  91192. depthSort?: boolean;
  91193. distanceTo?: Vector3;
  91194. depthSortedFacets?: any;
  91195. }): void;
  91196. /** @hidden */
  91197. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91198. /**
  91199. * Applies VertexData created from the imported parameters to the geometry
  91200. * @param parsedVertexData the parsed data from an imported file
  91201. * @param geometry the geometry to apply the VertexData to
  91202. */
  91203. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91204. }
  91205. }
  91206. declare module BABYLON {
  91207. /**
  91208. * Defines a target to use with MorphTargetManager
  91209. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91210. */
  91211. export class MorphTarget implements IAnimatable {
  91212. /** defines the name of the target */
  91213. name: string;
  91214. /**
  91215. * Gets or sets the list of animations
  91216. */
  91217. animations: Animation[];
  91218. private _scene;
  91219. private _positions;
  91220. private _normals;
  91221. private _tangents;
  91222. private _uvs;
  91223. private _influence;
  91224. private _uniqueId;
  91225. /**
  91226. * Observable raised when the influence changes
  91227. */
  91228. onInfluenceChanged: Observable<boolean>;
  91229. /** @hidden */
  91230. _onDataLayoutChanged: Observable<void>;
  91231. /**
  91232. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91233. */
  91234. influence: number;
  91235. /**
  91236. * Gets or sets the id of the morph Target
  91237. */
  91238. id: string;
  91239. private _animationPropertiesOverride;
  91240. /**
  91241. * Gets or sets the animation properties override
  91242. */
  91243. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91244. /**
  91245. * Creates a new MorphTarget
  91246. * @param name defines the name of the target
  91247. * @param influence defines the influence to use
  91248. * @param scene defines the scene the morphtarget belongs to
  91249. */
  91250. constructor(
  91251. /** defines the name of the target */
  91252. name: string, influence?: number, scene?: Nullable<Scene>);
  91253. /**
  91254. * Gets the unique ID of this manager
  91255. */
  91256. readonly uniqueId: number;
  91257. /**
  91258. * Gets a boolean defining if the target contains position data
  91259. */
  91260. readonly hasPositions: boolean;
  91261. /**
  91262. * Gets a boolean defining if the target contains normal data
  91263. */
  91264. readonly hasNormals: boolean;
  91265. /**
  91266. * Gets a boolean defining if the target contains tangent data
  91267. */
  91268. readonly hasTangents: boolean;
  91269. /**
  91270. * Gets a boolean defining if the target contains texture coordinates data
  91271. */
  91272. readonly hasUVs: boolean;
  91273. /**
  91274. * Affects position data to this target
  91275. * @param data defines the position data to use
  91276. */
  91277. setPositions(data: Nullable<FloatArray>): void;
  91278. /**
  91279. * Gets the position data stored in this target
  91280. * @returns a FloatArray containing the position data (or null if not present)
  91281. */
  91282. getPositions(): Nullable<FloatArray>;
  91283. /**
  91284. * Affects normal data to this target
  91285. * @param data defines the normal data to use
  91286. */
  91287. setNormals(data: Nullable<FloatArray>): void;
  91288. /**
  91289. * Gets the normal data stored in this target
  91290. * @returns a FloatArray containing the normal data (or null if not present)
  91291. */
  91292. getNormals(): Nullable<FloatArray>;
  91293. /**
  91294. * Affects tangent data to this target
  91295. * @param data defines the tangent data to use
  91296. */
  91297. setTangents(data: Nullable<FloatArray>): void;
  91298. /**
  91299. * Gets the tangent data stored in this target
  91300. * @returns a FloatArray containing the tangent data (or null if not present)
  91301. */
  91302. getTangents(): Nullable<FloatArray>;
  91303. /**
  91304. * Affects texture coordinates data to this target
  91305. * @param data defines the texture coordinates data to use
  91306. */
  91307. setUVs(data: Nullable<FloatArray>): void;
  91308. /**
  91309. * Gets the texture coordinates data stored in this target
  91310. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91311. */
  91312. getUVs(): Nullable<FloatArray>;
  91313. /**
  91314. * Clone the current target
  91315. * @returns a new MorphTarget
  91316. */
  91317. clone(): MorphTarget;
  91318. /**
  91319. * Serializes the current target into a Serialization object
  91320. * @returns the serialized object
  91321. */
  91322. serialize(): any;
  91323. /**
  91324. * Returns the string "MorphTarget"
  91325. * @returns "MorphTarget"
  91326. */
  91327. getClassName(): string;
  91328. /**
  91329. * Creates a new target from serialized data
  91330. * @param serializationObject defines the serialized data to use
  91331. * @returns a new MorphTarget
  91332. */
  91333. static Parse(serializationObject: any): MorphTarget;
  91334. /**
  91335. * Creates a MorphTarget from mesh data
  91336. * @param mesh defines the source mesh
  91337. * @param name defines the name to use for the new target
  91338. * @param influence defines the influence to attach to the target
  91339. * @returns a new MorphTarget
  91340. */
  91341. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91342. }
  91343. }
  91344. declare module BABYLON {
  91345. /**
  91346. * This class is used to deform meshes using morphing between different targets
  91347. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91348. */
  91349. export class MorphTargetManager {
  91350. private _targets;
  91351. private _targetInfluenceChangedObservers;
  91352. private _targetDataLayoutChangedObservers;
  91353. private _activeTargets;
  91354. private _scene;
  91355. private _influences;
  91356. private _supportsNormals;
  91357. private _supportsTangents;
  91358. private _supportsUVs;
  91359. private _vertexCount;
  91360. private _uniqueId;
  91361. private _tempInfluences;
  91362. /**
  91363. * Gets or sets a boolean indicating if normals must be morphed
  91364. */
  91365. enableNormalMorphing: boolean;
  91366. /**
  91367. * Gets or sets a boolean indicating if tangents must be morphed
  91368. */
  91369. enableTangentMorphing: boolean;
  91370. /**
  91371. * Gets or sets a boolean indicating if UV must be morphed
  91372. */
  91373. enableUVMorphing: boolean;
  91374. /**
  91375. * Creates a new MorphTargetManager
  91376. * @param scene defines the current scene
  91377. */
  91378. constructor(scene?: Nullable<Scene>);
  91379. /**
  91380. * Gets the unique ID of this manager
  91381. */
  91382. readonly uniqueId: number;
  91383. /**
  91384. * Gets the number of vertices handled by this manager
  91385. */
  91386. readonly vertexCount: number;
  91387. /**
  91388. * Gets a boolean indicating if this manager supports morphing of normals
  91389. */
  91390. readonly supportsNormals: boolean;
  91391. /**
  91392. * Gets a boolean indicating if this manager supports morphing of tangents
  91393. */
  91394. readonly supportsTangents: boolean;
  91395. /**
  91396. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91397. */
  91398. readonly supportsUVs: boolean;
  91399. /**
  91400. * Gets the number of targets stored in this manager
  91401. */
  91402. readonly numTargets: number;
  91403. /**
  91404. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91405. */
  91406. readonly numInfluencers: number;
  91407. /**
  91408. * Gets the list of influences (one per target)
  91409. */
  91410. readonly influences: Float32Array;
  91411. /**
  91412. * Gets the active target at specified index. An active target is a target with an influence > 0
  91413. * @param index defines the index to check
  91414. * @returns the requested target
  91415. */
  91416. getActiveTarget(index: number): MorphTarget;
  91417. /**
  91418. * Gets the target at specified index
  91419. * @param index defines the index to check
  91420. * @returns the requested target
  91421. */
  91422. getTarget(index: number): MorphTarget;
  91423. /**
  91424. * Add a new target to this manager
  91425. * @param target defines the target to add
  91426. */
  91427. addTarget(target: MorphTarget): void;
  91428. /**
  91429. * Removes a target from the manager
  91430. * @param target defines the target to remove
  91431. */
  91432. removeTarget(target: MorphTarget): void;
  91433. /**
  91434. * Clone the current manager
  91435. * @returns a new MorphTargetManager
  91436. */
  91437. clone(): MorphTargetManager;
  91438. /**
  91439. * Serializes the current manager into a Serialization object
  91440. * @returns the serialized object
  91441. */
  91442. serialize(): any;
  91443. private _syncActiveTargets;
  91444. /**
  91445. * Syncrhonize the targets with all the meshes using this morph target manager
  91446. */
  91447. synchronize(): void;
  91448. /**
  91449. * Creates a new MorphTargetManager from serialized data
  91450. * @param serializationObject defines the serialized data
  91451. * @param scene defines the hosting scene
  91452. * @returns the new MorphTargetManager
  91453. */
  91454. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91455. }
  91456. }
  91457. declare module BABYLON {
  91458. /**
  91459. * Class used to represent a specific level of detail of a mesh
  91460. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91461. */
  91462. export class MeshLODLevel {
  91463. /** Defines the distance where this level should start being displayed */
  91464. distance: number;
  91465. /** Defines the mesh to use to render this level */
  91466. mesh: Nullable<Mesh>;
  91467. /**
  91468. * Creates a new LOD level
  91469. * @param distance defines the distance where this level should star being displayed
  91470. * @param mesh defines the mesh to use to render this level
  91471. */
  91472. constructor(
  91473. /** Defines the distance where this level should start being displayed */
  91474. distance: number,
  91475. /** Defines the mesh to use to render this level */
  91476. mesh: Nullable<Mesh>);
  91477. }
  91478. }
  91479. declare module BABYLON {
  91480. /**
  91481. * Mesh representing the gorund
  91482. */
  91483. export class GroundMesh extends Mesh {
  91484. /** If octree should be generated */
  91485. generateOctree: boolean;
  91486. private _heightQuads;
  91487. /** @hidden */
  91488. _subdivisionsX: number;
  91489. /** @hidden */
  91490. _subdivisionsY: number;
  91491. /** @hidden */
  91492. _width: number;
  91493. /** @hidden */
  91494. _height: number;
  91495. /** @hidden */
  91496. _minX: number;
  91497. /** @hidden */
  91498. _maxX: number;
  91499. /** @hidden */
  91500. _minZ: number;
  91501. /** @hidden */
  91502. _maxZ: number;
  91503. constructor(name: string, scene: Scene);
  91504. /**
  91505. * "GroundMesh"
  91506. * @returns "GroundMesh"
  91507. */
  91508. getClassName(): string;
  91509. /**
  91510. * The minimum of x and y subdivisions
  91511. */
  91512. readonly subdivisions: number;
  91513. /**
  91514. * X subdivisions
  91515. */
  91516. readonly subdivisionsX: number;
  91517. /**
  91518. * Y subdivisions
  91519. */
  91520. readonly subdivisionsY: number;
  91521. /**
  91522. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91523. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91524. * @param chunksCount the number of subdivisions for x and y
  91525. * @param octreeBlocksSize (Default: 32)
  91526. */
  91527. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91528. /**
  91529. * Returns a height (y) value in the Worl system :
  91530. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91531. * @param x x coordinate
  91532. * @param z z coordinate
  91533. * @returns the ground y position if (x, z) are outside the ground surface.
  91534. */
  91535. getHeightAtCoordinates(x: number, z: number): number;
  91536. /**
  91537. * Returns a normalized vector (Vector3) orthogonal to the ground
  91538. * at the ground coordinates (x, z) expressed in the World system.
  91539. * @param x x coordinate
  91540. * @param z z coordinate
  91541. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91542. */
  91543. getNormalAtCoordinates(x: number, z: number): Vector3;
  91544. /**
  91545. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91546. * at the ground coordinates (x, z) expressed in the World system.
  91547. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91548. * @param x x coordinate
  91549. * @param z z coordinate
  91550. * @param ref vector to store the result
  91551. * @returns the GroundMesh.
  91552. */
  91553. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91554. /**
  91555. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91556. * if the ground has been updated.
  91557. * This can be used in the render loop.
  91558. * @returns the GroundMesh.
  91559. */
  91560. updateCoordinateHeights(): GroundMesh;
  91561. private _getFacetAt;
  91562. private _initHeightQuads;
  91563. private _computeHeightQuads;
  91564. /**
  91565. * Serializes this ground mesh
  91566. * @param serializationObject object to write serialization to
  91567. */
  91568. serialize(serializationObject: any): void;
  91569. /**
  91570. * Parses a serialized ground mesh
  91571. * @param parsedMesh the serialized mesh
  91572. * @param scene the scene to create the ground mesh in
  91573. * @returns the created ground mesh
  91574. */
  91575. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91576. }
  91577. }
  91578. declare module BABYLON {
  91579. /**
  91580. * Interface for Physics-Joint data
  91581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91582. */
  91583. export interface PhysicsJointData {
  91584. /**
  91585. * The main pivot of the joint
  91586. */
  91587. mainPivot?: Vector3;
  91588. /**
  91589. * The connected pivot of the joint
  91590. */
  91591. connectedPivot?: Vector3;
  91592. /**
  91593. * The main axis of the joint
  91594. */
  91595. mainAxis?: Vector3;
  91596. /**
  91597. * The connected axis of the joint
  91598. */
  91599. connectedAxis?: Vector3;
  91600. /**
  91601. * The collision of the joint
  91602. */
  91603. collision?: boolean;
  91604. /**
  91605. * Native Oimo/Cannon/Energy data
  91606. */
  91607. nativeParams?: any;
  91608. }
  91609. /**
  91610. * This is a holder class for the physics joint created by the physics plugin
  91611. * It holds a set of functions to control the underlying joint
  91612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91613. */
  91614. export class PhysicsJoint {
  91615. /**
  91616. * The type of the physics joint
  91617. */
  91618. type: number;
  91619. /**
  91620. * The data for the physics joint
  91621. */
  91622. jointData: PhysicsJointData;
  91623. private _physicsJoint;
  91624. protected _physicsPlugin: IPhysicsEnginePlugin;
  91625. /**
  91626. * Initializes the physics joint
  91627. * @param type The type of the physics joint
  91628. * @param jointData The data for the physics joint
  91629. */
  91630. constructor(
  91631. /**
  91632. * The type of the physics joint
  91633. */
  91634. type: number,
  91635. /**
  91636. * The data for the physics joint
  91637. */
  91638. jointData: PhysicsJointData);
  91639. /**
  91640. * Gets the physics joint
  91641. */
  91642. /**
  91643. * Sets the physics joint
  91644. */
  91645. physicsJoint: any;
  91646. /**
  91647. * Sets the physics plugin
  91648. */
  91649. physicsPlugin: IPhysicsEnginePlugin;
  91650. /**
  91651. * Execute a function that is physics-plugin specific.
  91652. * @param {Function} func the function that will be executed.
  91653. * It accepts two parameters: the physics world and the physics joint
  91654. */
  91655. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91656. /**
  91657. * Distance-Joint type
  91658. */
  91659. static DistanceJoint: number;
  91660. /**
  91661. * Hinge-Joint type
  91662. */
  91663. static HingeJoint: number;
  91664. /**
  91665. * Ball-and-Socket joint type
  91666. */
  91667. static BallAndSocketJoint: number;
  91668. /**
  91669. * Wheel-Joint type
  91670. */
  91671. static WheelJoint: number;
  91672. /**
  91673. * Slider-Joint type
  91674. */
  91675. static SliderJoint: number;
  91676. /**
  91677. * Prismatic-Joint type
  91678. */
  91679. static PrismaticJoint: number;
  91680. /**
  91681. * Universal-Joint type
  91682. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91683. */
  91684. static UniversalJoint: number;
  91685. /**
  91686. * Hinge-Joint 2 type
  91687. */
  91688. static Hinge2Joint: number;
  91689. /**
  91690. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91691. */
  91692. static PointToPointJoint: number;
  91693. /**
  91694. * Spring-Joint type
  91695. */
  91696. static SpringJoint: number;
  91697. /**
  91698. * Lock-Joint type
  91699. */
  91700. static LockJoint: number;
  91701. }
  91702. /**
  91703. * A class representing a physics distance joint
  91704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91705. */
  91706. export class DistanceJoint extends PhysicsJoint {
  91707. /**
  91708. *
  91709. * @param jointData The data for the Distance-Joint
  91710. */
  91711. constructor(jointData: DistanceJointData);
  91712. /**
  91713. * Update the predefined distance.
  91714. * @param maxDistance The maximum preferred distance
  91715. * @param minDistance The minimum preferred distance
  91716. */
  91717. updateDistance(maxDistance: number, minDistance?: number): void;
  91718. }
  91719. /**
  91720. * Represents a Motor-Enabled Joint
  91721. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91722. */
  91723. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91724. /**
  91725. * Initializes the Motor-Enabled Joint
  91726. * @param type The type of the joint
  91727. * @param jointData The physica joint data for the joint
  91728. */
  91729. constructor(type: number, jointData: PhysicsJointData);
  91730. /**
  91731. * Set the motor values.
  91732. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91733. * @param force the force to apply
  91734. * @param maxForce max force for this motor.
  91735. */
  91736. setMotor(force?: number, maxForce?: number): void;
  91737. /**
  91738. * Set the motor's limits.
  91739. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91740. * @param upperLimit The upper limit of the motor
  91741. * @param lowerLimit The lower limit of the motor
  91742. */
  91743. setLimit(upperLimit: number, lowerLimit?: number): void;
  91744. }
  91745. /**
  91746. * This class represents a single physics Hinge-Joint
  91747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91748. */
  91749. export class HingeJoint extends MotorEnabledJoint {
  91750. /**
  91751. * Initializes the Hinge-Joint
  91752. * @param jointData The joint data for the Hinge-Joint
  91753. */
  91754. constructor(jointData: PhysicsJointData);
  91755. /**
  91756. * Set the motor values.
  91757. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91758. * @param {number} force the force to apply
  91759. * @param {number} maxForce max force for this motor.
  91760. */
  91761. setMotor(force?: number, maxForce?: number): void;
  91762. /**
  91763. * Set the motor's limits.
  91764. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91765. * @param upperLimit The upper limit of the motor
  91766. * @param lowerLimit The lower limit of the motor
  91767. */
  91768. setLimit(upperLimit: number, lowerLimit?: number): void;
  91769. }
  91770. /**
  91771. * This class represents a dual hinge physics joint (same as wheel joint)
  91772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91773. */
  91774. export class Hinge2Joint extends MotorEnabledJoint {
  91775. /**
  91776. * Initializes the Hinge2-Joint
  91777. * @param jointData The joint data for the Hinge2-Joint
  91778. */
  91779. constructor(jointData: PhysicsJointData);
  91780. /**
  91781. * Set the motor values.
  91782. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91783. * @param {number} targetSpeed the speed the motor is to reach
  91784. * @param {number} maxForce max force for this motor.
  91785. * @param {motorIndex} the motor's index, 0 or 1.
  91786. */
  91787. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91788. /**
  91789. * Set the motor limits.
  91790. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91791. * @param {number} upperLimit the upper limit
  91792. * @param {number} lowerLimit lower limit
  91793. * @param {motorIndex} the motor's index, 0 or 1.
  91794. */
  91795. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91796. }
  91797. /**
  91798. * Interface for a motor enabled joint
  91799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91800. */
  91801. export interface IMotorEnabledJoint {
  91802. /**
  91803. * Physics joint
  91804. */
  91805. physicsJoint: any;
  91806. /**
  91807. * Sets the motor of the motor-enabled joint
  91808. * @param force The force of the motor
  91809. * @param maxForce The maximum force of the motor
  91810. * @param motorIndex The index of the motor
  91811. */
  91812. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91813. /**
  91814. * Sets the limit of the motor
  91815. * @param upperLimit The upper limit of the motor
  91816. * @param lowerLimit The lower limit of the motor
  91817. * @param motorIndex The index of the motor
  91818. */
  91819. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91820. }
  91821. /**
  91822. * Joint data for a Distance-Joint
  91823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91824. */
  91825. export interface DistanceJointData extends PhysicsJointData {
  91826. /**
  91827. * Max distance the 2 joint objects can be apart
  91828. */
  91829. maxDistance: number;
  91830. }
  91831. /**
  91832. * Joint data from a spring joint
  91833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91834. */
  91835. export interface SpringJointData extends PhysicsJointData {
  91836. /**
  91837. * Length of the spring
  91838. */
  91839. length: number;
  91840. /**
  91841. * Stiffness of the spring
  91842. */
  91843. stiffness: number;
  91844. /**
  91845. * Damping of the spring
  91846. */
  91847. damping: number;
  91848. /** this callback will be called when applying the force to the impostors. */
  91849. forceApplicationCallback: () => void;
  91850. }
  91851. }
  91852. declare module BABYLON {
  91853. /**
  91854. * Holds the data for the raycast result
  91855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91856. */
  91857. export class PhysicsRaycastResult {
  91858. private _hasHit;
  91859. private _hitDistance;
  91860. private _hitNormalWorld;
  91861. private _hitPointWorld;
  91862. private _rayFromWorld;
  91863. private _rayToWorld;
  91864. /**
  91865. * Gets if there was a hit
  91866. */
  91867. readonly hasHit: boolean;
  91868. /**
  91869. * Gets the distance from the hit
  91870. */
  91871. readonly hitDistance: number;
  91872. /**
  91873. * Gets the hit normal/direction in the world
  91874. */
  91875. readonly hitNormalWorld: Vector3;
  91876. /**
  91877. * Gets the hit point in the world
  91878. */
  91879. readonly hitPointWorld: Vector3;
  91880. /**
  91881. * Gets the ray "start point" of the ray in the world
  91882. */
  91883. readonly rayFromWorld: Vector3;
  91884. /**
  91885. * Gets the ray "end point" of the ray in the world
  91886. */
  91887. readonly rayToWorld: Vector3;
  91888. /**
  91889. * Sets the hit data (normal & point in world space)
  91890. * @param hitNormalWorld defines the normal in world space
  91891. * @param hitPointWorld defines the point in world space
  91892. */
  91893. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91894. /**
  91895. * Sets the distance from the start point to the hit point
  91896. * @param distance
  91897. */
  91898. setHitDistance(distance: number): void;
  91899. /**
  91900. * Calculates the distance manually
  91901. */
  91902. calculateHitDistance(): void;
  91903. /**
  91904. * Resets all the values to default
  91905. * @param from The from point on world space
  91906. * @param to The to point on world space
  91907. */
  91908. reset(from?: Vector3, to?: Vector3): void;
  91909. }
  91910. /**
  91911. * Interface for the size containing width and height
  91912. */
  91913. interface IXYZ {
  91914. /**
  91915. * X
  91916. */
  91917. x: number;
  91918. /**
  91919. * Y
  91920. */
  91921. y: number;
  91922. /**
  91923. * Z
  91924. */
  91925. z: number;
  91926. }
  91927. }
  91928. declare module BABYLON {
  91929. /**
  91930. * Interface used to describe a physics joint
  91931. */
  91932. export interface PhysicsImpostorJoint {
  91933. /** Defines the main impostor to which the joint is linked */
  91934. mainImpostor: PhysicsImpostor;
  91935. /** Defines the impostor that is connected to the main impostor using this joint */
  91936. connectedImpostor: PhysicsImpostor;
  91937. /** Defines the joint itself */
  91938. joint: PhysicsJoint;
  91939. }
  91940. /** @hidden */
  91941. export interface IPhysicsEnginePlugin {
  91942. world: any;
  91943. name: string;
  91944. setGravity(gravity: Vector3): void;
  91945. setTimeStep(timeStep: number): void;
  91946. getTimeStep(): number;
  91947. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91948. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91949. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91950. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91951. removePhysicsBody(impostor: PhysicsImpostor): void;
  91952. generateJoint(joint: PhysicsImpostorJoint): void;
  91953. removeJoint(joint: PhysicsImpostorJoint): void;
  91954. isSupported(): boolean;
  91955. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91956. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91957. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91958. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91959. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91960. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91961. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91962. getBodyMass(impostor: PhysicsImpostor): number;
  91963. getBodyFriction(impostor: PhysicsImpostor): number;
  91964. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91965. getBodyRestitution(impostor: PhysicsImpostor): number;
  91966. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91967. getBodyPressure?(impostor: PhysicsImpostor): number;
  91968. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91969. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91970. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91971. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91972. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91973. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91974. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91975. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91976. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91977. sleepBody(impostor: PhysicsImpostor): void;
  91978. wakeUpBody(impostor: PhysicsImpostor): void;
  91979. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91980. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91981. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91982. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91983. getRadius(impostor: PhysicsImpostor): number;
  91984. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91985. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91986. dispose(): void;
  91987. }
  91988. /**
  91989. * Interface used to define a physics engine
  91990. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91991. */
  91992. export interface IPhysicsEngine {
  91993. /**
  91994. * Gets the gravity vector used by the simulation
  91995. */
  91996. gravity: Vector3;
  91997. /**
  91998. * Sets the gravity vector used by the simulation
  91999. * @param gravity defines the gravity vector to use
  92000. */
  92001. setGravity(gravity: Vector3): void;
  92002. /**
  92003. * Set the time step of the physics engine.
  92004. * Default is 1/60.
  92005. * To slow it down, enter 1/600 for example.
  92006. * To speed it up, 1/30
  92007. * @param newTimeStep the new timestep to apply to this world.
  92008. */
  92009. setTimeStep(newTimeStep: number): void;
  92010. /**
  92011. * Get the time step of the physics engine.
  92012. * @returns the current time step
  92013. */
  92014. getTimeStep(): number;
  92015. /**
  92016. * Set the sub time step of the physics engine.
  92017. * Default is 0 meaning there is no sub steps
  92018. * To increase physics resolution precision, set a small value (like 1 ms)
  92019. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92020. */
  92021. setSubTimeStep(subTimeStep: number): void;
  92022. /**
  92023. * Get the sub time step of the physics engine.
  92024. * @returns the current sub time step
  92025. */
  92026. getSubTimeStep(): number;
  92027. /**
  92028. * Release all resources
  92029. */
  92030. dispose(): void;
  92031. /**
  92032. * Gets the name of the current physics plugin
  92033. * @returns the name of the plugin
  92034. */
  92035. getPhysicsPluginName(): string;
  92036. /**
  92037. * Adding a new impostor for the impostor tracking.
  92038. * This will be done by the impostor itself.
  92039. * @param impostor the impostor to add
  92040. */
  92041. addImpostor(impostor: PhysicsImpostor): void;
  92042. /**
  92043. * Remove an impostor from the engine.
  92044. * This impostor and its mesh will not longer be updated by the physics engine.
  92045. * @param impostor the impostor to remove
  92046. */
  92047. removeImpostor(impostor: PhysicsImpostor): void;
  92048. /**
  92049. * Add a joint to the physics engine
  92050. * @param mainImpostor defines the main impostor to which the joint is added.
  92051. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92052. * @param joint defines the joint that will connect both impostors.
  92053. */
  92054. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92055. /**
  92056. * Removes a joint from the simulation
  92057. * @param mainImpostor defines the impostor used with the joint
  92058. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92059. * @param joint defines the joint to remove
  92060. */
  92061. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92062. /**
  92063. * Gets the current plugin used to run the simulation
  92064. * @returns current plugin
  92065. */
  92066. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92067. /**
  92068. * Gets the list of physic impostors
  92069. * @returns an array of PhysicsImpostor
  92070. */
  92071. getImpostors(): Array<PhysicsImpostor>;
  92072. /**
  92073. * Gets the impostor for a physics enabled object
  92074. * @param object defines the object impersonated by the impostor
  92075. * @returns the PhysicsImpostor or null if not found
  92076. */
  92077. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92078. /**
  92079. * Gets the impostor for a physics body object
  92080. * @param body defines physics body used by the impostor
  92081. * @returns the PhysicsImpostor or null if not found
  92082. */
  92083. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92084. /**
  92085. * Does a raycast in the physics world
  92086. * @param from when should the ray start?
  92087. * @param to when should the ray end?
  92088. * @returns PhysicsRaycastResult
  92089. */
  92090. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92091. /**
  92092. * Called by the scene. No need to call it.
  92093. * @param delta defines the timespam between frames
  92094. */
  92095. _step(delta: number): void;
  92096. }
  92097. }
  92098. declare module BABYLON {
  92099. /**
  92100. * The interface for the physics imposter parameters
  92101. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92102. */
  92103. export interface PhysicsImpostorParameters {
  92104. /**
  92105. * The mass of the physics imposter
  92106. */
  92107. mass: number;
  92108. /**
  92109. * The friction of the physics imposter
  92110. */
  92111. friction?: number;
  92112. /**
  92113. * The coefficient of restitution of the physics imposter
  92114. */
  92115. restitution?: number;
  92116. /**
  92117. * The native options of the physics imposter
  92118. */
  92119. nativeOptions?: any;
  92120. /**
  92121. * Specifies if the parent should be ignored
  92122. */
  92123. ignoreParent?: boolean;
  92124. /**
  92125. * Specifies if bi-directional transformations should be disabled
  92126. */
  92127. disableBidirectionalTransformation?: boolean;
  92128. /**
  92129. * The pressure inside the physics imposter, soft object only
  92130. */
  92131. pressure?: number;
  92132. /**
  92133. * The stiffness the physics imposter, soft object only
  92134. */
  92135. stiffness?: number;
  92136. /**
  92137. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92138. */
  92139. velocityIterations?: number;
  92140. /**
  92141. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92142. */
  92143. positionIterations?: number;
  92144. /**
  92145. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92146. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92147. * Add to fix multiple points
  92148. */
  92149. fixedPoints?: number;
  92150. /**
  92151. * The collision margin around a soft object
  92152. */
  92153. margin?: number;
  92154. /**
  92155. * The collision margin around a soft object
  92156. */
  92157. damping?: number;
  92158. /**
  92159. * The path for a rope based on an extrusion
  92160. */
  92161. path?: any;
  92162. /**
  92163. * The shape of an extrusion used for a rope based on an extrusion
  92164. */
  92165. shape?: any;
  92166. }
  92167. /**
  92168. * Interface for a physics-enabled object
  92169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92170. */
  92171. export interface IPhysicsEnabledObject {
  92172. /**
  92173. * The position of the physics-enabled object
  92174. */
  92175. position: Vector3;
  92176. /**
  92177. * The rotation of the physics-enabled object
  92178. */
  92179. rotationQuaternion: Nullable<Quaternion>;
  92180. /**
  92181. * The scale of the physics-enabled object
  92182. */
  92183. scaling: Vector3;
  92184. /**
  92185. * The rotation of the physics-enabled object
  92186. */
  92187. rotation?: Vector3;
  92188. /**
  92189. * The parent of the physics-enabled object
  92190. */
  92191. parent?: any;
  92192. /**
  92193. * The bounding info of the physics-enabled object
  92194. * @returns The bounding info of the physics-enabled object
  92195. */
  92196. getBoundingInfo(): BoundingInfo;
  92197. /**
  92198. * Computes the world matrix
  92199. * @param force Specifies if the world matrix should be computed by force
  92200. * @returns A world matrix
  92201. */
  92202. computeWorldMatrix(force: boolean): Matrix;
  92203. /**
  92204. * Gets the world matrix
  92205. * @returns A world matrix
  92206. */
  92207. getWorldMatrix?(): Matrix;
  92208. /**
  92209. * Gets the child meshes
  92210. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92211. * @returns An array of abstract meshes
  92212. */
  92213. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92214. /**
  92215. * Gets the vertex data
  92216. * @param kind The type of vertex data
  92217. * @returns A nullable array of numbers, or a float32 array
  92218. */
  92219. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92220. /**
  92221. * Gets the indices from the mesh
  92222. * @returns A nullable array of index arrays
  92223. */
  92224. getIndices?(): Nullable<IndicesArray>;
  92225. /**
  92226. * Gets the scene from the mesh
  92227. * @returns the indices array or null
  92228. */
  92229. getScene?(): Scene;
  92230. /**
  92231. * Gets the absolute position from the mesh
  92232. * @returns the absolute position
  92233. */
  92234. getAbsolutePosition(): Vector3;
  92235. /**
  92236. * Gets the absolute pivot point from the mesh
  92237. * @returns the absolute pivot point
  92238. */
  92239. getAbsolutePivotPoint(): Vector3;
  92240. /**
  92241. * Rotates the mesh
  92242. * @param axis The axis of rotation
  92243. * @param amount The amount of rotation
  92244. * @param space The space of the rotation
  92245. * @returns The rotation transform node
  92246. */
  92247. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92248. /**
  92249. * Translates the mesh
  92250. * @param axis The axis of translation
  92251. * @param distance The distance of translation
  92252. * @param space The space of the translation
  92253. * @returns The transform node
  92254. */
  92255. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92256. /**
  92257. * Sets the absolute position of the mesh
  92258. * @param absolutePosition The absolute position of the mesh
  92259. * @returns The transform node
  92260. */
  92261. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92262. /**
  92263. * Gets the class name of the mesh
  92264. * @returns The class name
  92265. */
  92266. getClassName(): string;
  92267. }
  92268. /**
  92269. * Represents a physics imposter
  92270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92271. */
  92272. export class PhysicsImpostor {
  92273. /**
  92274. * The physics-enabled object used as the physics imposter
  92275. */
  92276. object: IPhysicsEnabledObject;
  92277. /**
  92278. * The type of the physics imposter
  92279. */
  92280. type: number;
  92281. private _options;
  92282. private _scene?;
  92283. /**
  92284. * The default object size of the imposter
  92285. */
  92286. static DEFAULT_OBJECT_SIZE: Vector3;
  92287. /**
  92288. * The identity quaternion of the imposter
  92289. */
  92290. static IDENTITY_QUATERNION: Quaternion;
  92291. /** @hidden */
  92292. _pluginData: any;
  92293. private _physicsEngine;
  92294. private _physicsBody;
  92295. private _bodyUpdateRequired;
  92296. private _onBeforePhysicsStepCallbacks;
  92297. private _onAfterPhysicsStepCallbacks;
  92298. /** @hidden */
  92299. _onPhysicsCollideCallbacks: Array<{
  92300. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92301. otherImpostors: Array<PhysicsImpostor>;
  92302. }>;
  92303. private _deltaPosition;
  92304. private _deltaRotation;
  92305. private _deltaRotationConjugated;
  92306. /** @hidden */
  92307. _isFromLine: boolean;
  92308. private _parent;
  92309. private _isDisposed;
  92310. private static _tmpVecs;
  92311. private static _tmpQuat;
  92312. /**
  92313. * Specifies if the physics imposter is disposed
  92314. */
  92315. readonly isDisposed: boolean;
  92316. /**
  92317. * Gets the mass of the physics imposter
  92318. */
  92319. mass: number;
  92320. /**
  92321. * Gets the coefficient of friction
  92322. */
  92323. /**
  92324. * Sets the coefficient of friction
  92325. */
  92326. friction: number;
  92327. /**
  92328. * Gets the coefficient of restitution
  92329. */
  92330. /**
  92331. * Sets the coefficient of restitution
  92332. */
  92333. restitution: number;
  92334. /**
  92335. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92336. */
  92337. /**
  92338. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92339. */
  92340. pressure: number;
  92341. /**
  92342. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92343. */
  92344. /**
  92345. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92346. */
  92347. stiffness: number;
  92348. /**
  92349. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92350. */
  92351. /**
  92352. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92353. */
  92354. velocityIterations: number;
  92355. /**
  92356. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92357. */
  92358. /**
  92359. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92360. */
  92361. positionIterations: number;
  92362. /**
  92363. * The unique id of the physics imposter
  92364. * set by the physics engine when adding this impostor to the array
  92365. */
  92366. uniqueId: number;
  92367. /**
  92368. * @hidden
  92369. */
  92370. soft: boolean;
  92371. /**
  92372. * @hidden
  92373. */
  92374. segments: number;
  92375. private _joints;
  92376. /**
  92377. * Initializes the physics imposter
  92378. * @param object The physics-enabled object used as the physics imposter
  92379. * @param type The type of the physics imposter
  92380. * @param _options The options for the physics imposter
  92381. * @param _scene The Babylon scene
  92382. */
  92383. constructor(
  92384. /**
  92385. * The physics-enabled object used as the physics imposter
  92386. */
  92387. object: IPhysicsEnabledObject,
  92388. /**
  92389. * The type of the physics imposter
  92390. */
  92391. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92392. /**
  92393. * This function will completly initialize this impostor.
  92394. * It will create a new body - but only if this mesh has no parent.
  92395. * If it has, this impostor will not be used other than to define the impostor
  92396. * of the child mesh.
  92397. * @hidden
  92398. */
  92399. _init(): void;
  92400. private _getPhysicsParent;
  92401. /**
  92402. * Should a new body be generated.
  92403. * @returns boolean specifying if body initialization is required
  92404. */
  92405. isBodyInitRequired(): boolean;
  92406. /**
  92407. * Sets the updated scaling
  92408. * @param updated Specifies if the scaling is updated
  92409. */
  92410. setScalingUpdated(): void;
  92411. /**
  92412. * Force a regeneration of this or the parent's impostor's body.
  92413. * Use under cautious - This will remove all joints already implemented.
  92414. */
  92415. forceUpdate(): void;
  92416. /**
  92417. * Gets the body that holds this impostor. Either its own, or its parent.
  92418. */
  92419. /**
  92420. * Set the physics body. Used mainly by the physics engine/plugin
  92421. */
  92422. physicsBody: any;
  92423. /**
  92424. * Get the parent of the physics imposter
  92425. * @returns Physics imposter or null
  92426. */
  92427. /**
  92428. * Sets the parent of the physics imposter
  92429. */
  92430. parent: Nullable<PhysicsImpostor>;
  92431. /**
  92432. * Resets the update flags
  92433. */
  92434. resetUpdateFlags(): void;
  92435. /**
  92436. * Gets the object extend size
  92437. * @returns the object extend size
  92438. */
  92439. getObjectExtendSize(): Vector3;
  92440. /**
  92441. * Gets the object center
  92442. * @returns The object center
  92443. */
  92444. getObjectCenter(): Vector3;
  92445. /**
  92446. * Get a specific parametes from the options parameter
  92447. * @param paramName The object parameter name
  92448. * @returns The object parameter
  92449. */
  92450. getParam(paramName: string): any;
  92451. /**
  92452. * Sets a specific parameter in the options given to the physics plugin
  92453. * @param paramName The parameter name
  92454. * @param value The value of the parameter
  92455. */
  92456. setParam(paramName: string, value: number): void;
  92457. /**
  92458. * Specifically change the body's mass option. Won't recreate the physics body object
  92459. * @param mass The mass of the physics imposter
  92460. */
  92461. setMass(mass: number): void;
  92462. /**
  92463. * Gets the linear velocity
  92464. * @returns linear velocity or null
  92465. */
  92466. getLinearVelocity(): Nullable<Vector3>;
  92467. /**
  92468. * Sets the linear velocity
  92469. * @param velocity linear velocity or null
  92470. */
  92471. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92472. /**
  92473. * Gets the angular velocity
  92474. * @returns angular velocity or null
  92475. */
  92476. getAngularVelocity(): Nullable<Vector3>;
  92477. /**
  92478. * Sets the angular velocity
  92479. * @param velocity The velocity or null
  92480. */
  92481. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92482. /**
  92483. * Execute a function with the physics plugin native code
  92484. * Provide a function the will have two variables - the world object and the physics body object
  92485. * @param func The function to execute with the physics plugin native code
  92486. */
  92487. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92488. /**
  92489. * Register a function that will be executed before the physics world is stepping forward
  92490. * @param func The function to execute before the physics world is stepped forward
  92491. */
  92492. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92493. /**
  92494. * Unregister a function that will be executed before the physics world is stepping forward
  92495. * @param func The function to execute before the physics world is stepped forward
  92496. */
  92497. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92498. /**
  92499. * Register a function that will be executed after the physics step
  92500. * @param func The function to execute after physics step
  92501. */
  92502. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92503. /**
  92504. * Unregisters a function that will be executed after the physics step
  92505. * @param func The function to execute after physics step
  92506. */
  92507. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92508. /**
  92509. * register a function that will be executed when this impostor collides against a different body
  92510. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92511. * @param func Callback that is executed on collision
  92512. */
  92513. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92514. /**
  92515. * Unregisters the physics imposter on contact
  92516. * @param collideAgainst The physics object to collide against
  92517. * @param func Callback to execute on collision
  92518. */
  92519. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92520. private _tmpQuat;
  92521. private _tmpQuat2;
  92522. /**
  92523. * Get the parent rotation
  92524. * @returns The parent rotation
  92525. */
  92526. getParentsRotation(): Quaternion;
  92527. /**
  92528. * this function is executed by the physics engine.
  92529. */
  92530. beforeStep: () => void;
  92531. /**
  92532. * this function is executed by the physics engine
  92533. */
  92534. afterStep: () => void;
  92535. /**
  92536. * Legacy collision detection event support
  92537. */
  92538. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92539. /**
  92540. * event and body object due to cannon's event-based architecture.
  92541. */
  92542. onCollide: (e: {
  92543. body: any;
  92544. }) => void;
  92545. /**
  92546. * Apply a force
  92547. * @param force The force to apply
  92548. * @param contactPoint The contact point for the force
  92549. * @returns The physics imposter
  92550. */
  92551. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92552. /**
  92553. * Apply an impulse
  92554. * @param force The impulse force
  92555. * @param contactPoint The contact point for the impulse force
  92556. * @returns The physics imposter
  92557. */
  92558. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92559. /**
  92560. * A help function to create a joint
  92561. * @param otherImpostor A physics imposter used to create a joint
  92562. * @param jointType The type of joint
  92563. * @param jointData The data for the joint
  92564. * @returns The physics imposter
  92565. */
  92566. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92567. /**
  92568. * Add a joint to this impostor with a different impostor
  92569. * @param otherImpostor A physics imposter used to add a joint
  92570. * @param joint The joint to add
  92571. * @returns The physics imposter
  92572. */
  92573. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92574. /**
  92575. * Add an anchor to a cloth impostor
  92576. * @param otherImpostor rigid impostor to anchor to
  92577. * @param width ratio across width from 0 to 1
  92578. * @param height ratio up height from 0 to 1
  92579. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92580. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92581. * @returns impostor the soft imposter
  92582. */
  92583. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92584. /**
  92585. * Add a hook to a rope impostor
  92586. * @param otherImpostor rigid impostor to anchor to
  92587. * @param length ratio across rope from 0 to 1
  92588. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92589. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92590. * @returns impostor the rope imposter
  92591. */
  92592. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92593. /**
  92594. * Will keep this body still, in a sleep mode.
  92595. * @returns the physics imposter
  92596. */
  92597. sleep(): PhysicsImpostor;
  92598. /**
  92599. * Wake the body up.
  92600. * @returns The physics imposter
  92601. */
  92602. wakeUp(): PhysicsImpostor;
  92603. /**
  92604. * Clones the physics imposter
  92605. * @param newObject The physics imposter clones to this physics-enabled object
  92606. * @returns A nullable physics imposter
  92607. */
  92608. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92609. /**
  92610. * Disposes the physics imposter
  92611. */
  92612. dispose(): void;
  92613. /**
  92614. * Sets the delta position
  92615. * @param position The delta position amount
  92616. */
  92617. setDeltaPosition(position: Vector3): void;
  92618. /**
  92619. * Sets the delta rotation
  92620. * @param rotation The delta rotation amount
  92621. */
  92622. setDeltaRotation(rotation: Quaternion): void;
  92623. /**
  92624. * Gets the box size of the physics imposter and stores the result in the input parameter
  92625. * @param result Stores the box size
  92626. * @returns The physics imposter
  92627. */
  92628. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92629. /**
  92630. * Gets the radius of the physics imposter
  92631. * @returns Radius of the physics imposter
  92632. */
  92633. getRadius(): number;
  92634. /**
  92635. * Sync a bone with this impostor
  92636. * @param bone The bone to sync to the impostor.
  92637. * @param boneMesh The mesh that the bone is influencing.
  92638. * @param jointPivot The pivot of the joint / bone in local space.
  92639. * @param distToJoint Optional distance from the impostor to the joint.
  92640. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92641. */
  92642. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92643. /**
  92644. * Sync impostor to a bone
  92645. * @param bone The bone that the impostor will be synced to.
  92646. * @param boneMesh The mesh that the bone is influencing.
  92647. * @param jointPivot The pivot of the joint / bone in local space.
  92648. * @param distToJoint Optional distance from the impostor to the joint.
  92649. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92650. * @param boneAxis Optional vector3 axis the bone is aligned with
  92651. */
  92652. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92653. /**
  92654. * No-Imposter type
  92655. */
  92656. static NoImpostor: number;
  92657. /**
  92658. * Sphere-Imposter type
  92659. */
  92660. static SphereImpostor: number;
  92661. /**
  92662. * Box-Imposter type
  92663. */
  92664. static BoxImpostor: number;
  92665. /**
  92666. * Plane-Imposter type
  92667. */
  92668. static PlaneImpostor: number;
  92669. /**
  92670. * Mesh-imposter type
  92671. */
  92672. static MeshImpostor: number;
  92673. /**
  92674. * Capsule-Impostor type (Ammo.js plugin only)
  92675. */
  92676. static CapsuleImpostor: number;
  92677. /**
  92678. * Cylinder-Imposter type
  92679. */
  92680. static CylinderImpostor: number;
  92681. /**
  92682. * Particle-Imposter type
  92683. */
  92684. static ParticleImpostor: number;
  92685. /**
  92686. * Heightmap-Imposter type
  92687. */
  92688. static HeightmapImpostor: number;
  92689. /**
  92690. * ConvexHull-Impostor type (Ammo.js plugin only)
  92691. */
  92692. static ConvexHullImpostor: number;
  92693. /**
  92694. * Custom-Imposter type (Ammo.js plugin only)
  92695. */
  92696. static CustomImpostor: number;
  92697. /**
  92698. * Rope-Imposter type
  92699. */
  92700. static RopeImpostor: number;
  92701. /**
  92702. * Cloth-Imposter type
  92703. */
  92704. static ClothImpostor: number;
  92705. /**
  92706. * Softbody-Imposter type
  92707. */
  92708. static SoftbodyImpostor: number;
  92709. }
  92710. }
  92711. declare module BABYLON {
  92712. /**
  92713. * @hidden
  92714. **/
  92715. export class _CreationDataStorage {
  92716. closePath?: boolean;
  92717. closeArray?: boolean;
  92718. idx: number[];
  92719. dashSize: number;
  92720. gapSize: number;
  92721. path3D: Path3D;
  92722. pathArray: Vector3[][];
  92723. arc: number;
  92724. radius: number;
  92725. cap: number;
  92726. tessellation: number;
  92727. }
  92728. /**
  92729. * @hidden
  92730. **/
  92731. class _InstanceDataStorage {
  92732. visibleInstances: any;
  92733. batchCache: _InstancesBatch;
  92734. instancesBufferSize: number;
  92735. instancesBuffer: Nullable<Buffer>;
  92736. instancesData: Float32Array;
  92737. overridenInstanceCount: number;
  92738. isFrozen: boolean;
  92739. previousBatch: Nullable<_InstancesBatch>;
  92740. hardwareInstancedRendering: boolean;
  92741. sideOrientation: number;
  92742. manualUpdate: boolean;
  92743. }
  92744. /**
  92745. * @hidden
  92746. **/
  92747. export class _InstancesBatch {
  92748. mustReturn: boolean;
  92749. visibleInstances: Nullable<InstancedMesh[]>[];
  92750. renderSelf: boolean[];
  92751. hardwareInstancedRendering: boolean[];
  92752. }
  92753. /**
  92754. * Class used to represent renderable models
  92755. */
  92756. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92757. /**
  92758. * Mesh side orientation : usually the external or front surface
  92759. */
  92760. static readonly FRONTSIDE: number;
  92761. /**
  92762. * Mesh side orientation : usually the internal or back surface
  92763. */
  92764. static readonly BACKSIDE: number;
  92765. /**
  92766. * Mesh side orientation : both internal and external or front and back surfaces
  92767. */
  92768. static readonly DOUBLESIDE: number;
  92769. /**
  92770. * Mesh side orientation : by default, `FRONTSIDE`
  92771. */
  92772. static readonly DEFAULTSIDE: number;
  92773. /**
  92774. * Mesh cap setting : no cap
  92775. */
  92776. static readonly NO_CAP: number;
  92777. /**
  92778. * Mesh cap setting : one cap at the beginning of the mesh
  92779. */
  92780. static readonly CAP_START: number;
  92781. /**
  92782. * Mesh cap setting : one cap at the end of the mesh
  92783. */
  92784. static readonly CAP_END: number;
  92785. /**
  92786. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92787. */
  92788. static readonly CAP_ALL: number;
  92789. /**
  92790. * Mesh pattern setting : no flip or rotate
  92791. */
  92792. static readonly NO_FLIP: number;
  92793. /**
  92794. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92795. */
  92796. static readonly FLIP_TILE: number;
  92797. /**
  92798. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92799. */
  92800. static readonly ROTATE_TILE: number;
  92801. /**
  92802. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92803. */
  92804. static readonly FLIP_ROW: number;
  92805. /**
  92806. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92807. */
  92808. static readonly ROTATE_ROW: number;
  92809. /**
  92810. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92811. */
  92812. static readonly FLIP_N_ROTATE_TILE: number;
  92813. /**
  92814. * Mesh pattern setting : rotate pattern and rotate
  92815. */
  92816. static readonly FLIP_N_ROTATE_ROW: number;
  92817. /**
  92818. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92819. */
  92820. static readonly CENTER: number;
  92821. /**
  92822. * Mesh tile positioning : part tiles on left
  92823. */
  92824. static readonly LEFT: number;
  92825. /**
  92826. * Mesh tile positioning : part tiles on right
  92827. */
  92828. static readonly RIGHT: number;
  92829. /**
  92830. * Mesh tile positioning : part tiles on top
  92831. */
  92832. static readonly TOP: number;
  92833. /**
  92834. * Mesh tile positioning : part tiles on bottom
  92835. */
  92836. static readonly BOTTOM: number;
  92837. /**
  92838. * Gets the default side orientation.
  92839. * @param orientation the orientation to value to attempt to get
  92840. * @returns the default orientation
  92841. * @hidden
  92842. */
  92843. static _GetDefaultSideOrientation(orientation?: number): number;
  92844. private _internalMeshDataInfo;
  92845. /**
  92846. * An event triggered before rendering the mesh
  92847. */
  92848. readonly onBeforeRenderObservable: Observable<Mesh>;
  92849. /**
  92850. * An event triggered before binding the mesh
  92851. */
  92852. readonly onBeforeBindObservable: Observable<Mesh>;
  92853. /**
  92854. * An event triggered after rendering the mesh
  92855. */
  92856. readonly onAfterRenderObservable: Observable<Mesh>;
  92857. /**
  92858. * An event triggered before drawing the mesh
  92859. */
  92860. readonly onBeforeDrawObservable: Observable<Mesh>;
  92861. private _onBeforeDrawObserver;
  92862. /**
  92863. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92864. */
  92865. onBeforeDraw: () => void;
  92866. readonly hasInstances: boolean;
  92867. /**
  92868. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92869. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92870. */
  92871. delayLoadState: number;
  92872. /**
  92873. * Gets the list of instances created from this mesh
  92874. * it is not supposed to be modified manually.
  92875. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92876. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92877. */
  92878. instances: InstancedMesh[];
  92879. /**
  92880. * Gets the file containing delay loading data for this mesh
  92881. */
  92882. delayLoadingFile: string;
  92883. /** @hidden */
  92884. _binaryInfo: any;
  92885. /**
  92886. * User defined function used to change how LOD level selection is done
  92887. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92888. */
  92889. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92890. /**
  92891. * Gets or sets the morph target manager
  92892. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92893. */
  92894. morphTargetManager: Nullable<MorphTargetManager>;
  92895. /** @hidden */
  92896. _creationDataStorage: Nullable<_CreationDataStorage>;
  92897. /** @hidden */
  92898. _geometry: Nullable<Geometry>;
  92899. /** @hidden */
  92900. _delayInfo: Array<string>;
  92901. /** @hidden */
  92902. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92903. /** @hidden */
  92904. _instanceDataStorage: _InstanceDataStorage;
  92905. private _effectiveMaterial;
  92906. /** @hidden */
  92907. _shouldGenerateFlatShading: boolean;
  92908. /** @hidden */
  92909. _originalBuilderSideOrientation: number;
  92910. /**
  92911. * Use this property to change the original side orientation defined at construction time
  92912. */
  92913. overrideMaterialSideOrientation: Nullable<number>;
  92914. /**
  92915. * Gets the source mesh (the one used to clone this one from)
  92916. */
  92917. readonly source: Nullable<Mesh>;
  92918. /**
  92919. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92920. */
  92921. isUnIndexed: boolean;
  92922. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92923. readonly worldMatrixInstancedBuffer: Float32Array;
  92924. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92925. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92926. /**
  92927. * @constructor
  92928. * @param name The value used by scene.getMeshByName() to do a lookup.
  92929. * @param scene The scene to add this mesh to.
  92930. * @param parent The parent of this mesh, if it has one
  92931. * @param source An optional Mesh from which geometry is shared, cloned.
  92932. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92933. * When false, achieved by calling a clone(), also passing False.
  92934. * This will make creation of children, recursive.
  92935. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92936. */
  92937. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92938. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92939. doNotInstantiate: boolean;
  92940. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92941. /**
  92942. * Gets the class name
  92943. * @returns the string "Mesh".
  92944. */
  92945. getClassName(): string;
  92946. /** @hidden */
  92947. readonly _isMesh: boolean;
  92948. /**
  92949. * Returns a description of this mesh
  92950. * @param fullDetails define if full details about this mesh must be used
  92951. * @returns a descriptive string representing this mesh
  92952. */
  92953. toString(fullDetails?: boolean): string;
  92954. /** @hidden */
  92955. _unBindEffect(): void;
  92956. /**
  92957. * Gets a boolean indicating if this mesh has LOD
  92958. */
  92959. readonly hasLODLevels: boolean;
  92960. /**
  92961. * Gets the list of MeshLODLevel associated with the current mesh
  92962. * @returns an array of MeshLODLevel
  92963. */
  92964. getLODLevels(): MeshLODLevel[];
  92965. private _sortLODLevels;
  92966. /**
  92967. * Add a mesh as LOD level triggered at the given distance.
  92968. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92969. * @param distance The distance from the center of the object to show this level
  92970. * @param mesh The mesh to be added as LOD level (can be null)
  92971. * @return This mesh (for chaining)
  92972. */
  92973. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92974. /**
  92975. * Returns the LOD level mesh at the passed distance or null if not found.
  92976. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92977. * @param distance The distance from the center of the object to show this level
  92978. * @returns a Mesh or `null`
  92979. */
  92980. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92981. /**
  92982. * Remove a mesh from the LOD array
  92983. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92984. * @param mesh defines the mesh to be removed
  92985. * @return This mesh (for chaining)
  92986. */
  92987. removeLODLevel(mesh: Mesh): Mesh;
  92988. /**
  92989. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92990. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92991. * @param camera defines the camera to use to compute distance
  92992. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92993. * @return This mesh (for chaining)
  92994. */
  92995. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92996. /**
  92997. * Gets the mesh internal Geometry object
  92998. */
  92999. readonly geometry: Nullable<Geometry>;
  93000. /**
  93001. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  93002. * @returns the total number of vertices
  93003. */
  93004. getTotalVertices(): number;
  93005. /**
  93006. * Returns the content of an associated vertex buffer
  93007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93008. * - VertexBuffer.PositionKind
  93009. * - VertexBuffer.UVKind
  93010. * - VertexBuffer.UV2Kind
  93011. * - VertexBuffer.UV3Kind
  93012. * - VertexBuffer.UV4Kind
  93013. * - VertexBuffer.UV5Kind
  93014. * - VertexBuffer.UV6Kind
  93015. * - VertexBuffer.ColorKind
  93016. * - VertexBuffer.MatricesIndicesKind
  93017. * - VertexBuffer.MatricesIndicesExtraKind
  93018. * - VertexBuffer.MatricesWeightsKind
  93019. * - VertexBuffer.MatricesWeightsExtraKind
  93020. * @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
  93021. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93022. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93023. */
  93024. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93025. /**
  93026. * Returns the mesh VertexBuffer object from the requested `kind`
  93027. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93028. * - VertexBuffer.PositionKind
  93029. * - VertexBuffer.NormalKind
  93030. * - VertexBuffer.UVKind
  93031. * - VertexBuffer.UV2Kind
  93032. * - VertexBuffer.UV3Kind
  93033. * - VertexBuffer.UV4Kind
  93034. * - VertexBuffer.UV5Kind
  93035. * - VertexBuffer.UV6Kind
  93036. * - VertexBuffer.ColorKind
  93037. * - VertexBuffer.MatricesIndicesKind
  93038. * - VertexBuffer.MatricesIndicesExtraKind
  93039. * - VertexBuffer.MatricesWeightsKind
  93040. * - VertexBuffer.MatricesWeightsExtraKind
  93041. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93042. */
  93043. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93044. /**
  93045. * Tests if a specific vertex buffer is associated with this mesh
  93046. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93047. * - VertexBuffer.PositionKind
  93048. * - VertexBuffer.NormalKind
  93049. * - VertexBuffer.UVKind
  93050. * - VertexBuffer.UV2Kind
  93051. * - VertexBuffer.UV3Kind
  93052. * - VertexBuffer.UV4Kind
  93053. * - VertexBuffer.UV5Kind
  93054. * - VertexBuffer.UV6Kind
  93055. * - VertexBuffer.ColorKind
  93056. * - VertexBuffer.MatricesIndicesKind
  93057. * - VertexBuffer.MatricesIndicesExtraKind
  93058. * - VertexBuffer.MatricesWeightsKind
  93059. * - VertexBuffer.MatricesWeightsExtraKind
  93060. * @returns a boolean
  93061. */
  93062. isVerticesDataPresent(kind: string): boolean;
  93063. /**
  93064. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93065. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93066. * - VertexBuffer.PositionKind
  93067. * - VertexBuffer.UVKind
  93068. * - VertexBuffer.UV2Kind
  93069. * - VertexBuffer.UV3Kind
  93070. * - VertexBuffer.UV4Kind
  93071. * - VertexBuffer.UV5Kind
  93072. * - VertexBuffer.UV6Kind
  93073. * - VertexBuffer.ColorKind
  93074. * - VertexBuffer.MatricesIndicesKind
  93075. * - VertexBuffer.MatricesIndicesExtraKind
  93076. * - VertexBuffer.MatricesWeightsKind
  93077. * - VertexBuffer.MatricesWeightsExtraKind
  93078. * @returns a boolean
  93079. */
  93080. isVertexBufferUpdatable(kind: string): boolean;
  93081. /**
  93082. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93083. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93084. * - VertexBuffer.PositionKind
  93085. * - VertexBuffer.NormalKind
  93086. * - VertexBuffer.UVKind
  93087. * - VertexBuffer.UV2Kind
  93088. * - VertexBuffer.UV3Kind
  93089. * - VertexBuffer.UV4Kind
  93090. * - VertexBuffer.UV5Kind
  93091. * - VertexBuffer.UV6Kind
  93092. * - VertexBuffer.ColorKind
  93093. * - VertexBuffer.MatricesIndicesKind
  93094. * - VertexBuffer.MatricesIndicesExtraKind
  93095. * - VertexBuffer.MatricesWeightsKind
  93096. * - VertexBuffer.MatricesWeightsExtraKind
  93097. * @returns an array of strings
  93098. */
  93099. getVerticesDataKinds(): string[];
  93100. /**
  93101. * Returns a positive integer : the total number of indices in this mesh geometry.
  93102. * @returns the numner of indices or zero if the mesh has no geometry.
  93103. */
  93104. getTotalIndices(): number;
  93105. /**
  93106. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93107. * @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.
  93108. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93109. * @returns the indices array or an empty array if the mesh has no geometry
  93110. */
  93111. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93112. readonly isBlocked: boolean;
  93113. /**
  93114. * Determine if the current mesh is ready to be rendered
  93115. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93116. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93117. * @returns true if all associated assets are ready (material, textures, shaders)
  93118. */
  93119. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93120. /**
  93121. * 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.
  93122. */
  93123. readonly areNormalsFrozen: boolean;
  93124. /**
  93125. * 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.
  93126. * @returns the current mesh
  93127. */
  93128. freezeNormals(): Mesh;
  93129. /**
  93130. * 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
  93131. * @returns the current mesh
  93132. */
  93133. unfreezeNormals(): Mesh;
  93134. /**
  93135. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93136. */
  93137. overridenInstanceCount: number;
  93138. /** @hidden */
  93139. _preActivate(): Mesh;
  93140. /** @hidden */
  93141. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93142. /** @hidden */
  93143. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93144. /**
  93145. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93146. * This means the mesh underlying bounding box and sphere are recomputed.
  93147. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93148. * @returns the current mesh
  93149. */
  93150. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93151. /** @hidden */
  93152. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93153. /**
  93154. * This function will subdivide the mesh into multiple submeshes
  93155. * @param count defines the expected number of submeshes
  93156. */
  93157. subdivide(count: number): void;
  93158. /**
  93159. * Copy a FloatArray into a specific associated vertex buffer
  93160. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93161. * - VertexBuffer.PositionKind
  93162. * - VertexBuffer.UVKind
  93163. * - VertexBuffer.UV2Kind
  93164. * - VertexBuffer.UV3Kind
  93165. * - VertexBuffer.UV4Kind
  93166. * - VertexBuffer.UV5Kind
  93167. * - VertexBuffer.UV6Kind
  93168. * - VertexBuffer.ColorKind
  93169. * - VertexBuffer.MatricesIndicesKind
  93170. * - VertexBuffer.MatricesIndicesExtraKind
  93171. * - VertexBuffer.MatricesWeightsKind
  93172. * - VertexBuffer.MatricesWeightsExtraKind
  93173. * @param data defines the data source
  93174. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93175. * @param stride defines the data stride size (can be null)
  93176. * @returns the current mesh
  93177. */
  93178. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93179. /**
  93180. * Delete a vertex buffer associated with this mesh
  93181. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93182. * - VertexBuffer.PositionKind
  93183. * - VertexBuffer.UVKind
  93184. * - VertexBuffer.UV2Kind
  93185. * - VertexBuffer.UV3Kind
  93186. * - VertexBuffer.UV4Kind
  93187. * - VertexBuffer.UV5Kind
  93188. * - VertexBuffer.UV6Kind
  93189. * - VertexBuffer.ColorKind
  93190. * - VertexBuffer.MatricesIndicesKind
  93191. * - VertexBuffer.MatricesIndicesExtraKind
  93192. * - VertexBuffer.MatricesWeightsKind
  93193. * - VertexBuffer.MatricesWeightsExtraKind
  93194. */
  93195. removeVerticesData(kind: string): void;
  93196. /**
  93197. * Flags an associated vertex buffer as updatable
  93198. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93199. * - VertexBuffer.PositionKind
  93200. * - VertexBuffer.UVKind
  93201. * - VertexBuffer.UV2Kind
  93202. * - VertexBuffer.UV3Kind
  93203. * - VertexBuffer.UV4Kind
  93204. * - VertexBuffer.UV5Kind
  93205. * - VertexBuffer.UV6Kind
  93206. * - VertexBuffer.ColorKind
  93207. * - VertexBuffer.MatricesIndicesKind
  93208. * - VertexBuffer.MatricesIndicesExtraKind
  93209. * - VertexBuffer.MatricesWeightsKind
  93210. * - VertexBuffer.MatricesWeightsExtraKind
  93211. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93212. */
  93213. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93214. /**
  93215. * Sets the mesh global Vertex Buffer
  93216. * @param buffer defines the buffer to use
  93217. * @returns the current mesh
  93218. */
  93219. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93220. /**
  93221. * Update a specific associated vertex buffer
  93222. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93223. * - VertexBuffer.PositionKind
  93224. * - VertexBuffer.UVKind
  93225. * - VertexBuffer.UV2Kind
  93226. * - VertexBuffer.UV3Kind
  93227. * - VertexBuffer.UV4Kind
  93228. * - VertexBuffer.UV5Kind
  93229. * - VertexBuffer.UV6Kind
  93230. * - VertexBuffer.ColorKind
  93231. * - VertexBuffer.MatricesIndicesKind
  93232. * - VertexBuffer.MatricesIndicesExtraKind
  93233. * - VertexBuffer.MatricesWeightsKind
  93234. * - VertexBuffer.MatricesWeightsExtraKind
  93235. * @param data defines the data source
  93236. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93237. * @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)
  93238. * @returns the current mesh
  93239. */
  93240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93241. /**
  93242. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93243. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93244. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93245. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93246. * @returns the current mesh
  93247. */
  93248. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93249. /**
  93250. * Creates a un-shared specific occurence of the geometry for the mesh.
  93251. * @returns the current mesh
  93252. */
  93253. makeGeometryUnique(): Mesh;
  93254. /**
  93255. * Set the index buffer of this mesh
  93256. * @param indices defines the source data
  93257. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93258. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93259. * @returns the current mesh
  93260. */
  93261. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93262. /**
  93263. * Update the current index buffer
  93264. * @param indices defines the source data
  93265. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93266. * @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)
  93267. * @returns the current mesh
  93268. */
  93269. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93270. /**
  93271. * Invert the geometry to move from a right handed system to a left handed one.
  93272. * @returns the current mesh
  93273. */
  93274. toLeftHanded(): Mesh;
  93275. /** @hidden */
  93276. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93277. /** @hidden */
  93278. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93279. /**
  93280. * Registers for this mesh a javascript function called just before the rendering process
  93281. * @param func defines the function to call before rendering this mesh
  93282. * @returns the current mesh
  93283. */
  93284. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93285. /**
  93286. * Disposes a previously registered javascript function called before the rendering
  93287. * @param func defines the function to remove
  93288. * @returns the current mesh
  93289. */
  93290. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93291. /**
  93292. * Registers for this mesh a javascript function called just after the rendering is complete
  93293. * @param func defines the function to call after rendering this mesh
  93294. * @returns the current mesh
  93295. */
  93296. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93297. /**
  93298. * Disposes a previously registered javascript function called after the rendering.
  93299. * @param func defines the function to remove
  93300. * @returns the current mesh
  93301. */
  93302. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93303. /** @hidden */
  93304. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93305. /** @hidden */
  93306. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93307. /** @hidden */
  93308. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93309. /** @hidden */
  93310. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93311. /** @hidden */
  93312. _rebuild(): void;
  93313. /** @hidden */
  93314. _freeze(): void;
  93315. /** @hidden */
  93316. _unFreeze(): void;
  93317. /**
  93318. * 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
  93319. * @param subMesh defines the subMesh to render
  93320. * @param enableAlphaMode defines if alpha mode can be changed
  93321. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93322. * @returns the current mesh
  93323. */
  93324. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93325. private _onBeforeDraw;
  93326. /**
  93327. * Renormalize the mesh and patch it up if there are no weights
  93328. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93329. * However in the case of zero weights then we set just a single influence to 1.
  93330. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93331. */
  93332. cleanMatrixWeights(): void;
  93333. private normalizeSkinFourWeights;
  93334. private normalizeSkinWeightsAndExtra;
  93335. /**
  93336. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93337. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93338. * the user know there was an issue with importing the mesh
  93339. * @returns a validation object with skinned, valid and report string
  93340. */
  93341. validateSkinning(): {
  93342. skinned: boolean;
  93343. valid: boolean;
  93344. report: string;
  93345. };
  93346. /** @hidden */
  93347. _checkDelayState(): Mesh;
  93348. private _queueLoad;
  93349. /**
  93350. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93351. * A mesh is in the frustum if its bounding box intersects the frustum
  93352. * @param frustumPlanes defines the frustum to test
  93353. * @returns true if the mesh is in the frustum planes
  93354. */
  93355. isInFrustum(frustumPlanes: Plane[]): boolean;
  93356. /**
  93357. * Sets the mesh material by the material or multiMaterial `id` property
  93358. * @param id is a string identifying the material or the multiMaterial
  93359. * @returns the current mesh
  93360. */
  93361. setMaterialByID(id: string): Mesh;
  93362. /**
  93363. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93364. * @returns an array of IAnimatable
  93365. */
  93366. getAnimatables(): IAnimatable[];
  93367. /**
  93368. * Modifies the mesh geometry according to the passed transformation matrix.
  93369. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93370. * The mesh normals are modified using the same transformation.
  93371. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93372. * @param transform defines the transform matrix to use
  93373. * @see http://doc.babylonjs.com/resources/baking_transformations
  93374. * @returns the current mesh
  93375. */
  93376. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93377. /**
  93378. * Modifies the mesh geometry according to its own current World Matrix.
  93379. * The mesh World Matrix is then reset.
  93380. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93382. * @see http://doc.babylonjs.com/resources/baking_transformations
  93383. * @returns the current mesh
  93384. */
  93385. bakeCurrentTransformIntoVertices(): Mesh;
  93386. /** @hidden */
  93387. readonly _positions: Nullable<Vector3[]>;
  93388. /** @hidden */
  93389. _resetPointsArrayCache(): Mesh;
  93390. /** @hidden */
  93391. _generatePointsArray(): boolean;
  93392. /**
  93393. * Returns a new Mesh object generated from the current mesh properties.
  93394. * This method must not get confused with createInstance()
  93395. * @param name is a string, the name given to the new mesh
  93396. * @param newParent can be any Node object (default `null`)
  93397. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93398. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93399. * @returns a new mesh
  93400. */
  93401. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93402. /**
  93403. * Releases resources associated with this mesh.
  93404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93406. */
  93407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93408. /** @hidden */
  93409. _disposeInstanceSpecificData(): void;
  93410. /**
  93411. * Modifies the mesh geometry according to a displacement map.
  93412. * 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.
  93413. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93414. * @param url is a string, the URL from the image file is to be downloaded.
  93415. * @param minHeight is the lower limit of the displacement.
  93416. * @param maxHeight is the upper limit of the displacement.
  93417. * @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.
  93418. * @param uvOffset is an optional vector2 used to offset UV.
  93419. * @param uvScale is an optional vector2 used to scale UV.
  93420. * @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.
  93421. * @returns the Mesh.
  93422. */
  93423. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93424. /**
  93425. * Modifies the mesh geometry according to a displacementMap buffer.
  93426. * 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.
  93427. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93428. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93429. * @param heightMapWidth is the width of the buffer image.
  93430. * @param heightMapHeight is the height of the buffer image.
  93431. * @param minHeight is the lower limit of the displacement.
  93432. * @param maxHeight is the upper limit of the displacement.
  93433. * @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.
  93434. * @param uvOffset is an optional vector2 used to offset UV.
  93435. * @param uvScale is an optional vector2 used to scale UV.
  93436. * @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.
  93437. * @returns the Mesh.
  93438. */
  93439. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93440. /**
  93441. * Modify the mesh to get a flat shading rendering.
  93442. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93443. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93444. * @returns current mesh
  93445. */
  93446. convertToFlatShadedMesh(): Mesh;
  93447. /**
  93448. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93449. * In other words, more vertices, no more indices and a single bigger VBO.
  93450. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93451. * @returns current mesh
  93452. */
  93453. convertToUnIndexedMesh(): Mesh;
  93454. /**
  93455. * Inverses facet orientations.
  93456. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93457. * @param flipNormals will also inverts the normals
  93458. * @returns current mesh
  93459. */
  93460. flipFaces(flipNormals?: boolean): Mesh;
  93461. /**
  93462. * Increase the number of facets and hence vertices in a mesh
  93463. * Vertex normals are interpolated from existing vertex normals
  93464. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93465. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93466. */
  93467. increaseVertices(numberPerEdge: number): void;
  93468. /**
  93469. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93470. * This will undo any application of covertToFlatShadedMesh
  93471. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93472. */
  93473. forceSharedVertices(): void;
  93474. /** @hidden */
  93475. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93476. /** @hidden */
  93477. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93478. /**
  93479. * Creates a new InstancedMesh object from the mesh model.
  93480. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93481. * @param name defines the name of the new instance
  93482. * @returns a new InstancedMesh
  93483. */
  93484. createInstance(name: string): InstancedMesh;
  93485. /**
  93486. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93487. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93488. * @returns the current mesh
  93489. */
  93490. synchronizeInstances(): Mesh;
  93491. /**
  93492. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93493. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93494. * This should be used together with the simplification to avoid disappearing triangles.
  93495. * @param successCallback an optional success callback to be called after the optimization finished.
  93496. * @returns the current mesh
  93497. */
  93498. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93499. /**
  93500. * Serialize current mesh
  93501. * @param serializationObject defines the object which will receive the serialization data
  93502. */
  93503. serialize(serializationObject: any): void;
  93504. /** @hidden */
  93505. _syncGeometryWithMorphTargetManager(): void;
  93506. /** @hidden */
  93507. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93508. /**
  93509. * Returns a new Mesh object parsed from the source provided.
  93510. * @param parsedMesh is the source
  93511. * @param scene defines the hosting scene
  93512. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93513. * @returns a new Mesh
  93514. */
  93515. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93516. /**
  93517. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93518. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93519. * @param name defines the name of the mesh to create
  93520. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93521. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93522. * @param closePath creates a seam between the first and the last points of each path of the path array
  93523. * @param offset is taken in account only if the `pathArray` is containing a single path
  93524. * @param scene defines the hosting scene
  93525. * @param updatable defines if the mesh must be flagged as updatable
  93526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93527. * @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)
  93528. * @returns a new Mesh
  93529. */
  93530. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93531. /**
  93532. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93533. * @param name defines the name of the mesh to create
  93534. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93535. * @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
  93536. * @param scene defines the hosting scene
  93537. * @param updatable defines if the mesh must be flagged as updatable
  93538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93539. * @returns a new Mesh
  93540. */
  93541. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93542. /**
  93543. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93544. * @param name defines the name of the mesh to create
  93545. * @param size sets the size (float) of each box side (default 1)
  93546. * @param scene defines the hosting scene
  93547. * @param updatable defines if the mesh must be flagged as updatable
  93548. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93549. * @returns a new Mesh
  93550. */
  93551. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93552. /**
  93553. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93554. * @param name defines the name of the mesh to create
  93555. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93556. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93557. * @param scene defines the hosting scene
  93558. * @param updatable defines if the mesh must be flagged as updatable
  93559. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93560. * @returns a new Mesh
  93561. */
  93562. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93563. /**
  93564. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93565. * @param name defines the name of the mesh to create
  93566. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93567. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93568. * @param scene defines the hosting scene
  93569. * @returns a new Mesh
  93570. */
  93571. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93572. /**
  93573. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93574. * @param name defines the name of the mesh to create
  93575. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93576. * @param diameterTop set the top cap diameter (floats, default 1)
  93577. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93578. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93579. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93580. * @param scene defines the hosting scene
  93581. * @param updatable defines if the mesh must be flagged as updatable
  93582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93583. * @returns a new Mesh
  93584. */
  93585. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93586. /**
  93587. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93588. * @param name defines the name of the mesh to create
  93589. * @param diameter sets the diameter size (float) of the torus (default 1)
  93590. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93591. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93592. * @param scene defines the hosting scene
  93593. * @param updatable defines if the mesh must be flagged as updatable
  93594. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93595. * @returns a new Mesh
  93596. */
  93597. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93598. /**
  93599. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93600. * @param name defines the name of the mesh to create
  93601. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93602. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93603. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93604. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93605. * @param p the number of windings on X axis (positive integers, default 2)
  93606. * @param q the number of windings on Y axis (positive integers, default 3)
  93607. * @param scene defines the hosting scene
  93608. * @param updatable defines if the mesh must be flagged as updatable
  93609. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93610. * @returns a new Mesh
  93611. */
  93612. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93613. /**
  93614. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93615. * @param name defines the name of the mesh to create
  93616. * @param points is an array successive Vector3
  93617. * @param scene defines the hosting scene
  93618. * @param updatable defines if the mesh must be flagged as updatable
  93619. * @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).
  93620. * @returns a new Mesh
  93621. */
  93622. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93623. /**
  93624. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93625. * @param name defines the name of the mesh to create
  93626. * @param points is an array successive Vector3
  93627. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93628. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93629. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93630. * @param scene defines the hosting scene
  93631. * @param updatable defines if the mesh must be flagged as updatable
  93632. * @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)
  93633. * @returns a new Mesh
  93634. */
  93635. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93636. /**
  93637. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93638. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93639. * 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.
  93640. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93641. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93642. * Remember you can only change the shape positions, not their number when updating a polygon.
  93643. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93644. * @param name defines the name of the mesh to create
  93645. * @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
  93646. * @param scene defines the hosting scene
  93647. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93648. * @param updatable defines if the mesh must be flagged as updatable
  93649. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93650. * @param earcutInjection can be used to inject your own earcut reference
  93651. * @returns a new Mesh
  93652. */
  93653. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93654. /**
  93655. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93656. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93657. * @param name defines the name of the mesh to create
  93658. * @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
  93659. * @param depth defines the height of extrusion
  93660. * @param scene defines the hosting scene
  93661. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93662. * @param updatable defines if the mesh must be flagged as updatable
  93663. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93664. * @param earcutInjection can be used to inject your own earcut reference
  93665. * @returns a new Mesh
  93666. */
  93667. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93668. /**
  93669. * Creates an extruded shape mesh.
  93670. * 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
  93671. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93672. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93673. * @param name defines the name of the mesh to create
  93674. * @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
  93675. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93676. * @param scale is the value to scale the shape
  93677. * @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
  93678. * @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
  93679. * @param scene defines the hosting scene
  93680. * @param updatable defines if the mesh must be flagged as updatable
  93681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93682. * @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)
  93683. * @returns a new Mesh
  93684. */
  93685. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93686. /**
  93687. * Creates an custom extruded shape mesh.
  93688. * The custom extrusion is a parametric shape.
  93689. * It has no predefined shape. Its final shape will depend on the input parameters.
  93690. * Please consider using the same method from the MeshBuilder class instead
  93691. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93692. * @param name defines the name of the mesh to create
  93693. * @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
  93694. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93695. * @param scaleFunction is a custom Javascript function called on each path point
  93696. * @param rotationFunction is a custom Javascript function called on each path point
  93697. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93698. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93699. * @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
  93700. * @param scene defines the hosting scene
  93701. * @param updatable defines if the mesh must be flagged as updatable
  93702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93703. * @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)
  93704. * @returns a new Mesh
  93705. */
  93706. 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;
  93707. /**
  93708. * Creates lathe mesh.
  93709. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93710. * Please consider using the same method from the MeshBuilder class instead
  93711. * @param name defines the name of the mesh to create
  93712. * @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
  93713. * @param radius is the radius value of the lathe
  93714. * @param tessellation is the side number of the lathe.
  93715. * @param scene defines the hosting scene
  93716. * @param updatable defines if the mesh must be flagged as updatable
  93717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93718. * @returns a new Mesh
  93719. */
  93720. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93721. /**
  93722. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93723. * @param name defines the name of the mesh to create
  93724. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93725. * @param scene defines the hosting scene
  93726. * @param updatable defines if the mesh must be flagged as updatable
  93727. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93728. * @returns a new Mesh
  93729. */
  93730. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93731. /**
  93732. * Creates a ground mesh.
  93733. * Please consider using the same method from the MeshBuilder class instead
  93734. * @param name defines the name of the mesh to create
  93735. * @param width set the width of the ground
  93736. * @param height set the height of the ground
  93737. * @param subdivisions sets the number of subdivisions per side
  93738. * @param scene defines the hosting scene
  93739. * @param updatable defines if the mesh must be flagged as updatable
  93740. * @returns a new Mesh
  93741. */
  93742. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93743. /**
  93744. * Creates a tiled ground mesh.
  93745. * Please consider using the same method from the MeshBuilder class instead
  93746. * @param name defines the name of the mesh to create
  93747. * @param xmin set the ground minimum X coordinate
  93748. * @param zmin set the ground minimum Y coordinate
  93749. * @param xmax set the ground maximum X coordinate
  93750. * @param zmax set the ground maximum Z coordinate
  93751. * @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
  93752. * @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
  93753. * @param scene defines the hosting scene
  93754. * @param updatable defines if the mesh must be flagged as updatable
  93755. * @returns a new Mesh
  93756. */
  93757. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93758. w: number;
  93759. h: number;
  93760. }, precision: {
  93761. w: number;
  93762. h: number;
  93763. }, scene: Scene, updatable?: boolean): Mesh;
  93764. /**
  93765. * Creates a ground mesh from a height map.
  93766. * Please consider using the same method from the MeshBuilder class instead
  93767. * @see http://doc.babylonjs.com/babylon101/height_map
  93768. * @param name defines the name of the mesh to create
  93769. * @param url sets the URL of the height map image resource
  93770. * @param width set the ground width size
  93771. * @param height set the ground height size
  93772. * @param subdivisions sets the number of subdivision per side
  93773. * @param minHeight is the minimum altitude on the ground
  93774. * @param maxHeight is the maximum altitude on the ground
  93775. * @param scene defines the hosting scene
  93776. * @param updatable defines if the mesh must be flagged as updatable
  93777. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93778. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93779. * @returns a new Mesh
  93780. */
  93781. 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;
  93782. /**
  93783. * Creates a tube mesh.
  93784. * The tube is a parametric shape.
  93785. * It has no predefined shape. Its final shape will depend on the input parameters.
  93786. * Please consider using the same method from the MeshBuilder class instead
  93787. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93788. * @param name defines the name of the mesh to create
  93789. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93790. * @param radius sets the tube radius size
  93791. * @param tessellation is the number of sides on the tubular surface
  93792. * @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
  93793. * @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
  93794. * @param scene defines the hosting scene
  93795. * @param updatable defines if the mesh must be flagged as updatable
  93796. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93797. * @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)
  93798. * @returns a new Mesh
  93799. */
  93800. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93801. (i: number, distance: number): number;
  93802. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93803. /**
  93804. * Creates a polyhedron mesh.
  93805. * Please consider using the same method from the MeshBuilder class instead.
  93806. * * 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
  93807. * * The parameter `size` (positive float, default 1) sets the polygon size
  93808. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93809. * * 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`
  93810. * * 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
  93811. * * 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)`)
  93812. * * 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
  93813. * * 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
  93814. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93815. * * If you create a double-sided mesh, you can choose what parts of 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
  93816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93817. * @param name defines the name of the mesh to create
  93818. * @param options defines the options used to create the mesh
  93819. * @param scene defines the hosting scene
  93820. * @returns a new Mesh
  93821. */
  93822. static CreatePolyhedron(name: string, options: {
  93823. type?: number;
  93824. size?: number;
  93825. sizeX?: number;
  93826. sizeY?: number;
  93827. sizeZ?: number;
  93828. custom?: any;
  93829. faceUV?: Vector4[];
  93830. faceColors?: Color4[];
  93831. updatable?: boolean;
  93832. sideOrientation?: number;
  93833. }, scene: Scene): Mesh;
  93834. /**
  93835. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93836. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93837. * * 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`)
  93838. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93839. * * 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
  93840. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93841. * * If you create a double-sided mesh, you can choose what parts of 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
  93842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93843. * @param name defines the name of the mesh
  93844. * @param options defines the options used to create the mesh
  93845. * @param scene defines the hosting scene
  93846. * @returns a new Mesh
  93847. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93848. */
  93849. static CreateIcoSphere(name: string, options: {
  93850. radius?: number;
  93851. flat?: boolean;
  93852. subdivisions?: number;
  93853. sideOrientation?: number;
  93854. updatable?: boolean;
  93855. }, scene: Scene): Mesh;
  93856. /**
  93857. * Creates a decal mesh.
  93858. * Please consider using the same method from the MeshBuilder class instead.
  93859. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93860. * @param name defines the name of the mesh
  93861. * @param sourceMesh defines the mesh receiving the decal
  93862. * @param position sets the position of the decal in world coordinates
  93863. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93864. * @param size sets the decal scaling
  93865. * @param angle sets the angle to rotate the decal
  93866. * @returns a new Mesh
  93867. */
  93868. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93869. /**
  93870. * Prepare internal position array for software CPU skinning
  93871. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93872. */
  93873. setPositionsForCPUSkinning(): Float32Array;
  93874. /**
  93875. * Prepare internal normal array for software CPU skinning
  93876. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93877. */
  93878. setNormalsForCPUSkinning(): Float32Array;
  93879. /**
  93880. * Updates the vertex buffer by applying transformation from the bones
  93881. * @param skeleton defines the skeleton to apply to current mesh
  93882. * @returns the current mesh
  93883. */
  93884. applySkeleton(skeleton: Skeleton): Mesh;
  93885. /**
  93886. * 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
  93887. * @param meshes defines the list of meshes to scan
  93888. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93889. */
  93890. static MinMax(meshes: AbstractMesh[]): {
  93891. min: Vector3;
  93892. max: Vector3;
  93893. };
  93894. /**
  93895. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93896. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93897. * @returns a vector3
  93898. */
  93899. static Center(meshesOrMinMaxVector: {
  93900. min: Vector3;
  93901. max: Vector3;
  93902. } | AbstractMesh[]): Vector3;
  93903. /**
  93904. * Merge the array of meshes into a single mesh for performance reasons.
  93905. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93906. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93907. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93908. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93909. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93910. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93911. * @returns a new mesh
  93912. */
  93913. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93914. /** @hidden */
  93915. addInstance(instance: InstancedMesh): void;
  93916. /** @hidden */
  93917. removeInstance(instance: InstancedMesh): void;
  93918. }
  93919. }
  93920. declare module BABYLON {
  93921. /**
  93922. * This is the base class of all the camera used in the application.
  93923. * @see http://doc.babylonjs.com/features/cameras
  93924. */
  93925. export class Camera extends Node {
  93926. /** @hidden */
  93927. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93928. /**
  93929. * This is the default projection mode used by the cameras.
  93930. * It helps recreating a feeling of perspective and better appreciate depth.
  93931. * This is the best way to simulate real life cameras.
  93932. */
  93933. static readonly PERSPECTIVE_CAMERA: number;
  93934. /**
  93935. * This helps creating camera with an orthographic mode.
  93936. * 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.
  93937. */
  93938. static readonly ORTHOGRAPHIC_CAMERA: number;
  93939. /**
  93940. * This is the default FOV mode for perspective cameras.
  93941. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93942. */
  93943. static readonly FOVMODE_VERTICAL_FIXED: number;
  93944. /**
  93945. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93946. */
  93947. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93948. /**
  93949. * This specifies ther is no need for a camera rig.
  93950. * Basically only one eye is rendered corresponding to the camera.
  93951. */
  93952. static readonly RIG_MODE_NONE: number;
  93953. /**
  93954. * Simulates a camera Rig with one blue eye and one red eye.
  93955. * This can be use with 3d blue and red glasses.
  93956. */
  93957. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93958. /**
  93959. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93960. */
  93961. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93962. /**
  93963. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93964. */
  93965. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93966. /**
  93967. * Defines that both eyes of the camera will be rendered over under each other.
  93968. */
  93969. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93970. /**
  93971. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93972. */
  93973. static readonly RIG_MODE_VR: number;
  93974. /**
  93975. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93976. */
  93977. static readonly RIG_MODE_WEBVR: number;
  93978. /**
  93979. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93980. */
  93981. static readonly RIG_MODE_CUSTOM: number;
  93982. /**
  93983. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93984. */
  93985. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93986. /**
  93987. * Define the input manager associated with the camera.
  93988. */
  93989. inputs: CameraInputsManager<Camera>;
  93990. /** @hidden */
  93991. _position: Vector3;
  93992. /**
  93993. * Define the current local position of the camera in the scene
  93994. */
  93995. position: Vector3;
  93996. /**
  93997. * The vector the camera should consider as up.
  93998. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93999. */
  94000. upVector: Vector3;
  94001. /**
  94002. * Define the current limit on the left side for an orthographic camera
  94003. * In scene unit
  94004. */
  94005. orthoLeft: Nullable<number>;
  94006. /**
  94007. * Define the current limit on the right side for an orthographic camera
  94008. * In scene unit
  94009. */
  94010. orthoRight: Nullable<number>;
  94011. /**
  94012. * Define the current limit on the bottom side for an orthographic camera
  94013. * In scene unit
  94014. */
  94015. orthoBottom: Nullable<number>;
  94016. /**
  94017. * Define the current limit on the top side for an orthographic camera
  94018. * In scene unit
  94019. */
  94020. orthoTop: Nullable<number>;
  94021. /**
  94022. * Field Of View is set in Radians. (default is 0.8)
  94023. */
  94024. fov: number;
  94025. /**
  94026. * Define the minimum distance the camera can see from.
  94027. * This is important to note that the depth buffer are not infinite and the closer it starts
  94028. * the more your scene might encounter depth fighting issue.
  94029. */
  94030. minZ: number;
  94031. /**
  94032. * Define the maximum distance the camera can see to.
  94033. * This is important to note that the depth buffer are not infinite and the further it end
  94034. * the more your scene might encounter depth fighting issue.
  94035. */
  94036. maxZ: number;
  94037. /**
  94038. * Define the default inertia of the camera.
  94039. * This helps giving a smooth feeling to the camera movement.
  94040. */
  94041. inertia: number;
  94042. /**
  94043. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94044. */
  94045. mode: number;
  94046. /**
  94047. * Define wether the camera is intermediate.
  94048. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94049. */
  94050. isIntermediate: boolean;
  94051. /**
  94052. * Define the viewport of the camera.
  94053. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94054. */
  94055. viewport: Viewport;
  94056. /**
  94057. * Restricts the camera to viewing objects with the same layerMask.
  94058. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94059. */
  94060. layerMask: number;
  94061. /**
  94062. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94063. */
  94064. fovMode: number;
  94065. /**
  94066. * Rig mode of the camera.
  94067. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94068. * This is normally controlled byt the camera themselves as internal use.
  94069. */
  94070. cameraRigMode: number;
  94071. /**
  94072. * Defines the distance between both "eyes" in case of a RIG
  94073. */
  94074. interaxialDistance: number;
  94075. /**
  94076. * Defines if stereoscopic rendering is done side by side or over under.
  94077. */
  94078. isStereoscopicSideBySide: boolean;
  94079. /**
  94080. * 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
  94081. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94082. * else in the scene. (Eg. security camera)
  94083. *
  94084. * 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)
  94085. */
  94086. customRenderTargets: RenderTargetTexture[];
  94087. /**
  94088. * When set, the camera will render to this render target instead of the default canvas
  94089. *
  94090. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94091. */
  94092. outputRenderTarget: Nullable<RenderTargetTexture>;
  94093. /**
  94094. * Observable triggered when the camera view matrix has changed.
  94095. */
  94096. onViewMatrixChangedObservable: Observable<Camera>;
  94097. /**
  94098. * Observable triggered when the camera Projection matrix has changed.
  94099. */
  94100. onProjectionMatrixChangedObservable: Observable<Camera>;
  94101. /**
  94102. * Observable triggered when the inputs have been processed.
  94103. */
  94104. onAfterCheckInputsObservable: Observable<Camera>;
  94105. /**
  94106. * Observable triggered when reset has been called and applied to the camera.
  94107. */
  94108. onRestoreStateObservable: Observable<Camera>;
  94109. /** @hidden */
  94110. _cameraRigParams: any;
  94111. /** @hidden */
  94112. _rigCameras: Camera[];
  94113. /** @hidden */
  94114. _rigPostProcess: Nullable<PostProcess>;
  94115. protected _webvrViewMatrix: Matrix;
  94116. /** @hidden */
  94117. _skipRendering: boolean;
  94118. /** @hidden */
  94119. _projectionMatrix: Matrix;
  94120. /** @hidden */
  94121. _postProcesses: Nullable<PostProcess>[];
  94122. /** @hidden */
  94123. _activeMeshes: SmartArray<AbstractMesh>;
  94124. protected _globalPosition: Vector3;
  94125. /** @hidden */
  94126. _computedViewMatrix: Matrix;
  94127. private _doNotComputeProjectionMatrix;
  94128. private _transformMatrix;
  94129. private _frustumPlanes;
  94130. private _refreshFrustumPlanes;
  94131. private _storedFov;
  94132. private _stateStored;
  94133. /**
  94134. * Instantiates a new camera object.
  94135. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94136. * @see http://doc.babylonjs.com/features/cameras
  94137. * @param name Defines the name of the camera in the scene
  94138. * @param position Defines the position of the camera
  94139. * @param scene Defines the scene the camera belongs too
  94140. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94141. */
  94142. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94143. /**
  94144. * Store current camera state (fov, position, etc..)
  94145. * @returns the camera
  94146. */
  94147. storeState(): Camera;
  94148. /**
  94149. * Restores the camera state values if it has been stored. You must call storeState() first
  94150. */
  94151. protected _restoreStateValues(): boolean;
  94152. /**
  94153. * Restored camera state. You must call storeState() first.
  94154. * @returns true if restored and false otherwise
  94155. */
  94156. restoreState(): boolean;
  94157. /**
  94158. * Gets the class name of the camera.
  94159. * @returns the class name
  94160. */
  94161. getClassName(): string;
  94162. /** @hidden */
  94163. readonly _isCamera: boolean;
  94164. /**
  94165. * Gets a string representation of the camera useful for debug purpose.
  94166. * @param fullDetails Defines that a more verboe level of logging is required
  94167. * @returns the string representation
  94168. */
  94169. toString(fullDetails?: boolean): string;
  94170. /**
  94171. * Gets the current world space position of the camera.
  94172. */
  94173. readonly globalPosition: Vector3;
  94174. /**
  94175. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94176. * @returns the active meshe list
  94177. */
  94178. getActiveMeshes(): SmartArray<AbstractMesh>;
  94179. /**
  94180. * Check wether a mesh is part of the current active mesh list of the camera
  94181. * @param mesh Defines the mesh to check
  94182. * @returns true if active, false otherwise
  94183. */
  94184. isActiveMesh(mesh: Mesh): boolean;
  94185. /**
  94186. * Is this camera ready to be used/rendered
  94187. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94188. * @return true if the camera is ready
  94189. */
  94190. isReady(completeCheck?: boolean): boolean;
  94191. /** @hidden */
  94192. _initCache(): void;
  94193. /** @hidden */
  94194. _updateCache(ignoreParentClass?: boolean): void;
  94195. /** @hidden */
  94196. _isSynchronized(): boolean;
  94197. /** @hidden */
  94198. _isSynchronizedViewMatrix(): boolean;
  94199. /** @hidden */
  94200. _isSynchronizedProjectionMatrix(): boolean;
  94201. /**
  94202. * Attach the input controls to a specific dom element to get the input from.
  94203. * @param element Defines the element the controls should be listened from
  94204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94205. */
  94206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94207. /**
  94208. * Detach the current controls from the specified dom element.
  94209. * @param element Defines the element to stop listening the inputs from
  94210. */
  94211. detachControl(element: HTMLElement): void;
  94212. /**
  94213. * Update the camera state according to the different inputs gathered during the frame.
  94214. */
  94215. update(): void;
  94216. /** @hidden */
  94217. _checkInputs(): void;
  94218. /** @hidden */
  94219. readonly rigCameras: Camera[];
  94220. /**
  94221. * Gets the post process used by the rig cameras
  94222. */
  94223. readonly rigPostProcess: Nullable<PostProcess>;
  94224. /**
  94225. * Internal, gets the first post proces.
  94226. * @returns the first post process to be run on this camera.
  94227. */
  94228. _getFirstPostProcess(): Nullable<PostProcess>;
  94229. private _cascadePostProcessesToRigCams;
  94230. /**
  94231. * Attach a post process to the camera.
  94232. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94233. * @param postProcess The post process to attach to the camera
  94234. * @param insertAt The position of the post process in case several of them are in use in the scene
  94235. * @returns the position the post process has been inserted at
  94236. */
  94237. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94238. /**
  94239. * Detach a post process to the camera.
  94240. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94241. * @param postProcess The post process to detach from the camera
  94242. */
  94243. detachPostProcess(postProcess: PostProcess): void;
  94244. /**
  94245. * Gets the current world matrix of the camera
  94246. */
  94247. getWorldMatrix(): Matrix;
  94248. /** @hidden */
  94249. _getViewMatrix(): Matrix;
  94250. /**
  94251. * Gets the current view matrix of the camera.
  94252. * @param force forces the camera to recompute the matrix without looking at the cached state
  94253. * @returns the view matrix
  94254. */
  94255. getViewMatrix(force?: boolean): Matrix;
  94256. /**
  94257. * Freeze the projection matrix.
  94258. * It will prevent the cache check of the camera projection compute and can speed up perf
  94259. * if no parameter of the camera are meant to change
  94260. * @param projection Defines manually a projection if necessary
  94261. */
  94262. freezeProjectionMatrix(projection?: Matrix): void;
  94263. /**
  94264. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94265. */
  94266. unfreezeProjectionMatrix(): void;
  94267. /**
  94268. * Gets the current projection matrix of the camera.
  94269. * @param force forces the camera to recompute the matrix without looking at the cached state
  94270. * @returns the projection matrix
  94271. */
  94272. getProjectionMatrix(force?: boolean): Matrix;
  94273. /**
  94274. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94275. * @returns a Matrix
  94276. */
  94277. getTransformationMatrix(): Matrix;
  94278. private _updateFrustumPlanes;
  94279. /**
  94280. * Checks if a cullable object (mesh...) is in the camera frustum
  94281. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94282. * @param target The object to check
  94283. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94284. * @returns true if the object is in frustum otherwise false
  94285. */
  94286. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94287. /**
  94288. * Checks if a cullable object (mesh...) is in the camera frustum
  94289. * Unlike isInFrustum this cheks the full bounding box
  94290. * @param target The object to check
  94291. * @returns true if the object is in frustum otherwise false
  94292. */
  94293. isCompletelyInFrustum(target: ICullable): boolean;
  94294. /**
  94295. * Gets a ray in the forward direction from the camera.
  94296. * @param length Defines the length of the ray to create
  94297. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94298. * @param origin Defines the start point of the ray which defaults to the camera position
  94299. * @returns the forward ray
  94300. */
  94301. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94302. /**
  94303. * Releases resources associated with this node.
  94304. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94305. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94306. */
  94307. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94308. /** @hidden */
  94309. _isLeftCamera: boolean;
  94310. /**
  94311. * Gets the left camera of a rig setup in case of Rigged Camera
  94312. */
  94313. readonly isLeftCamera: boolean;
  94314. /** @hidden */
  94315. _isRightCamera: boolean;
  94316. /**
  94317. * Gets the right camera of a rig setup in case of Rigged Camera
  94318. */
  94319. readonly isRightCamera: boolean;
  94320. /**
  94321. * Gets the left camera of a rig setup in case of Rigged Camera
  94322. */
  94323. readonly leftCamera: Nullable<FreeCamera>;
  94324. /**
  94325. * Gets the right camera of a rig setup in case of Rigged Camera
  94326. */
  94327. readonly rightCamera: Nullable<FreeCamera>;
  94328. /**
  94329. * Gets the left camera target of a rig setup in case of Rigged Camera
  94330. * @returns the target position
  94331. */
  94332. getLeftTarget(): Nullable<Vector3>;
  94333. /**
  94334. * Gets the right camera target of a rig setup in case of Rigged Camera
  94335. * @returns the target position
  94336. */
  94337. getRightTarget(): Nullable<Vector3>;
  94338. /**
  94339. * @hidden
  94340. */
  94341. setCameraRigMode(mode: number, rigParams: any): void;
  94342. /** @hidden */
  94343. static _setStereoscopicRigMode(camera: Camera): void;
  94344. /** @hidden */
  94345. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94346. /** @hidden */
  94347. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94348. /** @hidden */
  94349. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94350. /** @hidden */
  94351. _getVRProjectionMatrix(): Matrix;
  94352. protected _updateCameraRotationMatrix(): void;
  94353. protected _updateWebVRCameraRotationMatrix(): void;
  94354. /**
  94355. * This function MUST be overwritten by the different WebVR cameras available.
  94356. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94357. * @hidden
  94358. */
  94359. _getWebVRProjectionMatrix(): Matrix;
  94360. /**
  94361. * This function MUST be overwritten by the different WebVR cameras available.
  94362. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94363. * @hidden
  94364. */
  94365. _getWebVRViewMatrix(): Matrix;
  94366. /** @hidden */
  94367. setCameraRigParameter(name: string, value: any): void;
  94368. /**
  94369. * needs to be overridden by children so sub has required properties to be copied
  94370. * @hidden
  94371. */
  94372. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94373. /**
  94374. * May need to be overridden by children
  94375. * @hidden
  94376. */
  94377. _updateRigCameras(): void;
  94378. /** @hidden */
  94379. _setupInputs(): void;
  94380. /**
  94381. * Serialiaze the camera setup to a json represention
  94382. * @returns the JSON representation
  94383. */
  94384. serialize(): any;
  94385. /**
  94386. * Clones the current camera.
  94387. * @param name The cloned camera name
  94388. * @returns the cloned camera
  94389. */
  94390. clone(name: string): Camera;
  94391. /**
  94392. * Gets the direction of the camera relative to a given local axis.
  94393. * @param localAxis Defines the reference axis to provide a relative direction.
  94394. * @return the direction
  94395. */
  94396. getDirection(localAxis: Vector3): Vector3;
  94397. /**
  94398. * Returns the current camera absolute rotation
  94399. */
  94400. readonly absoluteRotation: Quaternion;
  94401. /**
  94402. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94403. * @param localAxis Defines the reference axis to provide a relative direction.
  94404. * @param result Defines the vector to store the result in
  94405. */
  94406. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94407. /**
  94408. * Gets a camera constructor for a given camera type
  94409. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94410. * @param name The name of the camera the result will be able to instantiate
  94411. * @param scene The scene the result will construct the camera in
  94412. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94413. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94414. * @returns a factory method to construc the camera
  94415. */
  94416. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94417. /**
  94418. * Compute the world matrix of the camera.
  94419. * @returns the camera world matrix
  94420. */
  94421. computeWorldMatrix(): Matrix;
  94422. /**
  94423. * Parse a JSON and creates the camera from the parsed information
  94424. * @param parsedCamera The JSON to parse
  94425. * @param scene The scene to instantiate the camera in
  94426. * @returns the newly constructed camera
  94427. */
  94428. static Parse(parsedCamera: any, scene: Scene): Camera;
  94429. }
  94430. }
  94431. declare module BABYLON {
  94432. /**
  94433. * Class containing static functions to help procedurally build meshes
  94434. */
  94435. export class DiscBuilder {
  94436. /**
  94437. * Creates a plane polygonal mesh. By default, this is a disc
  94438. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94439. * * 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
  94440. * * 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
  94441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94444. * @param name defines the name of the mesh
  94445. * @param options defines the options used to create the mesh
  94446. * @param scene defines the hosting scene
  94447. * @returns the plane polygonal mesh
  94448. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94449. */
  94450. static CreateDisc(name: string, options: {
  94451. radius?: number;
  94452. tessellation?: number;
  94453. arc?: number;
  94454. updatable?: boolean;
  94455. sideOrientation?: number;
  94456. frontUVs?: Vector4;
  94457. backUVs?: Vector4;
  94458. }, scene?: Nullable<Scene>): Mesh;
  94459. }
  94460. }
  94461. declare module BABYLON {
  94462. /**
  94463. * This represents all the required information to add a fresnel effect on a material:
  94464. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94465. */
  94466. export class FresnelParameters {
  94467. private _isEnabled;
  94468. /**
  94469. * Define if the fresnel effect is enable or not.
  94470. */
  94471. isEnabled: boolean;
  94472. /**
  94473. * Define the color used on edges (grazing angle)
  94474. */
  94475. leftColor: Color3;
  94476. /**
  94477. * Define the color used on center
  94478. */
  94479. rightColor: Color3;
  94480. /**
  94481. * Define bias applied to computed fresnel term
  94482. */
  94483. bias: number;
  94484. /**
  94485. * Defined the power exponent applied to fresnel term
  94486. */
  94487. power: number;
  94488. /**
  94489. * Clones the current fresnel and its valuues
  94490. * @returns a clone fresnel configuration
  94491. */
  94492. clone(): FresnelParameters;
  94493. /**
  94494. * Serializes the current fresnel parameters to a JSON representation.
  94495. * @return the JSON serialization
  94496. */
  94497. serialize(): any;
  94498. /**
  94499. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94500. * @param parsedFresnelParameters Define the JSON representation
  94501. * @returns the parsed parameters
  94502. */
  94503. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94504. }
  94505. }
  94506. declare module BABYLON {
  94507. /**
  94508. * Base class of materials working in push mode in babylon JS
  94509. * @hidden
  94510. */
  94511. export class PushMaterial extends Material {
  94512. protected _activeEffect: Effect;
  94513. protected _normalMatrix: Matrix;
  94514. /**
  94515. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94516. * This means that the material can keep using a previous shader while a new one is being compiled.
  94517. * This is mostly used when shader parallel compilation is supported (true by default)
  94518. */
  94519. allowShaderHotSwapping: boolean;
  94520. constructor(name: string, scene: Scene);
  94521. getEffect(): Effect;
  94522. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94523. /**
  94524. * Binds the given world matrix to the active effect
  94525. *
  94526. * @param world the matrix to bind
  94527. */
  94528. bindOnlyWorldMatrix(world: Matrix): void;
  94529. /**
  94530. * Binds the given normal matrix to the active effect
  94531. *
  94532. * @param normalMatrix the matrix to bind
  94533. */
  94534. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94535. bind(world: Matrix, mesh?: Mesh): void;
  94536. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94537. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94538. }
  94539. }
  94540. declare module BABYLON {
  94541. /**
  94542. * This groups all the flags used to control the materials channel.
  94543. */
  94544. export class MaterialFlags {
  94545. private static _DiffuseTextureEnabled;
  94546. /**
  94547. * Are diffuse textures enabled in the application.
  94548. */
  94549. static DiffuseTextureEnabled: boolean;
  94550. private static _AmbientTextureEnabled;
  94551. /**
  94552. * Are ambient textures enabled in the application.
  94553. */
  94554. static AmbientTextureEnabled: boolean;
  94555. private static _OpacityTextureEnabled;
  94556. /**
  94557. * Are opacity textures enabled in the application.
  94558. */
  94559. static OpacityTextureEnabled: boolean;
  94560. private static _ReflectionTextureEnabled;
  94561. /**
  94562. * Are reflection textures enabled in the application.
  94563. */
  94564. static ReflectionTextureEnabled: boolean;
  94565. private static _EmissiveTextureEnabled;
  94566. /**
  94567. * Are emissive textures enabled in the application.
  94568. */
  94569. static EmissiveTextureEnabled: boolean;
  94570. private static _SpecularTextureEnabled;
  94571. /**
  94572. * Are specular textures enabled in the application.
  94573. */
  94574. static SpecularTextureEnabled: boolean;
  94575. private static _BumpTextureEnabled;
  94576. /**
  94577. * Are bump textures enabled in the application.
  94578. */
  94579. static BumpTextureEnabled: boolean;
  94580. private static _LightmapTextureEnabled;
  94581. /**
  94582. * Are lightmap textures enabled in the application.
  94583. */
  94584. static LightmapTextureEnabled: boolean;
  94585. private static _RefractionTextureEnabled;
  94586. /**
  94587. * Are refraction textures enabled in the application.
  94588. */
  94589. static RefractionTextureEnabled: boolean;
  94590. private static _ColorGradingTextureEnabled;
  94591. /**
  94592. * Are color grading textures enabled in the application.
  94593. */
  94594. static ColorGradingTextureEnabled: boolean;
  94595. private static _FresnelEnabled;
  94596. /**
  94597. * Are fresnels enabled in the application.
  94598. */
  94599. static FresnelEnabled: boolean;
  94600. private static _ClearCoatTextureEnabled;
  94601. /**
  94602. * Are clear coat textures enabled in the application.
  94603. */
  94604. static ClearCoatTextureEnabled: boolean;
  94605. private static _ClearCoatBumpTextureEnabled;
  94606. /**
  94607. * Are clear coat bump textures enabled in the application.
  94608. */
  94609. static ClearCoatBumpTextureEnabled: boolean;
  94610. private static _ClearCoatTintTextureEnabled;
  94611. /**
  94612. * Are clear coat tint textures enabled in the application.
  94613. */
  94614. static ClearCoatTintTextureEnabled: boolean;
  94615. private static _SheenTextureEnabled;
  94616. /**
  94617. * Are sheen textures enabled in the application.
  94618. */
  94619. static SheenTextureEnabled: boolean;
  94620. private static _AnisotropicTextureEnabled;
  94621. /**
  94622. * Are anisotropic textures enabled in the application.
  94623. */
  94624. static AnisotropicTextureEnabled: boolean;
  94625. private static _ThicknessTextureEnabled;
  94626. /**
  94627. * Are thickness textures enabled in the application.
  94628. */
  94629. static ThicknessTextureEnabled: boolean;
  94630. }
  94631. }
  94632. declare module BABYLON {
  94633. /** @hidden */
  94634. export var defaultFragmentDeclaration: {
  94635. name: string;
  94636. shader: string;
  94637. };
  94638. }
  94639. declare module BABYLON {
  94640. /** @hidden */
  94641. export var defaultUboDeclaration: {
  94642. name: string;
  94643. shader: string;
  94644. };
  94645. }
  94646. declare module BABYLON {
  94647. /** @hidden */
  94648. export var lightFragmentDeclaration: {
  94649. name: string;
  94650. shader: string;
  94651. };
  94652. }
  94653. declare module BABYLON {
  94654. /** @hidden */
  94655. export var lightUboDeclaration: {
  94656. name: string;
  94657. shader: string;
  94658. };
  94659. }
  94660. declare module BABYLON {
  94661. /** @hidden */
  94662. export var lightsFragmentFunctions: {
  94663. name: string;
  94664. shader: string;
  94665. };
  94666. }
  94667. declare module BABYLON {
  94668. /** @hidden */
  94669. export var shadowsFragmentFunctions: {
  94670. name: string;
  94671. shader: string;
  94672. };
  94673. }
  94674. declare module BABYLON {
  94675. /** @hidden */
  94676. export var fresnelFunction: {
  94677. name: string;
  94678. shader: string;
  94679. };
  94680. }
  94681. declare module BABYLON {
  94682. /** @hidden */
  94683. export var reflectionFunction: {
  94684. name: string;
  94685. shader: string;
  94686. };
  94687. }
  94688. declare module BABYLON {
  94689. /** @hidden */
  94690. export var bumpFragmentFunctions: {
  94691. name: string;
  94692. shader: string;
  94693. };
  94694. }
  94695. declare module BABYLON {
  94696. /** @hidden */
  94697. export var logDepthDeclaration: {
  94698. name: string;
  94699. shader: string;
  94700. };
  94701. }
  94702. declare module BABYLON {
  94703. /** @hidden */
  94704. export var bumpFragment: {
  94705. name: string;
  94706. shader: string;
  94707. };
  94708. }
  94709. declare module BABYLON {
  94710. /** @hidden */
  94711. export var depthPrePass: {
  94712. name: string;
  94713. shader: string;
  94714. };
  94715. }
  94716. declare module BABYLON {
  94717. /** @hidden */
  94718. export var lightFragment: {
  94719. name: string;
  94720. shader: string;
  94721. };
  94722. }
  94723. declare module BABYLON {
  94724. /** @hidden */
  94725. export var logDepthFragment: {
  94726. name: string;
  94727. shader: string;
  94728. };
  94729. }
  94730. declare module BABYLON {
  94731. /** @hidden */
  94732. export var defaultPixelShader: {
  94733. name: string;
  94734. shader: string;
  94735. };
  94736. }
  94737. declare module BABYLON {
  94738. /** @hidden */
  94739. export var defaultVertexDeclaration: {
  94740. name: string;
  94741. shader: string;
  94742. };
  94743. }
  94744. declare module BABYLON {
  94745. /** @hidden */
  94746. export var bumpVertexDeclaration: {
  94747. name: string;
  94748. shader: string;
  94749. };
  94750. }
  94751. declare module BABYLON {
  94752. /** @hidden */
  94753. export var bumpVertex: {
  94754. name: string;
  94755. shader: string;
  94756. };
  94757. }
  94758. declare module BABYLON {
  94759. /** @hidden */
  94760. export var fogVertex: {
  94761. name: string;
  94762. shader: string;
  94763. };
  94764. }
  94765. declare module BABYLON {
  94766. /** @hidden */
  94767. export var shadowsVertex: {
  94768. name: string;
  94769. shader: string;
  94770. };
  94771. }
  94772. declare module BABYLON {
  94773. /** @hidden */
  94774. export var pointCloudVertex: {
  94775. name: string;
  94776. shader: string;
  94777. };
  94778. }
  94779. declare module BABYLON {
  94780. /** @hidden */
  94781. export var logDepthVertex: {
  94782. name: string;
  94783. shader: string;
  94784. };
  94785. }
  94786. declare module BABYLON {
  94787. /** @hidden */
  94788. export var defaultVertexShader: {
  94789. name: string;
  94790. shader: string;
  94791. };
  94792. }
  94793. declare module BABYLON {
  94794. /** @hidden */
  94795. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94796. MAINUV1: boolean;
  94797. MAINUV2: boolean;
  94798. DIFFUSE: boolean;
  94799. DIFFUSEDIRECTUV: number;
  94800. AMBIENT: boolean;
  94801. AMBIENTDIRECTUV: number;
  94802. OPACITY: boolean;
  94803. OPACITYDIRECTUV: number;
  94804. OPACITYRGB: boolean;
  94805. REFLECTION: boolean;
  94806. EMISSIVE: boolean;
  94807. EMISSIVEDIRECTUV: number;
  94808. SPECULAR: boolean;
  94809. SPECULARDIRECTUV: number;
  94810. BUMP: boolean;
  94811. BUMPDIRECTUV: number;
  94812. PARALLAX: boolean;
  94813. PARALLAXOCCLUSION: boolean;
  94814. SPECULAROVERALPHA: boolean;
  94815. CLIPPLANE: boolean;
  94816. CLIPPLANE2: boolean;
  94817. CLIPPLANE3: boolean;
  94818. CLIPPLANE4: boolean;
  94819. ALPHATEST: boolean;
  94820. DEPTHPREPASS: boolean;
  94821. ALPHAFROMDIFFUSE: boolean;
  94822. POINTSIZE: boolean;
  94823. FOG: boolean;
  94824. SPECULARTERM: boolean;
  94825. DIFFUSEFRESNEL: boolean;
  94826. OPACITYFRESNEL: boolean;
  94827. REFLECTIONFRESNEL: boolean;
  94828. REFRACTIONFRESNEL: boolean;
  94829. EMISSIVEFRESNEL: boolean;
  94830. FRESNEL: boolean;
  94831. NORMAL: boolean;
  94832. UV1: boolean;
  94833. UV2: boolean;
  94834. VERTEXCOLOR: boolean;
  94835. VERTEXALPHA: boolean;
  94836. NUM_BONE_INFLUENCERS: number;
  94837. BonesPerMesh: number;
  94838. BONETEXTURE: boolean;
  94839. INSTANCES: boolean;
  94840. GLOSSINESS: boolean;
  94841. ROUGHNESS: boolean;
  94842. EMISSIVEASILLUMINATION: boolean;
  94843. LINKEMISSIVEWITHDIFFUSE: boolean;
  94844. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94845. LIGHTMAP: boolean;
  94846. LIGHTMAPDIRECTUV: number;
  94847. OBJECTSPACE_NORMALMAP: boolean;
  94848. USELIGHTMAPASSHADOWMAP: boolean;
  94849. REFLECTIONMAP_3D: boolean;
  94850. REFLECTIONMAP_SPHERICAL: boolean;
  94851. REFLECTIONMAP_PLANAR: boolean;
  94852. REFLECTIONMAP_CUBIC: boolean;
  94853. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94854. REFLECTIONMAP_PROJECTION: boolean;
  94855. REFLECTIONMAP_SKYBOX: boolean;
  94856. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94857. REFLECTIONMAP_EXPLICIT: boolean;
  94858. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94859. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94860. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94861. INVERTCUBICMAP: boolean;
  94862. LOGARITHMICDEPTH: boolean;
  94863. REFRACTION: boolean;
  94864. REFRACTIONMAP_3D: boolean;
  94865. REFLECTIONOVERALPHA: boolean;
  94866. TWOSIDEDLIGHTING: boolean;
  94867. SHADOWFLOAT: boolean;
  94868. MORPHTARGETS: boolean;
  94869. MORPHTARGETS_NORMAL: boolean;
  94870. MORPHTARGETS_TANGENT: boolean;
  94871. MORPHTARGETS_UV: boolean;
  94872. NUM_MORPH_INFLUENCERS: number;
  94873. NONUNIFORMSCALING: boolean;
  94874. PREMULTIPLYALPHA: boolean;
  94875. IMAGEPROCESSING: boolean;
  94876. VIGNETTE: boolean;
  94877. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94878. VIGNETTEBLENDMODEOPAQUE: boolean;
  94879. TONEMAPPING: boolean;
  94880. TONEMAPPING_ACES: boolean;
  94881. CONTRAST: boolean;
  94882. COLORCURVES: boolean;
  94883. COLORGRADING: boolean;
  94884. COLORGRADING3D: boolean;
  94885. SAMPLER3DGREENDEPTH: boolean;
  94886. SAMPLER3DBGRMAP: boolean;
  94887. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94888. MULTIVIEW: boolean;
  94889. /**
  94890. * If the reflection texture on this material is in linear color space
  94891. * @hidden
  94892. */
  94893. IS_REFLECTION_LINEAR: boolean;
  94894. /**
  94895. * If the refraction texture on this material is in linear color space
  94896. * @hidden
  94897. */
  94898. IS_REFRACTION_LINEAR: boolean;
  94899. EXPOSURE: boolean;
  94900. constructor();
  94901. setReflectionMode(modeToEnable: string): void;
  94902. }
  94903. /**
  94904. * This is the default material used in Babylon. It is the best trade off between quality
  94905. * and performances.
  94906. * @see http://doc.babylonjs.com/babylon101/materials
  94907. */
  94908. export class StandardMaterial extends PushMaterial {
  94909. private _diffuseTexture;
  94910. /**
  94911. * The basic texture of the material as viewed under a light.
  94912. */
  94913. diffuseTexture: Nullable<BaseTexture>;
  94914. private _ambientTexture;
  94915. /**
  94916. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94917. */
  94918. ambientTexture: Nullable<BaseTexture>;
  94919. private _opacityTexture;
  94920. /**
  94921. * Define the transparency of the material from a texture.
  94922. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94923. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94924. */
  94925. opacityTexture: Nullable<BaseTexture>;
  94926. private _reflectionTexture;
  94927. /**
  94928. * Define the texture used to display the reflection.
  94929. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94930. */
  94931. reflectionTexture: Nullable<BaseTexture>;
  94932. private _emissiveTexture;
  94933. /**
  94934. * Define texture of the material as if self lit.
  94935. * This will be mixed in the final result even in the absence of light.
  94936. */
  94937. emissiveTexture: Nullable<BaseTexture>;
  94938. private _specularTexture;
  94939. /**
  94940. * Define how the color and intensity of the highlight given by the light in the material.
  94941. */
  94942. specularTexture: Nullable<BaseTexture>;
  94943. private _bumpTexture;
  94944. /**
  94945. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94946. * 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.
  94947. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94948. */
  94949. bumpTexture: Nullable<BaseTexture>;
  94950. private _lightmapTexture;
  94951. /**
  94952. * Complex lighting can be computationally expensive to compute at runtime.
  94953. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94954. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94955. */
  94956. lightmapTexture: Nullable<BaseTexture>;
  94957. private _refractionTexture;
  94958. /**
  94959. * Define the texture used to display the refraction.
  94960. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94961. */
  94962. refractionTexture: Nullable<BaseTexture>;
  94963. /**
  94964. * The color of the material lit by the environmental background lighting.
  94965. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94966. */
  94967. ambientColor: Color3;
  94968. /**
  94969. * The basic color of the material as viewed under a light.
  94970. */
  94971. diffuseColor: Color3;
  94972. /**
  94973. * Define how the color and intensity of the highlight given by the light in the material.
  94974. */
  94975. specularColor: Color3;
  94976. /**
  94977. * Define the color of the material as if self lit.
  94978. * This will be mixed in the final result even in the absence of light.
  94979. */
  94980. emissiveColor: Color3;
  94981. /**
  94982. * Defines how sharp are the highlights in the material.
  94983. * The bigger the value the sharper giving a more glossy feeling to the result.
  94984. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94985. */
  94986. specularPower: number;
  94987. private _useAlphaFromDiffuseTexture;
  94988. /**
  94989. * Does the transparency come from the diffuse texture alpha channel.
  94990. */
  94991. useAlphaFromDiffuseTexture: boolean;
  94992. private _useEmissiveAsIllumination;
  94993. /**
  94994. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94995. */
  94996. useEmissiveAsIllumination: boolean;
  94997. private _linkEmissiveWithDiffuse;
  94998. /**
  94999. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95000. * the emissive level when the final color is close to one.
  95001. */
  95002. linkEmissiveWithDiffuse: boolean;
  95003. private _useSpecularOverAlpha;
  95004. /**
  95005. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95006. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95007. */
  95008. useSpecularOverAlpha: boolean;
  95009. private _useReflectionOverAlpha;
  95010. /**
  95011. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95012. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95013. */
  95014. useReflectionOverAlpha: boolean;
  95015. private _disableLighting;
  95016. /**
  95017. * Does lights from the scene impacts this material.
  95018. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95019. */
  95020. disableLighting: boolean;
  95021. private _useObjectSpaceNormalMap;
  95022. /**
  95023. * Allows using an object space normal map (instead of tangent space).
  95024. */
  95025. useObjectSpaceNormalMap: boolean;
  95026. private _useParallax;
  95027. /**
  95028. * Is parallax enabled or not.
  95029. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95030. */
  95031. useParallax: boolean;
  95032. private _useParallaxOcclusion;
  95033. /**
  95034. * Is parallax occlusion enabled or not.
  95035. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95036. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95037. */
  95038. useParallaxOcclusion: boolean;
  95039. /**
  95040. * 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.
  95041. */
  95042. parallaxScaleBias: number;
  95043. private _roughness;
  95044. /**
  95045. * Helps to define how blurry the reflections should appears in the material.
  95046. */
  95047. roughness: number;
  95048. /**
  95049. * In case of refraction, define the value of the index of refraction.
  95050. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95051. */
  95052. indexOfRefraction: number;
  95053. /**
  95054. * Invert the refraction texture alongside the y axis.
  95055. * It can be useful with procedural textures or probe for instance.
  95056. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95057. */
  95058. invertRefractionY: boolean;
  95059. /**
  95060. * Defines the alpha limits in alpha test mode.
  95061. */
  95062. alphaCutOff: number;
  95063. private _useLightmapAsShadowmap;
  95064. /**
  95065. * In case of light mapping, define whether the map contains light or shadow informations.
  95066. */
  95067. useLightmapAsShadowmap: boolean;
  95068. private _diffuseFresnelParameters;
  95069. /**
  95070. * Define the diffuse fresnel parameters of the material.
  95071. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95072. */
  95073. diffuseFresnelParameters: FresnelParameters;
  95074. private _opacityFresnelParameters;
  95075. /**
  95076. * Define the opacity fresnel parameters of the material.
  95077. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95078. */
  95079. opacityFresnelParameters: FresnelParameters;
  95080. private _reflectionFresnelParameters;
  95081. /**
  95082. * Define the reflection fresnel parameters of the material.
  95083. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95084. */
  95085. reflectionFresnelParameters: FresnelParameters;
  95086. private _refractionFresnelParameters;
  95087. /**
  95088. * Define the refraction fresnel parameters of the material.
  95089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95090. */
  95091. refractionFresnelParameters: FresnelParameters;
  95092. private _emissiveFresnelParameters;
  95093. /**
  95094. * Define the emissive fresnel parameters of the material.
  95095. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95096. */
  95097. emissiveFresnelParameters: FresnelParameters;
  95098. private _useReflectionFresnelFromSpecular;
  95099. /**
  95100. * If true automatically deducts the fresnels values from the material specularity.
  95101. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95102. */
  95103. useReflectionFresnelFromSpecular: boolean;
  95104. private _useGlossinessFromSpecularMapAlpha;
  95105. /**
  95106. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95107. */
  95108. useGlossinessFromSpecularMapAlpha: boolean;
  95109. private _maxSimultaneousLights;
  95110. /**
  95111. * Defines the maximum number of lights that can be used in the material
  95112. */
  95113. maxSimultaneousLights: number;
  95114. private _invertNormalMapX;
  95115. /**
  95116. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95117. */
  95118. invertNormalMapX: boolean;
  95119. private _invertNormalMapY;
  95120. /**
  95121. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95122. */
  95123. invertNormalMapY: boolean;
  95124. private _twoSidedLighting;
  95125. /**
  95126. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95127. */
  95128. twoSidedLighting: boolean;
  95129. /**
  95130. * Default configuration related to image processing available in the standard Material.
  95131. */
  95132. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95133. /**
  95134. * Gets the image processing configuration used either in this material.
  95135. */
  95136. /**
  95137. * Sets the Default image processing configuration used either in the this material.
  95138. *
  95139. * If sets to null, the scene one is in use.
  95140. */
  95141. imageProcessingConfiguration: ImageProcessingConfiguration;
  95142. /**
  95143. * Keep track of the image processing observer to allow dispose and replace.
  95144. */
  95145. private _imageProcessingObserver;
  95146. /**
  95147. * Attaches a new image processing configuration to the Standard Material.
  95148. * @param configuration
  95149. */
  95150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95151. /**
  95152. * Gets wether the color curves effect is enabled.
  95153. */
  95154. /**
  95155. * Sets wether the color curves effect is enabled.
  95156. */
  95157. cameraColorCurvesEnabled: boolean;
  95158. /**
  95159. * Gets wether the color grading effect is enabled.
  95160. */
  95161. /**
  95162. * Gets wether the color grading effect is enabled.
  95163. */
  95164. cameraColorGradingEnabled: boolean;
  95165. /**
  95166. * Gets wether tonemapping is enabled or not.
  95167. */
  95168. /**
  95169. * Sets wether tonemapping is enabled or not
  95170. */
  95171. cameraToneMappingEnabled: boolean;
  95172. /**
  95173. * The camera exposure used on this material.
  95174. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95175. * This corresponds to a photographic exposure.
  95176. */
  95177. /**
  95178. * The camera exposure used on this material.
  95179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95180. * This corresponds to a photographic exposure.
  95181. */
  95182. cameraExposure: number;
  95183. /**
  95184. * Gets The camera contrast used on this material.
  95185. */
  95186. /**
  95187. * Sets The camera contrast used on this material.
  95188. */
  95189. cameraContrast: number;
  95190. /**
  95191. * Gets the Color Grading 2D Lookup Texture.
  95192. */
  95193. /**
  95194. * Sets the Color Grading 2D Lookup Texture.
  95195. */
  95196. cameraColorGradingTexture: Nullable<BaseTexture>;
  95197. /**
  95198. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95199. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95200. * 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;
  95201. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95202. */
  95203. /**
  95204. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95205. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95206. * 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;
  95207. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95208. */
  95209. cameraColorCurves: Nullable<ColorCurves>;
  95210. /**
  95211. * Custom callback helping to override the default shader used in the material.
  95212. */
  95213. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95214. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95215. protected _worldViewProjectionMatrix: Matrix;
  95216. protected _globalAmbientColor: Color3;
  95217. protected _useLogarithmicDepth: boolean;
  95218. protected _rebuildInParallel: boolean;
  95219. /**
  95220. * Instantiates a new standard material.
  95221. * This is the default material used in Babylon. It is the best trade off between quality
  95222. * and performances.
  95223. * @see http://doc.babylonjs.com/babylon101/materials
  95224. * @param name Define the name of the material in the scene
  95225. * @param scene Define the scene the material belong to
  95226. */
  95227. constructor(name: string, scene: Scene);
  95228. /**
  95229. * Gets a boolean indicating that current material needs to register RTT
  95230. */
  95231. readonly hasRenderTargetTextures: boolean;
  95232. /**
  95233. * Gets the current class name of the material e.g. "StandardMaterial"
  95234. * Mainly use in serialization.
  95235. * @returns the class name
  95236. */
  95237. getClassName(): string;
  95238. /**
  95239. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95240. * You can try switching to logarithmic depth.
  95241. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95242. */
  95243. useLogarithmicDepth: boolean;
  95244. /**
  95245. * Specifies if the material will require alpha blending
  95246. * @returns a boolean specifying if alpha blending is needed
  95247. */
  95248. needAlphaBlending(): boolean;
  95249. /**
  95250. * Specifies if this material should be rendered in alpha test mode
  95251. * @returns a boolean specifying if an alpha test is needed.
  95252. */
  95253. needAlphaTesting(): boolean;
  95254. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95255. /**
  95256. * Get the texture used for alpha test purpose.
  95257. * @returns the diffuse texture in case of the standard material.
  95258. */
  95259. getAlphaTestTexture(): Nullable<BaseTexture>;
  95260. /**
  95261. * Get if the submesh is ready to be used and all its information available.
  95262. * Child classes can use it to update shaders
  95263. * @param mesh defines the mesh to check
  95264. * @param subMesh defines which submesh to check
  95265. * @param useInstances specifies that instances should be used
  95266. * @returns a boolean indicating that the submesh is ready or not
  95267. */
  95268. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95269. /**
  95270. * Builds the material UBO layouts.
  95271. * Used internally during the effect preparation.
  95272. */
  95273. buildUniformLayout(): void;
  95274. /**
  95275. * Unbinds the material from the mesh
  95276. */
  95277. unbind(): void;
  95278. /**
  95279. * Binds the submesh to this material by preparing the effect and shader to draw
  95280. * @param world defines the world transformation matrix
  95281. * @param mesh defines the mesh containing the submesh
  95282. * @param subMesh defines the submesh to bind the material to
  95283. */
  95284. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95285. /**
  95286. * Get the list of animatables in the material.
  95287. * @returns the list of animatables object used in the material
  95288. */
  95289. getAnimatables(): IAnimatable[];
  95290. /**
  95291. * Gets the active textures from the material
  95292. * @returns an array of textures
  95293. */
  95294. getActiveTextures(): BaseTexture[];
  95295. /**
  95296. * Specifies if the material uses a texture
  95297. * @param texture defines the texture to check against the material
  95298. * @returns a boolean specifying if the material uses the texture
  95299. */
  95300. hasTexture(texture: BaseTexture): boolean;
  95301. /**
  95302. * Disposes the material
  95303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95305. */
  95306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95307. /**
  95308. * Makes a duplicate of the material, and gives it a new name
  95309. * @param name defines the new name for the duplicated material
  95310. * @returns the cloned material
  95311. */
  95312. clone(name: string): StandardMaterial;
  95313. /**
  95314. * Serializes this material in a JSON representation
  95315. * @returns the serialized material object
  95316. */
  95317. serialize(): any;
  95318. /**
  95319. * Creates a standard material from parsed material data
  95320. * @param source defines the JSON representation of the material
  95321. * @param scene defines the hosting scene
  95322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95323. * @returns a new standard material
  95324. */
  95325. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95326. /**
  95327. * Are diffuse textures enabled in the application.
  95328. */
  95329. static DiffuseTextureEnabled: boolean;
  95330. /**
  95331. * Are ambient textures enabled in the application.
  95332. */
  95333. static AmbientTextureEnabled: boolean;
  95334. /**
  95335. * Are opacity textures enabled in the application.
  95336. */
  95337. static OpacityTextureEnabled: boolean;
  95338. /**
  95339. * Are reflection textures enabled in the application.
  95340. */
  95341. static ReflectionTextureEnabled: boolean;
  95342. /**
  95343. * Are emissive textures enabled in the application.
  95344. */
  95345. static EmissiveTextureEnabled: boolean;
  95346. /**
  95347. * Are specular textures enabled in the application.
  95348. */
  95349. static SpecularTextureEnabled: boolean;
  95350. /**
  95351. * Are bump textures enabled in the application.
  95352. */
  95353. static BumpTextureEnabled: boolean;
  95354. /**
  95355. * Are lightmap textures enabled in the application.
  95356. */
  95357. static LightmapTextureEnabled: boolean;
  95358. /**
  95359. * Are refraction textures enabled in the application.
  95360. */
  95361. static RefractionTextureEnabled: boolean;
  95362. /**
  95363. * Are color grading textures enabled in the application.
  95364. */
  95365. static ColorGradingTextureEnabled: boolean;
  95366. /**
  95367. * Are fresnels enabled in the application.
  95368. */
  95369. static FresnelEnabled: boolean;
  95370. }
  95371. }
  95372. declare module BABYLON {
  95373. /**
  95374. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95375. *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.
  95376. * The SPS is also a particle system. It provides some methods to manage the particles.
  95377. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95378. *
  95379. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95380. */
  95381. export class SolidParticleSystem implements IDisposable {
  95382. /**
  95383. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95384. * Example : var p = SPS.particles[i];
  95385. */
  95386. particles: SolidParticle[];
  95387. /**
  95388. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95389. */
  95390. nbParticles: number;
  95391. /**
  95392. * If the particles must ever face the camera (default false). Useful for planar particles.
  95393. */
  95394. billboard: boolean;
  95395. /**
  95396. * Recompute normals when adding a shape
  95397. */
  95398. recomputeNormals: boolean;
  95399. /**
  95400. * This a counter ofr your own usage. It's not set by any SPS functions.
  95401. */
  95402. counter: number;
  95403. /**
  95404. * The SPS name. This name is also given to the underlying mesh.
  95405. */
  95406. name: string;
  95407. /**
  95408. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95409. */
  95410. mesh: Mesh;
  95411. /**
  95412. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95413. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95414. */
  95415. vars: any;
  95416. /**
  95417. * This array is populated when the SPS is set as 'pickable'.
  95418. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95419. * Each element of this array is an object `{idx: int, faceId: int}`.
  95420. * `idx` is the picked particle index in the `SPS.particles` array
  95421. * `faceId` is the picked face index counted within this particle.
  95422. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95423. */
  95424. pickedParticles: {
  95425. idx: number;
  95426. faceId: number;
  95427. }[];
  95428. /**
  95429. * This array is populated when `enableDepthSort` is set to true.
  95430. * Each element of this array is an instance of the class DepthSortedParticle.
  95431. */
  95432. depthSortedParticles: DepthSortedParticle[];
  95433. /**
  95434. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95435. * @hidden
  95436. */
  95437. _bSphereOnly: boolean;
  95438. /**
  95439. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95440. * @hidden
  95441. */
  95442. _bSphereRadiusFactor: number;
  95443. private _scene;
  95444. private _positions;
  95445. private _indices;
  95446. private _normals;
  95447. private _colors;
  95448. private _uvs;
  95449. private _indices32;
  95450. private _positions32;
  95451. private _normals32;
  95452. private _fixedNormal32;
  95453. private _colors32;
  95454. private _uvs32;
  95455. private _index;
  95456. private _updatable;
  95457. private _pickable;
  95458. private _isVisibilityBoxLocked;
  95459. private _alwaysVisible;
  95460. private _depthSort;
  95461. private _expandable;
  95462. private _shapeCounter;
  95463. private _copy;
  95464. private _color;
  95465. private _computeParticleColor;
  95466. private _computeParticleTexture;
  95467. private _computeParticleRotation;
  95468. private _computeParticleVertex;
  95469. private _computeBoundingBox;
  95470. private _depthSortParticles;
  95471. private _camera;
  95472. private _mustUnrotateFixedNormals;
  95473. private _particlesIntersect;
  95474. private _needs32Bits;
  95475. private _isNotBuilt;
  95476. private _lastParticleId;
  95477. private _idxOfId;
  95478. private _multimaterialEnabled;
  95479. private _useModelMaterial;
  95480. private _indicesByMaterial;
  95481. private _materialIndexes;
  95482. private _depthSortFunction;
  95483. private _materialSortFunction;
  95484. private _materials;
  95485. private _multimaterial;
  95486. private _materialIndexesById;
  95487. private _defaultMaterial;
  95488. private _autoUpdateSubMeshes;
  95489. /**
  95490. * Creates a SPS (Solid Particle System) object.
  95491. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95492. * @param scene (Scene) is the scene in which the SPS is added.
  95493. * @param options defines the options of the sps e.g.
  95494. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95495. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95496. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95497. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  95498. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95499. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95500. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95501. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95502. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95503. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95504. */
  95505. constructor(name: string, scene: Scene, options?: {
  95506. updatable?: boolean;
  95507. isPickable?: boolean;
  95508. enableDepthSort?: boolean;
  95509. particleIntersection?: boolean;
  95510. boundingSphereOnly?: boolean;
  95511. bSphereRadiusFactor?: number;
  95512. expandable?: boolean;
  95513. useModelMaterial?: boolean;
  95514. enableMultiMaterial?: boolean;
  95515. });
  95516. /**
  95517. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95518. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95519. * @returns the created mesh
  95520. */
  95521. buildMesh(): Mesh;
  95522. /**
  95523. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95524. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95525. * Thus the particles generated from `digest()` have their property `position` set yet.
  95526. * @param mesh ( Mesh ) is the mesh to be digested
  95527. * @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
  95528. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95529. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95530. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95531. * @returns the current SPS
  95532. */
  95533. digest(mesh: Mesh, options?: {
  95534. facetNb?: number;
  95535. number?: number;
  95536. delta?: number;
  95537. storage?: [];
  95538. }): SolidParticleSystem;
  95539. /**
  95540. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95541. * @hidden
  95542. */
  95543. private _unrotateFixedNormals;
  95544. /**
  95545. * Resets the temporary working copy particle
  95546. * @hidden
  95547. */
  95548. private _resetCopy;
  95549. /**
  95550. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  95551. * @param p the current index in the positions array to be updated
  95552. * @param ind the current index in the indices array
  95553. * @param shape a Vector3 array, the shape geometry
  95554. * @param positions the positions array to be updated
  95555. * @param meshInd the shape indices array
  95556. * @param indices the indices array to be updated
  95557. * @param meshUV the shape uv array
  95558. * @param uvs the uv array to be updated
  95559. * @param meshCol the shape color array
  95560. * @param colors the color array to be updated
  95561. * @param meshNor the shape normals array
  95562. * @param normals the normals array to be updated
  95563. * @param idx the particle index
  95564. * @param idxInShape the particle index in its shape
  95565. * @param options the addShape() method passed options
  95566. * @model the particle model
  95567. * @hidden
  95568. */
  95569. private _meshBuilder;
  95570. /**
  95571. * Returns a shape Vector3 array from positions float array
  95572. * @param positions float array
  95573. * @returns a vector3 array
  95574. * @hidden
  95575. */
  95576. private _posToShape;
  95577. /**
  95578. * Returns a shapeUV array from a float uvs (array deep copy)
  95579. * @param uvs as a float array
  95580. * @returns a shapeUV array
  95581. * @hidden
  95582. */
  95583. private _uvsToShapeUV;
  95584. /**
  95585. * Adds a new particle object in the particles array
  95586. * @param idx particle index in particles array
  95587. * @param id particle id
  95588. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  95589. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  95590. * @param model particle ModelShape object
  95591. * @param shapeId model shape identifier
  95592. * @param idxInShape index of the particle in the current model
  95593. * @param bInfo model bounding info object
  95594. * @param storage target storage array, if any
  95595. * @hidden
  95596. */
  95597. private _addParticle;
  95598. /**
  95599. * Adds some particles to the SPS from the model shape. Returns the shape id.
  95600. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  95601. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  95602. * @param nb (positive integer) the number of particles to be created from this model
  95603. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  95604. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  95605. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95606. * @returns the number of shapes in the system
  95607. */
  95608. addShape(mesh: Mesh, nb: number, options?: {
  95609. positionFunction?: any;
  95610. vertexFunction?: any;
  95611. storage?: [];
  95612. }): number;
  95613. /**
  95614. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  95615. * @hidden
  95616. */
  95617. private _rebuildParticle;
  95618. /**
  95619. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  95620. * @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.
  95621. * @returns the SPS.
  95622. */
  95623. rebuildMesh(reset?: boolean): SolidParticleSystem;
  95624. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  95625. * Returns an array with the removed particles.
  95626. * 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.
  95627. * The SPS can't be empty so at least one particle needs to remain in place.
  95628. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  95629. * @param start index of the first particle to remove
  95630. * @param end index of the last particle to remove (included)
  95631. * @returns an array populated with the removed particles
  95632. */
  95633. removeParticles(start: number, end: number): SolidParticle[];
  95634. /**
  95635. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  95636. * @param solidParticleArray an array populated with Solid Particles objects
  95637. * @returns the SPS
  95638. */
  95639. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  95640. /**
  95641. * Creates a new particle and modifies the SPS mesh geometry :
  95642. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  95643. * - calls _addParticle() to populate the particle array
  95644. * factorized code from addShape() and insertParticlesFromArray()
  95645. * @param idx particle index in the particles array
  95646. * @param i particle index in its shape
  95647. * @param modelShape particle ModelShape object
  95648. * @param shape shape vertex array
  95649. * @param meshInd shape indices array
  95650. * @param meshUV shape uv array
  95651. * @param meshCol shape color array
  95652. * @param meshNor shape normals array
  95653. * @param bbInfo shape bounding info
  95654. * @param storage target particle storage
  95655. * @options addShape() passed options
  95656. * @hidden
  95657. */
  95658. private _insertNewParticle;
  95659. /**
  95660. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  95661. * This method calls `updateParticle()` for each particle of the SPS.
  95662. * For an animated SPS, it is usually called within the render loop.
  95663. * 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.
  95664. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  95665. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  95666. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  95667. * @returns the SPS.
  95668. */
  95669. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  95670. /**
  95671. * Disposes the SPS.
  95672. */
  95673. dispose(): void;
  95674. /**
  95675. * Returns a SolidParticle object from its identifier : particle.id
  95676. * @param id (integer) the particle Id
  95677. * @returns the searched particle or null if not found in the SPS.
  95678. */
  95679. getParticleById(id: number): Nullable<SolidParticle>;
  95680. /**
  95681. * Returns a new array populated with the particles having the passed shapeId.
  95682. * @param shapeId (integer) the shape identifier
  95683. * @returns a new solid particle array
  95684. */
  95685. getParticlesByShapeId(shapeId: number): SolidParticle[];
  95686. /**
  95687. * Populates the passed array "ref" with the particles having the passed shapeId.
  95688. * @param shapeId the shape identifier
  95689. * @returns the SPS
  95690. * @param ref
  95691. */
  95692. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  95693. /**
  95694. * Computes the required SubMeshes according the materials assigned to the particles.
  95695. * @returns the solid particle system.
  95696. * Does nothing if called before the SPS mesh is built.
  95697. */
  95698. computeSubMeshes(): SolidParticleSystem;
  95699. /**
  95700. * Sorts the solid particles by material when MultiMaterial is enabled.
  95701. * Updates the indices32 array.
  95702. * Updates the indicesByMaterial array.
  95703. * Updates the mesh indices array.
  95704. * @returns the SPS
  95705. * @hidden
  95706. */
  95707. private _sortParticlesByMaterial;
  95708. /**
  95709. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  95710. * @hidden
  95711. */
  95712. private _setMaterialIndexesById;
  95713. /**
  95714. * Returns an array with unique values of Materials from the passed array
  95715. * @param array the material array to be checked and filtered
  95716. * @hidden
  95717. */
  95718. private _filterUniqueMaterialId;
  95719. /**
  95720. * Sets a new Standard Material as _defaultMaterial if not already set.
  95721. * @hidden
  95722. */
  95723. private _setDefaultMaterial;
  95724. /**
  95725. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  95726. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95727. * @returns the SPS.
  95728. */
  95729. refreshVisibleSize(): SolidParticleSystem;
  95730. /**
  95731. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  95732. * @param size the size (float) of the visibility box
  95733. * note : this doesn't lock the SPS mesh bounding box.
  95734. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95735. */
  95736. setVisibilityBox(size: number): void;
  95737. /**
  95738. * Gets whether the SPS as always visible or not
  95739. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95740. */
  95741. /**
  95742. * Sets the SPS as always visible or not
  95743. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95744. */
  95745. isAlwaysVisible: boolean;
  95746. /**
  95747. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95748. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95749. */
  95750. /**
  95751. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95752. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95753. */
  95754. isVisibilityBoxLocked: boolean;
  95755. /**
  95756. * Tells to `setParticles()` to compute the particle rotations or not.
  95757. * Default value : true. The SPS is faster when it's set to false.
  95758. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95759. */
  95760. /**
  95761. * Gets if `setParticles()` computes the particle rotations or not.
  95762. * Default value : true. The SPS is faster when it's set to false.
  95763. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95764. */
  95765. computeParticleRotation: boolean;
  95766. /**
  95767. * Tells to `setParticles()` to compute the particle colors or not.
  95768. * Default value : true. The SPS is faster when it's set to false.
  95769. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95770. */
  95771. /**
  95772. * Gets if `setParticles()` computes the particle colors or not.
  95773. * Default value : true. The SPS is faster when it's set to false.
  95774. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95775. */
  95776. computeParticleColor: boolean;
  95777. /**
  95778. * Gets if `setParticles()` computes the particle textures or not.
  95779. * Default value : true. The SPS is faster when it's set to false.
  95780. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  95781. */
  95782. computeParticleTexture: boolean;
  95783. /**
  95784. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  95785. * Default value : false. The SPS is faster when it's set to false.
  95786. * Note : the particle custom vertex positions aren't stored values.
  95787. */
  95788. /**
  95789. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  95790. * Default value : false. The SPS is faster when it's set to false.
  95791. * Note : the particle custom vertex positions aren't stored values.
  95792. */
  95793. computeParticleVertex: boolean;
  95794. /**
  95795. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  95796. */
  95797. /**
  95798. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  95799. */
  95800. computeBoundingBox: boolean;
  95801. /**
  95802. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  95803. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95804. * Default : `true`
  95805. */
  95806. /**
  95807. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  95808. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95809. * Default : `true`
  95810. */
  95811. depthSortParticles: boolean;
  95812. /**
  95813. * Gets if the SPS is created as expandable at construction time.
  95814. * Default : `false`
  95815. */
  95816. readonly expandable: boolean;
  95817. /**
  95818. * Gets if the SPS supports the Multi Materials
  95819. */
  95820. readonly multimaterialEnabled: boolean;
  95821. /**
  95822. * Gets if the SPS uses the model materials for its own multimaterial.
  95823. */
  95824. readonly useModelMaterial: boolean;
  95825. /**
  95826. * The SPS used material array.
  95827. */
  95828. readonly materials: Material[];
  95829. /**
  95830. * Sets the SPS MultiMaterial from the passed materials.
  95831. * Note : the passed array is internally copied and not used then by reference.
  95832. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  95833. */
  95834. setMultiMaterial(materials: Material[]): void;
  95835. /**
  95836. * The SPS computed multimaterial object
  95837. */
  95838. multimaterial: MultiMaterial;
  95839. /**
  95840. * If the subMeshes must be updated on the next call to setParticles()
  95841. */
  95842. autoUpdateSubMeshes: boolean;
  95843. /**
  95844. * This function does nothing. It may be overwritten to set all the particle first values.
  95845. * The SPS doesn't call this function, you may have to call it by your own.
  95846. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95847. */
  95848. initParticles(): void;
  95849. /**
  95850. * This function does nothing. It may be overwritten to recycle a particle.
  95851. * The SPS doesn't call this function, you may have to call it by your own.
  95852. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95853. * @param particle The particle to recycle
  95854. * @returns the recycled particle
  95855. */
  95856. recycleParticle(particle: SolidParticle): SolidParticle;
  95857. /**
  95858. * Updates a particle : this function should be overwritten by the user.
  95859. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  95860. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95861. * @example : just set a particle position or velocity and recycle conditions
  95862. * @param particle The particle to update
  95863. * @returns the updated particle
  95864. */
  95865. updateParticle(particle: SolidParticle): SolidParticle;
  95866. /**
  95867. * Updates a vertex of a particle : it can be overwritten by the user.
  95868. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  95869. * @param particle the current particle
  95870. * @param vertex the current index of the current particle
  95871. * @param pt the index of the current vertex in the particle shape
  95872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  95873. * @example : just set a vertex particle position
  95874. * @returns the updated vertex
  95875. */
  95876. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  95877. /**
  95878. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  95879. * This does nothing and may be overwritten by the user.
  95880. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95881. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95882. * @param update the boolean update value actually passed to setParticles()
  95883. */
  95884. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95885. /**
  95886. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  95887. * This will be passed three parameters.
  95888. * This does nothing and may be overwritten by the user.
  95889. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95890. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95891. * @param update the boolean update value actually passed to setParticles()
  95892. */
  95893. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95894. }
  95895. }
  95896. declare module BABYLON {
  95897. /**
  95898. * Represents one particle of a solid particle system.
  95899. */
  95900. export class SolidParticle {
  95901. /**
  95902. * particle global index
  95903. */
  95904. idx: number;
  95905. /**
  95906. * particle identifier
  95907. */
  95908. id: number;
  95909. /**
  95910. * The color of the particle
  95911. */
  95912. color: Nullable<Color4>;
  95913. /**
  95914. * The world space position of the particle.
  95915. */
  95916. position: Vector3;
  95917. /**
  95918. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  95919. */
  95920. rotation: Vector3;
  95921. /**
  95922. * The world space rotation quaternion of the particle.
  95923. */
  95924. rotationQuaternion: Nullable<Quaternion>;
  95925. /**
  95926. * The scaling of the particle.
  95927. */
  95928. scaling: Vector3;
  95929. /**
  95930. * The uvs of the particle.
  95931. */
  95932. uvs: Vector4;
  95933. /**
  95934. * The current speed of the particle.
  95935. */
  95936. velocity: Vector3;
  95937. /**
  95938. * The pivot point in the particle local space.
  95939. */
  95940. pivot: Vector3;
  95941. /**
  95942. * Must the particle be translated from its pivot point in its local space ?
  95943. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  95944. * Default : false
  95945. */
  95946. translateFromPivot: boolean;
  95947. /**
  95948. * Is the particle active or not ?
  95949. */
  95950. alive: boolean;
  95951. /**
  95952. * Is the particle visible or not ?
  95953. */
  95954. isVisible: boolean;
  95955. /**
  95956. * Index of this particle in the global "positions" array (Internal use)
  95957. * @hidden
  95958. */
  95959. _pos: number;
  95960. /**
  95961. * @hidden Index of this particle in the global "indices" array (Internal use)
  95962. */
  95963. _ind: number;
  95964. /**
  95965. * @hidden ModelShape of this particle (Internal use)
  95966. */
  95967. _model: ModelShape;
  95968. /**
  95969. * ModelShape id of this particle
  95970. */
  95971. shapeId: number;
  95972. /**
  95973. * Index of the particle in its shape id
  95974. */
  95975. idxInShape: number;
  95976. /**
  95977. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  95978. */
  95979. _modelBoundingInfo: BoundingInfo;
  95980. /**
  95981. * @hidden Particle BoundingInfo object (Internal use)
  95982. */
  95983. _boundingInfo: BoundingInfo;
  95984. /**
  95985. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  95986. */
  95987. _sps: SolidParticleSystem;
  95988. /**
  95989. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  95990. */
  95991. _stillInvisible: boolean;
  95992. /**
  95993. * @hidden Last computed particle rotation matrix
  95994. */
  95995. _rotationMatrix: number[];
  95996. /**
  95997. * Parent particle Id, if any.
  95998. * Default null.
  95999. */
  96000. parentId: Nullable<number>;
  96001. /**
  96002. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  96003. */
  96004. materialIndex: Nullable<number>;
  96005. /**
  96006. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  96007. * The possible values are :
  96008. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96009. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96010. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96011. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96012. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96013. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  96014. * */
  96015. cullingStrategy: number;
  96016. /**
  96017. * @hidden Internal global position in the SPS.
  96018. */
  96019. _globalPosition: Vector3;
  96020. /**
  96021. * Creates a Solid Particle object.
  96022. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96023. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96024. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96025. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96026. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96027. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96028. * @param shapeId (integer) is the model shape identifier in the SPS.
  96029. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96030. * @param sps defines the sps it is associated to
  96031. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96032. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96033. */
  96034. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96035. /**
  96036. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96037. * @param target the particle target
  96038. * @returns the current particle
  96039. */
  96040. copyToRef(target: SolidParticle): SolidParticle;
  96041. /**
  96042. * Legacy support, changed scale to scaling
  96043. */
  96044. /**
  96045. * Legacy support, changed scale to scaling
  96046. */
  96047. scale: Vector3;
  96048. /**
  96049. * Legacy support, changed quaternion to rotationQuaternion
  96050. */
  96051. /**
  96052. * Legacy support, changed quaternion to rotationQuaternion
  96053. */
  96054. quaternion: Nullable<Quaternion>;
  96055. /**
  96056. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96057. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96058. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96059. * @returns true if it intersects
  96060. */
  96061. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96062. /**
  96063. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96064. * A particle is in the frustum if its bounding box intersects the frustum
  96065. * @param frustumPlanes defines the frustum to test
  96066. * @returns true if the particle is in the frustum planes
  96067. */
  96068. isInFrustum(frustumPlanes: Plane[]): boolean;
  96069. /**
  96070. * get the rotation matrix of the particle
  96071. * @hidden
  96072. */
  96073. getRotationMatrix(m: Matrix): void;
  96074. }
  96075. /**
  96076. * Represents the shape of the model used by one particle of a solid particle system.
  96077. * SPS internal tool, don't use it manually.
  96078. */
  96079. export class ModelShape {
  96080. /**
  96081. * The shape id
  96082. * @hidden
  96083. */
  96084. shapeID: number;
  96085. /**
  96086. * flat array of model positions (internal use)
  96087. * @hidden
  96088. */
  96089. _shape: Vector3[];
  96090. /**
  96091. * flat array of model UVs (internal use)
  96092. * @hidden
  96093. */
  96094. _shapeUV: number[];
  96095. /**
  96096. * color array of the model
  96097. * @hidden
  96098. */
  96099. _shapeColors: number[];
  96100. /**
  96101. * indices array of the model
  96102. * @hidden
  96103. */
  96104. _indices: number[];
  96105. /**
  96106. * normals array of the model
  96107. * @hidden
  96108. */
  96109. _normals: number[];
  96110. /**
  96111. * length of the shape in the model indices array (internal use)
  96112. * @hidden
  96113. */
  96114. _indicesLength: number;
  96115. /**
  96116. * Custom position function (internal use)
  96117. * @hidden
  96118. */
  96119. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96120. /**
  96121. * Custom vertex function (internal use)
  96122. * @hidden
  96123. */
  96124. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96125. /**
  96126. * Model material (internal use)
  96127. * @hidden
  96128. */
  96129. _material: Nullable<Material>;
  96130. /**
  96131. * 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.
  96132. * SPS internal tool, don't use it manually.
  96133. * @hidden
  96134. */
  96135. 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>, material: Nullable<Material>);
  96136. }
  96137. /**
  96138. * Represents a Depth Sorted Particle in the solid particle system.
  96139. * @hidden
  96140. */
  96141. export class DepthSortedParticle {
  96142. /**
  96143. * Index of the particle in the "indices" array
  96144. */
  96145. ind: number;
  96146. /**
  96147. * Length of the particle shape in the "indices" array
  96148. */
  96149. indicesLength: number;
  96150. /**
  96151. * Squared distance from the particle to the camera
  96152. */
  96153. sqDistance: number;
  96154. /**
  96155. * Material index when used with MultiMaterials
  96156. */
  96157. materialIndex: number;
  96158. /**
  96159. * Creates a new sorted particle
  96160. * @param materialIndex
  96161. */
  96162. constructor(ind: number, indLength: number, materialIndex: number);
  96163. }
  96164. }
  96165. declare module BABYLON {
  96166. /**
  96167. * @hidden
  96168. */
  96169. export class _MeshCollisionData {
  96170. _checkCollisions: boolean;
  96171. _collisionMask: number;
  96172. _collisionGroup: number;
  96173. _collider: Nullable<Collider>;
  96174. _oldPositionForCollisions: Vector3;
  96175. _diffPositionForCollisions: Vector3;
  96176. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96177. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96178. }
  96179. }
  96180. declare module BABYLON {
  96181. /** @hidden */
  96182. class _FacetDataStorage {
  96183. facetPositions: Vector3[];
  96184. facetNormals: Vector3[];
  96185. facetPartitioning: number[][];
  96186. facetNb: number;
  96187. partitioningSubdivisions: number;
  96188. partitioningBBoxRatio: number;
  96189. facetDataEnabled: boolean;
  96190. facetParameters: any;
  96191. bbSize: Vector3;
  96192. subDiv: {
  96193. max: number;
  96194. X: number;
  96195. Y: number;
  96196. Z: number;
  96197. };
  96198. facetDepthSort: boolean;
  96199. facetDepthSortEnabled: boolean;
  96200. depthSortedIndices: IndicesArray;
  96201. depthSortedFacets: {
  96202. ind: number;
  96203. sqDistance: number;
  96204. }[];
  96205. facetDepthSortFunction: (f1: {
  96206. ind: number;
  96207. sqDistance: number;
  96208. }, f2: {
  96209. ind: number;
  96210. sqDistance: number;
  96211. }) => number;
  96212. facetDepthSortFrom: Vector3;
  96213. facetDepthSortOrigin: Vector3;
  96214. invertedMatrix: Matrix;
  96215. }
  96216. /**
  96217. * @hidden
  96218. **/
  96219. class _InternalAbstractMeshDataInfo {
  96220. _hasVertexAlpha: boolean;
  96221. _useVertexColors: boolean;
  96222. _numBoneInfluencers: number;
  96223. _applyFog: boolean;
  96224. _receiveShadows: boolean;
  96225. _facetData: _FacetDataStorage;
  96226. _visibility: number;
  96227. _skeleton: Nullable<Skeleton>;
  96228. _layerMask: number;
  96229. _computeBonesUsingShaders: boolean;
  96230. _isActive: boolean;
  96231. _onlyForInstances: boolean;
  96232. _isActiveIntermediate: boolean;
  96233. _onlyForInstancesIntermediate: boolean;
  96234. _actAsRegularMesh: boolean;
  96235. }
  96236. /**
  96237. * Class used to store all common mesh properties
  96238. */
  96239. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96240. /** No occlusion */
  96241. static OCCLUSION_TYPE_NONE: number;
  96242. /** Occlusion set to optimisitic */
  96243. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96244. /** Occlusion set to strict */
  96245. static OCCLUSION_TYPE_STRICT: number;
  96246. /** Use an accurante occlusion algorithm */
  96247. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96248. /** Use a conservative occlusion algorithm */
  96249. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96250. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96251. * Test order :
  96252. * Is the bounding sphere outside the frustum ?
  96253. * If not, are the bounding box vertices outside the frustum ?
  96254. * It not, then the cullable object is in the frustum.
  96255. */
  96256. static readonly CULLINGSTRATEGY_STANDARD: number;
  96257. /** Culling strategy : Bounding Sphere Only.
  96258. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96259. * It's also less accurate than the standard because some not visible objects can still be selected.
  96260. * Test : is the bounding sphere outside the frustum ?
  96261. * If not, then the cullable object is in the frustum.
  96262. */
  96263. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96264. /** Culling strategy : Optimistic Inclusion.
  96265. * This in an inclusion test first, then the standard exclusion test.
  96266. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96267. * 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.
  96268. * Anyway, it's as accurate as the standard strategy.
  96269. * Test :
  96270. * Is the cullable object bounding sphere center in the frustum ?
  96271. * If not, apply the default culling strategy.
  96272. */
  96273. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96274. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96275. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96276. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96277. * 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.
  96278. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96279. * Test :
  96280. * Is the cullable object bounding sphere center in the frustum ?
  96281. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96282. */
  96283. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96284. /**
  96285. * No billboard
  96286. */
  96287. static readonly BILLBOARDMODE_NONE: number;
  96288. /** Billboard on X axis */
  96289. static readonly BILLBOARDMODE_X: number;
  96290. /** Billboard on Y axis */
  96291. static readonly BILLBOARDMODE_Y: number;
  96292. /** Billboard on Z axis */
  96293. static readonly BILLBOARDMODE_Z: number;
  96294. /** Billboard on all axes */
  96295. static readonly BILLBOARDMODE_ALL: number;
  96296. /** Billboard on using position instead of orientation */
  96297. static readonly BILLBOARDMODE_USE_POSITION: number;
  96298. /** @hidden */
  96299. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96300. /**
  96301. * The culling strategy to use to check whether the mesh must be rendered or not.
  96302. * This value can be changed at any time and will be used on the next render mesh selection.
  96303. * The possible values are :
  96304. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96305. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96306. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96307. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96308. * Please read each static variable documentation to get details about the culling process.
  96309. * */
  96310. cullingStrategy: number;
  96311. /**
  96312. * Gets the number of facets in the mesh
  96313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96314. */
  96315. readonly facetNb: number;
  96316. /**
  96317. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96319. */
  96320. partitioningSubdivisions: number;
  96321. /**
  96322. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96323. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96325. */
  96326. partitioningBBoxRatio: number;
  96327. /**
  96328. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96329. * Works only for updatable meshes.
  96330. * Doesn't work with multi-materials
  96331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96332. */
  96333. mustDepthSortFacets: boolean;
  96334. /**
  96335. * The location (Vector3) where the facet depth sort must be computed from.
  96336. * By default, the active camera position.
  96337. * Used only when facet depth sort is enabled
  96338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96339. */
  96340. facetDepthSortFrom: Vector3;
  96341. /**
  96342. * gets a boolean indicating if facetData is enabled
  96343. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96344. */
  96345. readonly isFacetDataEnabled: boolean;
  96346. /** @hidden */
  96347. _updateNonUniformScalingState(value: boolean): boolean;
  96348. /**
  96349. * An event triggered when this mesh collides with another one
  96350. */
  96351. onCollideObservable: Observable<AbstractMesh>;
  96352. /** Set a function to call when this mesh collides with another one */
  96353. onCollide: () => void;
  96354. /**
  96355. * An event triggered when the collision's position changes
  96356. */
  96357. onCollisionPositionChangeObservable: Observable<Vector3>;
  96358. /** Set a function to call when the collision's position changes */
  96359. onCollisionPositionChange: () => void;
  96360. /**
  96361. * An event triggered when material is changed
  96362. */
  96363. onMaterialChangedObservable: Observable<AbstractMesh>;
  96364. /**
  96365. * Gets or sets the orientation for POV movement & rotation
  96366. */
  96367. definedFacingForward: boolean;
  96368. /** @hidden */
  96369. _occlusionQuery: Nullable<WebGLQuery>;
  96370. /** @hidden */
  96371. _renderingGroup: Nullable<RenderingGroup>;
  96372. /**
  96373. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96374. */
  96375. /**
  96376. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96377. */
  96378. visibility: number;
  96379. /** Gets or sets the alpha index used to sort transparent meshes
  96380. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96381. */
  96382. alphaIndex: number;
  96383. /**
  96384. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96385. */
  96386. isVisible: boolean;
  96387. /**
  96388. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96389. */
  96390. isPickable: boolean;
  96391. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96392. showSubMeshesBoundingBox: boolean;
  96393. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96394. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96395. */
  96396. isBlocker: boolean;
  96397. /**
  96398. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96399. */
  96400. enablePointerMoveEvents: boolean;
  96401. /**
  96402. * Specifies the rendering group id for this mesh (0 by default)
  96403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96404. */
  96405. renderingGroupId: number;
  96406. private _material;
  96407. /** Gets or sets current material */
  96408. material: Nullable<Material>;
  96409. /**
  96410. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96411. * @see http://doc.babylonjs.com/babylon101/shadows
  96412. */
  96413. receiveShadows: boolean;
  96414. /** Defines color to use when rendering outline */
  96415. outlineColor: Color3;
  96416. /** Define width to use when rendering outline */
  96417. outlineWidth: number;
  96418. /** Defines color to use when rendering overlay */
  96419. overlayColor: Color3;
  96420. /** Defines alpha to use when rendering overlay */
  96421. overlayAlpha: number;
  96422. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96423. hasVertexAlpha: boolean;
  96424. /** 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) */
  96425. useVertexColors: boolean;
  96426. /**
  96427. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96428. */
  96429. computeBonesUsingShaders: boolean;
  96430. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96431. numBoneInfluencers: number;
  96432. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96433. applyFog: boolean;
  96434. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96435. useOctreeForRenderingSelection: boolean;
  96436. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96437. useOctreeForPicking: boolean;
  96438. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96439. useOctreeForCollisions: boolean;
  96440. /**
  96441. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96442. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96443. */
  96444. layerMask: number;
  96445. /**
  96446. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96447. */
  96448. alwaysSelectAsActiveMesh: boolean;
  96449. /**
  96450. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96451. */
  96452. doNotSyncBoundingInfo: boolean;
  96453. /**
  96454. * Gets or sets the current action manager
  96455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96456. */
  96457. actionManager: Nullable<AbstractActionManager>;
  96458. private _meshCollisionData;
  96459. /**
  96460. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96461. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96462. */
  96463. ellipsoid: Vector3;
  96464. /**
  96465. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96466. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96467. */
  96468. ellipsoidOffset: Vector3;
  96469. /**
  96470. * Gets or sets a collision mask used to mask collisions (default is -1).
  96471. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96472. */
  96473. collisionMask: number;
  96474. /**
  96475. * Gets or sets the current collision group mask (-1 by default).
  96476. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96477. */
  96478. collisionGroup: number;
  96479. /**
  96480. * Defines edge width used when edgesRenderer is enabled
  96481. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96482. */
  96483. edgesWidth: number;
  96484. /**
  96485. * Defines edge color used when edgesRenderer is enabled
  96486. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96487. */
  96488. edgesColor: Color4;
  96489. /** @hidden */
  96490. _edgesRenderer: Nullable<IEdgesRenderer>;
  96491. /** @hidden */
  96492. _masterMesh: Nullable<AbstractMesh>;
  96493. /** @hidden */
  96494. _boundingInfo: Nullable<BoundingInfo>;
  96495. /** @hidden */
  96496. _renderId: number;
  96497. /**
  96498. * Gets or sets the list of subMeshes
  96499. * @see http://doc.babylonjs.com/how_to/multi_materials
  96500. */
  96501. subMeshes: SubMesh[];
  96502. /** @hidden */
  96503. _intersectionsInProgress: AbstractMesh[];
  96504. /** @hidden */
  96505. _unIndexed: boolean;
  96506. /** @hidden */
  96507. _lightSources: Light[];
  96508. /** Gets the list of lights affecting that mesh */
  96509. readonly lightSources: Light[];
  96510. /** @hidden */
  96511. readonly _positions: Nullable<Vector3[]>;
  96512. /** @hidden */
  96513. _waitingData: {
  96514. lods: Nullable<any>;
  96515. actions: Nullable<any>;
  96516. freezeWorldMatrix: Nullable<boolean>;
  96517. };
  96518. /** @hidden */
  96519. _bonesTransformMatrices: Nullable<Float32Array>;
  96520. /** @hidden */
  96521. _transformMatrixTexture: Nullable<RawTexture>;
  96522. /**
  96523. * Gets or sets a skeleton to apply skining transformations
  96524. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96525. */
  96526. skeleton: Nullable<Skeleton>;
  96527. /**
  96528. * An event triggered when the mesh is rebuilt.
  96529. */
  96530. onRebuildObservable: Observable<AbstractMesh>;
  96531. /**
  96532. * Creates a new AbstractMesh
  96533. * @param name defines the name of the mesh
  96534. * @param scene defines the hosting scene
  96535. */
  96536. constructor(name: string, scene?: Nullable<Scene>);
  96537. /**
  96538. * Returns the string "AbstractMesh"
  96539. * @returns "AbstractMesh"
  96540. */
  96541. getClassName(): string;
  96542. /**
  96543. * Gets a string representation of the current mesh
  96544. * @param fullDetails defines a boolean indicating if full details must be included
  96545. * @returns a string representation of the current mesh
  96546. */
  96547. toString(fullDetails?: boolean): string;
  96548. /**
  96549. * @hidden
  96550. */
  96551. protected _getEffectiveParent(): Nullable<Node>;
  96552. /** @hidden */
  96553. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96554. /** @hidden */
  96555. _rebuild(): void;
  96556. /** @hidden */
  96557. _resyncLightSources(): void;
  96558. /** @hidden */
  96559. _resyncLightSource(light: Light): void;
  96560. /** @hidden */
  96561. _unBindEffect(): void;
  96562. /** @hidden */
  96563. _removeLightSource(light: Light, dispose: boolean): void;
  96564. private _markSubMeshesAsDirty;
  96565. /** @hidden */
  96566. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  96567. /** @hidden */
  96568. _markSubMeshesAsAttributesDirty(): void;
  96569. /** @hidden */
  96570. _markSubMeshesAsMiscDirty(): void;
  96571. /**
  96572. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  96573. */
  96574. scaling: Vector3;
  96575. /**
  96576. * Returns true if the mesh is blocked. Implemented by child classes
  96577. */
  96578. readonly isBlocked: boolean;
  96579. /**
  96580. * Returns the mesh itself by default. Implemented by child classes
  96581. * @param camera defines the camera to use to pick the right LOD level
  96582. * @returns the currentAbstractMesh
  96583. */
  96584. getLOD(camera: Camera): Nullable<AbstractMesh>;
  96585. /**
  96586. * Returns 0 by default. Implemented by child classes
  96587. * @returns an integer
  96588. */
  96589. getTotalVertices(): number;
  96590. /**
  96591. * Returns a positive integer : the total number of indices in this mesh geometry.
  96592. * @returns the numner of indices or zero if the mesh has no geometry.
  96593. */
  96594. getTotalIndices(): number;
  96595. /**
  96596. * Returns null by default. Implemented by child classes
  96597. * @returns null
  96598. */
  96599. getIndices(): Nullable<IndicesArray>;
  96600. /**
  96601. * Returns the array of the requested vertex data kind. Implemented by child classes
  96602. * @param kind defines the vertex data kind to use
  96603. * @returns null
  96604. */
  96605. getVerticesData(kind: string): Nullable<FloatArray>;
  96606. /**
  96607. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96608. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96609. * Note that a new underlying VertexBuffer object is created each call.
  96610. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96611. * @param kind defines vertex data kind:
  96612. * * VertexBuffer.PositionKind
  96613. * * VertexBuffer.UVKind
  96614. * * VertexBuffer.UV2Kind
  96615. * * VertexBuffer.UV3Kind
  96616. * * VertexBuffer.UV4Kind
  96617. * * VertexBuffer.UV5Kind
  96618. * * VertexBuffer.UV6Kind
  96619. * * VertexBuffer.ColorKind
  96620. * * VertexBuffer.MatricesIndicesKind
  96621. * * VertexBuffer.MatricesIndicesExtraKind
  96622. * * VertexBuffer.MatricesWeightsKind
  96623. * * VertexBuffer.MatricesWeightsExtraKind
  96624. * @param data defines the data source
  96625. * @param updatable defines if the data must be flagged as updatable (or static)
  96626. * @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
  96627. * @returns the current mesh
  96628. */
  96629. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96630. /**
  96631. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96632. * If the mesh has no geometry, it is simply returned as it is.
  96633. * @param kind defines vertex data kind:
  96634. * * VertexBuffer.PositionKind
  96635. * * VertexBuffer.UVKind
  96636. * * VertexBuffer.UV2Kind
  96637. * * VertexBuffer.UV3Kind
  96638. * * VertexBuffer.UV4Kind
  96639. * * VertexBuffer.UV5Kind
  96640. * * VertexBuffer.UV6Kind
  96641. * * VertexBuffer.ColorKind
  96642. * * VertexBuffer.MatricesIndicesKind
  96643. * * VertexBuffer.MatricesIndicesExtraKind
  96644. * * VertexBuffer.MatricesWeightsKind
  96645. * * VertexBuffer.MatricesWeightsExtraKind
  96646. * @param data defines the data source
  96647. * @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
  96648. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  96649. * @returns the current mesh
  96650. */
  96651. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  96652. /**
  96653. * Sets the mesh indices,
  96654. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96655. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  96656. * @param totalVertices Defines the total number of vertices
  96657. * @returns the current mesh
  96658. */
  96659. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  96660. /**
  96661. * Gets a boolean indicating if specific vertex data is present
  96662. * @param kind defines the vertex data kind to use
  96663. * @returns true is data kind is present
  96664. */
  96665. isVerticesDataPresent(kind: string): boolean;
  96666. /**
  96667. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  96668. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  96669. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  96670. * @returns a BoundingInfo
  96671. */
  96672. getBoundingInfo(): BoundingInfo;
  96673. /**
  96674. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96675. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96676. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96677. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96678. * @returns the current mesh
  96679. */
  96680. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  96681. /**
  96682. * Overwrite the current bounding info
  96683. * @param boundingInfo defines the new bounding info
  96684. * @returns the current mesh
  96685. */
  96686. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  96687. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  96688. readonly useBones: boolean;
  96689. /** @hidden */
  96690. _preActivate(): void;
  96691. /** @hidden */
  96692. _preActivateForIntermediateRendering(renderId: number): void;
  96693. /** @hidden */
  96694. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96695. /** @hidden */
  96696. _postActivate(): void;
  96697. /** @hidden */
  96698. _freeze(): void;
  96699. /** @hidden */
  96700. _unFreeze(): void;
  96701. /**
  96702. * Gets the current world matrix
  96703. * @returns a Matrix
  96704. */
  96705. getWorldMatrix(): Matrix;
  96706. /** @hidden */
  96707. _getWorldMatrixDeterminant(): number;
  96708. /**
  96709. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  96710. */
  96711. readonly isAnInstance: boolean;
  96712. /**
  96713. * Gets a boolean indicating if this mesh has instances
  96714. */
  96715. readonly hasInstances: boolean;
  96716. /**
  96717. * Perform relative position change from the point of view of behind the front of the mesh.
  96718. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96719. * Supports definition of mesh facing forward or backward
  96720. * @param amountRight defines the distance on the right axis
  96721. * @param amountUp defines the distance on the up axis
  96722. * @param amountForward defines the distance on the forward axis
  96723. * @returns the current mesh
  96724. */
  96725. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  96726. /**
  96727. * Calculate relative position change from the point of view of behind the front of the mesh.
  96728. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96729. * Supports definition of mesh facing forward or backward
  96730. * @param amountRight defines the distance on the right axis
  96731. * @param amountUp defines the distance on the up axis
  96732. * @param amountForward defines the distance on the forward axis
  96733. * @returns the new displacement vector
  96734. */
  96735. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  96736. /**
  96737. * Perform relative rotation change from the point of view of behind the front of the mesh.
  96738. * Supports definition of mesh facing forward or backward
  96739. * @param flipBack defines the flip
  96740. * @param twirlClockwise defines the twirl
  96741. * @param tiltRight defines the tilt
  96742. * @returns the current mesh
  96743. */
  96744. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  96745. /**
  96746. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  96747. * Supports definition of mesh facing forward or backward.
  96748. * @param flipBack defines the flip
  96749. * @param twirlClockwise defines the twirl
  96750. * @param tiltRight defines the tilt
  96751. * @returns the new rotation vector
  96752. */
  96753. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  96754. /**
  96755. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96756. * This means the mesh underlying bounding box and sphere are recomputed.
  96757. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96758. * @returns the current mesh
  96759. */
  96760. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  96761. /** @hidden */
  96762. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  96763. /** @hidden */
  96764. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  96765. /** @hidden */
  96766. _updateBoundingInfo(): AbstractMesh;
  96767. /** @hidden */
  96768. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  96769. /** @hidden */
  96770. protected _afterComputeWorldMatrix(): void;
  96771. /** @hidden */
  96772. readonly _effectiveMesh: AbstractMesh;
  96773. /**
  96774. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96775. * A mesh is in the frustum if its bounding box intersects the frustum
  96776. * @param frustumPlanes defines the frustum to test
  96777. * @returns true if the mesh is in the frustum planes
  96778. */
  96779. isInFrustum(frustumPlanes: Plane[]): boolean;
  96780. /**
  96781. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  96782. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  96783. * @param frustumPlanes defines the frustum to test
  96784. * @returns true if the mesh is completely in the frustum planes
  96785. */
  96786. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96787. /**
  96788. * True if the mesh intersects another mesh or a SolidParticle object
  96789. * @param mesh defines a target mesh or SolidParticle to test
  96790. * @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)
  96791. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  96792. * @returns true if there is an intersection
  96793. */
  96794. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  96795. /**
  96796. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  96797. * @param point defines the point to test
  96798. * @returns true if there is an intersection
  96799. */
  96800. intersectsPoint(point: Vector3): boolean;
  96801. /**
  96802. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  96803. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96804. */
  96805. checkCollisions: boolean;
  96806. /**
  96807. * Gets Collider object used to compute collisions (not physics)
  96808. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96809. */
  96810. readonly collider: Nullable<Collider>;
  96811. /**
  96812. * Move the mesh using collision engine
  96813. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96814. * @param displacement defines the requested displacement vector
  96815. * @returns the current mesh
  96816. */
  96817. moveWithCollisions(displacement: Vector3): AbstractMesh;
  96818. private _onCollisionPositionChange;
  96819. /** @hidden */
  96820. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  96821. /** @hidden */
  96822. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  96823. /** @hidden */
  96824. _checkCollision(collider: Collider): AbstractMesh;
  96825. /** @hidden */
  96826. _generatePointsArray(): boolean;
  96827. /**
  96828. * Checks if the passed Ray intersects with the mesh
  96829. * @param ray defines the ray to use
  96830. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  96831. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96832. * @returns the picking info
  96833. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  96834. */
  96835. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  96836. /**
  96837. * Clones the current mesh
  96838. * @param name defines the mesh name
  96839. * @param newParent defines the new mesh parent
  96840. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  96841. * @returns the new mesh
  96842. */
  96843. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  96844. /**
  96845. * Disposes all the submeshes of the current meshnp
  96846. * @returns the current mesh
  96847. */
  96848. releaseSubMeshes(): AbstractMesh;
  96849. /**
  96850. * Releases resources associated with this abstract mesh.
  96851. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96852. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96853. */
  96854. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96855. /**
  96856. * Adds the passed mesh as a child to the current mesh
  96857. * @param mesh defines the child mesh
  96858. * @returns the current mesh
  96859. */
  96860. addChild(mesh: AbstractMesh): AbstractMesh;
  96861. /**
  96862. * Removes the passed mesh from the current mesh children list
  96863. * @param mesh defines the child mesh
  96864. * @returns the current mesh
  96865. */
  96866. removeChild(mesh: AbstractMesh): AbstractMesh;
  96867. /** @hidden */
  96868. private _initFacetData;
  96869. /**
  96870. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  96871. * This method can be called within the render loop.
  96872. * 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
  96873. * @returns the current mesh
  96874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96875. */
  96876. updateFacetData(): AbstractMesh;
  96877. /**
  96878. * Returns the facetLocalNormals array.
  96879. * The normals are expressed in the mesh local spac
  96880. * @returns an array of Vector3
  96881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96882. */
  96883. getFacetLocalNormals(): Vector3[];
  96884. /**
  96885. * Returns the facetLocalPositions array.
  96886. * The facet positions are expressed in the mesh local space
  96887. * @returns an array of Vector3
  96888. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96889. */
  96890. getFacetLocalPositions(): Vector3[];
  96891. /**
  96892. * Returns the facetLocalPartioning array
  96893. * @returns an array of array of numbers
  96894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96895. */
  96896. getFacetLocalPartitioning(): number[][];
  96897. /**
  96898. * Returns the i-th facet position in the world system.
  96899. * This method allocates a new Vector3 per call
  96900. * @param i defines the facet index
  96901. * @returns a new Vector3
  96902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96903. */
  96904. getFacetPosition(i: number): Vector3;
  96905. /**
  96906. * Sets the reference Vector3 with the i-th facet position in the world system
  96907. * @param i defines the facet index
  96908. * @param ref defines the target vector
  96909. * @returns the current mesh
  96910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96911. */
  96912. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  96913. /**
  96914. * Returns the i-th facet normal in the world system.
  96915. * This method allocates a new Vector3 per call
  96916. * @param i defines the facet index
  96917. * @returns a new Vector3
  96918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96919. */
  96920. getFacetNormal(i: number): Vector3;
  96921. /**
  96922. * Sets the reference Vector3 with the i-th facet normal in the world system
  96923. * @param i defines the facet index
  96924. * @param ref defines the target vector
  96925. * @returns the current mesh
  96926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96927. */
  96928. getFacetNormalToRef(i: number, ref: Vector3): this;
  96929. /**
  96930. * 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)
  96931. * @param x defines x coordinate
  96932. * @param y defines y coordinate
  96933. * @param z defines z coordinate
  96934. * @returns the array of facet indexes
  96935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96936. */
  96937. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  96938. /**
  96939. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  96940. * @param projected sets as the (x,y,z) world projection on the facet
  96941. * @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
  96942. * @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
  96943. * @param x defines x coordinate
  96944. * @param y defines y coordinate
  96945. * @param z defines z coordinate
  96946. * @returns the face index if found (or null instead)
  96947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96948. */
  96949. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96950. /**
  96951. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  96952. * @param projected sets as the (x,y,z) local projection on the facet
  96953. * @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
  96954. * @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
  96955. * @param x defines x coordinate
  96956. * @param y defines y coordinate
  96957. * @param z defines z coordinate
  96958. * @returns the face index if found (or null instead)
  96959. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96960. */
  96961. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96962. /**
  96963. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  96964. * @returns the parameters
  96965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96966. */
  96967. getFacetDataParameters(): any;
  96968. /**
  96969. * Disables the feature FacetData and frees the related memory
  96970. * @returns the current mesh
  96971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96972. */
  96973. disableFacetData(): AbstractMesh;
  96974. /**
  96975. * Updates the AbstractMesh indices array
  96976. * @param indices defines the data source
  96977. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  96978. * @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)
  96979. * @returns the current mesh
  96980. */
  96981. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  96982. /**
  96983. * Creates new normals data for the mesh
  96984. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  96985. * @returns the current mesh
  96986. */
  96987. createNormals(updatable: boolean): AbstractMesh;
  96988. /**
  96989. * Align the mesh with a normal
  96990. * @param normal defines the normal to use
  96991. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  96992. * @returns the current mesh
  96993. */
  96994. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  96995. /** @hidden */
  96996. _checkOcclusionQuery(): boolean;
  96997. /**
  96998. * Disables the mesh edge rendering mode
  96999. * @returns the currentAbstractMesh
  97000. */
  97001. disableEdgesRendering(): AbstractMesh;
  97002. /**
  97003. * Enables the edge rendering mode on the mesh.
  97004. * This mode makes the mesh edges visible
  97005. * @param epsilon defines the maximal distance between two angles to detect a face
  97006. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97007. * @returns the currentAbstractMesh
  97008. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97009. */
  97010. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97011. }
  97012. }
  97013. declare module BABYLON {
  97014. /**
  97015. * Interface used to define ActionEvent
  97016. */
  97017. export interface IActionEvent {
  97018. /** The mesh or sprite that triggered the action */
  97019. source: any;
  97020. /** The X mouse cursor position at the time of the event */
  97021. pointerX: number;
  97022. /** The Y mouse cursor position at the time of the event */
  97023. pointerY: number;
  97024. /** The mesh that is currently pointed at (can be null) */
  97025. meshUnderPointer: Nullable<AbstractMesh>;
  97026. /** the original (browser) event that triggered the ActionEvent */
  97027. sourceEvent?: any;
  97028. /** additional data for the event */
  97029. additionalData?: any;
  97030. }
  97031. /**
  97032. * ActionEvent is the event being sent when an action is triggered.
  97033. */
  97034. export class ActionEvent implements IActionEvent {
  97035. /** The mesh or sprite that triggered the action */
  97036. source: any;
  97037. /** The X mouse cursor position at the time of the event */
  97038. pointerX: number;
  97039. /** The Y mouse cursor position at the time of the event */
  97040. pointerY: number;
  97041. /** The mesh that is currently pointed at (can be null) */
  97042. meshUnderPointer: Nullable<AbstractMesh>;
  97043. /** the original (browser) event that triggered the ActionEvent */
  97044. sourceEvent?: any;
  97045. /** additional data for the event */
  97046. additionalData?: any;
  97047. /**
  97048. * Creates a new ActionEvent
  97049. * @param source The mesh or sprite that triggered the action
  97050. * @param pointerX The X mouse cursor position at the time of the event
  97051. * @param pointerY The Y mouse cursor position at the time of the event
  97052. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97053. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97054. * @param additionalData additional data for the event
  97055. */
  97056. constructor(
  97057. /** The mesh or sprite that triggered the action */
  97058. source: any,
  97059. /** The X mouse cursor position at the time of the event */
  97060. pointerX: number,
  97061. /** The Y mouse cursor position at the time of the event */
  97062. pointerY: number,
  97063. /** The mesh that is currently pointed at (can be null) */
  97064. meshUnderPointer: Nullable<AbstractMesh>,
  97065. /** the original (browser) event that triggered the ActionEvent */
  97066. sourceEvent?: any,
  97067. /** additional data for the event */
  97068. additionalData?: any);
  97069. /**
  97070. * Helper function to auto-create an ActionEvent from a source mesh.
  97071. * @param source The source mesh that triggered the event
  97072. * @param evt The original (browser) event
  97073. * @param additionalData additional data for the event
  97074. * @returns the new ActionEvent
  97075. */
  97076. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97077. /**
  97078. * Helper function to auto-create an ActionEvent from a source sprite
  97079. * @param source The source sprite that triggered the event
  97080. * @param scene Scene associated with the sprite
  97081. * @param evt The original (browser) event
  97082. * @param additionalData additional data for the event
  97083. * @returns the new ActionEvent
  97084. */
  97085. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97086. /**
  97087. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97088. * @param scene the scene where the event occurred
  97089. * @param evt The original (browser) event
  97090. * @returns the new ActionEvent
  97091. */
  97092. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97093. /**
  97094. * Helper function to auto-create an ActionEvent from a primitive
  97095. * @param prim defines the target primitive
  97096. * @param pointerPos defines the pointer position
  97097. * @param evt The original (browser) event
  97098. * @param additionalData additional data for the event
  97099. * @returns the new ActionEvent
  97100. */
  97101. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97102. }
  97103. }
  97104. declare module BABYLON {
  97105. /**
  97106. * Abstract class used to decouple action Manager from scene and meshes.
  97107. * Do not instantiate.
  97108. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97109. */
  97110. export abstract class AbstractActionManager implements IDisposable {
  97111. /** Gets the list of active triggers */
  97112. static Triggers: {
  97113. [key: string]: number;
  97114. };
  97115. /** Gets the cursor to use when hovering items */
  97116. hoverCursor: string;
  97117. /** Gets the list of actions */
  97118. actions: IAction[];
  97119. /**
  97120. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97121. */
  97122. isRecursive: boolean;
  97123. /**
  97124. * Releases all associated resources
  97125. */
  97126. abstract dispose(): void;
  97127. /**
  97128. * Does this action manager has pointer triggers
  97129. */
  97130. abstract readonly hasPointerTriggers: boolean;
  97131. /**
  97132. * Does this action manager has pick triggers
  97133. */
  97134. abstract readonly hasPickTriggers: boolean;
  97135. /**
  97136. * Process a specific trigger
  97137. * @param trigger defines the trigger to process
  97138. * @param evt defines the event details to be processed
  97139. */
  97140. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97141. /**
  97142. * Does this action manager handles actions of any of the given triggers
  97143. * @param triggers defines the triggers to be tested
  97144. * @return a boolean indicating whether one (or more) of the triggers is handled
  97145. */
  97146. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97147. /**
  97148. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97149. * speed.
  97150. * @param triggerA defines the trigger to be tested
  97151. * @param triggerB defines the trigger to be tested
  97152. * @return a boolean indicating whether one (or more) of the triggers is handled
  97153. */
  97154. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97155. /**
  97156. * Does this action manager handles actions of a given trigger
  97157. * @param trigger defines the trigger to be tested
  97158. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97159. * @return whether the trigger is handled
  97160. */
  97161. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97162. /**
  97163. * Serialize this manager to a JSON object
  97164. * @param name defines the property name to store this manager
  97165. * @returns a JSON representation of this manager
  97166. */
  97167. abstract serialize(name: string): any;
  97168. /**
  97169. * Registers an action to this action manager
  97170. * @param action defines the action to be registered
  97171. * @return the action amended (prepared) after registration
  97172. */
  97173. abstract registerAction(action: IAction): Nullable<IAction>;
  97174. /**
  97175. * Unregisters an action to this action manager
  97176. * @param action defines the action to be unregistered
  97177. * @return a boolean indicating whether the action has been unregistered
  97178. */
  97179. abstract unregisterAction(action: IAction): Boolean;
  97180. /**
  97181. * Does exist one action manager with at least one trigger
  97182. **/
  97183. static readonly HasTriggers: boolean;
  97184. /**
  97185. * Does exist one action manager with at least one pick trigger
  97186. **/
  97187. static readonly HasPickTriggers: boolean;
  97188. /**
  97189. * Does exist one action manager that handles actions of a given trigger
  97190. * @param trigger defines the trigger to be tested
  97191. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97192. **/
  97193. static HasSpecificTrigger(trigger: number): boolean;
  97194. }
  97195. }
  97196. declare module BABYLON {
  97197. /**
  97198. * Defines how a node can be built from a string name.
  97199. */
  97200. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97201. /**
  97202. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97203. */
  97204. export class Node implements IBehaviorAware<Node> {
  97205. /** @hidden */
  97206. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97207. private static _NodeConstructors;
  97208. /**
  97209. * Add a new node constructor
  97210. * @param type defines the type name of the node to construct
  97211. * @param constructorFunc defines the constructor function
  97212. */
  97213. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97214. /**
  97215. * Returns a node constructor based on type name
  97216. * @param type defines the type name
  97217. * @param name defines the new node name
  97218. * @param scene defines the hosting scene
  97219. * @param options defines optional options to transmit to constructors
  97220. * @returns the new constructor or null
  97221. */
  97222. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97223. /**
  97224. * Gets or sets the name of the node
  97225. */
  97226. name: string;
  97227. /**
  97228. * Gets or sets the id of the node
  97229. */
  97230. id: string;
  97231. /**
  97232. * Gets or sets the unique id of the node
  97233. */
  97234. uniqueId: number;
  97235. /**
  97236. * Gets or sets a string used to store user defined state for the node
  97237. */
  97238. state: string;
  97239. /**
  97240. * Gets or sets an object used to store user defined information for the node
  97241. */
  97242. metadata: any;
  97243. /**
  97244. * For internal use only. Please do not use.
  97245. */
  97246. reservedDataStore: any;
  97247. /**
  97248. * List of inspectable custom properties (used by the Inspector)
  97249. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97250. */
  97251. inspectableCustomProperties: IInspectable[];
  97252. private _doNotSerialize;
  97253. /**
  97254. * Gets or sets a boolean used to define if the node must be serialized
  97255. */
  97256. doNotSerialize: boolean;
  97257. /** @hidden */
  97258. _isDisposed: boolean;
  97259. /**
  97260. * Gets a list of Animations associated with the node
  97261. */
  97262. animations: Animation[];
  97263. protected _ranges: {
  97264. [name: string]: Nullable<AnimationRange>;
  97265. };
  97266. /**
  97267. * Callback raised when the node is ready to be used
  97268. */
  97269. onReady: Nullable<(node: Node) => void>;
  97270. private _isEnabled;
  97271. private _isParentEnabled;
  97272. private _isReady;
  97273. /** @hidden */
  97274. _currentRenderId: number;
  97275. private _parentUpdateId;
  97276. /** @hidden */
  97277. _childUpdateId: number;
  97278. /** @hidden */
  97279. _waitingParentId: Nullable<string>;
  97280. /** @hidden */
  97281. _scene: Scene;
  97282. /** @hidden */
  97283. _cache: any;
  97284. private _parentNode;
  97285. private _children;
  97286. /** @hidden */
  97287. _worldMatrix: Matrix;
  97288. /** @hidden */
  97289. _worldMatrixDeterminant: number;
  97290. /** @hidden */
  97291. _worldMatrixDeterminantIsDirty: boolean;
  97292. /** @hidden */
  97293. private _sceneRootNodesIndex;
  97294. /**
  97295. * Gets a boolean indicating if the node has been disposed
  97296. * @returns true if the node was disposed
  97297. */
  97298. isDisposed(): boolean;
  97299. /**
  97300. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97301. * @see https://doc.babylonjs.com/how_to/parenting
  97302. */
  97303. parent: Nullable<Node>;
  97304. /** @hidden */
  97305. _addToSceneRootNodes(): void;
  97306. /** @hidden */
  97307. _removeFromSceneRootNodes(): void;
  97308. private _animationPropertiesOverride;
  97309. /**
  97310. * Gets or sets the animation properties override
  97311. */
  97312. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97313. /**
  97314. * Gets a string idenfifying the name of the class
  97315. * @returns "Node" string
  97316. */
  97317. getClassName(): string;
  97318. /** @hidden */
  97319. readonly _isNode: boolean;
  97320. /**
  97321. * An event triggered when the mesh is disposed
  97322. */
  97323. onDisposeObservable: Observable<Node>;
  97324. private _onDisposeObserver;
  97325. /**
  97326. * Sets a callback that will be raised when the node will be disposed
  97327. */
  97328. onDispose: () => void;
  97329. /**
  97330. * Creates a new Node
  97331. * @param name the name and id to be given to this node
  97332. * @param scene the scene this node will be added to
  97333. */
  97334. constructor(name: string, scene?: Nullable<Scene>);
  97335. /**
  97336. * Gets the scene of the node
  97337. * @returns a scene
  97338. */
  97339. getScene(): Scene;
  97340. /**
  97341. * Gets the engine of the node
  97342. * @returns a Engine
  97343. */
  97344. getEngine(): Engine;
  97345. private _behaviors;
  97346. /**
  97347. * Attach a behavior to the node
  97348. * @see http://doc.babylonjs.com/features/behaviour
  97349. * @param behavior defines the behavior to attach
  97350. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97351. * @returns the current Node
  97352. */
  97353. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97354. /**
  97355. * Remove an attached behavior
  97356. * @see http://doc.babylonjs.com/features/behaviour
  97357. * @param behavior defines the behavior to attach
  97358. * @returns the current Node
  97359. */
  97360. removeBehavior(behavior: Behavior<Node>): Node;
  97361. /**
  97362. * Gets the list of attached behaviors
  97363. * @see http://doc.babylonjs.com/features/behaviour
  97364. */
  97365. readonly behaviors: Behavior<Node>[];
  97366. /**
  97367. * Gets an attached behavior by name
  97368. * @param name defines the name of the behavior to look for
  97369. * @see http://doc.babylonjs.com/features/behaviour
  97370. * @returns null if behavior was not found else the requested behavior
  97371. */
  97372. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97373. /**
  97374. * Returns the latest update of the World matrix
  97375. * @returns a Matrix
  97376. */
  97377. getWorldMatrix(): Matrix;
  97378. /** @hidden */
  97379. _getWorldMatrixDeterminant(): number;
  97380. /**
  97381. * Returns directly the latest state of the mesh World matrix.
  97382. * A Matrix is returned.
  97383. */
  97384. readonly worldMatrixFromCache: Matrix;
  97385. /** @hidden */
  97386. _initCache(): void;
  97387. /** @hidden */
  97388. updateCache(force?: boolean): void;
  97389. /** @hidden */
  97390. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97391. /** @hidden */
  97392. _updateCache(ignoreParentClass?: boolean): void;
  97393. /** @hidden */
  97394. _isSynchronized(): boolean;
  97395. /** @hidden */
  97396. _markSyncedWithParent(): void;
  97397. /** @hidden */
  97398. isSynchronizedWithParent(): boolean;
  97399. /** @hidden */
  97400. isSynchronized(): boolean;
  97401. /**
  97402. * Is this node ready to be used/rendered
  97403. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97404. * @return true if the node is ready
  97405. */
  97406. isReady(completeCheck?: boolean): boolean;
  97407. /**
  97408. * Is this node enabled?
  97409. * 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
  97410. * @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
  97411. * @return whether this node (and its parent) is enabled
  97412. */
  97413. isEnabled(checkAncestors?: boolean): boolean;
  97414. /** @hidden */
  97415. protected _syncParentEnabledState(): void;
  97416. /**
  97417. * Set the enabled state of this node
  97418. * @param value defines the new enabled state
  97419. */
  97420. setEnabled(value: boolean): void;
  97421. /**
  97422. * Is this node a descendant of the given node?
  97423. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97424. * @param ancestor defines the parent node to inspect
  97425. * @returns a boolean indicating if this node is a descendant of the given node
  97426. */
  97427. isDescendantOf(ancestor: Node): boolean;
  97428. /** @hidden */
  97429. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97430. /**
  97431. * Will return all nodes that have this node as ascendant
  97432. * @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
  97433. * @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
  97434. * @return all children nodes of all types
  97435. */
  97436. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97437. /**
  97438. * Get all child-meshes of this node
  97439. * @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)
  97440. * @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
  97441. * @returns an array of AbstractMesh
  97442. */
  97443. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97444. /**
  97445. * Get all direct children of this node
  97446. * @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
  97447. * @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)
  97448. * @returns an array of Node
  97449. */
  97450. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97451. /** @hidden */
  97452. _setReady(state: boolean): void;
  97453. /**
  97454. * Get an animation by name
  97455. * @param name defines the name of the animation to look for
  97456. * @returns null if not found else the requested animation
  97457. */
  97458. getAnimationByName(name: string): Nullable<Animation>;
  97459. /**
  97460. * Creates an animation range for this node
  97461. * @param name defines the name of the range
  97462. * @param from defines the starting key
  97463. * @param to defines the end key
  97464. */
  97465. createAnimationRange(name: string, from: number, to: number): void;
  97466. /**
  97467. * Delete a specific animation range
  97468. * @param name defines the name of the range to delete
  97469. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97470. */
  97471. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97472. /**
  97473. * Get an animation range by name
  97474. * @param name defines the name of the animation range to look for
  97475. * @returns null if not found else the requested animation range
  97476. */
  97477. getAnimationRange(name: string): Nullable<AnimationRange>;
  97478. /**
  97479. * Gets the list of all animation ranges defined on this node
  97480. * @returns an array
  97481. */
  97482. getAnimationRanges(): Nullable<AnimationRange>[];
  97483. /**
  97484. * Will start the animation sequence
  97485. * @param name defines the range frames for animation sequence
  97486. * @param loop defines if the animation should loop (false by default)
  97487. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97488. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97489. * @returns the object created for this animation. If range does not exist, it will return null
  97490. */
  97491. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97492. /**
  97493. * Serialize animation ranges into a JSON compatible object
  97494. * @returns serialization object
  97495. */
  97496. serializeAnimationRanges(): any;
  97497. /**
  97498. * Computes the world matrix of the node
  97499. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97500. * @returns the world matrix
  97501. */
  97502. computeWorldMatrix(force?: boolean): Matrix;
  97503. /**
  97504. * Releases resources associated with this node.
  97505. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97506. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97507. */
  97508. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97509. /**
  97510. * Parse animation range data from a serialization object and store them into a given node
  97511. * @param node defines where to store the animation ranges
  97512. * @param parsedNode defines the serialization object to read data from
  97513. * @param scene defines the hosting scene
  97514. */
  97515. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97516. /**
  97517. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97518. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97519. * @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
  97520. * @returns the new bounding vectors
  97521. */
  97522. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97523. min: Vector3;
  97524. max: Vector3;
  97525. };
  97526. }
  97527. }
  97528. declare module BABYLON {
  97529. /**
  97530. * @hidden
  97531. */
  97532. export class _IAnimationState {
  97533. key: number;
  97534. repeatCount: number;
  97535. workValue?: any;
  97536. loopMode?: number;
  97537. offsetValue?: any;
  97538. highLimitValue?: any;
  97539. }
  97540. /**
  97541. * Class used to store any kind of animation
  97542. */
  97543. export class Animation {
  97544. /**Name of the animation */
  97545. name: string;
  97546. /**Property to animate */
  97547. targetProperty: string;
  97548. /**The frames per second of the animation */
  97549. framePerSecond: number;
  97550. /**The data type of the animation */
  97551. dataType: number;
  97552. /**The loop mode of the animation */
  97553. loopMode?: number | undefined;
  97554. /**Specifies if blending should be enabled */
  97555. enableBlending?: boolean | undefined;
  97556. /**
  97557. * Use matrix interpolation instead of using direct key value when animating matrices
  97558. */
  97559. static AllowMatricesInterpolation: boolean;
  97560. /**
  97561. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  97562. */
  97563. static AllowMatrixDecomposeForInterpolation: boolean;
  97564. /**
  97565. * Stores the key frames of the animation
  97566. */
  97567. private _keys;
  97568. /**
  97569. * Stores the easing function of the animation
  97570. */
  97571. private _easingFunction;
  97572. /**
  97573. * @hidden Internal use only
  97574. */
  97575. _runtimeAnimations: RuntimeAnimation[];
  97576. /**
  97577. * The set of event that will be linked to this animation
  97578. */
  97579. private _events;
  97580. /**
  97581. * Stores an array of target property paths
  97582. */
  97583. targetPropertyPath: string[];
  97584. /**
  97585. * Stores the blending speed of the animation
  97586. */
  97587. blendingSpeed: number;
  97588. /**
  97589. * Stores the animation ranges for the animation
  97590. */
  97591. private _ranges;
  97592. /**
  97593. * @hidden Internal use
  97594. */
  97595. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  97596. /**
  97597. * Sets up an animation
  97598. * @param property The property to animate
  97599. * @param animationType The animation type to apply
  97600. * @param framePerSecond The frames per second of the animation
  97601. * @param easingFunction The easing function used in the animation
  97602. * @returns The created animation
  97603. */
  97604. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  97605. /**
  97606. * Create and start an animation on a node
  97607. * @param name defines the name of the global animation that will be run on all nodes
  97608. * @param node defines the root node where the animation will take place
  97609. * @param targetProperty defines property to animate
  97610. * @param framePerSecond defines the number of frame per second yo use
  97611. * @param totalFrame defines the number of frames in total
  97612. * @param from defines the initial value
  97613. * @param to defines the final value
  97614. * @param loopMode defines which loop mode you want to use (off by default)
  97615. * @param easingFunction defines the easing function to use (linear by default)
  97616. * @param onAnimationEnd defines the callback to call when animation end
  97617. * @returns the animatable created for this animation
  97618. */
  97619. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97620. /**
  97621. * Create and start an animation on a node and its descendants
  97622. * @param name defines the name of the global animation that will be run on all nodes
  97623. * @param node defines the root node where the animation will take place
  97624. * @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
  97625. * @param targetProperty defines property to animate
  97626. * @param framePerSecond defines the number of frame per second to use
  97627. * @param totalFrame defines the number of frames in total
  97628. * @param from defines the initial value
  97629. * @param to defines the final value
  97630. * @param loopMode defines which loop mode you want to use (off by default)
  97631. * @param easingFunction defines the easing function to use (linear by default)
  97632. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97633. * @returns the list of animatables created for all nodes
  97634. * @example https://www.babylonjs-playground.com/#MH0VLI
  97635. */
  97636. 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[]>;
  97637. /**
  97638. * Creates a new animation, merges it with the existing animations and starts it
  97639. * @param name Name of the animation
  97640. * @param node Node which contains the scene that begins the animations
  97641. * @param targetProperty Specifies which property to animate
  97642. * @param framePerSecond The frames per second of the animation
  97643. * @param totalFrame The total number of frames
  97644. * @param from The frame at the beginning of the animation
  97645. * @param to The frame at the end of the animation
  97646. * @param loopMode Specifies the loop mode of the animation
  97647. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  97648. * @param onAnimationEnd Callback to run once the animation is complete
  97649. * @returns Nullable animation
  97650. */
  97651. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97652. /**
  97653. * Transition property of an host to the target Value
  97654. * @param property The property to transition
  97655. * @param targetValue The target Value of the property
  97656. * @param host The object where the property to animate belongs
  97657. * @param scene Scene used to run the animation
  97658. * @param frameRate Framerate (in frame/s) to use
  97659. * @param transition The transition type we want to use
  97660. * @param duration The duration of the animation, in milliseconds
  97661. * @param onAnimationEnd Callback trigger at the end of the animation
  97662. * @returns Nullable animation
  97663. */
  97664. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  97665. /**
  97666. * Return the array of runtime animations currently using this animation
  97667. */
  97668. readonly runtimeAnimations: RuntimeAnimation[];
  97669. /**
  97670. * Specifies if any of the runtime animations are currently running
  97671. */
  97672. readonly hasRunningRuntimeAnimations: boolean;
  97673. /**
  97674. * Initializes the animation
  97675. * @param name Name of the animation
  97676. * @param targetProperty Property to animate
  97677. * @param framePerSecond The frames per second of the animation
  97678. * @param dataType The data type of the animation
  97679. * @param loopMode The loop mode of the animation
  97680. * @param enableBlending Specifies if blending should be enabled
  97681. */
  97682. constructor(
  97683. /**Name of the animation */
  97684. name: string,
  97685. /**Property to animate */
  97686. targetProperty: string,
  97687. /**The frames per second of the animation */
  97688. framePerSecond: number,
  97689. /**The data type of the animation */
  97690. dataType: number,
  97691. /**The loop mode of the animation */
  97692. loopMode?: number | undefined,
  97693. /**Specifies if blending should be enabled */
  97694. enableBlending?: boolean | undefined);
  97695. /**
  97696. * Converts the animation to a string
  97697. * @param fullDetails support for multiple levels of logging within scene loading
  97698. * @returns String form of the animation
  97699. */
  97700. toString(fullDetails?: boolean): string;
  97701. /**
  97702. * Add an event to this animation
  97703. * @param event Event to add
  97704. */
  97705. addEvent(event: AnimationEvent): void;
  97706. /**
  97707. * Remove all events found at the given frame
  97708. * @param frame The frame to remove events from
  97709. */
  97710. removeEvents(frame: number): void;
  97711. /**
  97712. * Retrieves all the events from the animation
  97713. * @returns Events from the animation
  97714. */
  97715. getEvents(): AnimationEvent[];
  97716. /**
  97717. * Creates an animation range
  97718. * @param name Name of the animation range
  97719. * @param from Starting frame of the animation range
  97720. * @param to Ending frame of the animation
  97721. */
  97722. createRange(name: string, from: number, to: number): void;
  97723. /**
  97724. * Deletes an animation range by name
  97725. * @param name Name of the animation range to delete
  97726. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  97727. */
  97728. deleteRange(name: string, deleteFrames?: boolean): void;
  97729. /**
  97730. * Gets the animation range by name, or null if not defined
  97731. * @param name Name of the animation range
  97732. * @returns Nullable animation range
  97733. */
  97734. getRange(name: string): Nullable<AnimationRange>;
  97735. /**
  97736. * Gets the key frames from the animation
  97737. * @returns The key frames of the animation
  97738. */
  97739. getKeys(): Array<IAnimationKey>;
  97740. /**
  97741. * Gets the highest frame rate of the animation
  97742. * @returns Highest frame rate of the animation
  97743. */
  97744. getHighestFrame(): number;
  97745. /**
  97746. * Gets the easing function of the animation
  97747. * @returns Easing function of the animation
  97748. */
  97749. getEasingFunction(): IEasingFunction;
  97750. /**
  97751. * Sets the easing function of the animation
  97752. * @param easingFunction A custom mathematical formula for animation
  97753. */
  97754. setEasingFunction(easingFunction: EasingFunction): void;
  97755. /**
  97756. * Interpolates a scalar linearly
  97757. * @param startValue Start value of the animation curve
  97758. * @param endValue End value of the animation curve
  97759. * @param gradient Scalar amount to interpolate
  97760. * @returns Interpolated scalar value
  97761. */
  97762. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  97763. /**
  97764. * Interpolates a scalar cubically
  97765. * @param startValue Start value of the animation curve
  97766. * @param outTangent End tangent of the animation
  97767. * @param endValue End value of the animation curve
  97768. * @param inTangent Start tangent of the animation curve
  97769. * @param gradient Scalar amount to interpolate
  97770. * @returns Interpolated scalar value
  97771. */
  97772. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  97773. /**
  97774. * Interpolates a quaternion using a spherical linear interpolation
  97775. * @param startValue Start value of the animation curve
  97776. * @param endValue End value of the animation curve
  97777. * @param gradient Scalar amount to interpolate
  97778. * @returns Interpolated quaternion value
  97779. */
  97780. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  97781. /**
  97782. * Interpolates a quaternion cubically
  97783. * @param startValue Start value of the animation curve
  97784. * @param outTangent End tangent of the animation curve
  97785. * @param endValue End value of the animation curve
  97786. * @param inTangent Start tangent of the animation curve
  97787. * @param gradient Scalar amount to interpolate
  97788. * @returns Interpolated quaternion value
  97789. */
  97790. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  97791. /**
  97792. * Interpolates a Vector3 linearl
  97793. * @param startValue Start value of the animation curve
  97794. * @param endValue End value of the animation curve
  97795. * @param gradient Scalar amount to interpolate
  97796. * @returns Interpolated scalar value
  97797. */
  97798. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  97799. /**
  97800. * Interpolates a Vector3 cubically
  97801. * @param startValue Start value of the animation curve
  97802. * @param outTangent End tangent of the animation
  97803. * @param endValue End value of the animation curve
  97804. * @param inTangent Start tangent of the animation curve
  97805. * @param gradient Scalar amount to interpolate
  97806. * @returns InterpolatedVector3 value
  97807. */
  97808. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  97809. /**
  97810. * Interpolates a Vector2 linearly
  97811. * @param startValue Start value of the animation curve
  97812. * @param endValue End value of the animation curve
  97813. * @param gradient Scalar amount to interpolate
  97814. * @returns Interpolated Vector2 value
  97815. */
  97816. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  97817. /**
  97818. * Interpolates a Vector2 cubically
  97819. * @param startValue Start value of the animation curve
  97820. * @param outTangent End tangent of the animation
  97821. * @param endValue End value of the animation curve
  97822. * @param inTangent Start tangent of the animation curve
  97823. * @param gradient Scalar amount to interpolate
  97824. * @returns Interpolated Vector2 value
  97825. */
  97826. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  97827. /**
  97828. * Interpolates a size linearly
  97829. * @param startValue Start value of the animation curve
  97830. * @param endValue End value of the animation curve
  97831. * @param gradient Scalar amount to interpolate
  97832. * @returns Interpolated Size value
  97833. */
  97834. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  97835. /**
  97836. * Interpolates a Color3 linearly
  97837. * @param startValue Start value of the animation curve
  97838. * @param endValue End value of the animation curve
  97839. * @param gradient Scalar amount to interpolate
  97840. * @returns Interpolated Color3 value
  97841. */
  97842. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  97843. /**
  97844. * Interpolates a Color4 linearly
  97845. * @param startValue Start value of the animation curve
  97846. * @param endValue End value of the animation curve
  97847. * @param gradient Scalar amount to interpolate
  97848. * @returns Interpolated Color3 value
  97849. */
  97850. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  97851. /**
  97852. * @hidden Internal use only
  97853. */
  97854. _getKeyValue(value: any): any;
  97855. /**
  97856. * @hidden Internal use only
  97857. */
  97858. _interpolate(currentFrame: number, state: _IAnimationState): any;
  97859. /**
  97860. * Defines the function to use to interpolate matrices
  97861. * @param startValue defines the start matrix
  97862. * @param endValue defines the end matrix
  97863. * @param gradient defines the gradient between both matrices
  97864. * @param result defines an optional target matrix where to store the interpolation
  97865. * @returns the interpolated matrix
  97866. */
  97867. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  97868. /**
  97869. * Makes a copy of the animation
  97870. * @returns Cloned animation
  97871. */
  97872. clone(): Animation;
  97873. /**
  97874. * Sets the key frames of the animation
  97875. * @param values The animation key frames to set
  97876. */
  97877. setKeys(values: Array<IAnimationKey>): void;
  97878. /**
  97879. * Serializes the animation to an object
  97880. * @returns Serialized object
  97881. */
  97882. serialize(): any;
  97883. /**
  97884. * Float animation type
  97885. */
  97886. static readonly ANIMATIONTYPE_FLOAT: number;
  97887. /**
  97888. * Vector3 animation type
  97889. */
  97890. static readonly ANIMATIONTYPE_VECTOR3: number;
  97891. /**
  97892. * Quaternion animation type
  97893. */
  97894. static readonly ANIMATIONTYPE_QUATERNION: number;
  97895. /**
  97896. * Matrix animation type
  97897. */
  97898. static readonly ANIMATIONTYPE_MATRIX: number;
  97899. /**
  97900. * Color3 animation type
  97901. */
  97902. static readonly ANIMATIONTYPE_COLOR3: number;
  97903. /**
  97904. * Color3 animation type
  97905. */
  97906. static readonly ANIMATIONTYPE_COLOR4: number;
  97907. /**
  97908. * Vector2 animation type
  97909. */
  97910. static readonly ANIMATIONTYPE_VECTOR2: number;
  97911. /**
  97912. * Size animation type
  97913. */
  97914. static readonly ANIMATIONTYPE_SIZE: number;
  97915. /**
  97916. * Relative Loop Mode
  97917. */
  97918. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  97919. /**
  97920. * Cycle Loop Mode
  97921. */
  97922. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  97923. /**
  97924. * Constant Loop Mode
  97925. */
  97926. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  97927. /** @hidden */
  97928. static _UniversalLerp(left: any, right: any, amount: number): any;
  97929. /**
  97930. * Parses an animation object and creates an animation
  97931. * @param parsedAnimation Parsed animation object
  97932. * @returns Animation object
  97933. */
  97934. static Parse(parsedAnimation: any): Animation;
  97935. /**
  97936. * Appends the serialized animations from the source animations
  97937. * @param source Source containing the animations
  97938. * @param destination Target to store the animations
  97939. */
  97940. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97941. }
  97942. }
  97943. declare module BABYLON {
  97944. /**
  97945. * Interface containing an array of animations
  97946. */
  97947. export interface IAnimatable {
  97948. /**
  97949. * Array of animations
  97950. */
  97951. animations: Nullable<Array<Animation>>;
  97952. }
  97953. }
  97954. declare module BABYLON {
  97955. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  97956. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97957. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97958. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97959. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97960. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97961. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97962. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97963. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97964. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97965. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97966. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97967. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97968. /**
  97969. * Decorator used to define property that can be serialized as reference to a camera
  97970. * @param sourceName defines the name of the property to decorate
  97971. */
  97972. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97973. /**
  97974. * Class used to help serialization objects
  97975. */
  97976. export class SerializationHelper {
  97977. /** @hidden */
  97978. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  97979. /** @hidden */
  97980. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  97981. /** @hidden */
  97982. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  97983. /** @hidden */
  97984. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  97985. /**
  97986. * Appends the serialized animations from the source animations
  97987. * @param source Source containing the animations
  97988. * @param destination Target to store the animations
  97989. */
  97990. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97991. /**
  97992. * Static function used to serialized a specific entity
  97993. * @param entity defines the entity to serialize
  97994. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  97995. * @returns a JSON compatible object representing the serialization of the entity
  97996. */
  97997. static Serialize<T>(entity: T, serializationObject?: any): any;
  97998. /**
  97999. * Creates a new entity from a serialization data object
  98000. * @param creationFunction defines a function used to instanciated the new entity
  98001. * @param source defines the source serialization data
  98002. * @param scene defines the hosting scene
  98003. * @param rootUrl defines the root url for resources
  98004. * @returns a new entity
  98005. */
  98006. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  98007. /**
  98008. * Clones an object
  98009. * @param creationFunction defines the function used to instanciate the new object
  98010. * @param source defines the source object
  98011. * @returns the cloned object
  98012. */
  98013. static Clone<T>(creationFunction: () => T, source: T): T;
  98014. /**
  98015. * Instanciates a new object based on a source one (some data will be shared between both object)
  98016. * @param creationFunction defines the function used to instanciate the new object
  98017. * @param source defines the source object
  98018. * @returns the new object
  98019. */
  98020. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98021. }
  98022. }
  98023. declare module BABYLON {
  98024. /**
  98025. * Class used to manipulate GUIDs
  98026. */
  98027. export class GUID {
  98028. /**
  98029. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98030. * Be aware Math.random() could cause collisions, but:
  98031. * "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"
  98032. * @returns a pseudo random id
  98033. */
  98034. static RandomId(): string;
  98035. }
  98036. }
  98037. declare module BABYLON {
  98038. /**
  98039. * Base class of all the textures in babylon.
  98040. * It groups all the common properties the materials, post process, lights... might need
  98041. * in order to make a correct use of the texture.
  98042. */
  98043. export class BaseTexture implements IAnimatable {
  98044. /**
  98045. * Default anisotropic filtering level for the application.
  98046. * It is set to 4 as a good tradeoff between perf and quality.
  98047. */
  98048. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98049. /**
  98050. * Gets or sets the unique id of the texture
  98051. */
  98052. uniqueId: number;
  98053. /**
  98054. * Define the name of the texture.
  98055. */
  98056. name: string;
  98057. /**
  98058. * Gets or sets an object used to store user defined information.
  98059. */
  98060. metadata: any;
  98061. /**
  98062. * For internal use only. Please do not use.
  98063. */
  98064. reservedDataStore: any;
  98065. private _hasAlpha;
  98066. /**
  98067. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98068. */
  98069. hasAlpha: boolean;
  98070. /**
  98071. * Defines if the alpha value should be determined via the rgb values.
  98072. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98073. */
  98074. getAlphaFromRGB: boolean;
  98075. /**
  98076. * Intensity or strength of the texture.
  98077. * It is commonly used by materials to fine tune the intensity of the texture
  98078. */
  98079. level: number;
  98080. /**
  98081. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98082. * This is part of the texture as textures usually maps to one uv set.
  98083. */
  98084. coordinatesIndex: number;
  98085. private _coordinatesMode;
  98086. /**
  98087. * How a texture is mapped.
  98088. *
  98089. * | Value | Type | Description |
  98090. * | ----- | ----------------------------------- | ----------- |
  98091. * | 0 | EXPLICIT_MODE | |
  98092. * | 1 | SPHERICAL_MODE | |
  98093. * | 2 | PLANAR_MODE | |
  98094. * | 3 | CUBIC_MODE | |
  98095. * | 4 | PROJECTION_MODE | |
  98096. * | 5 | SKYBOX_MODE | |
  98097. * | 6 | INVCUBIC_MODE | |
  98098. * | 7 | EQUIRECTANGULAR_MODE | |
  98099. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98100. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98101. */
  98102. coordinatesMode: number;
  98103. /**
  98104. * | Value | Type | Description |
  98105. * | ----- | ------------------ | ----------- |
  98106. * | 0 | CLAMP_ADDRESSMODE | |
  98107. * | 1 | WRAP_ADDRESSMODE | |
  98108. * | 2 | MIRROR_ADDRESSMODE | |
  98109. */
  98110. wrapU: number;
  98111. /**
  98112. * | Value | Type | Description |
  98113. * | ----- | ------------------ | ----------- |
  98114. * | 0 | CLAMP_ADDRESSMODE | |
  98115. * | 1 | WRAP_ADDRESSMODE | |
  98116. * | 2 | MIRROR_ADDRESSMODE | |
  98117. */
  98118. wrapV: number;
  98119. /**
  98120. * | Value | Type | Description |
  98121. * | ----- | ------------------ | ----------- |
  98122. * | 0 | CLAMP_ADDRESSMODE | |
  98123. * | 1 | WRAP_ADDRESSMODE | |
  98124. * | 2 | MIRROR_ADDRESSMODE | |
  98125. */
  98126. wrapR: number;
  98127. /**
  98128. * With compliant hardware and browser (supporting anisotropic filtering)
  98129. * this defines the level of anisotropic filtering in the texture.
  98130. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98131. */
  98132. anisotropicFilteringLevel: number;
  98133. /**
  98134. * Define if the texture is a cube texture or if false a 2d texture.
  98135. */
  98136. isCube: boolean;
  98137. /**
  98138. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98139. */
  98140. is3D: boolean;
  98141. /**
  98142. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98143. */
  98144. is2DArray: boolean;
  98145. /**
  98146. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98147. * HDR texture are usually stored in linear space.
  98148. * This only impacts the PBR and Background materials
  98149. */
  98150. gammaSpace: boolean;
  98151. /**
  98152. * Gets or sets whether or not the texture contains RGBD data.
  98153. */
  98154. isRGBD: boolean;
  98155. /**
  98156. * Is Z inverted in the texture (useful in a cube texture).
  98157. */
  98158. invertZ: boolean;
  98159. /**
  98160. * Are mip maps generated for this texture or not.
  98161. */
  98162. readonly noMipmap: boolean;
  98163. /**
  98164. * @hidden
  98165. */
  98166. lodLevelInAlpha: boolean;
  98167. /**
  98168. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98169. */
  98170. lodGenerationOffset: number;
  98171. /**
  98172. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98173. */
  98174. lodGenerationScale: number;
  98175. /**
  98176. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98177. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98178. * average roughness values.
  98179. */
  98180. linearSpecularLOD: boolean;
  98181. /**
  98182. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98183. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98184. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98185. */
  98186. irradianceTexture: Nullable<BaseTexture>;
  98187. /**
  98188. * Define if the texture is a render target.
  98189. */
  98190. isRenderTarget: boolean;
  98191. /**
  98192. * Define the unique id of the texture in the scene.
  98193. */
  98194. readonly uid: string;
  98195. /**
  98196. * Return a string representation of the texture.
  98197. * @returns the texture as a string
  98198. */
  98199. toString(): string;
  98200. /**
  98201. * Get the class name of the texture.
  98202. * @returns "BaseTexture"
  98203. */
  98204. getClassName(): string;
  98205. /**
  98206. * Define the list of animation attached to the texture.
  98207. */
  98208. animations: Animation[];
  98209. /**
  98210. * An event triggered when the texture is disposed.
  98211. */
  98212. onDisposeObservable: Observable<BaseTexture>;
  98213. private _onDisposeObserver;
  98214. /**
  98215. * Callback triggered when the texture has been disposed.
  98216. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98217. */
  98218. onDispose: () => void;
  98219. /**
  98220. * Define the current state of the loading sequence when in delayed load mode.
  98221. */
  98222. delayLoadState: number;
  98223. private _scene;
  98224. /** @hidden */
  98225. _texture: Nullable<InternalTexture>;
  98226. private _uid;
  98227. /**
  98228. * Define if the texture is preventinga material to render or not.
  98229. * If not and the texture is not ready, the engine will use a default black texture instead.
  98230. */
  98231. readonly isBlocking: boolean;
  98232. /**
  98233. * Instantiates a new BaseTexture.
  98234. * Base class of all the textures in babylon.
  98235. * It groups all the common properties the materials, post process, lights... might need
  98236. * in order to make a correct use of the texture.
  98237. * @param scene Define the scene the texture blongs to
  98238. */
  98239. constructor(scene: Nullable<Scene>);
  98240. /**
  98241. * Get the scene the texture belongs to.
  98242. * @returns the scene or null if undefined
  98243. */
  98244. getScene(): Nullable<Scene>;
  98245. /**
  98246. * Get the texture transform matrix used to offset tile the texture for istance.
  98247. * @returns the transformation matrix
  98248. */
  98249. getTextureMatrix(): Matrix;
  98250. /**
  98251. * Get the texture reflection matrix used to rotate/transform the reflection.
  98252. * @returns the reflection matrix
  98253. */
  98254. getReflectionTextureMatrix(): Matrix;
  98255. /**
  98256. * Get the underlying lower level texture from Babylon.
  98257. * @returns the insternal texture
  98258. */
  98259. getInternalTexture(): Nullable<InternalTexture>;
  98260. /**
  98261. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98262. * @returns true if ready or not blocking
  98263. */
  98264. isReadyOrNotBlocking(): boolean;
  98265. /**
  98266. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98267. * @returns true if fully ready
  98268. */
  98269. isReady(): boolean;
  98270. private _cachedSize;
  98271. /**
  98272. * Get the size of the texture.
  98273. * @returns the texture size.
  98274. */
  98275. getSize(): ISize;
  98276. /**
  98277. * Get the base size of the texture.
  98278. * It can be different from the size if the texture has been resized for POT for instance
  98279. * @returns the base size
  98280. */
  98281. getBaseSize(): ISize;
  98282. /**
  98283. * Update the sampling mode of the texture.
  98284. * Default is Trilinear mode.
  98285. *
  98286. * | Value | Type | Description |
  98287. * | ----- | ------------------ | ----------- |
  98288. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98289. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98290. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98291. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98292. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98293. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98294. * | 7 | NEAREST_LINEAR | |
  98295. * | 8 | NEAREST_NEAREST | |
  98296. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98297. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98298. * | 11 | LINEAR_LINEAR | |
  98299. * | 12 | LINEAR_NEAREST | |
  98300. *
  98301. * > _mag_: magnification filter (close to the viewer)
  98302. * > _min_: minification filter (far from the viewer)
  98303. * > _mip_: filter used between mip map levels
  98304. *@param samplingMode Define the new sampling mode of the texture
  98305. */
  98306. updateSamplingMode(samplingMode: number): void;
  98307. /**
  98308. * Scales the texture if is `canRescale()`
  98309. * @param ratio the resize factor we want to use to rescale
  98310. */
  98311. scale(ratio: number): void;
  98312. /**
  98313. * Get if the texture can rescale.
  98314. */
  98315. readonly canRescale: boolean;
  98316. /** @hidden */
  98317. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98318. /** @hidden */
  98319. _rebuild(): void;
  98320. /**
  98321. * Triggers the load sequence in delayed load mode.
  98322. */
  98323. delayLoad(): void;
  98324. /**
  98325. * Clones the texture.
  98326. * @returns the cloned texture
  98327. */
  98328. clone(): Nullable<BaseTexture>;
  98329. /**
  98330. * Get the texture underlying type (INT, FLOAT...)
  98331. */
  98332. readonly textureType: number;
  98333. /**
  98334. * Get the texture underlying format (RGB, RGBA...)
  98335. */
  98336. readonly textureFormat: number;
  98337. /**
  98338. * Indicates that textures need to be re-calculated for all materials
  98339. */
  98340. protected _markAllSubMeshesAsTexturesDirty(): void;
  98341. /**
  98342. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98343. * This will returns an RGBA array buffer containing either in values (0-255) or
  98344. * float values (0-1) depending of the underlying buffer type.
  98345. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98346. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98347. * @param buffer defines a user defined buffer to fill with data (can be null)
  98348. * @returns The Array buffer containing the pixels data.
  98349. */
  98350. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98351. /**
  98352. * Release and destroy the underlying lower level texture aka internalTexture.
  98353. */
  98354. releaseInternalTexture(): void;
  98355. /** @hidden */
  98356. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98357. /** @hidden */
  98358. readonly _lodTextureMid: Nullable<BaseTexture>;
  98359. /** @hidden */
  98360. readonly _lodTextureLow: Nullable<BaseTexture>;
  98361. /**
  98362. * Dispose the texture and release its associated resources.
  98363. */
  98364. dispose(): void;
  98365. /**
  98366. * Serialize the texture into a JSON representation that can be parsed later on.
  98367. * @returns the JSON representation of the texture
  98368. */
  98369. serialize(): any;
  98370. /**
  98371. * Helper function to be called back once a list of texture contains only ready textures.
  98372. * @param textures Define the list of textures to wait for
  98373. * @param callback Define the callback triggered once the entire list will be ready
  98374. */
  98375. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98376. }
  98377. }
  98378. declare module BABYLON {
  98379. /**
  98380. * Options to be used when creating an effect.
  98381. */
  98382. export interface IEffectCreationOptions {
  98383. /**
  98384. * Atrributes that will be used in the shader.
  98385. */
  98386. attributes: string[];
  98387. /**
  98388. * Uniform varible names that will be set in the shader.
  98389. */
  98390. uniformsNames: string[];
  98391. /**
  98392. * Uniform buffer variable names that will be set in the shader.
  98393. */
  98394. uniformBuffersNames: string[];
  98395. /**
  98396. * Sampler texture variable names that will be set in the shader.
  98397. */
  98398. samplers: string[];
  98399. /**
  98400. * Define statements that will be set in the shader.
  98401. */
  98402. defines: any;
  98403. /**
  98404. * Possible fallbacks for this effect to improve performance when needed.
  98405. */
  98406. fallbacks: Nullable<IEffectFallbacks>;
  98407. /**
  98408. * Callback that will be called when the shader is compiled.
  98409. */
  98410. onCompiled: Nullable<(effect: Effect) => void>;
  98411. /**
  98412. * Callback that will be called if an error occurs during shader compilation.
  98413. */
  98414. onError: Nullable<(effect: Effect, errors: string) => void>;
  98415. /**
  98416. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98417. */
  98418. indexParameters?: any;
  98419. /**
  98420. * Max number of lights that can be used in the shader.
  98421. */
  98422. maxSimultaneousLights?: number;
  98423. /**
  98424. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98425. */
  98426. transformFeedbackVaryings?: Nullable<string[]>;
  98427. }
  98428. /**
  98429. * Effect containing vertex and fragment shader that can be executed on an object.
  98430. */
  98431. export class Effect implements IDisposable {
  98432. /**
  98433. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98434. */
  98435. static ShadersRepository: string;
  98436. /**
  98437. * Name of the effect.
  98438. */
  98439. name: any;
  98440. /**
  98441. * String container all the define statements that should be set on the shader.
  98442. */
  98443. defines: string;
  98444. /**
  98445. * Callback that will be called when the shader is compiled.
  98446. */
  98447. onCompiled: Nullable<(effect: Effect) => void>;
  98448. /**
  98449. * Callback that will be called if an error occurs during shader compilation.
  98450. */
  98451. onError: Nullable<(effect: Effect, errors: string) => void>;
  98452. /**
  98453. * Callback that will be called when effect is bound.
  98454. */
  98455. onBind: Nullable<(effect: Effect) => void>;
  98456. /**
  98457. * Unique ID of the effect.
  98458. */
  98459. uniqueId: number;
  98460. /**
  98461. * Observable that will be called when the shader is compiled.
  98462. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98463. */
  98464. onCompileObservable: Observable<Effect>;
  98465. /**
  98466. * Observable that will be called if an error occurs during shader compilation.
  98467. */
  98468. onErrorObservable: Observable<Effect>;
  98469. /** @hidden */
  98470. _onBindObservable: Nullable<Observable<Effect>>;
  98471. /**
  98472. * Observable that will be called when effect is bound.
  98473. */
  98474. readonly onBindObservable: Observable<Effect>;
  98475. /** @hidden */
  98476. _bonesComputationForcedToCPU: boolean;
  98477. private static _uniqueIdSeed;
  98478. private _engine;
  98479. private _uniformBuffersNames;
  98480. private _uniformsNames;
  98481. private _samplerList;
  98482. private _samplers;
  98483. private _isReady;
  98484. private _compilationError;
  98485. private _allFallbacksProcessed;
  98486. private _attributesNames;
  98487. private _attributes;
  98488. private _uniforms;
  98489. /**
  98490. * Key for the effect.
  98491. * @hidden
  98492. */
  98493. _key: string;
  98494. private _indexParameters;
  98495. private _fallbacks;
  98496. private _vertexSourceCode;
  98497. private _fragmentSourceCode;
  98498. private _vertexSourceCodeOverride;
  98499. private _fragmentSourceCodeOverride;
  98500. private _transformFeedbackVaryings;
  98501. /**
  98502. * Compiled shader to webGL program.
  98503. * @hidden
  98504. */
  98505. _pipelineContext: Nullable<IPipelineContext>;
  98506. private _valueCache;
  98507. private static _baseCache;
  98508. /**
  98509. * Instantiates an effect.
  98510. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98511. * @param baseName Name of the effect.
  98512. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98513. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98514. * @param samplers List of sampler variables that will be passed to the shader.
  98515. * @param engine Engine to be used to render the effect
  98516. * @param defines Define statements to be added to the shader.
  98517. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98518. * @param onCompiled Callback that will be called when the shader is compiled.
  98519. * @param onError Callback that will be called if an error occurs during shader compilation.
  98520. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98521. */
  98522. 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);
  98523. private _useFinalCode;
  98524. /**
  98525. * Unique key for this effect
  98526. */
  98527. readonly key: string;
  98528. /**
  98529. * If the effect has been compiled and prepared.
  98530. * @returns if the effect is compiled and prepared.
  98531. */
  98532. isReady(): boolean;
  98533. private _isReadyInternal;
  98534. /**
  98535. * The engine the effect was initialized with.
  98536. * @returns the engine.
  98537. */
  98538. getEngine(): Engine;
  98539. /**
  98540. * The pipeline context for this effect
  98541. * @returns the associated pipeline context
  98542. */
  98543. getPipelineContext(): Nullable<IPipelineContext>;
  98544. /**
  98545. * The set of names of attribute variables for the shader.
  98546. * @returns An array of attribute names.
  98547. */
  98548. getAttributesNames(): string[];
  98549. /**
  98550. * Returns the attribute at the given index.
  98551. * @param index The index of the attribute.
  98552. * @returns The location of the attribute.
  98553. */
  98554. getAttributeLocation(index: number): number;
  98555. /**
  98556. * Returns the attribute based on the name of the variable.
  98557. * @param name of the attribute to look up.
  98558. * @returns the attribute location.
  98559. */
  98560. getAttributeLocationByName(name: string): number;
  98561. /**
  98562. * The number of attributes.
  98563. * @returns the numnber of attributes.
  98564. */
  98565. getAttributesCount(): number;
  98566. /**
  98567. * Gets the index of a uniform variable.
  98568. * @param uniformName of the uniform to look up.
  98569. * @returns the index.
  98570. */
  98571. getUniformIndex(uniformName: string): number;
  98572. /**
  98573. * Returns the attribute based on the name of the variable.
  98574. * @param uniformName of the uniform to look up.
  98575. * @returns the location of the uniform.
  98576. */
  98577. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  98578. /**
  98579. * Returns an array of sampler variable names
  98580. * @returns The array of sampler variable neames.
  98581. */
  98582. getSamplers(): string[];
  98583. /**
  98584. * The error from the last compilation.
  98585. * @returns the error string.
  98586. */
  98587. getCompilationError(): string;
  98588. /**
  98589. * Gets a boolean indicating that all fallbacks were used during compilation
  98590. * @returns true if all fallbacks were used
  98591. */
  98592. allFallbacksProcessed(): boolean;
  98593. /**
  98594. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  98595. * @param func The callback to be used.
  98596. */
  98597. executeWhenCompiled(func: (effect: Effect) => void): void;
  98598. private _checkIsReady;
  98599. private _loadShader;
  98600. /**
  98601. * Recompiles the webGL program
  98602. * @param vertexSourceCode The source code for the vertex shader.
  98603. * @param fragmentSourceCode The source code for the fragment shader.
  98604. * @param onCompiled Callback called when completed.
  98605. * @param onError Callback called on error.
  98606. * @hidden
  98607. */
  98608. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  98609. /**
  98610. * Prepares the effect
  98611. * @hidden
  98612. */
  98613. _prepareEffect(): void;
  98614. private _processCompilationErrors;
  98615. /**
  98616. * Checks if the effect is supported. (Must be called after compilation)
  98617. */
  98618. readonly isSupported: boolean;
  98619. /**
  98620. * Binds a texture to the engine to be used as output of the shader.
  98621. * @param channel Name of the output variable.
  98622. * @param texture Texture to bind.
  98623. * @hidden
  98624. */
  98625. _bindTexture(channel: string, texture: InternalTexture): void;
  98626. /**
  98627. * Sets a texture on the engine to be used in the shader.
  98628. * @param channel Name of the sampler variable.
  98629. * @param texture Texture to set.
  98630. */
  98631. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  98632. /**
  98633. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  98634. * @param channel Name of the sampler variable.
  98635. * @param texture Texture to set.
  98636. */
  98637. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  98638. /**
  98639. * Sets an array of textures on the engine to be used in the shader.
  98640. * @param channel Name of the variable.
  98641. * @param textures Textures to set.
  98642. */
  98643. setTextureArray(channel: string, textures: BaseTexture[]): void;
  98644. /**
  98645. * 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)
  98646. * @param channel Name of the sampler variable.
  98647. * @param postProcess Post process to get the input texture from.
  98648. */
  98649. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  98650. /**
  98651. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  98652. * 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)
  98653. * @param channel Name of the sampler variable.
  98654. * @param postProcess Post process to get the output texture from.
  98655. */
  98656. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  98657. /** @hidden */
  98658. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  98659. /** @hidden */
  98660. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  98661. /** @hidden */
  98662. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  98663. /** @hidden */
  98664. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  98665. /**
  98666. * Binds a buffer to a uniform.
  98667. * @param buffer Buffer to bind.
  98668. * @param name Name of the uniform variable to bind to.
  98669. */
  98670. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  98671. /**
  98672. * Binds block to a uniform.
  98673. * @param blockName Name of the block to bind.
  98674. * @param index Index to bind.
  98675. */
  98676. bindUniformBlock(blockName: string, index: number): void;
  98677. /**
  98678. * Sets an interger value on a uniform variable.
  98679. * @param uniformName Name of the variable.
  98680. * @param value Value to be set.
  98681. * @returns this effect.
  98682. */
  98683. setInt(uniformName: string, value: number): Effect;
  98684. /**
  98685. * Sets an int array on a uniform variable.
  98686. * @param uniformName Name of the variable.
  98687. * @param array array to be set.
  98688. * @returns this effect.
  98689. */
  98690. setIntArray(uniformName: string, array: Int32Array): Effect;
  98691. /**
  98692. * 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)
  98693. * @param uniformName Name of the variable.
  98694. * @param array array to be set.
  98695. * @returns this effect.
  98696. */
  98697. setIntArray2(uniformName: string, array: Int32Array): Effect;
  98698. /**
  98699. * 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)
  98700. * @param uniformName Name of the variable.
  98701. * @param array array to be set.
  98702. * @returns this effect.
  98703. */
  98704. setIntArray3(uniformName: string, array: Int32Array): Effect;
  98705. /**
  98706. * 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)
  98707. * @param uniformName Name of the variable.
  98708. * @param array array to be set.
  98709. * @returns this effect.
  98710. */
  98711. setIntArray4(uniformName: string, array: Int32Array): Effect;
  98712. /**
  98713. * Sets an float array on a uniform variable.
  98714. * @param uniformName Name of the variable.
  98715. * @param array array to be set.
  98716. * @returns this effect.
  98717. */
  98718. setFloatArray(uniformName: string, array: Float32Array): Effect;
  98719. /**
  98720. * 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)
  98721. * @param uniformName Name of the variable.
  98722. * @param array array to be set.
  98723. * @returns this effect.
  98724. */
  98725. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  98726. /**
  98727. * 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)
  98728. * @param uniformName Name of the variable.
  98729. * @param array array to be set.
  98730. * @returns this effect.
  98731. */
  98732. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  98733. /**
  98734. * 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)
  98735. * @param uniformName Name of the variable.
  98736. * @param array array to be set.
  98737. * @returns this effect.
  98738. */
  98739. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  98740. /**
  98741. * Sets an array on a uniform variable.
  98742. * @param uniformName Name of the variable.
  98743. * @param array array to be set.
  98744. * @returns this effect.
  98745. */
  98746. setArray(uniformName: string, array: number[]): Effect;
  98747. /**
  98748. * 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)
  98749. * @param uniformName Name of the variable.
  98750. * @param array array to be set.
  98751. * @returns this effect.
  98752. */
  98753. setArray2(uniformName: string, array: number[]): Effect;
  98754. /**
  98755. * 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)
  98756. * @param uniformName Name of the variable.
  98757. * @param array array to be set.
  98758. * @returns this effect.
  98759. */
  98760. setArray3(uniformName: string, array: number[]): Effect;
  98761. /**
  98762. * 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)
  98763. * @param uniformName Name of the variable.
  98764. * @param array array to be set.
  98765. * @returns this effect.
  98766. */
  98767. setArray4(uniformName: string, array: number[]): Effect;
  98768. /**
  98769. * Sets matrices on a uniform variable.
  98770. * @param uniformName Name of the variable.
  98771. * @param matrices matrices to be set.
  98772. * @returns this effect.
  98773. */
  98774. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  98775. /**
  98776. * Sets matrix on a uniform variable.
  98777. * @param uniformName Name of the variable.
  98778. * @param matrix matrix to be set.
  98779. * @returns this effect.
  98780. */
  98781. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  98782. /**
  98783. * 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)
  98784. * @param uniformName Name of the variable.
  98785. * @param matrix matrix to be set.
  98786. * @returns this effect.
  98787. */
  98788. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  98789. /**
  98790. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  98791. * @param uniformName Name of the variable.
  98792. * @param matrix matrix to be set.
  98793. * @returns this effect.
  98794. */
  98795. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  98796. /**
  98797. * Sets a float on a uniform variable.
  98798. * @param uniformName Name of the variable.
  98799. * @param value value to be set.
  98800. * @returns this effect.
  98801. */
  98802. setFloat(uniformName: string, value: number): Effect;
  98803. /**
  98804. * Sets a boolean on a uniform variable.
  98805. * @param uniformName Name of the variable.
  98806. * @param bool value to be set.
  98807. * @returns this effect.
  98808. */
  98809. setBool(uniformName: string, bool: boolean): Effect;
  98810. /**
  98811. * Sets a Vector2 on a uniform variable.
  98812. * @param uniformName Name of the variable.
  98813. * @param vector2 vector2 to be set.
  98814. * @returns this effect.
  98815. */
  98816. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  98817. /**
  98818. * Sets a float2 on a uniform variable.
  98819. * @param uniformName Name of the variable.
  98820. * @param x First float in float2.
  98821. * @param y Second float in float2.
  98822. * @returns this effect.
  98823. */
  98824. setFloat2(uniformName: string, x: number, y: number): Effect;
  98825. /**
  98826. * Sets a Vector3 on a uniform variable.
  98827. * @param uniformName Name of the variable.
  98828. * @param vector3 Value to be set.
  98829. * @returns this effect.
  98830. */
  98831. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  98832. /**
  98833. * Sets a float3 on a uniform variable.
  98834. * @param uniformName Name of the variable.
  98835. * @param x First float in float3.
  98836. * @param y Second float in float3.
  98837. * @param z Third float in float3.
  98838. * @returns this effect.
  98839. */
  98840. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  98841. /**
  98842. * Sets a Vector4 on a uniform variable.
  98843. * @param uniformName Name of the variable.
  98844. * @param vector4 Value to be set.
  98845. * @returns this effect.
  98846. */
  98847. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  98848. /**
  98849. * Sets a float4 on a uniform variable.
  98850. * @param uniformName Name of the variable.
  98851. * @param x First float in float4.
  98852. * @param y Second float in float4.
  98853. * @param z Third float in float4.
  98854. * @param w Fourth float in float4.
  98855. * @returns this effect.
  98856. */
  98857. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  98858. /**
  98859. * Sets a Color3 on a uniform variable.
  98860. * @param uniformName Name of the variable.
  98861. * @param color3 Value to be set.
  98862. * @returns this effect.
  98863. */
  98864. setColor3(uniformName: string, color3: IColor3Like): Effect;
  98865. /**
  98866. * Sets a Color4 on a uniform variable.
  98867. * @param uniformName Name of the variable.
  98868. * @param color3 Value to be set.
  98869. * @param alpha Alpha value to be set.
  98870. * @returns this effect.
  98871. */
  98872. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  98873. /**
  98874. * Sets a Color4 on a uniform variable
  98875. * @param uniformName defines the name of the variable
  98876. * @param color4 defines the value to be set
  98877. * @returns this effect.
  98878. */
  98879. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  98880. /** Release all associated resources */
  98881. dispose(): void;
  98882. /**
  98883. * This function will add a new shader to the shader store
  98884. * @param name the name of the shader
  98885. * @param pixelShader optional pixel shader content
  98886. * @param vertexShader optional vertex shader content
  98887. */
  98888. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  98889. /**
  98890. * Store of each shader (The can be looked up using effect.key)
  98891. */
  98892. static ShadersStore: {
  98893. [key: string]: string;
  98894. };
  98895. /**
  98896. * Store of each included file for a shader (The can be looked up using effect.key)
  98897. */
  98898. static IncludesShadersStore: {
  98899. [key: string]: string;
  98900. };
  98901. /**
  98902. * Resets the cache of effects.
  98903. */
  98904. static ResetCache(): void;
  98905. }
  98906. }
  98907. declare module BABYLON {
  98908. /**
  98909. * Interface used to describe the capabilities of the engine relatively to the current browser
  98910. */
  98911. export interface EngineCapabilities {
  98912. /** Maximum textures units per fragment shader */
  98913. maxTexturesImageUnits: number;
  98914. /** Maximum texture units per vertex shader */
  98915. maxVertexTextureImageUnits: number;
  98916. /** Maximum textures units in the entire pipeline */
  98917. maxCombinedTexturesImageUnits: number;
  98918. /** Maximum texture size */
  98919. maxTextureSize: number;
  98920. /** Maximum texture samples */
  98921. maxSamples?: number;
  98922. /** Maximum cube texture size */
  98923. maxCubemapTextureSize: number;
  98924. /** Maximum render texture size */
  98925. maxRenderTextureSize: number;
  98926. /** Maximum number of vertex attributes */
  98927. maxVertexAttribs: number;
  98928. /** Maximum number of varyings */
  98929. maxVaryingVectors: number;
  98930. /** Maximum number of uniforms per vertex shader */
  98931. maxVertexUniformVectors: number;
  98932. /** Maximum number of uniforms per fragment shader */
  98933. maxFragmentUniformVectors: number;
  98934. /** Defines if standard derivates (dx/dy) are supported */
  98935. standardDerivatives: boolean;
  98936. /** Defines if s3tc texture compression is supported */
  98937. s3tc?: WEBGL_compressed_texture_s3tc;
  98938. /** Defines if pvrtc texture compression is supported */
  98939. pvrtc: any;
  98940. /** Defines if etc1 texture compression is supported */
  98941. etc1: any;
  98942. /** Defines if etc2 texture compression is supported */
  98943. etc2: any;
  98944. /** Defines if astc texture compression is supported */
  98945. astc: any;
  98946. /** Defines if float textures are supported */
  98947. textureFloat: boolean;
  98948. /** Defines if vertex array objects are supported */
  98949. vertexArrayObject: boolean;
  98950. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  98951. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  98952. /** Gets the maximum level of anisotropy supported */
  98953. maxAnisotropy: number;
  98954. /** Defines if instancing is supported */
  98955. instancedArrays: boolean;
  98956. /** Defines if 32 bits indices are supported */
  98957. uintIndices: boolean;
  98958. /** Defines if high precision shaders are supported */
  98959. highPrecisionShaderSupported: boolean;
  98960. /** Defines if depth reading in the fragment shader is supported */
  98961. fragmentDepthSupported: boolean;
  98962. /** Defines if float texture linear filtering is supported*/
  98963. textureFloatLinearFiltering: boolean;
  98964. /** Defines if rendering to float textures is supported */
  98965. textureFloatRender: boolean;
  98966. /** Defines if half float textures are supported*/
  98967. textureHalfFloat: boolean;
  98968. /** Defines if half float texture linear filtering is supported*/
  98969. textureHalfFloatLinearFiltering: boolean;
  98970. /** Defines if rendering to half float textures is supported */
  98971. textureHalfFloatRender: boolean;
  98972. /** Defines if textureLOD shader command is supported */
  98973. textureLOD: boolean;
  98974. /** Defines if draw buffers extension is supported */
  98975. drawBuffersExtension: boolean;
  98976. /** Defines if depth textures are supported */
  98977. depthTextureExtension: boolean;
  98978. /** Defines if float color buffer are supported */
  98979. colorBufferFloat: boolean;
  98980. /** Gets disjoint timer query extension (null if not supported) */
  98981. timerQuery?: EXT_disjoint_timer_query;
  98982. /** Defines if timestamp can be used with timer query */
  98983. canUseTimestampForTimerQuery: boolean;
  98984. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  98985. multiview?: any;
  98986. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  98987. oculusMultiview?: any;
  98988. /** Function used to let the system compiles shaders in background */
  98989. parallelShaderCompile?: {
  98990. COMPLETION_STATUS_KHR: number;
  98991. };
  98992. /** Max number of texture samples for MSAA */
  98993. maxMSAASamples: number;
  98994. /** Defines if the blend min max extension is supported */
  98995. blendMinMax: boolean;
  98996. }
  98997. }
  98998. declare module BABYLON {
  98999. /**
  99000. * @hidden
  99001. **/
  99002. export class DepthCullingState {
  99003. private _isDepthTestDirty;
  99004. private _isDepthMaskDirty;
  99005. private _isDepthFuncDirty;
  99006. private _isCullFaceDirty;
  99007. private _isCullDirty;
  99008. private _isZOffsetDirty;
  99009. private _isFrontFaceDirty;
  99010. private _depthTest;
  99011. private _depthMask;
  99012. private _depthFunc;
  99013. private _cull;
  99014. private _cullFace;
  99015. private _zOffset;
  99016. private _frontFace;
  99017. /**
  99018. * Initializes the state.
  99019. */
  99020. constructor();
  99021. readonly isDirty: boolean;
  99022. zOffset: number;
  99023. cullFace: Nullable<number>;
  99024. cull: Nullable<boolean>;
  99025. depthFunc: Nullable<number>;
  99026. depthMask: boolean;
  99027. depthTest: boolean;
  99028. frontFace: Nullable<number>;
  99029. reset(): void;
  99030. apply(gl: WebGLRenderingContext): void;
  99031. }
  99032. }
  99033. declare module BABYLON {
  99034. /**
  99035. * @hidden
  99036. **/
  99037. export class StencilState {
  99038. /** 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 */
  99039. static readonly ALWAYS: number;
  99040. /** Passed to stencilOperation to specify that stencil value must be kept */
  99041. static readonly KEEP: number;
  99042. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99043. static readonly REPLACE: number;
  99044. private _isStencilTestDirty;
  99045. private _isStencilMaskDirty;
  99046. private _isStencilFuncDirty;
  99047. private _isStencilOpDirty;
  99048. private _stencilTest;
  99049. private _stencilMask;
  99050. private _stencilFunc;
  99051. private _stencilFuncRef;
  99052. private _stencilFuncMask;
  99053. private _stencilOpStencilFail;
  99054. private _stencilOpDepthFail;
  99055. private _stencilOpStencilDepthPass;
  99056. readonly isDirty: boolean;
  99057. stencilFunc: number;
  99058. stencilFuncRef: number;
  99059. stencilFuncMask: number;
  99060. stencilOpStencilFail: number;
  99061. stencilOpDepthFail: number;
  99062. stencilOpStencilDepthPass: number;
  99063. stencilMask: number;
  99064. stencilTest: boolean;
  99065. constructor();
  99066. reset(): void;
  99067. apply(gl: WebGLRenderingContext): void;
  99068. }
  99069. }
  99070. declare module BABYLON {
  99071. /**
  99072. * @hidden
  99073. **/
  99074. export class AlphaState {
  99075. private _isAlphaBlendDirty;
  99076. private _isBlendFunctionParametersDirty;
  99077. private _isBlendEquationParametersDirty;
  99078. private _isBlendConstantsDirty;
  99079. private _alphaBlend;
  99080. private _blendFunctionParameters;
  99081. private _blendEquationParameters;
  99082. private _blendConstants;
  99083. /**
  99084. * Initializes the state.
  99085. */
  99086. constructor();
  99087. readonly isDirty: boolean;
  99088. alphaBlend: boolean;
  99089. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99090. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99091. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99092. reset(): void;
  99093. apply(gl: WebGLRenderingContext): void;
  99094. }
  99095. }
  99096. declare module BABYLON {
  99097. /** @hidden */
  99098. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99099. attributeProcessor(attribute: string): string;
  99100. varyingProcessor(varying: string, isFragment: boolean): string;
  99101. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99102. }
  99103. }
  99104. declare module BABYLON {
  99105. /**
  99106. * Interface for attribute information associated with buffer instanciation
  99107. */
  99108. export interface InstancingAttributeInfo {
  99109. /**
  99110. * Index/offset of the attribute in the vertex shader
  99111. */
  99112. index: number;
  99113. /**
  99114. * size of the attribute, 1, 2, 3 or 4
  99115. */
  99116. attributeSize: number;
  99117. /**
  99118. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99119. * default is FLOAT
  99120. */
  99121. attributeType: number;
  99122. /**
  99123. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99124. */
  99125. normalized: boolean;
  99126. /**
  99127. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99128. */
  99129. offset: number;
  99130. /**
  99131. * Name of the GLSL attribute, for debugging purpose only
  99132. */
  99133. attributeName: string;
  99134. }
  99135. }
  99136. declare module BABYLON {
  99137. interface ThinEngine {
  99138. /**
  99139. * Update a video texture
  99140. * @param texture defines the texture to update
  99141. * @param video defines the video element to use
  99142. * @param invertY defines if data must be stored with Y axis inverted
  99143. */
  99144. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99145. }
  99146. }
  99147. declare module BABYLON {
  99148. /**
  99149. * Settings for finer control over video usage
  99150. */
  99151. export interface VideoTextureSettings {
  99152. /**
  99153. * Applies `autoplay` to video, if specified
  99154. */
  99155. autoPlay?: boolean;
  99156. /**
  99157. * Applies `loop` to video, if specified
  99158. */
  99159. loop?: boolean;
  99160. /**
  99161. * Automatically updates internal texture from video at every frame in the render loop
  99162. */
  99163. autoUpdateTexture: boolean;
  99164. /**
  99165. * Image src displayed during the video loading or until the user interacts with the video.
  99166. */
  99167. poster?: string;
  99168. }
  99169. /**
  99170. * If you want to display a video in your scene, this is the special texture for that.
  99171. * This special texture works similar to other textures, with the exception of a few parameters.
  99172. * @see https://doc.babylonjs.com/how_to/video_texture
  99173. */
  99174. export class VideoTexture extends Texture {
  99175. /**
  99176. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99177. */
  99178. readonly autoUpdateTexture: boolean;
  99179. /**
  99180. * The video instance used by the texture internally
  99181. */
  99182. readonly video: HTMLVideoElement;
  99183. private _onUserActionRequestedObservable;
  99184. /**
  99185. * Event triggerd when a dom action is required by the user to play the video.
  99186. * This happens due to recent changes in browser policies preventing video to auto start.
  99187. */
  99188. readonly onUserActionRequestedObservable: Observable<Texture>;
  99189. private _generateMipMaps;
  99190. private _engine;
  99191. private _stillImageCaptured;
  99192. private _displayingPosterTexture;
  99193. private _settings;
  99194. private _createInternalTextureOnEvent;
  99195. private _frameId;
  99196. /**
  99197. * Creates a video texture.
  99198. * If you want to display a video in your scene, this is the special texture for that.
  99199. * This special texture works similar to other textures, with the exception of a few parameters.
  99200. * @see https://doc.babylonjs.com/how_to/video_texture
  99201. * @param name optional name, will detect from video source, if not defined
  99202. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99203. * @param scene is obviously the current scene.
  99204. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99205. * @param invertY is false by default but can be used to invert video on Y axis
  99206. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99207. * @param settings allows finer control over video usage
  99208. */
  99209. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99210. private _getName;
  99211. private _getVideo;
  99212. private _createInternalTexture;
  99213. private reset;
  99214. /**
  99215. * @hidden Internal method to initiate `update`.
  99216. */
  99217. _rebuild(): void;
  99218. /**
  99219. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99220. */
  99221. update(): void;
  99222. /**
  99223. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99224. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99225. */
  99226. updateTexture(isVisible: boolean): void;
  99227. protected _updateInternalTexture: () => void;
  99228. /**
  99229. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99230. * @param url New url.
  99231. */
  99232. updateURL(url: string): void;
  99233. /**
  99234. * Dispose the texture and release its associated resources.
  99235. */
  99236. dispose(): void;
  99237. /**
  99238. * Creates a video texture straight from a stream.
  99239. * @param scene Define the scene the texture should be created in
  99240. * @param stream Define the stream the texture should be created from
  99241. * @returns The created video texture as a promise
  99242. */
  99243. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99244. /**
  99245. * Creates a video texture straight from your WebCam video feed.
  99246. * @param scene Define the scene the texture should be created in
  99247. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99248. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99249. * @returns The created video texture as a promise
  99250. */
  99251. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99252. minWidth: number;
  99253. maxWidth: number;
  99254. minHeight: number;
  99255. maxHeight: number;
  99256. deviceId: string;
  99257. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99258. /**
  99259. * Creates a video texture straight from your WebCam video feed.
  99260. * @param scene Define the scene the texture should be created in
  99261. * @param onReady Define a callback to triggered once the texture will be ready
  99262. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99263. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99264. */
  99265. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99266. minWidth: number;
  99267. maxWidth: number;
  99268. minHeight: number;
  99269. maxHeight: number;
  99270. deviceId: string;
  99271. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99272. }
  99273. }
  99274. declare module BABYLON {
  99275. /**
  99276. * Defines the interface used by objects working like Scene
  99277. * @hidden
  99278. */
  99279. interface ISceneLike {
  99280. _addPendingData(data: any): void;
  99281. _removePendingData(data: any): void;
  99282. offlineProvider: IOfflineProvider;
  99283. }
  99284. /** Interface defining initialization parameters for Engine class */
  99285. export interface EngineOptions extends WebGLContextAttributes {
  99286. /**
  99287. * Defines if the engine should no exceed a specified device ratio
  99288. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99289. */
  99290. limitDeviceRatio?: number;
  99291. /**
  99292. * Defines if webvr should be enabled automatically
  99293. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99294. */
  99295. autoEnableWebVR?: boolean;
  99296. /**
  99297. * Defines if webgl2 should be turned off even if supported
  99298. * @see http://doc.babylonjs.com/features/webgl2
  99299. */
  99300. disableWebGL2Support?: boolean;
  99301. /**
  99302. * Defines if webaudio should be initialized as well
  99303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99304. */
  99305. audioEngine?: boolean;
  99306. /**
  99307. * Defines if animations should run using a deterministic lock step
  99308. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99309. */
  99310. deterministicLockstep?: boolean;
  99311. /** Defines the maximum steps to use with deterministic lock step mode */
  99312. lockstepMaxSteps?: number;
  99313. /** Defines the seconds between each deterministic lock step */
  99314. timeStep?: number;
  99315. /**
  99316. * Defines that engine should ignore context lost events
  99317. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99318. */
  99319. doNotHandleContextLost?: boolean;
  99320. /**
  99321. * Defines that engine should ignore modifying touch action attribute and style
  99322. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99323. */
  99324. doNotHandleTouchAction?: boolean;
  99325. /**
  99326. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99327. */
  99328. useHighPrecisionFloats?: boolean;
  99329. }
  99330. /**
  99331. * The base engine class (root of all engines)
  99332. */
  99333. export class ThinEngine {
  99334. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99335. static ExceptionList: ({
  99336. key: string;
  99337. capture: string;
  99338. captureConstraint: number;
  99339. targets: string[];
  99340. } | {
  99341. key: string;
  99342. capture: null;
  99343. captureConstraint: null;
  99344. targets: string[];
  99345. })[];
  99346. /** @hidden */
  99347. static _TextureLoaders: IInternalTextureLoader[];
  99348. /**
  99349. * Returns the current npm package of the sdk
  99350. */
  99351. static readonly NpmPackage: string;
  99352. /**
  99353. * Returns the current version of the framework
  99354. */
  99355. static readonly Version: string;
  99356. /**
  99357. * Returns a string describing the current engine
  99358. */
  99359. readonly description: string;
  99360. /**
  99361. * Gets or sets the epsilon value used by collision engine
  99362. */
  99363. static CollisionsEpsilon: number;
  99364. /**
  99365. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99366. */
  99367. static ShadersRepository: string;
  99368. /**
  99369. * Gets or sets the textures that the engine should not attempt to load as compressed
  99370. */
  99371. protected _excludedCompressedTextures: string[];
  99372. /**
  99373. * Filters the compressed texture formats to only include
  99374. * files that are not included in the skippable list
  99375. *
  99376. * @param url the current extension
  99377. * @param textureFormatInUse the current compressed texture format
  99378. * @returns "format" string
  99379. */
  99380. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  99381. /** @hidden */
  99382. _shaderProcessor: IShaderProcessor;
  99383. /**
  99384. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99385. */
  99386. forcePOTTextures: boolean;
  99387. /**
  99388. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99389. */
  99390. isFullscreen: boolean;
  99391. /**
  99392. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99393. */
  99394. cullBackFaces: boolean;
  99395. /**
  99396. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99397. */
  99398. renderEvenInBackground: boolean;
  99399. /**
  99400. * Gets or sets a boolean indicating that cache can be kept between frames
  99401. */
  99402. preventCacheWipeBetweenFrames: boolean;
  99403. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99404. validateShaderPrograms: boolean;
  99405. /**
  99406. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99407. * This can provide greater z depth for distant objects.
  99408. */
  99409. useReverseDepthBuffer: boolean;
  99410. /**
  99411. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99412. */
  99413. disableUniformBuffers: boolean;
  99414. /** @hidden */
  99415. _uniformBuffers: UniformBuffer[];
  99416. /**
  99417. * Gets a boolean indicating that the engine supports uniform buffers
  99418. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99419. */
  99420. readonly supportsUniformBuffers: boolean;
  99421. /** @hidden */
  99422. _gl: WebGLRenderingContext;
  99423. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99424. protected _windowIsBackground: boolean;
  99425. protected _webGLVersion: number;
  99426. protected _creationOptions: EngineOptions;
  99427. protected _highPrecisionShadersAllowed: boolean;
  99428. /** @hidden */
  99429. readonly _shouldUseHighPrecisionShader: boolean;
  99430. /**
  99431. * Gets a boolean indicating that only power of 2 textures are supported
  99432. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99433. */
  99434. readonly needPOTTextures: boolean;
  99435. /** @hidden */
  99436. _badOS: boolean;
  99437. /** @hidden */
  99438. _badDesktopOS: boolean;
  99439. private _hardwareScalingLevel;
  99440. /** @hidden */
  99441. _caps: EngineCapabilities;
  99442. private _isStencilEnable;
  99443. protected _colorWrite: boolean;
  99444. private _glVersion;
  99445. private _glRenderer;
  99446. private _glVendor;
  99447. /** @hidden */
  99448. _videoTextureSupported: boolean;
  99449. protected _renderingQueueLaunched: boolean;
  99450. protected _activeRenderLoops: (() => void)[];
  99451. /**
  99452. * Observable signaled when a context lost event is raised
  99453. */
  99454. onContextLostObservable: Observable<ThinEngine>;
  99455. /**
  99456. * Observable signaled when a context restored event is raised
  99457. */
  99458. onContextRestoredObservable: Observable<ThinEngine>;
  99459. private _onContextLost;
  99460. private _onContextRestored;
  99461. protected _contextWasLost: boolean;
  99462. /** @hidden */
  99463. _doNotHandleContextLost: boolean;
  99464. /**
  99465. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99466. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99467. */
  99468. doNotHandleContextLost: boolean;
  99469. /**
  99470. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99471. */
  99472. disableVertexArrayObjects: boolean;
  99473. /** @hidden */
  99474. protected _depthCullingState: DepthCullingState;
  99475. /** @hidden */
  99476. protected _stencilState: StencilState;
  99477. /** @hidden */
  99478. protected _alphaState: AlphaState;
  99479. /** @hidden */
  99480. _internalTexturesCache: InternalTexture[];
  99481. /** @hidden */
  99482. protected _activeChannel: number;
  99483. private _currentTextureChannel;
  99484. /** @hidden */
  99485. protected _boundTexturesCache: {
  99486. [key: string]: Nullable<InternalTexture>;
  99487. };
  99488. /** @hidden */
  99489. protected _currentEffect: Nullable<Effect>;
  99490. /** @hidden */
  99491. protected _currentProgram: Nullable<WebGLProgram>;
  99492. private _compiledEffects;
  99493. private _vertexAttribArraysEnabled;
  99494. /** @hidden */
  99495. protected _cachedViewport: Nullable<IViewportLike>;
  99496. private _cachedVertexArrayObject;
  99497. /** @hidden */
  99498. protected _cachedVertexBuffers: any;
  99499. /** @hidden */
  99500. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99501. /** @hidden */
  99502. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99503. /** @hidden */
  99504. _currentRenderTarget: Nullable<InternalTexture>;
  99505. private _uintIndicesCurrentlySet;
  99506. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99507. /** @hidden */
  99508. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99509. private _currentBufferPointers;
  99510. private _currentInstanceLocations;
  99511. private _currentInstanceBuffers;
  99512. private _textureUnits;
  99513. /** @hidden */
  99514. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99515. /** @hidden */
  99516. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99517. /** @hidden */
  99518. _boundRenderFunction: any;
  99519. private _vaoRecordInProgress;
  99520. private _mustWipeVertexAttributes;
  99521. private _emptyTexture;
  99522. private _emptyCubeTexture;
  99523. private _emptyTexture3D;
  99524. private _emptyTexture2DArray;
  99525. /** @hidden */
  99526. _frameHandler: number;
  99527. private _nextFreeTextureSlots;
  99528. private _maxSimultaneousTextures;
  99529. private _activeRequests;
  99530. protected _texturesSupported: string[];
  99531. /** @hidden */
  99532. _textureFormatInUse: Nullable<string>;
  99533. protected readonly _supportsHardwareTextureRescaling: boolean;
  99534. /**
  99535. * Gets the list of texture formats supported
  99536. */
  99537. readonly texturesSupported: Array<string>;
  99538. /**
  99539. * Gets the list of texture formats in use
  99540. */
  99541. readonly textureFormatInUse: Nullable<string>;
  99542. /**
  99543. * Gets the current viewport
  99544. */
  99545. readonly currentViewport: Nullable<IViewportLike>;
  99546. /**
  99547. * Gets the default empty texture
  99548. */
  99549. readonly emptyTexture: InternalTexture;
  99550. /**
  99551. * Gets the default empty 3D texture
  99552. */
  99553. readonly emptyTexture3D: InternalTexture;
  99554. /**
  99555. * Gets the default empty 2D array texture
  99556. */
  99557. readonly emptyTexture2DArray: InternalTexture;
  99558. /**
  99559. * Gets the default empty cube texture
  99560. */
  99561. readonly emptyCubeTexture: InternalTexture;
  99562. /**
  99563. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  99564. */
  99565. readonly premultipliedAlpha: boolean;
  99566. /**
  99567. * Observable event triggered before each texture is initialized
  99568. */
  99569. onBeforeTextureInitObservable: Observable<Texture>;
  99570. /**
  99571. * Creates a new engine
  99572. * @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
  99573. * @param antialias defines enable antialiasing (default: false)
  99574. * @param options defines further options to be sent to the getContext() function
  99575. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99576. */
  99577. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99578. private _rebuildInternalTextures;
  99579. private _rebuildEffects;
  99580. /**
  99581. * Gets a boolean indicating if all created effects are ready
  99582. * @returns true if all effects are ready
  99583. */
  99584. areAllEffectsReady(): boolean;
  99585. protected _rebuildBuffers(): void;
  99586. private _initGLContext;
  99587. /**
  99588. * Gets version of the current webGL context
  99589. */
  99590. readonly webGLVersion: number;
  99591. /**
  99592. * Gets a string idenfifying the name of the class
  99593. * @returns "Engine" string
  99594. */
  99595. getClassName(): string;
  99596. /**
  99597. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  99598. */
  99599. readonly isStencilEnable: boolean;
  99600. /** @hidden */
  99601. _prepareWorkingCanvas(): void;
  99602. /**
  99603. * Reset the texture cache to empty state
  99604. */
  99605. resetTextureCache(): void;
  99606. /**
  99607. * Gets an object containing information about the current webGL context
  99608. * @returns an object containing the vender, the renderer and the version of the current webGL context
  99609. */
  99610. getGlInfo(): {
  99611. vendor: string;
  99612. renderer: string;
  99613. version: string;
  99614. };
  99615. /**
  99616. * Defines the hardware scaling level.
  99617. * By default the hardware scaling level is computed from the window device ratio.
  99618. * 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.
  99619. * @param level defines the level to use
  99620. */
  99621. setHardwareScalingLevel(level: number): void;
  99622. /**
  99623. * Gets the current hardware scaling level.
  99624. * By default the hardware scaling level is computed from the window device ratio.
  99625. * 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.
  99626. * @returns a number indicating the current hardware scaling level
  99627. */
  99628. getHardwareScalingLevel(): number;
  99629. /**
  99630. * Gets the list of loaded textures
  99631. * @returns an array containing all loaded textures
  99632. */
  99633. getLoadedTexturesCache(): InternalTexture[];
  99634. /**
  99635. * Gets the object containing all engine capabilities
  99636. * @returns the EngineCapabilities object
  99637. */
  99638. getCaps(): EngineCapabilities;
  99639. /**
  99640. * stop executing a render loop function and remove it from the execution array
  99641. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  99642. */
  99643. stopRenderLoop(renderFunction?: () => void): void;
  99644. /** @hidden */
  99645. _renderLoop(): void;
  99646. /**
  99647. * Gets the HTML canvas attached with the current webGL context
  99648. * @returns a HTML canvas
  99649. */
  99650. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  99651. /**
  99652. * Gets host window
  99653. * @returns the host window object
  99654. */
  99655. getHostWindow(): Nullable<Window>;
  99656. /**
  99657. * Gets the current render width
  99658. * @param useScreen defines if screen size must be used (or the current render target if any)
  99659. * @returns a number defining the current render width
  99660. */
  99661. getRenderWidth(useScreen?: boolean): number;
  99662. /**
  99663. * Gets the current render height
  99664. * @param useScreen defines if screen size must be used (or the current render target if any)
  99665. * @returns a number defining the current render height
  99666. */
  99667. getRenderHeight(useScreen?: boolean): number;
  99668. /**
  99669. * Can be used to override the current requestAnimationFrame requester.
  99670. * @hidden
  99671. */
  99672. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  99673. /**
  99674. * Register and execute a render loop. The engine can have more than one render function
  99675. * @param renderFunction defines the function to continuously execute
  99676. */
  99677. runRenderLoop(renderFunction: () => void): void;
  99678. /**
  99679. * Clear the current render buffer or the current render target (if any is set up)
  99680. * @param color defines the color to use
  99681. * @param backBuffer defines if the back buffer must be cleared
  99682. * @param depth defines if the depth buffer must be cleared
  99683. * @param stencil defines if the stencil buffer must be cleared
  99684. */
  99685. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99686. private _viewportCached;
  99687. /** @hidden */
  99688. _viewport(x: number, y: number, width: number, height: number): void;
  99689. /**
  99690. * Set the WebGL's viewport
  99691. * @param viewport defines the viewport element to be used
  99692. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  99693. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  99694. */
  99695. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  99696. /**
  99697. * Begin a new frame
  99698. */
  99699. beginFrame(): void;
  99700. /**
  99701. * Enf the current frame
  99702. */
  99703. endFrame(): void;
  99704. /**
  99705. * Resize the view according to the canvas' size
  99706. */
  99707. resize(): void;
  99708. /**
  99709. * Force a specific size of the canvas
  99710. * @param width defines the new canvas' width
  99711. * @param height defines the new canvas' height
  99712. */
  99713. setSize(width: number, height: number): void;
  99714. /**
  99715. * Binds the frame buffer to the specified texture.
  99716. * @param texture The texture to render to or null for the default canvas
  99717. * @param faceIndex The face of the texture to render to in case of cube texture
  99718. * @param requiredWidth The width of the target to render to
  99719. * @param requiredHeight The height of the target to render to
  99720. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  99721. * @param depthStencilTexture The depth stencil texture to use to render
  99722. * @param lodLevel defines le lod level to bind to the frame buffer
  99723. */
  99724. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  99725. /** @hidden */
  99726. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  99727. /**
  99728. * Unbind the current render target texture from the webGL context
  99729. * @param texture defines the render target texture to unbind
  99730. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99731. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99732. */
  99733. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99734. /**
  99735. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  99736. */
  99737. flushFramebuffer(): void;
  99738. /**
  99739. * Unbind the current render target and bind the default framebuffer
  99740. */
  99741. restoreDefaultFramebuffer(): void;
  99742. /** @hidden */
  99743. protected _resetVertexBufferBinding(): void;
  99744. /**
  99745. * Creates a vertex buffer
  99746. * @param data the data for the vertex buffer
  99747. * @returns the new WebGL static buffer
  99748. */
  99749. createVertexBuffer(data: DataArray): DataBuffer;
  99750. private _createVertexBuffer;
  99751. /**
  99752. * Creates a dynamic vertex buffer
  99753. * @param data the data for the dynamic vertex buffer
  99754. * @returns the new WebGL dynamic buffer
  99755. */
  99756. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  99757. protected _resetIndexBufferBinding(): void;
  99758. /**
  99759. * Creates a new index buffer
  99760. * @param indices defines the content of the index buffer
  99761. * @param updatable defines if the index buffer must be updatable
  99762. * @returns a new webGL buffer
  99763. */
  99764. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  99765. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  99766. /**
  99767. * Bind a webGL buffer to the webGL context
  99768. * @param buffer defines the buffer to bind
  99769. */
  99770. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  99771. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  99772. private bindBuffer;
  99773. /**
  99774. * update the bound buffer with the given data
  99775. * @param data defines the data to update
  99776. */
  99777. updateArrayBuffer(data: Float32Array): void;
  99778. private _vertexAttribPointer;
  99779. private _bindIndexBufferWithCache;
  99780. private _bindVertexBuffersAttributes;
  99781. /**
  99782. * Records a vertex array object
  99783. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99784. * @param vertexBuffers defines the list of vertex buffers to store
  99785. * @param indexBuffer defines the index buffer to store
  99786. * @param effect defines the effect to store
  99787. * @returns the new vertex array object
  99788. */
  99789. recordVertexArrayObject(vertexBuffers: {
  99790. [key: string]: VertexBuffer;
  99791. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  99792. /**
  99793. * Bind a specific vertex array object
  99794. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99795. * @param vertexArrayObject defines the vertex array object to bind
  99796. * @param indexBuffer defines the index buffer to bind
  99797. */
  99798. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  99799. /**
  99800. * Bind webGl buffers directly to the webGL context
  99801. * @param vertexBuffer defines the vertex buffer to bind
  99802. * @param indexBuffer defines the index buffer to bind
  99803. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  99804. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  99805. * @param effect defines the effect associated with the vertex buffer
  99806. */
  99807. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  99808. private _unbindVertexArrayObject;
  99809. /**
  99810. * Bind a list of vertex buffers to the webGL context
  99811. * @param vertexBuffers defines the list of vertex buffers to bind
  99812. * @param indexBuffer defines the index buffer to bind
  99813. * @param effect defines the effect associated with the vertex buffers
  99814. */
  99815. bindBuffers(vertexBuffers: {
  99816. [key: string]: Nullable<VertexBuffer>;
  99817. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  99818. /**
  99819. * Unbind all instance attributes
  99820. */
  99821. unbindInstanceAttributes(): void;
  99822. /**
  99823. * Release and free the memory of a vertex array object
  99824. * @param vao defines the vertex array object to delete
  99825. */
  99826. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  99827. /** @hidden */
  99828. _releaseBuffer(buffer: DataBuffer): boolean;
  99829. protected _deleteBuffer(buffer: DataBuffer): void;
  99830. /**
  99831. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  99832. * @param instancesBuffer defines the webGL buffer to update and bind
  99833. * @param data defines the data to store in the buffer
  99834. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  99835. */
  99836. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  99837. /**
  99838. * Apply all cached states (depth, culling, stencil and alpha)
  99839. */
  99840. applyStates(): void;
  99841. /**
  99842. * Send a draw order
  99843. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99844. * @param indexStart defines the starting index
  99845. * @param indexCount defines the number of index to draw
  99846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99847. */
  99848. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99849. /**
  99850. * Draw a list of points
  99851. * @param verticesStart defines the index of first vertex to draw
  99852. * @param verticesCount defines the count of vertices to draw
  99853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99854. */
  99855. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99856. /**
  99857. * Draw a list of unindexed primitives
  99858. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99859. * @param verticesStart defines the index of first vertex to draw
  99860. * @param verticesCount defines the count of vertices to draw
  99861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99862. */
  99863. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99864. /**
  99865. * Draw a list of indexed primitives
  99866. * @param fillMode defines the primitive to use
  99867. * @param indexStart defines the starting index
  99868. * @param indexCount defines the number of index to draw
  99869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99870. */
  99871. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99872. /**
  99873. * Draw a list of unindexed primitives
  99874. * @param fillMode defines the primitive to use
  99875. * @param verticesStart defines the index of first vertex to draw
  99876. * @param verticesCount defines the count of vertices to draw
  99877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99878. */
  99879. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99880. private _drawMode;
  99881. /** @hidden */
  99882. protected _reportDrawCall(): void;
  99883. /** @hidden */
  99884. _releaseEffect(effect: Effect): void;
  99885. /** @hidden */
  99886. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99887. /**
  99888. * Create a new effect (used to store vertex/fragment shaders)
  99889. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  99890. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  99891. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  99892. * @param samplers defines an array of string used to represent textures
  99893. * @param defines defines the string containing the defines to use to compile the shaders
  99894. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  99895. * @param onCompiled defines a function to call when the effect creation is successful
  99896. * @param onError defines a function to call when the effect creation has failed
  99897. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  99898. * @returns the new Effect
  99899. */
  99900. 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;
  99901. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  99902. private _compileShader;
  99903. private _compileRawShader;
  99904. /**
  99905. * Directly creates a webGL program
  99906. * @param pipelineContext defines the pipeline context to attach to
  99907. * @param vertexCode defines the vertex shader code to use
  99908. * @param fragmentCode defines the fragment shader code to use
  99909. * @param context defines the webGL context to use (if not set, the current one will be used)
  99910. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99911. * @returns the new webGL program
  99912. */
  99913. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99914. /**
  99915. * Creates a webGL program
  99916. * @param pipelineContext defines the pipeline context to attach to
  99917. * @param vertexCode defines the vertex shader code to use
  99918. * @param fragmentCode defines the fragment shader code to use
  99919. * @param defines defines the string containing the defines to use to compile the shaders
  99920. * @param context defines the webGL context to use (if not set, the current one will be used)
  99921. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99922. * @returns the new webGL program
  99923. */
  99924. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99925. /**
  99926. * Creates a new pipeline context
  99927. * @returns the new pipeline
  99928. */
  99929. createPipelineContext(): IPipelineContext;
  99930. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99931. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  99932. /** @hidden */
  99933. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  99934. /** @hidden */
  99935. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  99936. /** @hidden */
  99937. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  99938. /**
  99939. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  99940. * @param pipelineContext defines the pipeline context to use
  99941. * @param uniformsNames defines the list of uniform names
  99942. * @returns an array of webGL uniform locations
  99943. */
  99944. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  99945. /**
  99946. * Gets the lsit of active attributes for a given webGL program
  99947. * @param pipelineContext defines the pipeline context to use
  99948. * @param attributesNames defines the list of attribute names to get
  99949. * @returns an array of indices indicating the offset of each attribute
  99950. */
  99951. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  99952. /**
  99953. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  99954. * @param effect defines the effect to activate
  99955. */
  99956. enableEffect(effect: Nullable<Effect>): void;
  99957. /**
  99958. * Set the value of an uniform to a number (int)
  99959. * @param uniform defines the webGL uniform location where to store the value
  99960. * @param value defines the int number to store
  99961. */
  99962. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  99963. /**
  99964. * Set the value of an uniform to an array of int32
  99965. * @param uniform defines the webGL uniform location where to store the value
  99966. * @param array defines the array of int32 to store
  99967. */
  99968. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99969. /**
  99970. * Set the value of an uniform to an array of int32 (stored as vec2)
  99971. * @param uniform defines the webGL uniform location where to store the value
  99972. * @param array defines the array of int32 to store
  99973. */
  99974. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99975. /**
  99976. * Set the value of an uniform to an array of int32 (stored as vec3)
  99977. * @param uniform defines the webGL uniform location where to store the value
  99978. * @param array defines the array of int32 to store
  99979. */
  99980. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99981. /**
  99982. * Set the value of an uniform to an array of int32 (stored as vec4)
  99983. * @param uniform defines the webGL uniform location where to store the value
  99984. * @param array defines the array of int32 to store
  99985. */
  99986. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99987. /**
  99988. * Set the value of an uniform to an array of number
  99989. * @param uniform defines the webGL uniform location where to store the value
  99990. * @param array defines the array of number to store
  99991. */
  99992. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99993. /**
  99994. * Set the value of an uniform to an array of number (stored as vec2)
  99995. * @param uniform defines the webGL uniform location where to store the value
  99996. * @param array defines the array of number to store
  99997. */
  99998. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99999. /**
  100000. * Set the value of an uniform to an array of number (stored as vec3)
  100001. * @param uniform defines the webGL uniform location where to store the value
  100002. * @param array defines the array of number to store
  100003. */
  100004. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100005. /**
  100006. * Set the value of an uniform to an array of number (stored as vec4)
  100007. * @param uniform defines the webGL uniform location where to store the value
  100008. * @param array defines the array of number to store
  100009. */
  100010. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100011. /**
  100012. * Set the value of an uniform to an array of float32 (stored as matrices)
  100013. * @param uniform defines the webGL uniform location where to store the value
  100014. * @param matrices defines the array of float32 to store
  100015. */
  100016. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  100017. /**
  100018. * Set the value of an uniform to a matrix (3x3)
  100019. * @param uniform defines the webGL uniform location where to store the value
  100020. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  100021. */
  100022. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100023. /**
  100024. * Set the value of an uniform to a matrix (2x2)
  100025. * @param uniform defines the webGL uniform location where to store the value
  100026. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  100027. */
  100028. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100029. /**
  100030. * Set the value of an uniform to a number (float)
  100031. * @param uniform defines the webGL uniform location where to store the value
  100032. * @param value defines the float number to store
  100033. */
  100034. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100035. /**
  100036. * Set the value of an uniform to a vec2
  100037. * @param uniform defines the webGL uniform location where to store the value
  100038. * @param x defines the 1st component of the value
  100039. * @param y defines the 2nd component of the value
  100040. */
  100041. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100042. /**
  100043. * Set the value of an uniform to a vec3
  100044. * @param uniform defines the webGL uniform location where to store the value
  100045. * @param x defines the 1st component of the value
  100046. * @param y defines the 2nd component of the value
  100047. * @param z defines the 3rd component of the value
  100048. */
  100049. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100050. /**
  100051. * Set the value of an uniform to a vec4
  100052. * @param uniform defines the webGL uniform location where to store the value
  100053. * @param x defines the 1st component of the value
  100054. * @param y defines the 2nd component of the value
  100055. * @param z defines the 3rd component of the value
  100056. * @param w defines the 4th component of the value
  100057. */
  100058. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100059. /**
  100060. * Gets the depth culling state manager
  100061. */
  100062. readonly depthCullingState: DepthCullingState;
  100063. /**
  100064. * Gets the alpha state manager
  100065. */
  100066. readonly alphaState: AlphaState;
  100067. /**
  100068. * Gets the stencil state manager
  100069. */
  100070. readonly stencilState: StencilState;
  100071. /**
  100072. * Clears the list of texture accessible through engine.
  100073. * This can help preventing texture load conflict due to name collision.
  100074. */
  100075. clearInternalTexturesCache(): void;
  100076. /**
  100077. * Force the entire cache to be cleared
  100078. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100079. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100080. */
  100081. wipeCaches(bruteForce?: boolean): void;
  100082. /** @hidden */
  100083. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100084. min: number;
  100085. mag: number;
  100086. };
  100087. /** @hidden */
  100088. _createTexture(): WebGLTexture;
  100089. /**
  100090. * Usually called from Texture.ts.
  100091. * Passed information to create a WebGLTexture
  100092. * @param urlArg defines a value which contains one of the following:
  100093. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100094. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100095. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100096. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100097. * @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)
  100098. * @param scene needed for loading to the correct scene
  100099. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100100. * @param onLoad optional callback to be called upon successful completion
  100101. * @param onError optional callback to be called upon failure
  100102. * @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
  100103. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100104. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100105. * @param forcedExtension defines the extension to use to pick the right loader
  100106. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100107. * @param mimeType defines an optional mime type
  100108. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100109. */
  100110. 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;
  100111. /**
  100112. * @hidden
  100113. */
  100114. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100115. /**
  100116. * Creates a raw texture
  100117. * @param data defines the data to store in the texture
  100118. * @param width defines the width of the texture
  100119. * @param height defines the height of the texture
  100120. * @param format defines the format of the data
  100121. * @param generateMipMaps defines if the engine should generate the mip levels
  100122. * @param invertY defines if data must be stored with Y axis inverted
  100123. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100124. * @param compression defines the compression used (null by default)
  100125. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100126. * @returns the raw texture inside an InternalTexture
  100127. */
  100128. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100129. /**
  100130. * Creates a new raw cube texture
  100131. * @param data defines the array of data to use to create each face
  100132. * @param size defines the size of the textures
  100133. * @param format defines the format of the data
  100134. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100135. * @param generateMipMaps defines if the engine should generate the mip levels
  100136. * @param invertY defines if data must be stored with Y axis inverted
  100137. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100138. * @param compression defines the compression used (null by default)
  100139. * @returns the cube texture as an InternalTexture
  100140. */
  100141. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100142. /**
  100143. * Creates a new raw 3D texture
  100144. * @param data defines the data used to create the texture
  100145. * @param width defines the width of the texture
  100146. * @param height defines the height of the texture
  100147. * @param depth defines the depth of the texture
  100148. * @param format defines the format of the texture
  100149. * @param generateMipMaps defines if the engine must generate mip levels
  100150. * @param invertY defines if data must be stored with Y axis inverted
  100151. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100152. * @param compression defines the compressed used (can be null)
  100153. * @param textureType defines the compressed used (can be null)
  100154. * @returns a new raw 3D texture (stored in an InternalTexture)
  100155. */
  100156. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100157. /**
  100158. * Creates a new raw 2D array texture
  100159. * @param data defines the data used to create the texture
  100160. * @param width defines the width of the texture
  100161. * @param height defines the height of the texture
  100162. * @param depth defines the number of layers of the texture
  100163. * @param format defines the format of the texture
  100164. * @param generateMipMaps defines if the engine must generate mip levels
  100165. * @param invertY defines if data must be stored with Y axis inverted
  100166. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100167. * @param compression defines the compressed used (can be null)
  100168. * @param textureType defines the compressed used (can be null)
  100169. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100170. */
  100171. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100172. private _unpackFlipYCached;
  100173. /**
  100174. * In case you are sharing the context with other applications, it might
  100175. * be interested to not cache the unpack flip y state to ensure a consistent
  100176. * value would be set.
  100177. */
  100178. enableUnpackFlipYCached: boolean;
  100179. /** @hidden */
  100180. _unpackFlipY(value: boolean): void;
  100181. /** @hidden */
  100182. _getUnpackAlignement(): number;
  100183. /**
  100184. * Update the sampling mode of a given texture
  100185. * @param samplingMode defines the required sampling mode
  100186. * @param texture defines the texture to update
  100187. */
  100188. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100189. /** @hidden */
  100190. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100191. width: number;
  100192. height: number;
  100193. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100194. /** @hidden */
  100195. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100196. /** @hidden */
  100197. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100198. /** @hidden */
  100199. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100200. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100201. private _prepareWebGLTexture;
  100202. /** @hidden */
  100203. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100204. /** @hidden */
  100205. _releaseFramebufferObjects(texture: InternalTexture): void;
  100206. /** @hidden */
  100207. _releaseTexture(texture: InternalTexture): void;
  100208. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100209. protected _setProgram(program: WebGLProgram): void;
  100210. protected _boundUniforms: {
  100211. [key: number]: WebGLUniformLocation;
  100212. };
  100213. /**
  100214. * Binds an effect to the webGL context
  100215. * @param effect defines the effect to bind
  100216. */
  100217. bindSamplers(effect: Effect): void;
  100218. private _activateCurrentTexture;
  100219. /** @hidden */
  100220. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100221. /** @hidden */
  100222. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100223. /**
  100224. * Unbind all textures from the webGL context
  100225. */
  100226. unbindAllTextures(): void;
  100227. /**
  100228. * Sets a texture to the according uniform.
  100229. * @param channel The texture channel
  100230. * @param uniform The uniform to set
  100231. * @param texture The texture to apply
  100232. */
  100233. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100234. private _bindSamplerUniformToChannel;
  100235. private _getTextureWrapMode;
  100236. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100237. /**
  100238. * Sets an array of texture to the webGL context
  100239. * @param channel defines the channel where the texture array must be set
  100240. * @param uniform defines the associated uniform location
  100241. * @param textures defines the array of textures to bind
  100242. */
  100243. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100244. /** @hidden */
  100245. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100246. private _setTextureParameterFloat;
  100247. private _setTextureParameterInteger;
  100248. /**
  100249. * Unbind all vertex attributes from the webGL context
  100250. */
  100251. unbindAllAttributes(): void;
  100252. /**
  100253. * 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
  100254. */
  100255. releaseEffects(): void;
  100256. /**
  100257. * Dispose and release all associated resources
  100258. */
  100259. dispose(): void;
  100260. /**
  100261. * Attach a new callback raised when context lost event is fired
  100262. * @param callback defines the callback to call
  100263. */
  100264. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100265. /**
  100266. * Attach a new callback raised when context restored event is fired
  100267. * @param callback defines the callback to call
  100268. */
  100269. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100270. /**
  100271. * Get the current error code of the webGL context
  100272. * @returns the error code
  100273. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100274. */
  100275. getError(): number;
  100276. private _canRenderToFloatFramebuffer;
  100277. private _canRenderToHalfFloatFramebuffer;
  100278. private _canRenderToFramebuffer;
  100279. /** @hidden */
  100280. _getWebGLTextureType(type: number): number;
  100281. /** @hidden */
  100282. _getInternalFormat(format: number): number;
  100283. /** @hidden */
  100284. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100285. /** @hidden */
  100286. _getRGBAMultiSampleBufferFormat(type: number): number;
  100287. /** @hidden */
  100288. _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;
  100289. /**
  100290. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100291. * @returns true if the engine can be created
  100292. * @ignorenaming
  100293. */
  100294. static isSupported(): boolean;
  100295. /**
  100296. * Find the next highest power of two.
  100297. * @param x Number to start search from.
  100298. * @return Next highest power of two.
  100299. */
  100300. static CeilingPOT(x: number): number;
  100301. /**
  100302. * Find the next lowest power of two.
  100303. * @param x Number to start search from.
  100304. * @return Next lowest power of two.
  100305. */
  100306. static FloorPOT(x: number): number;
  100307. /**
  100308. * Find the nearest power of two.
  100309. * @param x Number to start search from.
  100310. * @return Next nearest power of two.
  100311. */
  100312. static NearestPOT(x: number): number;
  100313. /**
  100314. * Get the closest exponent of two
  100315. * @param value defines the value to approximate
  100316. * @param max defines the maximum value to return
  100317. * @param mode defines how to define the closest value
  100318. * @returns closest exponent of two of the given value
  100319. */
  100320. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100321. /**
  100322. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100323. * @param func - the function to be called
  100324. * @param requester - the object that will request the next frame. Falls back to window.
  100325. * @returns frame number
  100326. */
  100327. static QueueNewFrame(func: () => void, requester?: any): number;
  100328. /**
  100329. * Gets host document
  100330. * @returns the host document object
  100331. */
  100332. getHostDocument(): Document;
  100333. }
  100334. }
  100335. declare module BABYLON {
  100336. /**
  100337. * Class representing spherical harmonics coefficients to the 3rd degree
  100338. */
  100339. export class SphericalHarmonics {
  100340. /**
  100341. * Defines whether or not the harmonics have been prescaled for rendering.
  100342. */
  100343. preScaled: boolean;
  100344. /**
  100345. * The l0,0 coefficients of the spherical harmonics
  100346. */
  100347. l00: Vector3;
  100348. /**
  100349. * The l1,-1 coefficients of the spherical harmonics
  100350. */
  100351. l1_1: Vector3;
  100352. /**
  100353. * The l1,0 coefficients of the spherical harmonics
  100354. */
  100355. l10: Vector3;
  100356. /**
  100357. * The l1,1 coefficients of the spherical harmonics
  100358. */
  100359. l11: Vector3;
  100360. /**
  100361. * The l2,-2 coefficients of the spherical harmonics
  100362. */
  100363. l2_2: Vector3;
  100364. /**
  100365. * The l2,-1 coefficients of the spherical harmonics
  100366. */
  100367. l2_1: Vector3;
  100368. /**
  100369. * The l2,0 coefficients of the spherical harmonics
  100370. */
  100371. l20: Vector3;
  100372. /**
  100373. * The l2,1 coefficients of the spherical harmonics
  100374. */
  100375. l21: Vector3;
  100376. /**
  100377. * The l2,2 coefficients of the spherical harmonics
  100378. */
  100379. l22: Vector3;
  100380. /**
  100381. * Adds a light to the spherical harmonics
  100382. * @param direction the direction of the light
  100383. * @param color the color of the light
  100384. * @param deltaSolidAngle the delta solid angle of the light
  100385. */
  100386. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100387. /**
  100388. * Scales the spherical harmonics by the given amount
  100389. * @param scale the amount to scale
  100390. */
  100391. scaleInPlace(scale: number): void;
  100392. /**
  100393. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100394. *
  100395. * ```
  100396. * E_lm = A_l * L_lm
  100397. * ```
  100398. *
  100399. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100400. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100401. * the scaling factors are given in equation 9.
  100402. */
  100403. convertIncidentRadianceToIrradiance(): void;
  100404. /**
  100405. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100406. *
  100407. * ```
  100408. * L = (1/pi) * E * rho
  100409. * ```
  100410. *
  100411. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100412. */
  100413. convertIrradianceToLambertianRadiance(): void;
  100414. /**
  100415. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100416. * required operations at run time.
  100417. *
  100418. * This is simply done by scaling back the SH with Ylm constants parameter.
  100419. * The trigonometric part being applied by the shader at run time.
  100420. */
  100421. preScaleForRendering(): void;
  100422. /**
  100423. * Constructs a spherical harmonics from an array.
  100424. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100425. * @returns the spherical harmonics
  100426. */
  100427. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100428. /**
  100429. * Gets the spherical harmonics from polynomial
  100430. * @param polynomial the spherical polynomial
  100431. * @returns the spherical harmonics
  100432. */
  100433. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100434. }
  100435. /**
  100436. * Class representing spherical polynomial coefficients to the 3rd degree
  100437. */
  100438. export class SphericalPolynomial {
  100439. private _harmonics;
  100440. /**
  100441. * The spherical harmonics used to create the polynomials.
  100442. */
  100443. readonly preScaledHarmonics: SphericalHarmonics;
  100444. /**
  100445. * The x coefficients of the spherical polynomial
  100446. */
  100447. x: Vector3;
  100448. /**
  100449. * The y coefficients of the spherical polynomial
  100450. */
  100451. y: Vector3;
  100452. /**
  100453. * The z coefficients of the spherical polynomial
  100454. */
  100455. z: Vector3;
  100456. /**
  100457. * The xx coefficients of the spherical polynomial
  100458. */
  100459. xx: Vector3;
  100460. /**
  100461. * The yy coefficients of the spherical polynomial
  100462. */
  100463. yy: Vector3;
  100464. /**
  100465. * The zz coefficients of the spherical polynomial
  100466. */
  100467. zz: Vector3;
  100468. /**
  100469. * The xy coefficients of the spherical polynomial
  100470. */
  100471. xy: Vector3;
  100472. /**
  100473. * The yz coefficients of the spherical polynomial
  100474. */
  100475. yz: Vector3;
  100476. /**
  100477. * The zx coefficients of the spherical polynomial
  100478. */
  100479. zx: Vector3;
  100480. /**
  100481. * Adds an ambient color to the spherical polynomial
  100482. * @param color the color to add
  100483. */
  100484. addAmbient(color: Color3): void;
  100485. /**
  100486. * Scales the spherical polynomial by the given amount
  100487. * @param scale the amount to scale
  100488. */
  100489. scaleInPlace(scale: number): void;
  100490. /**
  100491. * Gets the spherical polynomial from harmonics
  100492. * @param harmonics the spherical harmonics
  100493. * @returns the spherical polynomial
  100494. */
  100495. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  100496. /**
  100497. * Constructs a spherical polynomial from an array.
  100498. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  100499. * @returns the spherical polynomial
  100500. */
  100501. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  100502. }
  100503. }
  100504. declare module BABYLON {
  100505. /**
  100506. * Defines the source of the internal texture
  100507. */
  100508. export enum InternalTextureSource {
  100509. /**
  100510. * The source of the texture data is unknown
  100511. */
  100512. Unknown = 0,
  100513. /**
  100514. * Texture data comes from an URL
  100515. */
  100516. Url = 1,
  100517. /**
  100518. * Texture data is only used for temporary storage
  100519. */
  100520. Temp = 2,
  100521. /**
  100522. * Texture data comes from raw data (ArrayBuffer)
  100523. */
  100524. Raw = 3,
  100525. /**
  100526. * Texture content is dynamic (video or dynamic texture)
  100527. */
  100528. Dynamic = 4,
  100529. /**
  100530. * Texture content is generated by rendering to it
  100531. */
  100532. RenderTarget = 5,
  100533. /**
  100534. * Texture content is part of a multi render target process
  100535. */
  100536. MultiRenderTarget = 6,
  100537. /**
  100538. * Texture data comes from a cube data file
  100539. */
  100540. Cube = 7,
  100541. /**
  100542. * Texture data comes from a raw cube data
  100543. */
  100544. CubeRaw = 8,
  100545. /**
  100546. * Texture data come from a prefiltered cube data file
  100547. */
  100548. CubePrefiltered = 9,
  100549. /**
  100550. * Texture content is raw 3D data
  100551. */
  100552. Raw3D = 10,
  100553. /**
  100554. * Texture content is raw 2D array data
  100555. */
  100556. Raw2DArray = 11,
  100557. /**
  100558. * Texture content is a depth texture
  100559. */
  100560. Depth = 12,
  100561. /**
  100562. * Texture data comes from a raw cube data encoded with RGBD
  100563. */
  100564. CubeRawRGBD = 13
  100565. }
  100566. /**
  100567. * Class used to store data associated with WebGL texture data for the engine
  100568. * This class should not be used directly
  100569. */
  100570. export class InternalTexture {
  100571. /** @hidden */
  100572. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  100573. /**
  100574. * Defines if the texture is ready
  100575. */
  100576. isReady: boolean;
  100577. /**
  100578. * Defines if the texture is a cube texture
  100579. */
  100580. isCube: boolean;
  100581. /**
  100582. * Defines if the texture contains 3D data
  100583. */
  100584. is3D: boolean;
  100585. /**
  100586. * Defines if the texture contains 2D array data
  100587. */
  100588. is2DArray: boolean;
  100589. /**
  100590. * Defines if the texture contains multiview data
  100591. */
  100592. isMultiview: boolean;
  100593. /**
  100594. * Gets the URL used to load this texture
  100595. */
  100596. url: string;
  100597. /**
  100598. * Gets the sampling mode of the texture
  100599. */
  100600. samplingMode: number;
  100601. /**
  100602. * Gets a boolean indicating if the texture needs mipmaps generation
  100603. */
  100604. generateMipMaps: boolean;
  100605. /**
  100606. * Gets the number of samples used by the texture (WebGL2+ only)
  100607. */
  100608. samples: number;
  100609. /**
  100610. * Gets the type of the texture (int, float...)
  100611. */
  100612. type: number;
  100613. /**
  100614. * Gets the format of the texture (RGB, RGBA...)
  100615. */
  100616. format: number;
  100617. /**
  100618. * Observable called when the texture is loaded
  100619. */
  100620. onLoadedObservable: Observable<InternalTexture>;
  100621. /**
  100622. * Gets the width of the texture
  100623. */
  100624. width: number;
  100625. /**
  100626. * Gets the height of the texture
  100627. */
  100628. height: number;
  100629. /**
  100630. * Gets the depth of the texture
  100631. */
  100632. depth: number;
  100633. /**
  100634. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  100635. */
  100636. baseWidth: number;
  100637. /**
  100638. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  100639. */
  100640. baseHeight: number;
  100641. /**
  100642. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  100643. */
  100644. baseDepth: number;
  100645. /**
  100646. * Gets a boolean indicating if the texture is inverted on Y axis
  100647. */
  100648. invertY: boolean;
  100649. /** @hidden */
  100650. _invertVScale: boolean;
  100651. /** @hidden */
  100652. _associatedChannel: number;
  100653. /** @hidden */
  100654. _source: InternalTextureSource;
  100655. /** @hidden */
  100656. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100657. /** @hidden */
  100658. _bufferView: Nullable<ArrayBufferView>;
  100659. /** @hidden */
  100660. _bufferViewArray: Nullable<ArrayBufferView[]>;
  100661. /** @hidden */
  100662. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  100663. /** @hidden */
  100664. _size: number;
  100665. /** @hidden */
  100666. _extension: string;
  100667. /** @hidden */
  100668. _files: Nullable<string[]>;
  100669. /** @hidden */
  100670. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100671. /** @hidden */
  100672. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100673. /** @hidden */
  100674. _framebuffer: Nullable<WebGLFramebuffer>;
  100675. /** @hidden */
  100676. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  100677. /** @hidden */
  100678. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  100679. /** @hidden */
  100680. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  100681. /** @hidden */
  100682. _attachments: Nullable<number[]>;
  100683. /** @hidden */
  100684. _cachedCoordinatesMode: Nullable<number>;
  100685. /** @hidden */
  100686. _cachedWrapU: Nullable<number>;
  100687. /** @hidden */
  100688. _cachedWrapV: Nullable<number>;
  100689. /** @hidden */
  100690. _cachedWrapR: Nullable<number>;
  100691. /** @hidden */
  100692. _cachedAnisotropicFilteringLevel: Nullable<number>;
  100693. /** @hidden */
  100694. _isDisabled: boolean;
  100695. /** @hidden */
  100696. _compression: Nullable<string>;
  100697. /** @hidden */
  100698. _generateStencilBuffer: boolean;
  100699. /** @hidden */
  100700. _generateDepthBuffer: boolean;
  100701. /** @hidden */
  100702. _comparisonFunction: number;
  100703. /** @hidden */
  100704. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  100705. /** @hidden */
  100706. _lodGenerationScale: number;
  100707. /** @hidden */
  100708. _lodGenerationOffset: number;
  100709. /** @hidden */
  100710. _colorTextureArray: Nullable<WebGLTexture>;
  100711. /** @hidden */
  100712. _depthStencilTextureArray: Nullable<WebGLTexture>;
  100713. /** @hidden */
  100714. _lodTextureHigh: Nullable<BaseTexture>;
  100715. /** @hidden */
  100716. _lodTextureMid: Nullable<BaseTexture>;
  100717. /** @hidden */
  100718. _lodTextureLow: Nullable<BaseTexture>;
  100719. /** @hidden */
  100720. _isRGBD: boolean;
  100721. /** @hidden */
  100722. _linearSpecularLOD: boolean;
  100723. /** @hidden */
  100724. _irradianceTexture: Nullable<BaseTexture>;
  100725. /** @hidden */
  100726. _webGLTexture: Nullable<WebGLTexture>;
  100727. /** @hidden */
  100728. _references: number;
  100729. private _engine;
  100730. /**
  100731. * Gets the Engine the texture belongs to.
  100732. * @returns The babylon engine
  100733. */
  100734. getEngine(): ThinEngine;
  100735. /**
  100736. * Gets the data source type of the texture
  100737. */
  100738. readonly source: InternalTextureSource;
  100739. /**
  100740. * Creates a new InternalTexture
  100741. * @param engine defines the engine to use
  100742. * @param source defines the type of data that will be used
  100743. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100744. */
  100745. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  100746. /**
  100747. * Increments the number of references (ie. the number of Texture that point to it)
  100748. */
  100749. incrementReferences(): void;
  100750. /**
  100751. * Change the size of the texture (not the size of the content)
  100752. * @param width defines the new width
  100753. * @param height defines the new height
  100754. * @param depth defines the new depth (1 by default)
  100755. */
  100756. updateSize(width: int, height: int, depth?: int): void;
  100757. /** @hidden */
  100758. _rebuild(): void;
  100759. /** @hidden */
  100760. _swapAndDie(target: InternalTexture): void;
  100761. /**
  100762. * Dispose the current allocated resources
  100763. */
  100764. dispose(): void;
  100765. }
  100766. }
  100767. declare module BABYLON {
  100768. /**
  100769. * Class used to work with sound analyzer using fast fourier transform (FFT)
  100770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100771. */
  100772. export class Analyser {
  100773. /**
  100774. * Gets or sets the smoothing
  100775. * @ignorenaming
  100776. */
  100777. SMOOTHING: number;
  100778. /**
  100779. * Gets or sets the FFT table size
  100780. * @ignorenaming
  100781. */
  100782. FFT_SIZE: number;
  100783. /**
  100784. * Gets or sets the bar graph amplitude
  100785. * @ignorenaming
  100786. */
  100787. BARGRAPHAMPLITUDE: number;
  100788. /**
  100789. * Gets or sets the position of the debug canvas
  100790. * @ignorenaming
  100791. */
  100792. DEBUGCANVASPOS: {
  100793. x: number;
  100794. y: number;
  100795. };
  100796. /**
  100797. * Gets or sets the debug canvas size
  100798. * @ignorenaming
  100799. */
  100800. DEBUGCANVASSIZE: {
  100801. width: number;
  100802. height: number;
  100803. };
  100804. private _byteFreqs;
  100805. private _byteTime;
  100806. private _floatFreqs;
  100807. private _webAudioAnalyser;
  100808. private _debugCanvas;
  100809. private _debugCanvasContext;
  100810. private _scene;
  100811. private _registerFunc;
  100812. private _audioEngine;
  100813. /**
  100814. * Creates a new analyser
  100815. * @param scene defines hosting scene
  100816. */
  100817. constructor(scene: Scene);
  100818. /**
  100819. * Get the number of data values you will have to play with for the visualization
  100820. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  100821. * @returns a number
  100822. */
  100823. getFrequencyBinCount(): number;
  100824. /**
  100825. * Gets the current frequency data as a byte array
  100826. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100827. * @returns a Uint8Array
  100828. */
  100829. getByteFrequencyData(): Uint8Array;
  100830. /**
  100831. * Gets the current waveform as a byte array
  100832. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  100833. * @returns a Uint8Array
  100834. */
  100835. getByteTimeDomainData(): Uint8Array;
  100836. /**
  100837. * Gets the current frequency data as a float array
  100838. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100839. * @returns a Float32Array
  100840. */
  100841. getFloatFrequencyData(): Float32Array;
  100842. /**
  100843. * Renders the debug canvas
  100844. */
  100845. drawDebugCanvas(): void;
  100846. /**
  100847. * Stops rendering the debug canvas and removes it
  100848. */
  100849. stopDebugCanvas(): void;
  100850. /**
  100851. * Connects two audio nodes
  100852. * @param inputAudioNode defines first node to connect
  100853. * @param outputAudioNode defines second node to connect
  100854. */
  100855. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  100856. /**
  100857. * Releases all associated resources
  100858. */
  100859. dispose(): void;
  100860. }
  100861. }
  100862. declare module BABYLON {
  100863. /**
  100864. * This represents an audio engine and it is responsible
  100865. * to play, synchronize and analyse sounds throughout the application.
  100866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100867. */
  100868. export interface IAudioEngine extends IDisposable {
  100869. /**
  100870. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100871. */
  100872. readonly canUseWebAudio: boolean;
  100873. /**
  100874. * Gets the current AudioContext if available.
  100875. */
  100876. readonly audioContext: Nullable<AudioContext>;
  100877. /**
  100878. * The master gain node defines the global audio volume of your audio engine.
  100879. */
  100880. readonly masterGain: GainNode;
  100881. /**
  100882. * Gets whether or not mp3 are supported by your browser.
  100883. */
  100884. readonly isMP3supported: boolean;
  100885. /**
  100886. * Gets whether or not ogg are supported by your browser.
  100887. */
  100888. readonly isOGGsupported: boolean;
  100889. /**
  100890. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100891. * @ignoreNaming
  100892. */
  100893. WarnedWebAudioUnsupported: boolean;
  100894. /**
  100895. * Defines if the audio engine relies on a custom unlocked button.
  100896. * In this case, the embedded button will not be displayed.
  100897. */
  100898. useCustomUnlockedButton: boolean;
  100899. /**
  100900. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  100901. */
  100902. readonly unlocked: boolean;
  100903. /**
  100904. * Event raised when audio has been unlocked on the browser.
  100905. */
  100906. onAudioUnlockedObservable: Observable<AudioEngine>;
  100907. /**
  100908. * Event raised when audio has been locked on the browser.
  100909. */
  100910. onAudioLockedObservable: Observable<AudioEngine>;
  100911. /**
  100912. * Flags the audio engine in Locked state.
  100913. * This happens due to new browser policies preventing audio to autoplay.
  100914. */
  100915. lock(): void;
  100916. /**
  100917. * Unlocks the audio engine once a user action has been done on the dom.
  100918. * This is helpful to resume play once browser policies have been satisfied.
  100919. */
  100920. unlock(): void;
  100921. }
  100922. /**
  100923. * This represents the default audio engine used in babylon.
  100924. * It is responsible to play, synchronize and analyse sounds throughout the application.
  100925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100926. */
  100927. export class AudioEngine implements IAudioEngine {
  100928. private _audioContext;
  100929. private _audioContextInitialized;
  100930. private _muteButton;
  100931. private _hostElement;
  100932. /**
  100933. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100934. */
  100935. canUseWebAudio: boolean;
  100936. /**
  100937. * The master gain node defines the global audio volume of your audio engine.
  100938. */
  100939. masterGain: GainNode;
  100940. /**
  100941. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100942. * @ignoreNaming
  100943. */
  100944. WarnedWebAudioUnsupported: boolean;
  100945. /**
  100946. * Gets whether or not mp3 are supported by your browser.
  100947. */
  100948. isMP3supported: boolean;
  100949. /**
  100950. * Gets whether or not ogg are supported by your browser.
  100951. */
  100952. isOGGsupported: boolean;
  100953. /**
  100954. * Gets whether audio has been unlocked on the device.
  100955. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  100956. * a user interaction has happened.
  100957. */
  100958. unlocked: boolean;
  100959. /**
  100960. * Defines if the audio engine relies on a custom unlocked button.
  100961. * In this case, the embedded button will not be displayed.
  100962. */
  100963. useCustomUnlockedButton: boolean;
  100964. /**
  100965. * Event raised when audio has been unlocked on the browser.
  100966. */
  100967. onAudioUnlockedObservable: Observable<AudioEngine>;
  100968. /**
  100969. * Event raised when audio has been locked on the browser.
  100970. */
  100971. onAudioLockedObservable: Observable<AudioEngine>;
  100972. /**
  100973. * Gets the current AudioContext if available.
  100974. */
  100975. readonly audioContext: Nullable<AudioContext>;
  100976. private _connectedAnalyser;
  100977. /**
  100978. * Instantiates a new audio engine.
  100979. *
  100980. * There should be only one per page as some browsers restrict the number
  100981. * of audio contexts you can create.
  100982. * @param hostElement defines the host element where to display the mute icon if necessary
  100983. */
  100984. constructor(hostElement?: Nullable<HTMLElement>);
  100985. /**
  100986. * Flags the audio engine in Locked state.
  100987. * This happens due to new browser policies preventing audio to autoplay.
  100988. */
  100989. lock(): void;
  100990. /**
  100991. * Unlocks the audio engine once a user action has been done on the dom.
  100992. * This is helpful to resume play once browser policies have been satisfied.
  100993. */
  100994. unlock(): void;
  100995. private _resumeAudioContext;
  100996. private _initializeAudioContext;
  100997. private _tryToRun;
  100998. private _triggerRunningState;
  100999. private _triggerSuspendedState;
  101000. private _displayMuteButton;
  101001. private _moveButtonToTopLeft;
  101002. private _onResize;
  101003. private _hideMuteButton;
  101004. /**
  101005. * Destroy and release the resources associated with the audio ccontext.
  101006. */
  101007. dispose(): void;
  101008. /**
  101009. * Gets the global volume sets on the master gain.
  101010. * @returns the global volume if set or -1 otherwise
  101011. */
  101012. getGlobalVolume(): number;
  101013. /**
  101014. * Sets the global volume of your experience (sets on the master gain).
  101015. * @param newVolume Defines the new global volume of the application
  101016. */
  101017. setGlobalVolume(newVolume: number): void;
  101018. /**
  101019. * Connect the audio engine to an audio analyser allowing some amazing
  101020. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101022. * @param analyser The analyser to connect to the engine
  101023. */
  101024. connectToAnalyser(analyser: Analyser): void;
  101025. }
  101026. }
  101027. declare module BABYLON {
  101028. /**
  101029. * Interface used to present a loading screen while loading a scene
  101030. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101031. */
  101032. export interface ILoadingScreen {
  101033. /**
  101034. * Function called to display the loading screen
  101035. */
  101036. displayLoadingUI: () => void;
  101037. /**
  101038. * Function called to hide the loading screen
  101039. */
  101040. hideLoadingUI: () => void;
  101041. /**
  101042. * Gets or sets the color to use for the background
  101043. */
  101044. loadingUIBackgroundColor: string;
  101045. /**
  101046. * Gets or sets the text to display while loading
  101047. */
  101048. loadingUIText: string;
  101049. }
  101050. /**
  101051. * Class used for the default loading screen
  101052. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101053. */
  101054. export class DefaultLoadingScreen implements ILoadingScreen {
  101055. private _renderingCanvas;
  101056. private _loadingText;
  101057. private _loadingDivBackgroundColor;
  101058. private _loadingDiv;
  101059. private _loadingTextDiv;
  101060. /** Gets or sets the logo url to use for the default loading screen */
  101061. static DefaultLogoUrl: string;
  101062. /** Gets or sets the spinner url to use for the default loading screen */
  101063. static DefaultSpinnerUrl: string;
  101064. /**
  101065. * Creates a new default loading screen
  101066. * @param _renderingCanvas defines the canvas used to render the scene
  101067. * @param _loadingText defines the default text to display
  101068. * @param _loadingDivBackgroundColor defines the default background color
  101069. */
  101070. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101071. /**
  101072. * Function called to display the loading screen
  101073. */
  101074. displayLoadingUI(): void;
  101075. /**
  101076. * Function called to hide the loading screen
  101077. */
  101078. hideLoadingUI(): void;
  101079. /**
  101080. * Gets or sets the text to display while loading
  101081. */
  101082. loadingUIText: string;
  101083. /**
  101084. * Gets or sets the color to use for the background
  101085. */
  101086. loadingUIBackgroundColor: string;
  101087. private _resizeLoadingUI;
  101088. }
  101089. }
  101090. declare module BABYLON {
  101091. /**
  101092. * Interface for any object that can request an animation frame
  101093. */
  101094. export interface ICustomAnimationFrameRequester {
  101095. /**
  101096. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101097. */
  101098. renderFunction?: Function;
  101099. /**
  101100. * Called to request the next frame to render to
  101101. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101102. */
  101103. requestAnimationFrame: Function;
  101104. /**
  101105. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101106. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101107. */
  101108. requestID?: number;
  101109. }
  101110. }
  101111. declare module BABYLON {
  101112. /**
  101113. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101114. */
  101115. export class PerformanceMonitor {
  101116. private _enabled;
  101117. private _rollingFrameTime;
  101118. private _lastFrameTimeMs;
  101119. /**
  101120. * constructor
  101121. * @param frameSampleSize The number of samples required to saturate the sliding window
  101122. */
  101123. constructor(frameSampleSize?: number);
  101124. /**
  101125. * Samples current frame
  101126. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101127. */
  101128. sampleFrame(timeMs?: number): void;
  101129. /**
  101130. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101131. */
  101132. readonly averageFrameTime: number;
  101133. /**
  101134. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101135. */
  101136. readonly averageFrameTimeVariance: number;
  101137. /**
  101138. * Returns the frame time of the most recent frame
  101139. */
  101140. readonly instantaneousFrameTime: number;
  101141. /**
  101142. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101143. */
  101144. readonly averageFPS: number;
  101145. /**
  101146. * Returns the average framerate in frames per second using the most recent frame time
  101147. */
  101148. readonly instantaneousFPS: number;
  101149. /**
  101150. * Returns true if enough samples have been taken to completely fill the sliding window
  101151. */
  101152. readonly isSaturated: boolean;
  101153. /**
  101154. * Enables contributions to the sliding window sample set
  101155. */
  101156. enable(): void;
  101157. /**
  101158. * Disables contributions to the sliding window sample set
  101159. * Samples will not be interpolated over the disabled period
  101160. */
  101161. disable(): void;
  101162. /**
  101163. * Returns true if sampling is enabled
  101164. */
  101165. readonly isEnabled: boolean;
  101166. /**
  101167. * Resets performance monitor
  101168. */
  101169. reset(): void;
  101170. }
  101171. /**
  101172. * RollingAverage
  101173. *
  101174. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101175. */
  101176. export class RollingAverage {
  101177. /**
  101178. * Current average
  101179. */
  101180. average: number;
  101181. /**
  101182. * Current variance
  101183. */
  101184. variance: number;
  101185. protected _samples: Array<number>;
  101186. protected _sampleCount: number;
  101187. protected _pos: number;
  101188. protected _m2: number;
  101189. /**
  101190. * constructor
  101191. * @param length The number of samples required to saturate the sliding window
  101192. */
  101193. constructor(length: number);
  101194. /**
  101195. * Adds a sample to the sample set
  101196. * @param v The sample value
  101197. */
  101198. add(v: number): void;
  101199. /**
  101200. * Returns previously added values or null if outside of history or outside the sliding window domain
  101201. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101202. * @return Value previously recorded with add() or null if outside of range
  101203. */
  101204. history(i: number): number;
  101205. /**
  101206. * Returns true if enough samples have been taken to completely fill the sliding window
  101207. * @return true if sample-set saturated
  101208. */
  101209. isSaturated(): boolean;
  101210. /**
  101211. * Resets the rolling average (equivalent to 0 samples taken so far)
  101212. */
  101213. reset(): void;
  101214. /**
  101215. * Wraps a value around the sample range boundaries
  101216. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101217. * @return Wrapped position in sample range
  101218. */
  101219. protected _wrapPosition(i: number): number;
  101220. }
  101221. }
  101222. declare module BABYLON {
  101223. /**
  101224. * This class is used to track a performance counter which is number based.
  101225. * The user has access to many properties which give statistics of different nature.
  101226. *
  101227. * The implementer can track two kinds of Performance Counter: time and count.
  101228. * 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.
  101229. * 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.
  101230. */
  101231. export class PerfCounter {
  101232. /**
  101233. * Gets or sets a global boolean to turn on and off all the counters
  101234. */
  101235. static Enabled: boolean;
  101236. /**
  101237. * Returns the smallest value ever
  101238. */
  101239. readonly min: number;
  101240. /**
  101241. * Returns the biggest value ever
  101242. */
  101243. readonly max: number;
  101244. /**
  101245. * Returns the average value since the performance counter is running
  101246. */
  101247. readonly average: number;
  101248. /**
  101249. * Returns the average value of the last second the counter was monitored
  101250. */
  101251. readonly lastSecAverage: number;
  101252. /**
  101253. * Returns the current value
  101254. */
  101255. readonly current: number;
  101256. /**
  101257. * Gets the accumulated total
  101258. */
  101259. readonly total: number;
  101260. /**
  101261. * Gets the total value count
  101262. */
  101263. readonly count: number;
  101264. /**
  101265. * Creates a new counter
  101266. */
  101267. constructor();
  101268. /**
  101269. * Call this method to start monitoring a new frame.
  101270. * 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.
  101271. */
  101272. fetchNewFrame(): void;
  101273. /**
  101274. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101275. * @param newCount the count value to add to the monitored count
  101276. * @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.
  101277. */
  101278. addCount(newCount: number, fetchResult: boolean): void;
  101279. /**
  101280. * Start monitoring this performance counter
  101281. */
  101282. beginMonitoring(): void;
  101283. /**
  101284. * Compute the time lapsed since the previous beginMonitoring() call.
  101285. * @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
  101286. */
  101287. endMonitoring(newFrame?: boolean): void;
  101288. private _fetchResult;
  101289. private _startMonitoringTime;
  101290. private _min;
  101291. private _max;
  101292. private _average;
  101293. private _current;
  101294. private _totalValueCount;
  101295. private _totalAccumulated;
  101296. private _lastSecAverage;
  101297. private _lastSecAccumulated;
  101298. private _lastSecTime;
  101299. private _lastSecValueCount;
  101300. }
  101301. }
  101302. declare module BABYLON {
  101303. /**
  101304. * Defines the interface used by display changed events
  101305. */
  101306. export interface IDisplayChangedEventArgs {
  101307. /** Gets the vrDisplay object (if any) */
  101308. vrDisplay: Nullable<any>;
  101309. /** Gets a boolean indicating if webVR is supported */
  101310. vrSupported: boolean;
  101311. }
  101312. /**
  101313. * Defines the interface used by objects containing a viewport (like a camera)
  101314. */
  101315. interface IViewportOwnerLike {
  101316. /**
  101317. * Gets or sets the viewport
  101318. */
  101319. viewport: IViewportLike;
  101320. }
  101321. /**
  101322. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101323. */
  101324. export class Engine extends ThinEngine {
  101325. /** Defines that alpha blending is disabled */
  101326. static readonly ALPHA_DISABLE: number;
  101327. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101328. static readonly ALPHA_ADD: number;
  101329. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101330. static readonly ALPHA_COMBINE: number;
  101331. /** Defines that alpha blending to DEST - SRC * DEST */
  101332. static readonly ALPHA_SUBTRACT: number;
  101333. /** Defines that alpha blending to SRC * DEST */
  101334. static readonly ALPHA_MULTIPLY: number;
  101335. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101336. static readonly ALPHA_MAXIMIZED: number;
  101337. /** Defines that alpha blending to SRC + DEST */
  101338. static readonly ALPHA_ONEONE: number;
  101339. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101340. static readonly ALPHA_PREMULTIPLIED: number;
  101341. /**
  101342. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101343. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101344. */
  101345. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101346. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101347. static readonly ALPHA_INTERPOLATE: number;
  101348. /**
  101349. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101350. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101351. */
  101352. static readonly ALPHA_SCREENMODE: number;
  101353. /** Defines that the ressource is not delayed*/
  101354. static readonly DELAYLOADSTATE_NONE: number;
  101355. /** Defines that the ressource was successfully delay loaded */
  101356. static readonly DELAYLOADSTATE_LOADED: number;
  101357. /** Defines that the ressource is currently delay loading */
  101358. static readonly DELAYLOADSTATE_LOADING: number;
  101359. /** Defines that the ressource is delayed and has not started loading */
  101360. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101362. static readonly NEVER: number;
  101363. /** 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 */
  101364. static readonly ALWAYS: number;
  101365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101366. static readonly LESS: number;
  101367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101368. static readonly EQUAL: number;
  101369. /** 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 */
  101370. static readonly LEQUAL: number;
  101371. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101372. static readonly GREATER: number;
  101373. /** 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 */
  101374. static readonly GEQUAL: number;
  101375. /** 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 */
  101376. static readonly NOTEQUAL: number;
  101377. /** Passed to stencilOperation to specify that stencil value must be kept */
  101378. static readonly KEEP: number;
  101379. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101380. static readonly REPLACE: number;
  101381. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101382. static readonly INCR: number;
  101383. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101384. static readonly DECR: number;
  101385. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101386. static readonly INVERT: number;
  101387. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101388. static readonly INCR_WRAP: number;
  101389. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101390. static readonly DECR_WRAP: number;
  101391. /** Texture is not repeating outside of 0..1 UVs */
  101392. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101393. /** Texture is repeating outside of 0..1 UVs */
  101394. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101395. /** Texture is repeating and mirrored */
  101396. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101397. /** ALPHA */
  101398. static readonly TEXTUREFORMAT_ALPHA: number;
  101399. /** LUMINANCE */
  101400. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101401. /** LUMINANCE_ALPHA */
  101402. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101403. /** RGB */
  101404. static readonly TEXTUREFORMAT_RGB: number;
  101405. /** RGBA */
  101406. static readonly TEXTUREFORMAT_RGBA: number;
  101407. /** RED */
  101408. static readonly TEXTUREFORMAT_RED: number;
  101409. /** RED (2nd reference) */
  101410. static readonly TEXTUREFORMAT_R: number;
  101411. /** RG */
  101412. static readonly TEXTUREFORMAT_RG: number;
  101413. /** RED_INTEGER */
  101414. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101415. /** RED_INTEGER (2nd reference) */
  101416. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101417. /** RG_INTEGER */
  101418. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101419. /** RGB_INTEGER */
  101420. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101421. /** RGBA_INTEGER */
  101422. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101423. /** UNSIGNED_BYTE */
  101424. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101425. /** UNSIGNED_BYTE (2nd reference) */
  101426. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101427. /** FLOAT */
  101428. static readonly TEXTURETYPE_FLOAT: number;
  101429. /** HALF_FLOAT */
  101430. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101431. /** BYTE */
  101432. static readonly TEXTURETYPE_BYTE: number;
  101433. /** SHORT */
  101434. static readonly TEXTURETYPE_SHORT: number;
  101435. /** UNSIGNED_SHORT */
  101436. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101437. /** INT */
  101438. static readonly TEXTURETYPE_INT: number;
  101439. /** UNSIGNED_INT */
  101440. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101441. /** UNSIGNED_SHORT_4_4_4_4 */
  101442. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101443. /** UNSIGNED_SHORT_5_5_5_1 */
  101444. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101445. /** UNSIGNED_SHORT_5_6_5 */
  101446. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101447. /** UNSIGNED_INT_2_10_10_10_REV */
  101448. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101449. /** UNSIGNED_INT_24_8 */
  101450. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101451. /** UNSIGNED_INT_10F_11F_11F_REV */
  101452. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101453. /** UNSIGNED_INT_5_9_9_9_REV */
  101454. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101455. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101456. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101457. /** nearest is mag = nearest and min = nearest and mip = linear */
  101458. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101460. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  101461. /** Trilinear is mag = linear and min = linear and mip = linear */
  101462. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  101463. /** nearest is mag = nearest and min = nearest and mip = linear */
  101464. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  101465. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101466. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  101467. /** Trilinear is mag = linear and min = linear and mip = linear */
  101468. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  101469. /** mag = nearest and min = nearest and mip = nearest */
  101470. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  101471. /** mag = nearest and min = linear and mip = nearest */
  101472. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  101473. /** mag = nearest and min = linear and mip = linear */
  101474. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  101475. /** mag = nearest and min = linear and mip = none */
  101476. static readonly TEXTURE_NEAREST_LINEAR: number;
  101477. /** mag = nearest and min = nearest and mip = none */
  101478. static readonly TEXTURE_NEAREST_NEAREST: number;
  101479. /** mag = linear and min = nearest and mip = nearest */
  101480. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  101481. /** mag = linear and min = nearest and mip = linear */
  101482. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  101483. /** mag = linear and min = linear and mip = none */
  101484. static readonly TEXTURE_LINEAR_LINEAR: number;
  101485. /** mag = linear and min = nearest and mip = none */
  101486. static readonly TEXTURE_LINEAR_NEAREST: number;
  101487. /** Explicit coordinates mode */
  101488. static readonly TEXTURE_EXPLICIT_MODE: number;
  101489. /** Spherical coordinates mode */
  101490. static readonly TEXTURE_SPHERICAL_MODE: number;
  101491. /** Planar coordinates mode */
  101492. static readonly TEXTURE_PLANAR_MODE: number;
  101493. /** Cubic coordinates mode */
  101494. static readonly TEXTURE_CUBIC_MODE: number;
  101495. /** Projection coordinates mode */
  101496. static readonly TEXTURE_PROJECTION_MODE: number;
  101497. /** Skybox coordinates mode */
  101498. static readonly TEXTURE_SKYBOX_MODE: number;
  101499. /** Inverse Cubic coordinates mode */
  101500. static readonly TEXTURE_INVCUBIC_MODE: number;
  101501. /** Equirectangular coordinates mode */
  101502. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  101503. /** Equirectangular Fixed coordinates mode */
  101504. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  101505. /** Equirectangular Fixed Mirrored coordinates mode */
  101506. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101507. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  101508. static readonly SCALEMODE_FLOOR: number;
  101509. /** Defines that texture rescaling will look for the nearest power of 2 size */
  101510. static readonly SCALEMODE_NEAREST: number;
  101511. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  101512. static readonly SCALEMODE_CEILING: number;
  101513. /**
  101514. * Returns the current npm package of the sdk
  101515. */
  101516. static readonly NpmPackage: string;
  101517. /**
  101518. * Returns the current version of the framework
  101519. */
  101520. static readonly Version: string;
  101521. /** Gets the list of created engines */
  101522. static readonly Instances: Engine[];
  101523. /**
  101524. * Gets the latest created engine
  101525. */
  101526. static readonly LastCreatedEngine: Nullable<Engine>;
  101527. /**
  101528. * Gets the latest created scene
  101529. */
  101530. static readonly LastCreatedScene: Nullable<Scene>;
  101531. /**
  101532. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  101533. * @param flag defines which part of the materials must be marked as dirty
  101534. * @param predicate defines a predicate used to filter which materials should be affected
  101535. */
  101536. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101537. /**
  101538. * Method called to create the default loading screen.
  101539. * This can be overriden in your own app.
  101540. * @param canvas The rendering canvas element
  101541. * @returns The loading screen
  101542. */
  101543. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  101544. /**
  101545. * Method called to create the default rescale post process on each engine.
  101546. */
  101547. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  101548. /**
  101549. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  101550. **/
  101551. enableOfflineSupport: boolean;
  101552. /**
  101553. * 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)
  101554. **/
  101555. disableManifestCheck: boolean;
  101556. /**
  101557. * Gets the list of created scenes
  101558. */
  101559. scenes: Scene[];
  101560. /**
  101561. * Event raised when a new scene is created
  101562. */
  101563. onNewSceneAddedObservable: Observable<Scene>;
  101564. /**
  101565. * Gets the list of created postprocesses
  101566. */
  101567. postProcesses: PostProcess[];
  101568. /**
  101569. * Gets a boolean indicating if the pointer is currently locked
  101570. */
  101571. isPointerLock: boolean;
  101572. /**
  101573. * Observable event triggered each time the rendering canvas is resized
  101574. */
  101575. onResizeObservable: Observable<Engine>;
  101576. /**
  101577. * Observable event triggered each time the canvas loses focus
  101578. */
  101579. onCanvasBlurObservable: Observable<Engine>;
  101580. /**
  101581. * Observable event triggered each time the canvas gains focus
  101582. */
  101583. onCanvasFocusObservable: Observable<Engine>;
  101584. /**
  101585. * Observable event triggered each time the canvas receives pointerout event
  101586. */
  101587. onCanvasPointerOutObservable: Observable<PointerEvent>;
  101588. /**
  101589. * Observable raised when the engine begins a new frame
  101590. */
  101591. onBeginFrameObservable: Observable<Engine>;
  101592. /**
  101593. * If set, will be used to request the next animation frame for the render loop
  101594. */
  101595. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  101596. /**
  101597. * Observable raised when the engine ends the current frame
  101598. */
  101599. onEndFrameObservable: Observable<Engine>;
  101600. /**
  101601. * Observable raised when the engine is about to compile a shader
  101602. */
  101603. onBeforeShaderCompilationObservable: Observable<Engine>;
  101604. /**
  101605. * Observable raised when the engine has jsut compiled a shader
  101606. */
  101607. onAfterShaderCompilationObservable: Observable<Engine>;
  101608. /**
  101609. * Gets the audio engine
  101610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101611. * @ignorenaming
  101612. */
  101613. static audioEngine: IAudioEngine;
  101614. /**
  101615. * Default AudioEngine factory responsible of creating the Audio Engine.
  101616. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  101617. */
  101618. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  101619. /**
  101620. * Default offline support factory responsible of creating a tool used to store data locally.
  101621. * By default, this will create a Database object if the workload has been embedded.
  101622. */
  101623. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  101624. private _loadingScreen;
  101625. private _pointerLockRequested;
  101626. private _dummyFramebuffer;
  101627. private _rescalePostProcess;
  101628. /** @hidden */
  101629. protected _alphaMode: number;
  101630. /** @hidden */
  101631. protected _alphaEquation: number;
  101632. private _deterministicLockstep;
  101633. private _lockstepMaxSteps;
  101634. private _timeStep;
  101635. protected readonly _supportsHardwareTextureRescaling: boolean;
  101636. private _fps;
  101637. private _deltaTime;
  101638. /** @hidden */
  101639. _drawCalls: PerfCounter;
  101640. /**
  101641. * Turn this value on if you want to pause FPS computation when in background
  101642. */
  101643. disablePerformanceMonitorInBackground: boolean;
  101644. private _performanceMonitor;
  101645. /**
  101646. * Gets the performance monitor attached to this engine
  101647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101648. */
  101649. readonly performanceMonitor: PerformanceMonitor;
  101650. private _onFocus;
  101651. private _onBlur;
  101652. private _onCanvasPointerOut;
  101653. private _onCanvasBlur;
  101654. private _onCanvasFocus;
  101655. private _onFullscreenChange;
  101656. private _onPointerLockChange;
  101657. /**
  101658. * Gets the HTML element used to attach event listeners
  101659. * @returns a HTML element
  101660. */
  101661. getInputElement(): Nullable<HTMLElement>;
  101662. /**
  101663. * Creates a new engine
  101664. * @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
  101665. * @param antialias defines enable antialiasing (default: false)
  101666. * @param options defines further options to be sent to the getContext() function
  101667. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101668. */
  101669. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101670. /**
  101671. * Gets current aspect ratio
  101672. * @param viewportOwner defines the camera to use to get the aspect ratio
  101673. * @param useScreen defines if screen size must be used (or the current render target if any)
  101674. * @returns a number defining the aspect ratio
  101675. */
  101676. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  101677. /**
  101678. * Gets current screen aspect ratio
  101679. * @returns a number defining the aspect ratio
  101680. */
  101681. getScreenAspectRatio(): number;
  101682. /**
  101683. * Gets the client rect of the HTML canvas attached with the current webGL context
  101684. * @returns a client rectanglee
  101685. */
  101686. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  101687. /**
  101688. * Gets the client rect of the HTML element used for events
  101689. * @returns a client rectanglee
  101690. */
  101691. getInputElementClientRect(): Nullable<ClientRect>;
  101692. /**
  101693. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  101694. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101695. * @returns true if engine is in deterministic lock step mode
  101696. */
  101697. isDeterministicLockStep(): boolean;
  101698. /**
  101699. * Gets the max steps when engine is running in deterministic lock step
  101700. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101701. * @returns the max steps
  101702. */
  101703. getLockstepMaxSteps(): number;
  101704. /**
  101705. * Returns the time in ms between steps when using deterministic lock step.
  101706. * @returns time step in (ms)
  101707. */
  101708. getTimeStep(): number;
  101709. /**
  101710. * Force the mipmap generation for the given render target texture
  101711. * @param texture defines the render target texture to use
  101712. */
  101713. generateMipMapsForCubemap(texture: InternalTexture): void;
  101714. /** States */
  101715. /**
  101716. * Set various states to the webGL context
  101717. * @param culling defines backface culling state
  101718. * @param zOffset defines the value to apply to zOffset (0 by default)
  101719. * @param force defines if states must be applied even if cache is up to date
  101720. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  101721. */
  101722. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101723. /**
  101724. * Set the z offset to apply to current rendering
  101725. * @param value defines the offset to apply
  101726. */
  101727. setZOffset(value: number): void;
  101728. /**
  101729. * Gets the current value of the zOffset
  101730. * @returns the current zOffset state
  101731. */
  101732. getZOffset(): number;
  101733. /**
  101734. * Enable or disable depth buffering
  101735. * @param enable defines the state to set
  101736. */
  101737. setDepthBuffer(enable: boolean): void;
  101738. /**
  101739. * Gets a boolean indicating if depth writing is enabled
  101740. * @returns the current depth writing state
  101741. */
  101742. getDepthWrite(): boolean;
  101743. /**
  101744. * Enable or disable depth writing
  101745. * @param enable defines the state to set
  101746. */
  101747. setDepthWrite(enable: boolean): void;
  101748. /**
  101749. * Enable or disable color writing
  101750. * @param enable defines the state to set
  101751. */
  101752. setColorWrite(enable: boolean): void;
  101753. /**
  101754. * Gets a boolean indicating if color writing is enabled
  101755. * @returns the current color writing state
  101756. */
  101757. getColorWrite(): boolean;
  101758. /**
  101759. * Sets alpha constants used by some alpha blending modes
  101760. * @param r defines the red component
  101761. * @param g defines the green component
  101762. * @param b defines the blue component
  101763. * @param a defines the alpha component
  101764. */
  101765. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101766. /**
  101767. * Sets the current alpha mode
  101768. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101769. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101770. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101771. */
  101772. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101773. /**
  101774. * Gets the current alpha mode
  101775. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101776. * @returns the current alpha mode
  101777. */
  101778. getAlphaMode(): number;
  101779. /**
  101780. * Sets the current alpha equation
  101781. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101782. */
  101783. setAlphaEquation(equation: number): void;
  101784. /**
  101785. * Gets the current alpha equation.
  101786. * @returns the current alpha equation
  101787. */
  101788. getAlphaEquation(): number;
  101789. /**
  101790. * Gets a boolean indicating if stencil buffer is enabled
  101791. * @returns the current stencil buffer state
  101792. */
  101793. getStencilBuffer(): boolean;
  101794. /**
  101795. * Enable or disable the stencil buffer
  101796. * @param enable defines if the stencil buffer must be enabled or disabled
  101797. */
  101798. setStencilBuffer(enable: boolean): void;
  101799. /**
  101800. * Gets the current stencil mask
  101801. * @returns a number defining the new stencil mask to use
  101802. */
  101803. getStencilMask(): number;
  101804. /**
  101805. * Sets the current stencil mask
  101806. * @param mask defines the new stencil mask to use
  101807. */
  101808. setStencilMask(mask: number): void;
  101809. /**
  101810. * Gets the current stencil function
  101811. * @returns a number defining the stencil function to use
  101812. */
  101813. getStencilFunction(): number;
  101814. /**
  101815. * Gets the current stencil reference value
  101816. * @returns a number defining the stencil reference value to use
  101817. */
  101818. getStencilFunctionReference(): number;
  101819. /**
  101820. * Gets the current stencil mask
  101821. * @returns a number defining the stencil mask to use
  101822. */
  101823. getStencilFunctionMask(): number;
  101824. /**
  101825. * Sets the current stencil function
  101826. * @param stencilFunc defines the new stencil function to use
  101827. */
  101828. setStencilFunction(stencilFunc: number): void;
  101829. /**
  101830. * Sets the current stencil reference
  101831. * @param reference defines the new stencil reference to use
  101832. */
  101833. setStencilFunctionReference(reference: number): void;
  101834. /**
  101835. * Sets the current stencil mask
  101836. * @param mask defines the new stencil mask to use
  101837. */
  101838. setStencilFunctionMask(mask: number): void;
  101839. /**
  101840. * Gets the current stencil operation when stencil fails
  101841. * @returns a number defining stencil operation to use when stencil fails
  101842. */
  101843. getStencilOperationFail(): number;
  101844. /**
  101845. * Gets the current stencil operation when depth fails
  101846. * @returns a number defining stencil operation to use when depth fails
  101847. */
  101848. getStencilOperationDepthFail(): number;
  101849. /**
  101850. * Gets the current stencil operation when stencil passes
  101851. * @returns a number defining stencil operation to use when stencil passes
  101852. */
  101853. getStencilOperationPass(): number;
  101854. /**
  101855. * Sets the stencil operation to use when stencil fails
  101856. * @param operation defines the stencil operation to use when stencil fails
  101857. */
  101858. setStencilOperationFail(operation: number): void;
  101859. /**
  101860. * Sets the stencil operation to use when depth fails
  101861. * @param operation defines the stencil operation to use when depth fails
  101862. */
  101863. setStencilOperationDepthFail(operation: number): void;
  101864. /**
  101865. * Sets the stencil operation to use when stencil passes
  101866. * @param operation defines the stencil operation to use when stencil passes
  101867. */
  101868. setStencilOperationPass(operation: number): void;
  101869. /**
  101870. * Sets a boolean indicating if the dithering state is enabled or disabled
  101871. * @param value defines the dithering state
  101872. */
  101873. setDitheringState(value: boolean): void;
  101874. /**
  101875. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  101876. * @param value defines the rasterizer state
  101877. */
  101878. setRasterizerState(value: boolean): void;
  101879. /**
  101880. * Gets the current depth function
  101881. * @returns a number defining the depth function
  101882. */
  101883. getDepthFunction(): Nullable<number>;
  101884. /**
  101885. * Sets the current depth function
  101886. * @param depthFunc defines the function to use
  101887. */
  101888. setDepthFunction(depthFunc: number): void;
  101889. /**
  101890. * Sets the current depth function to GREATER
  101891. */
  101892. setDepthFunctionToGreater(): void;
  101893. /**
  101894. * Sets the current depth function to GEQUAL
  101895. */
  101896. setDepthFunctionToGreaterOrEqual(): void;
  101897. /**
  101898. * Sets the current depth function to LESS
  101899. */
  101900. setDepthFunctionToLess(): void;
  101901. /**
  101902. * Sets the current depth function to LEQUAL
  101903. */
  101904. setDepthFunctionToLessOrEqual(): void;
  101905. private _cachedStencilBuffer;
  101906. private _cachedStencilFunction;
  101907. private _cachedStencilMask;
  101908. private _cachedStencilOperationPass;
  101909. private _cachedStencilOperationFail;
  101910. private _cachedStencilOperationDepthFail;
  101911. private _cachedStencilReference;
  101912. /**
  101913. * Caches the the state of the stencil buffer
  101914. */
  101915. cacheStencilState(): void;
  101916. /**
  101917. * Restores the state of the stencil buffer
  101918. */
  101919. restoreStencilState(): void;
  101920. /**
  101921. * Directly set the WebGL Viewport
  101922. * @param x defines the x coordinate of the viewport (in screen space)
  101923. * @param y defines the y coordinate of the viewport (in screen space)
  101924. * @param width defines the width of the viewport (in screen space)
  101925. * @param height defines the height of the viewport (in screen space)
  101926. * @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
  101927. */
  101928. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  101929. /**
  101930. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  101931. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101932. * @param y defines the y-coordinate of the corner of the clear rectangle
  101933. * @param width defines the width of the clear rectangle
  101934. * @param height defines the height of the clear rectangle
  101935. * @param clearColor defines the clear color
  101936. */
  101937. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  101938. /**
  101939. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  101940. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101941. * @param y defines the y-coordinate of the corner of the clear rectangle
  101942. * @param width defines the width of the clear rectangle
  101943. * @param height defines the height of the clear rectangle
  101944. */
  101945. enableScissor(x: number, y: number, width: number, height: number): void;
  101946. /**
  101947. * Disable previously set scissor test rectangle
  101948. */
  101949. disableScissor(): void;
  101950. protected _reportDrawCall(): void;
  101951. /**
  101952. * Initializes a webVR display and starts listening to display change events
  101953. * The onVRDisplayChangedObservable will be notified upon these changes
  101954. * @returns The onVRDisplayChangedObservable
  101955. */
  101956. initWebVR(): Observable<IDisplayChangedEventArgs>;
  101957. /** @hidden */
  101958. _prepareVRComponent(): void;
  101959. /** @hidden */
  101960. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  101961. /** @hidden */
  101962. _submitVRFrame(): void;
  101963. /**
  101964. * Call this function to leave webVR mode
  101965. * Will do nothing if webVR is not supported or if there is no webVR device
  101966. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101967. */
  101968. disableVR(): void;
  101969. /**
  101970. * Gets a boolean indicating that the system is in VR mode and is presenting
  101971. * @returns true if VR mode is engaged
  101972. */
  101973. isVRPresenting(): boolean;
  101974. /** @hidden */
  101975. _requestVRFrame(): void;
  101976. /** @hidden */
  101977. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101978. /**
  101979. * Gets the source code of the vertex shader associated with a specific webGL program
  101980. * @param program defines the program to use
  101981. * @returns a string containing the source code of the vertex shader associated with the program
  101982. */
  101983. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  101984. /**
  101985. * Gets the source code of the fragment shader associated with a specific webGL program
  101986. * @param program defines the program to use
  101987. * @returns a string containing the source code of the fragment shader associated with the program
  101988. */
  101989. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  101990. /**
  101991. * Reads pixels from the current frame buffer. Please note that this function can be slow
  101992. * @param x defines the x coordinate of the rectangle where pixels must be read
  101993. * @param y defines the y coordinate of the rectangle where pixels must be read
  101994. * @param width defines the width of the rectangle where pixels must be read
  101995. * @param height defines the height of the rectangle where pixels must be read
  101996. * @returns a Uint8Array containing RGBA colors
  101997. */
  101998. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  101999. /**
  102000. * Sets a depth stencil texture from a render target to the according uniform.
  102001. * @param channel The texture channel
  102002. * @param uniform The uniform to set
  102003. * @param texture The render target texture containing the depth stencil texture to apply
  102004. */
  102005. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  102006. /**
  102007. * Sets a texture to the webGL context from a postprocess
  102008. * @param channel defines the channel to use
  102009. * @param postProcess defines the source postprocess
  102010. */
  102011. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  102012. /**
  102013. * Binds the output of the passed in post process to the texture channel specified
  102014. * @param channel The channel the texture should be bound to
  102015. * @param postProcess The post process which's output should be bound
  102016. */
  102017. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  102018. /** @hidden */
  102019. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  102020. protected _rebuildBuffers(): void;
  102021. /** @hidden */
  102022. _renderFrame(): void;
  102023. _renderLoop(): void;
  102024. /** @hidden */
  102025. _renderViews(): boolean;
  102026. /**
  102027. * Toggle full screen mode
  102028. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102029. */
  102030. switchFullscreen(requestPointerLock: boolean): void;
  102031. /**
  102032. * Enters full screen mode
  102033. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102034. */
  102035. enterFullscreen(requestPointerLock: boolean): void;
  102036. /**
  102037. * Exits full screen mode
  102038. */
  102039. exitFullscreen(): void;
  102040. /**
  102041. * Enters Pointerlock mode
  102042. */
  102043. enterPointerlock(): void;
  102044. /**
  102045. * Exits Pointerlock mode
  102046. */
  102047. exitPointerlock(): void;
  102048. /**
  102049. * Begin a new frame
  102050. */
  102051. beginFrame(): void;
  102052. /**
  102053. * Enf the current frame
  102054. */
  102055. endFrame(): void;
  102056. resize(): void;
  102057. /**
  102058. * Set the compressed texture format to use, based on the formats you have, and the formats
  102059. * supported by the hardware / browser.
  102060. *
  102061. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102062. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102063. * to API arguments needed to compressed textures. This puts the burden on the container
  102064. * generator to house the arcane code for determining these for current & future formats.
  102065. *
  102066. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102067. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102068. *
  102069. * Note: The result of this call is not taken into account when a texture is base64.
  102070. *
  102071. * @param formatsAvailable defines the list of those format families you have created
  102072. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102073. *
  102074. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102075. * @returns The extension selected.
  102076. */
  102077. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102078. /**
  102079. * Set the compressed texture extensions or file names to skip.
  102080. *
  102081. * @param skippedFiles defines the list of those texture files you want to skip
  102082. * Example: [".dds", ".env", "myfile.png"]
  102083. */
  102084. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  102085. /**
  102086. * Force a specific size of the canvas
  102087. * @param width defines the new canvas' width
  102088. * @param height defines the new canvas' height
  102089. */
  102090. setSize(width: number, height: number): void;
  102091. /**
  102092. * Updates a dynamic vertex buffer.
  102093. * @param vertexBuffer the vertex buffer to update
  102094. * @param data the data used to update the vertex buffer
  102095. * @param byteOffset the byte offset of the data
  102096. * @param byteLength the byte length of the data
  102097. */
  102098. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102099. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102100. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102101. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102102. _releaseTexture(texture: InternalTexture): void;
  102103. /**
  102104. * @hidden
  102105. * Rescales a texture
  102106. * @param source input texutre
  102107. * @param destination destination texture
  102108. * @param scene scene to use to render the resize
  102109. * @param internalFormat format to use when resizing
  102110. * @param onComplete callback to be called when resize has completed
  102111. */
  102112. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102113. /**
  102114. * Gets the current framerate
  102115. * @returns a number representing the framerate
  102116. */
  102117. getFps(): number;
  102118. /**
  102119. * Gets the time spent between current and previous frame
  102120. * @returns a number representing the delta time in ms
  102121. */
  102122. getDeltaTime(): number;
  102123. private _measureFps;
  102124. /** @hidden */
  102125. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102126. /**
  102127. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102128. * @param renderTarget The render target to set the frame buffer for
  102129. */
  102130. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102131. /**
  102132. * Update a dynamic index buffer
  102133. * @param indexBuffer defines the target index buffer
  102134. * @param indices defines the data to update
  102135. * @param offset defines the offset in the target index buffer where update should start
  102136. */
  102137. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102138. /**
  102139. * Updates the sample count of a render target texture
  102140. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102141. * @param texture defines the texture to update
  102142. * @param samples defines the sample count to set
  102143. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102144. */
  102145. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102146. /**
  102147. * Updates a depth texture Comparison Mode and Function.
  102148. * If the comparison Function is equal to 0, the mode will be set to none.
  102149. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102150. * @param texture The texture to set the comparison function for
  102151. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102152. */
  102153. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102154. /**
  102155. * Creates a webGL buffer to use with instanciation
  102156. * @param capacity defines the size of the buffer
  102157. * @returns the webGL buffer
  102158. */
  102159. createInstancesBuffer(capacity: number): DataBuffer;
  102160. /**
  102161. * Delete a webGL buffer used with instanciation
  102162. * @param buffer defines the webGL buffer to delete
  102163. */
  102164. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102165. /** @hidden */
  102166. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102167. dispose(): void;
  102168. private _disableTouchAction;
  102169. /**
  102170. * Display the loading screen
  102171. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102172. */
  102173. displayLoadingUI(): void;
  102174. /**
  102175. * Hide the loading screen
  102176. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102177. */
  102178. hideLoadingUI(): void;
  102179. /**
  102180. * Gets the current loading screen object
  102181. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102182. */
  102183. /**
  102184. * Sets the current loading screen object
  102185. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102186. */
  102187. loadingScreen: ILoadingScreen;
  102188. /**
  102189. * Sets the current loading screen text
  102190. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102191. */
  102192. loadingUIText: string;
  102193. /**
  102194. * Sets the current loading screen background color
  102195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102196. */
  102197. loadingUIBackgroundColor: string;
  102198. /** Pointerlock and fullscreen */
  102199. /**
  102200. * Ask the browser to promote the current element to pointerlock mode
  102201. * @param element defines the DOM element to promote
  102202. */
  102203. static _RequestPointerlock(element: HTMLElement): void;
  102204. /**
  102205. * Asks the browser to exit pointerlock mode
  102206. */
  102207. static _ExitPointerlock(): void;
  102208. /**
  102209. * Ask the browser to promote the current element to fullscreen rendering mode
  102210. * @param element defines the DOM element to promote
  102211. */
  102212. static _RequestFullscreen(element: HTMLElement): void;
  102213. /**
  102214. * Asks the browser to exit fullscreen mode
  102215. */
  102216. static _ExitFullscreen(): void;
  102217. }
  102218. }
  102219. declare module BABYLON {
  102220. /**
  102221. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102222. * during the life time of the application.
  102223. */
  102224. export class EngineStore {
  102225. /** Gets the list of created engines */
  102226. static Instances: Engine[];
  102227. /** @hidden */
  102228. static _LastCreatedScene: Nullable<Scene>;
  102229. /**
  102230. * Gets the latest created engine
  102231. */
  102232. static readonly LastCreatedEngine: Nullable<Engine>;
  102233. /**
  102234. * Gets the latest created scene
  102235. */
  102236. static readonly LastCreatedScene: Nullable<Scene>;
  102237. /**
  102238. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102239. * @ignorenaming
  102240. */
  102241. static UseFallbackTexture: boolean;
  102242. /**
  102243. * Texture content used if a texture cannot loaded
  102244. * @ignorenaming
  102245. */
  102246. static FallbackTexture: string;
  102247. }
  102248. }
  102249. declare module BABYLON {
  102250. /**
  102251. * Helper class that provides a small promise polyfill
  102252. */
  102253. export class PromisePolyfill {
  102254. /**
  102255. * Static function used to check if the polyfill is required
  102256. * If this is the case then the function will inject the polyfill to window.Promise
  102257. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102258. */
  102259. static Apply(force?: boolean): void;
  102260. }
  102261. }
  102262. declare module BABYLON {
  102263. /**
  102264. * Interface for screenshot methods with describe argument called `size` as object with options
  102265. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102266. */
  102267. export interface IScreenshotSize {
  102268. /**
  102269. * number in pixels for canvas height
  102270. */
  102271. height?: number;
  102272. /**
  102273. * multiplier allowing render at a higher or lower resolution
  102274. * If value is defined then height and width will be ignored and taken from camera
  102275. */
  102276. precision?: number;
  102277. /**
  102278. * number in pixels for canvas width
  102279. */
  102280. width?: number;
  102281. }
  102282. }
  102283. declare module BABYLON {
  102284. interface IColor4Like {
  102285. r: float;
  102286. g: float;
  102287. b: float;
  102288. a: float;
  102289. }
  102290. /**
  102291. * Class containing a set of static utilities functions
  102292. */
  102293. export class Tools {
  102294. /**
  102295. * Gets or sets the base URL to use to load assets
  102296. */
  102297. static BaseUrl: string;
  102298. /**
  102299. * Enable/Disable Custom HTTP Request Headers globally.
  102300. * default = false
  102301. * @see CustomRequestHeaders
  102302. */
  102303. static UseCustomRequestHeaders: boolean;
  102304. /**
  102305. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102306. * i.e. when loading files, where the server/service expects an Authorization header
  102307. */
  102308. static CustomRequestHeaders: {
  102309. [key: string]: string;
  102310. };
  102311. /**
  102312. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102313. */
  102314. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102315. /**
  102316. * Default behaviour for cors in the application.
  102317. * It can be a string if the expected behavior is identical in the entire app.
  102318. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102319. */
  102320. static CorsBehavior: string | ((url: string | string[]) => string);
  102321. /**
  102322. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102323. * @ignorenaming
  102324. */
  102325. static UseFallbackTexture: boolean;
  102326. /**
  102327. * Use this object to register external classes like custom textures or material
  102328. * to allow the laoders to instantiate them
  102329. */
  102330. static RegisteredExternalClasses: {
  102331. [key: string]: Object;
  102332. };
  102333. /**
  102334. * Texture content used if a texture cannot loaded
  102335. * @ignorenaming
  102336. */
  102337. static fallbackTexture: string;
  102338. /**
  102339. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102340. * @param u defines the coordinate on X axis
  102341. * @param v defines the coordinate on Y axis
  102342. * @param width defines the width of the source data
  102343. * @param height defines the height of the source data
  102344. * @param pixels defines the source byte array
  102345. * @param color defines the output color
  102346. */
  102347. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102348. /**
  102349. * Interpolates between a and b via alpha
  102350. * @param a The lower value (returned when alpha = 0)
  102351. * @param b The upper value (returned when alpha = 1)
  102352. * @param alpha The interpolation-factor
  102353. * @return The mixed value
  102354. */
  102355. static Mix(a: number, b: number, alpha: number): number;
  102356. /**
  102357. * Tries to instantiate a new object from a given class name
  102358. * @param className defines the class name to instantiate
  102359. * @returns the new object or null if the system was not able to do the instantiation
  102360. */
  102361. static Instantiate(className: string): any;
  102362. /**
  102363. * Provides a slice function that will work even on IE
  102364. * @param data defines the array to slice
  102365. * @param start defines the start of the data (optional)
  102366. * @param end defines the end of the data (optional)
  102367. * @returns the new sliced array
  102368. */
  102369. static Slice<T>(data: T, start?: number, end?: number): T;
  102370. /**
  102371. * Polyfill for setImmediate
  102372. * @param action defines the action to execute after the current execution block
  102373. */
  102374. static SetImmediate(action: () => void): void;
  102375. /**
  102376. * Function indicating if a number is an exponent of 2
  102377. * @param value defines the value to test
  102378. * @returns true if the value is an exponent of 2
  102379. */
  102380. static IsExponentOfTwo(value: number): boolean;
  102381. private static _tmpFloatArray;
  102382. /**
  102383. * Returns the nearest 32-bit single precision float representation of a Number
  102384. * @param value A Number. If the parameter is of a different type, it will get converted
  102385. * to a number or to NaN if it cannot be converted
  102386. * @returns number
  102387. */
  102388. static FloatRound(value: number): number;
  102389. /**
  102390. * Extracts the filename from a path
  102391. * @param path defines the path to use
  102392. * @returns the filename
  102393. */
  102394. static GetFilename(path: string): string;
  102395. /**
  102396. * Extracts the "folder" part of a path (everything before the filename).
  102397. * @param uri The URI to extract the info from
  102398. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102399. * @returns The "folder" part of the path
  102400. */
  102401. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102402. /**
  102403. * Extracts text content from a DOM element hierarchy
  102404. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102405. */
  102406. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102407. /**
  102408. * Convert an angle in radians to degrees
  102409. * @param angle defines the angle to convert
  102410. * @returns the angle in degrees
  102411. */
  102412. static ToDegrees(angle: number): number;
  102413. /**
  102414. * Convert an angle in degrees to radians
  102415. * @param angle defines the angle to convert
  102416. * @returns the angle in radians
  102417. */
  102418. static ToRadians(angle: number): number;
  102419. /**
  102420. * Returns an array if obj is not an array
  102421. * @param obj defines the object to evaluate as an array
  102422. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102423. * @returns either obj directly if obj is an array or a new array containing obj
  102424. */
  102425. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102426. /**
  102427. * Gets the pointer prefix to use
  102428. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102429. */
  102430. static GetPointerPrefix(): string;
  102431. /**
  102432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102433. * @param url define the url we are trying
  102434. * @param element define the dom element where to configure the cors policy
  102435. */
  102436. static SetCorsBehavior(url: string | string[], element: {
  102437. crossOrigin: string | null;
  102438. }): void;
  102439. /**
  102440. * Removes unwanted characters from an url
  102441. * @param url defines the url to clean
  102442. * @returns the cleaned url
  102443. */
  102444. static CleanUrl(url: string): string;
  102445. /**
  102446. * Gets or sets a function used to pre-process url before using them to load assets
  102447. */
  102448. static PreprocessUrl: (url: string) => string;
  102449. /**
  102450. * Loads an image as an HTMLImageElement.
  102451. * @param input url string, ArrayBuffer, or Blob to load
  102452. * @param onLoad callback called when the image successfully loads
  102453. * @param onError callback called when the image fails to load
  102454. * @param offlineProvider offline provider for caching
  102455. * @param mimeType optional mime type
  102456. * @returns the HTMLImageElement of the loaded image
  102457. */
  102458. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102459. /**
  102460. * Loads a file from a url
  102461. * @param url url string, ArrayBuffer, or Blob to load
  102462. * @param onSuccess callback called when the file successfully loads
  102463. * @param onProgress callback called while file is loading (if the server supports this mode)
  102464. * @param offlineProvider defines the offline provider for caching
  102465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102466. * @param onError callback called when the file fails to load
  102467. * @returns a file request object
  102468. */
  102469. 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;
  102470. /**
  102471. * Loads a file from a url
  102472. * @param url the file url to load
  102473. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102474. */
  102475. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102476. /**
  102477. * Load a script (identified by an url). When the url returns, the
  102478. * content of this file is added into a new script element, attached to the DOM (body element)
  102479. * @param scriptUrl defines the url of the script to laod
  102480. * @param onSuccess defines the callback called when the script is loaded
  102481. * @param onError defines the callback to call if an error occurs
  102482. * @param scriptId defines the id of the script element
  102483. */
  102484. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102485. /**
  102486. * Load an asynchronous script (identified by an url). When the url returns, the
  102487. * content of this file is added into a new script element, attached to the DOM (body element)
  102488. * @param scriptUrl defines the url of the script to laod
  102489. * @param scriptId defines the id of the script element
  102490. * @returns a promise request object
  102491. */
  102492. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102493. /**
  102494. * Loads a file from a blob
  102495. * @param fileToLoad defines the blob to use
  102496. * @param callback defines the callback to call when data is loaded
  102497. * @param progressCallback defines the callback to call during loading process
  102498. * @returns a file request object
  102499. */
  102500. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102501. /**
  102502. * Reads a file from a File object
  102503. * @param file defines the file to load
  102504. * @param onSuccess defines the callback to call when data is loaded
  102505. * @param onProgress defines the callback to call during loading process
  102506. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102507. * @param onError defines the callback to call when an error occurs
  102508. * @returns a file request object
  102509. */
  102510. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102511. /**
  102512. * Creates a data url from a given string content
  102513. * @param content defines the content to convert
  102514. * @returns the new data url link
  102515. */
  102516. static FileAsURL(content: string): string;
  102517. /**
  102518. * Format the given number to a specific decimal format
  102519. * @param value defines the number to format
  102520. * @param decimals defines the number of decimals to use
  102521. * @returns the formatted string
  102522. */
  102523. static Format(value: number, decimals?: number): string;
  102524. /**
  102525. * Tries to copy an object by duplicating every property
  102526. * @param source defines the source object
  102527. * @param destination defines the target object
  102528. * @param doNotCopyList defines a list of properties to avoid
  102529. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102530. */
  102531. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  102532. /**
  102533. * Gets a boolean indicating if the given object has no own property
  102534. * @param obj defines the object to test
  102535. * @returns true if object has no own property
  102536. */
  102537. static IsEmpty(obj: any): boolean;
  102538. /**
  102539. * Function used to register events at window level
  102540. * @param windowElement defines the Window object to use
  102541. * @param events defines the events to register
  102542. */
  102543. static RegisterTopRootEvents(windowElement: Window, events: {
  102544. name: string;
  102545. handler: Nullable<(e: FocusEvent) => any>;
  102546. }[]): void;
  102547. /**
  102548. * Function used to unregister events from window level
  102549. * @param windowElement defines the Window object to use
  102550. * @param events defines the events to unregister
  102551. */
  102552. static UnregisterTopRootEvents(windowElement: Window, events: {
  102553. name: string;
  102554. handler: Nullable<(e: FocusEvent) => any>;
  102555. }[]): void;
  102556. /**
  102557. * @ignore
  102558. */
  102559. static _ScreenshotCanvas: HTMLCanvasElement;
  102560. /**
  102561. * Dumps the current bound framebuffer
  102562. * @param width defines the rendering width
  102563. * @param height defines the rendering height
  102564. * @param engine defines the hosting engine
  102565. * @param successCallback defines the callback triggered once the data are available
  102566. * @param mimeType defines the mime type of the result
  102567. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102568. */
  102569. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102570. /**
  102571. * Converts the canvas data to blob.
  102572. * This acts as a polyfill for browsers not supporting the to blob function.
  102573. * @param canvas Defines the canvas to extract the data from
  102574. * @param successCallback Defines the callback triggered once the data are available
  102575. * @param mimeType Defines the mime type of the result
  102576. */
  102577. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  102578. /**
  102579. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102580. * @param successCallback defines the callback triggered once the data are available
  102581. * @param mimeType defines the mime type of the result
  102582. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102583. */
  102584. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102585. /**
  102586. * Downloads a blob in the browser
  102587. * @param blob defines the blob to download
  102588. * @param fileName defines the name of the downloaded file
  102589. */
  102590. static Download(blob: Blob, fileName: string): void;
  102591. /**
  102592. * Captures a screenshot of the current rendering
  102593. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102594. * @param engine defines the rendering engine
  102595. * @param camera defines the source camera
  102596. * @param size This parameter can be set to a single number or to an object with the
  102597. * following (optional) properties: precision, width, height. If a single number is passed,
  102598. * it will be used for both width and height. If an object is passed, the screenshot size
  102599. * will be derived from the parameters. The precision property is a multiplier allowing
  102600. * rendering at a higher or lower resolution
  102601. * @param successCallback defines the callback receives a single parameter which contains the
  102602. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102603. * src parameter of an <img> to display it
  102604. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102605. * Check your browser for supported MIME types
  102606. */
  102607. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  102608. /**
  102609. * Captures a screenshot of the current rendering
  102610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102611. * @param engine defines the rendering engine
  102612. * @param camera defines the source camera
  102613. * @param size This parameter can be set to a single number or to an object with the
  102614. * following (optional) properties: precision, width, height. If a single number is passed,
  102615. * it will be used for both width and height. If an object is passed, the screenshot size
  102616. * will be derived from the parameters. The precision property is a multiplier allowing
  102617. * rendering at a higher or lower resolution
  102618. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102619. * Check your browser for supported MIME types
  102620. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102621. * to the src parameter of an <img> to display it
  102622. */
  102623. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  102624. /**
  102625. * Generates an image screenshot from the specified camera.
  102626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102627. * @param engine The engine to use for rendering
  102628. * @param camera The camera to use for rendering
  102629. * @param size This parameter can be set to a single number or to an object with the
  102630. * following (optional) properties: precision, width, height. If a single number is passed,
  102631. * it will be used for both width and height. If an object is passed, the screenshot size
  102632. * will be derived from the parameters. The precision property is a multiplier allowing
  102633. * rendering at a higher or lower resolution
  102634. * @param successCallback The callback receives a single parameter which contains the
  102635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102636. * src parameter of an <img> to display it
  102637. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102638. * Check your browser for supported MIME types
  102639. * @param samples Texture samples (default: 1)
  102640. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102641. * @param fileName A name for for the downloaded file.
  102642. */
  102643. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  102644. /**
  102645. * Generates an image screenshot from the specified camera.
  102646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102647. * @param engine The engine to use for rendering
  102648. * @param camera The camera to use for rendering
  102649. * @param size This parameter can be set to a single number or to an object with the
  102650. * following (optional) properties: precision, width, height. If a single number is passed,
  102651. * it will be used for both width and height. If an object is passed, the screenshot size
  102652. * will be derived from the parameters. The precision property is a multiplier allowing
  102653. * rendering at a higher or lower resolution
  102654. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102655. * Check your browser for supported MIME types
  102656. * @param samples Texture samples (default: 1)
  102657. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102658. * @param fileName A name for for the downloaded file.
  102659. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102660. * to the src parameter of an <img> to display it
  102661. */
  102662. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  102663. /**
  102664. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102665. * Be aware Math.random() could cause collisions, but:
  102666. * "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"
  102667. * @returns a pseudo random id
  102668. */
  102669. static RandomId(): string;
  102670. /**
  102671. * Test if the given uri is a base64 string
  102672. * @param uri The uri to test
  102673. * @return True if the uri is a base64 string or false otherwise
  102674. */
  102675. static IsBase64(uri: string): boolean;
  102676. /**
  102677. * Decode the given base64 uri.
  102678. * @param uri The uri to decode
  102679. * @return The decoded base64 data.
  102680. */
  102681. static DecodeBase64(uri: string): ArrayBuffer;
  102682. /**
  102683. * Gets the absolute url.
  102684. * @param url the input url
  102685. * @return the absolute url
  102686. */
  102687. static GetAbsoluteUrl(url: string): string;
  102688. /**
  102689. * No log
  102690. */
  102691. static readonly NoneLogLevel: number;
  102692. /**
  102693. * Only message logs
  102694. */
  102695. static readonly MessageLogLevel: number;
  102696. /**
  102697. * Only warning logs
  102698. */
  102699. static readonly WarningLogLevel: number;
  102700. /**
  102701. * Only error logs
  102702. */
  102703. static readonly ErrorLogLevel: number;
  102704. /**
  102705. * All logs
  102706. */
  102707. static readonly AllLogLevel: number;
  102708. /**
  102709. * Gets a value indicating the number of loading errors
  102710. * @ignorenaming
  102711. */
  102712. static readonly errorsCount: number;
  102713. /**
  102714. * Callback called when a new log is added
  102715. */
  102716. static OnNewCacheEntry: (entry: string) => void;
  102717. /**
  102718. * Log a message to the console
  102719. * @param message defines the message to log
  102720. */
  102721. static Log(message: string): void;
  102722. /**
  102723. * Write a warning message to the console
  102724. * @param message defines the message to log
  102725. */
  102726. static Warn(message: string): void;
  102727. /**
  102728. * Write an error message to the console
  102729. * @param message defines the message to log
  102730. */
  102731. static Error(message: string): void;
  102732. /**
  102733. * Gets current log cache (list of logs)
  102734. */
  102735. static readonly LogCache: string;
  102736. /**
  102737. * Clears the log cache
  102738. */
  102739. static ClearLogCache(): void;
  102740. /**
  102741. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102742. */
  102743. static LogLevels: number;
  102744. /**
  102745. * Checks if the window object exists
  102746. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102747. */
  102748. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  102749. /**
  102750. * No performance log
  102751. */
  102752. static readonly PerformanceNoneLogLevel: number;
  102753. /**
  102754. * Use user marks to log performance
  102755. */
  102756. static readonly PerformanceUserMarkLogLevel: number;
  102757. /**
  102758. * Log performance to the console
  102759. */
  102760. static readonly PerformanceConsoleLogLevel: number;
  102761. private static _performance;
  102762. /**
  102763. * Sets the current performance log level
  102764. */
  102765. static PerformanceLogLevel: number;
  102766. private static _StartPerformanceCounterDisabled;
  102767. private static _EndPerformanceCounterDisabled;
  102768. private static _StartUserMark;
  102769. private static _EndUserMark;
  102770. private static _StartPerformanceConsole;
  102771. private static _EndPerformanceConsole;
  102772. /**
  102773. * Starts a performance counter
  102774. */
  102775. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102776. /**
  102777. * Ends a specific performance coutner
  102778. */
  102779. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102780. /**
  102781. * Gets either window.performance.now() if supported or Date.now() else
  102782. */
  102783. static readonly Now: number;
  102784. /**
  102785. * This method will return the name of the class used to create the instance of the given object.
  102786. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102787. * @param object the object to get the class name from
  102788. * @param isType defines if the object is actually a type
  102789. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102790. */
  102791. static GetClassName(object: any, isType?: boolean): string;
  102792. /**
  102793. * Gets the first element of an array satisfying a given predicate
  102794. * @param array defines the array to browse
  102795. * @param predicate defines the predicate to use
  102796. * @returns null if not found or the element
  102797. */
  102798. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  102799. /**
  102800. * This method will return the name of the full name of the class, including its owning module (if any).
  102801. * 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).
  102802. * @param object the object to get the class name from
  102803. * @param isType defines if the object is actually a type
  102804. * @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.
  102805. * @ignorenaming
  102806. */
  102807. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  102808. /**
  102809. * Returns a promise that resolves after the given amount of time.
  102810. * @param delay Number of milliseconds to delay
  102811. * @returns Promise that resolves after the given amount of time
  102812. */
  102813. static DelayAsync(delay: number): Promise<void>;
  102814. }
  102815. /**
  102816. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  102817. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  102818. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  102819. * @param name The name of the class, case should be preserved
  102820. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  102821. */
  102822. export function className(name: string, module?: string): (target: Object) => void;
  102823. /**
  102824. * An implementation of a loop for asynchronous functions.
  102825. */
  102826. export class AsyncLoop {
  102827. /**
  102828. * Defines the number of iterations for the loop
  102829. */
  102830. iterations: number;
  102831. /**
  102832. * Defines the current index of the loop.
  102833. */
  102834. index: number;
  102835. private _done;
  102836. private _fn;
  102837. private _successCallback;
  102838. /**
  102839. * Constructor.
  102840. * @param iterations the number of iterations.
  102841. * @param func the function to run each iteration
  102842. * @param successCallback the callback that will be called upon succesful execution
  102843. * @param offset starting offset.
  102844. */
  102845. constructor(
  102846. /**
  102847. * Defines the number of iterations for the loop
  102848. */
  102849. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  102850. /**
  102851. * Execute the next iteration. Must be called after the last iteration was finished.
  102852. */
  102853. executeNext(): void;
  102854. /**
  102855. * Break the loop and run the success callback.
  102856. */
  102857. breakLoop(): void;
  102858. /**
  102859. * Create and run an async loop.
  102860. * @param iterations the number of iterations.
  102861. * @param fn the function to run each iteration
  102862. * @param successCallback the callback that will be called upon succesful execution
  102863. * @param offset starting offset.
  102864. * @returns the created async loop object
  102865. */
  102866. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  102867. /**
  102868. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102869. * @param iterations total number of iterations
  102870. * @param syncedIterations number of synchronous iterations in each async iteration.
  102871. * @param fn the function to call each iteration.
  102872. * @param callback a success call back that will be called when iterating stops.
  102873. * @param breakFunction a break condition (optional)
  102874. * @param timeout timeout settings for the setTimeout function. default - 0.
  102875. * @returns the created async loop object
  102876. */
  102877. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  102878. }
  102879. }
  102880. declare module BABYLON {
  102881. /**
  102882. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102883. * The underlying implementation relies on an associative array to ensure the best performances.
  102884. * The value can be anything including 'null' but except 'undefined'
  102885. */
  102886. export class StringDictionary<T> {
  102887. /**
  102888. * This will clear this dictionary and copy the content from the 'source' one.
  102889. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102890. * @param source the dictionary to take the content from and copy to this dictionary
  102891. */
  102892. copyFrom(source: StringDictionary<T>): void;
  102893. /**
  102894. * Get a value based from its key
  102895. * @param key the given key to get the matching value from
  102896. * @return the value if found, otherwise undefined is returned
  102897. */
  102898. get(key: string): T | undefined;
  102899. /**
  102900. * Get a value from its key or add it if it doesn't exist.
  102901. * This method will ensure you that a given key/data will be present in the dictionary.
  102902. * @param key the given key to get the matching value from
  102903. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102904. * The factory will only be invoked if there's no data for the given key.
  102905. * @return the value corresponding to the key.
  102906. */
  102907. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  102908. /**
  102909. * Get a value from its key if present in the dictionary otherwise add it
  102910. * @param key the key to get the value from
  102911. * @param val if there's no such key/value pair in the dictionary add it with this value
  102912. * @return the value corresponding to the key
  102913. */
  102914. getOrAdd(key: string, val: T): T;
  102915. /**
  102916. * Check if there's a given key in the dictionary
  102917. * @param key the key to check for
  102918. * @return true if the key is present, false otherwise
  102919. */
  102920. contains(key: string): boolean;
  102921. /**
  102922. * Add a new key and its corresponding value
  102923. * @param key the key to add
  102924. * @param value the value corresponding to the key
  102925. * @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
  102926. */
  102927. add(key: string, value: T): boolean;
  102928. /**
  102929. * Update a specific value associated to a key
  102930. * @param key defines the key to use
  102931. * @param value defines the value to store
  102932. * @returns true if the value was updated (or false if the key was not found)
  102933. */
  102934. set(key: string, value: T): boolean;
  102935. /**
  102936. * Get the element of the given key and remove it from the dictionary
  102937. * @param key defines the key to search
  102938. * @returns the value associated with the key or null if not found
  102939. */
  102940. getAndRemove(key: string): Nullable<T>;
  102941. /**
  102942. * Remove a key/value from the dictionary.
  102943. * @param key the key to remove
  102944. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102945. */
  102946. remove(key: string): boolean;
  102947. /**
  102948. * Clear the whole content of the dictionary
  102949. */
  102950. clear(): void;
  102951. /**
  102952. * Gets the current count
  102953. */
  102954. readonly count: number;
  102955. /**
  102956. * Execute a callback on each key/val of the dictionary.
  102957. * Note that you can remove any element in this dictionary in the callback implementation
  102958. * @param callback the callback to execute on a given key/value pair
  102959. */
  102960. forEach(callback: (key: string, val: T) => void): void;
  102961. /**
  102962. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102963. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102964. * Note that you can remove any element in this dictionary in the callback implementation
  102965. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102966. * @returns the first item
  102967. */
  102968. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  102969. private _count;
  102970. private _data;
  102971. }
  102972. }
  102973. declare module BABYLON {
  102974. /** @hidden */
  102975. export interface ICollisionCoordinator {
  102976. createCollider(): Collider;
  102977. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  102978. init(scene: Scene): void;
  102979. }
  102980. /** @hidden */
  102981. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  102982. private _scene;
  102983. private _scaledPosition;
  102984. private _scaledVelocity;
  102985. private _finalPosition;
  102986. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  102987. createCollider(): Collider;
  102988. init(scene: Scene): void;
  102989. private _collideWithWorld;
  102990. }
  102991. }
  102992. declare module BABYLON {
  102993. /**
  102994. * Class used to manage all inputs for the scene.
  102995. */
  102996. export class InputManager {
  102997. /** The distance in pixel that you have to move to prevent some events */
  102998. static DragMovementThreshold: number;
  102999. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  103000. static LongPressDelay: number;
  103001. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  103002. static DoubleClickDelay: number;
  103003. /** If you need to check double click without raising a single click at first click, enable this flag */
  103004. static ExclusiveDoubleClickMode: boolean;
  103005. private _wheelEventName;
  103006. private _onPointerMove;
  103007. private _onPointerDown;
  103008. private _onPointerUp;
  103009. private _initClickEvent;
  103010. private _initActionManager;
  103011. private _delayedSimpleClick;
  103012. private _delayedSimpleClickTimeout;
  103013. private _previousDelayedSimpleClickTimeout;
  103014. private _meshPickProceed;
  103015. private _previousButtonPressed;
  103016. private _currentPickResult;
  103017. private _previousPickResult;
  103018. private _totalPointersPressed;
  103019. private _doubleClickOccured;
  103020. private _pointerOverMesh;
  103021. private _pickedDownMesh;
  103022. private _pickedUpMesh;
  103023. private _pointerX;
  103024. private _pointerY;
  103025. private _unTranslatedPointerX;
  103026. private _unTranslatedPointerY;
  103027. private _startingPointerPosition;
  103028. private _previousStartingPointerPosition;
  103029. private _startingPointerTime;
  103030. private _previousStartingPointerTime;
  103031. private _pointerCaptures;
  103032. private _onKeyDown;
  103033. private _onKeyUp;
  103034. private _onCanvasFocusObserver;
  103035. private _onCanvasBlurObserver;
  103036. private _scene;
  103037. /**
  103038. * Creates a new InputManager
  103039. * @param scene defines the hosting scene
  103040. */
  103041. constructor(scene: Scene);
  103042. /**
  103043. * Gets the mesh that is currently under the pointer
  103044. */
  103045. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103046. /**
  103047. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103048. */
  103049. readonly unTranslatedPointer: Vector2;
  103050. /**
  103051. * Gets or sets the current on-screen X position of the pointer
  103052. */
  103053. pointerX: number;
  103054. /**
  103055. * Gets or sets the current on-screen Y position of the pointer
  103056. */
  103057. pointerY: number;
  103058. private _updatePointerPosition;
  103059. private _processPointerMove;
  103060. private _setRayOnPointerInfo;
  103061. private _checkPrePointerObservable;
  103062. /**
  103063. * Use this method to simulate a pointer move on a mesh
  103064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103067. */
  103068. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103069. /**
  103070. * Use this method to simulate a pointer down on a mesh
  103071. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103072. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103073. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103074. */
  103075. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103076. private _processPointerDown;
  103077. /** @hidden */
  103078. _isPointerSwiping(): boolean;
  103079. /**
  103080. * Use this method to simulate a pointer up on a mesh
  103081. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103082. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103083. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103084. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103085. */
  103086. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103087. private _processPointerUp;
  103088. /**
  103089. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103090. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103091. * @returns true if the pointer was captured
  103092. */
  103093. isPointerCaptured(pointerId?: number): boolean;
  103094. /**
  103095. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103096. * @param attachUp defines if you want to attach events to pointerup
  103097. * @param attachDown defines if you want to attach events to pointerdown
  103098. * @param attachMove defines if you want to attach events to pointermove
  103099. */
  103100. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103101. /**
  103102. * Detaches all event handlers
  103103. */
  103104. detachControl(): void;
  103105. /**
  103106. * Force the value of meshUnderPointer
  103107. * @param mesh defines the mesh to use
  103108. */
  103109. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103110. /**
  103111. * Gets the mesh under the pointer
  103112. * @returns a Mesh or null if no mesh is under the pointer
  103113. */
  103114. getPointerOverMesh(): Nullable<AbstractMesh>;
  103115. }
  103116. }
  103117. declare module BABYLON {
  103118. /**
  103119. * Helper class used to generate session unique ID
  103120. */
  103121. export class UniqueIdGenerator {
  103122. private static _UniqueIdCounter;
  103123. /**
  103124. * Gets an unique (relatively to the current scene) Id
  103125. */
  103126. static readonly UniqueId: number;
  103127. }
  103128. }
  103129. declare module BABYLON {
  103130. /**
  103131. * This class defines the direct association between an animation and a target
  103132. */
  103133. export class TargetedAnimation {
  103134. /**
  103135. * Animation to perform
  103136. */
  103137. animation: Animation;
  103138. /**
  103139. * Target to animate
  103140. */
  103141. target: any;
  103142. /**
  103143. * Serialize the object
  103144. * @returns the JSON object representing the current entity
  103145. */
  103146. serialize(): any;
  103147. }
  103148. /**
  103149. * Use this class to create coordinated animations on multiple targets
  103150. */
  103151. export class AnimationGroup implements IDisposable {
  103152. /** The name of the animation group */
  103153. name: string;
  103154. private _scene;
  103155. private _targetedAnimations;
  103156. private _animatables;
  103157. private _from;
  103158. private _to;
  103159. private _isStarted;
  103160. private _isPaused;
  103161. private _speedRatio;
  103162. private _loopAnimation;
  103163. /**
  103164. * Gets or sets the unique id of the node
  103165. */
  103166. uniqueId: number;
  103167. /**
  103168. * This observable will notify when one animation have ended
  103169. */
  103170. onAnimationEndObservable: Observable<TargetedAnimation>;
  103171. /**
  103172. * Observer raised when one animation loops
  103173. */
  103174. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103175. /**
  103176. * Observer raised when all animations have looped
  103177. */
  103178. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103179. /**
  103180. * This observable will notify when all animations have ended.
  103181. */
  103182. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103183. /**
  103184. * This observable will notify when all animations have paused.
  103185. */
  103186. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103187. /**
  103188. * This observable will notify when all animations are playing.
  103189. */
  103190. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103191. /**
  103192. * Gets the first frame
  103193. */
  103194. readonly from: number;
  103195. /**
  103196. * Gets the last frame
  103197. */
  103198. readonly to: number;
  103199. /**
  103200. * Define if the animations are started
  103201. */
  103202. readonly isStarted: boolean;
  103203. /**
  103204. * Gets a value indicating that the current group is playing
  103205. */
  103206. readonly isPlaying: boolean;
  103207. /**
  103208. * Gets or sets the speed ratio to use for all animations
  103209. */
  103210. /**
  103211. * Gets or sets the speed ratio to use for all animations
  103212. */
  103213. speedRatio: number;
  103214. /**
  103215. * Gets or sets if all animations should loop or not
  103216. */
  103217. loopAnimation: boolean;
  103218. /**
  103219. * Gets the targeted animations for this animation group
  103220. */
  103221. readonly targetedAnimations: Array<TargetedAnimation>;
  103222. /**
  103223. * returning the list of animatables controlled by this animation group.
  103224. */
  103225. readonly animatables: Array<Animatable>;
  103226. /**
  103227. * Instantiates a new Animation Group.
  103228. * This helps managing several animations at once.
  103229. * @see http://doc.babylonjs.com/how_to/group
  103230. * @param name Defines the name of the group
  103231. * @param scene Defines the scene the group belongs to
  103232. */
  103233. constructor(
  103234. /** The name of the animation group */
  103235. name: string, scene?: Nullable<Scene>);
  103236. /**
  103237. * Add an animation (with its target) in the group
  103238. * @param animation defines the animation we want to add
  103239. * @param target defines the target of the animation
  103240. * @returns the TargetedAnimation object
  103241. */
  103242. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103243. /**
  103244. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103245. * It can add constant keys at begin or end
  103246. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103247. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103248. * @returns the animation group
  103249. */
  103250. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103251. private _animationLoopCount;
  103252. private _animationLoopFlags;
  103253. private _processLoop;
  103254. /**
  103255. * Start all animations on given targets
  103256. * @param loop defines if animations must loop
  103257. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103258. * @param from defines the from key (optional)
  103259. * @param to defines the to key (optional)
  103260. * @returns the current animation group
  103261. */
  103262. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103263. /**
  103264. * Pause all animations
  103265. * @returns the animation group
  103266. */
  103267. pause(): AnimationGroup;
  103268. /**
  103269. * Play all animations to initial state
  103270. * This function will start() the animations if they were not started or will restart() them if they were paused
  103271. * @param loop defines if animations must loop
  103272. * @returns the animation group
  103273. */
  103274. play(loop?: boolean): AnimationGroup;
  103275. /**
  103276. * Reset all animations to initial state
  103277. * @returns the animation group
  103278. */
  103279. reset(): AnimationGroup;
  103280. /**
  103281. * Restart animations from key 0
  103282. * @returns the animation group
  103283. */
  103284. restart(): AnimationGroup;
  103285. /**
  103286. * Stop all animations
  103287. * @returns the animation group
  103288. */
  103289. stop(): AnimationGroup;
  103290. /**
  103291. * Set animation weight for all animatables
  103292. * @param weight defines the weight to use
  103293. * @return the animationGroup
  103294. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103295. */
  103296. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103297. /**
  103298. * Synchronize and normalize all animatables with a source animatable
  103299. * @param root defines the root animatable to synchronize with
  103300. * @return the animationGroup
  103301. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103302. */
  103303. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103304. /**
  103305. * Goes to a specific frame in this animation group
  103306. * @param frame the frame number to go to
  103307. * @return the animationGroup
  103308. */
  103309. goToFrame(frame: number): AnimationGroup;
  103310. /**
  103311. * Dispose all associated resources
  103312. */
  103313. dispose(): void;
  103314. private _checkAnimationGroupEnded;
  103315. /**
  103316. * Clone the current animation group and returns a copy
  103317. * @param newName defines the name of the new group
  103318. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103319. * @returns the new aniamtion group
  103320. */
  103321. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103322. /**
  103323. * Serializes the animationGroup to an object
  103324. * @returns Serialized object
  103325. */
  103326. serialize(): any;
  103327. /**
  103328. * Returns a new AnimationGroup object parsed from the source provided.
  103329. * @param parsedAnimationGroup defines the source
  103330. * @param scene defines the scene that will receive the animationGroup
  103331. * @returns a new AnimationGroup
  103332. */
  103333. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103334. /**
  103335. * Returns the string "AnimationGroup"
  103336. * @returns "AnimationGroup"
  103337. */
  103338. getClassName(): string;
  103339. /**
  103340. * Creates a detailled string about the object
  103341. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103342. * @returns a string representing the object
  103343. */
  103344. toString(fullDetails?: boolean): string;
  103345. }
  103346. }
  103347. declare module BABYLON {
  103348. /**
  103349. * Define an interface for all classes that will hold resources
  103350. */
  103351. export interface IDisposable {
  103352. /**
  103353. * Releases all held resources
  103354. */
  103355. dispose(): void;
  103356. }
  103357. /** Interface defining initialization parameters for Scene class */
  103358. export interface SceneOptions {
  103359. /**
  103360. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103361. * It will improve performance when the number of geometries becomes important.
  103362. */
  103363. useGeometryUniqueIdsMap?: boolean;
  103364. /**
  103365. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103366. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103367. */
  103368. useMaterialMeshMap?: boolean;
  103369. /**
  103370. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103371. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103372. */
  103373. useClonedMeshhMap?: boolean;
  103374. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103375. virtual?: boolean;
  103376. }
  103377. /**
  103378. * Represents a scene to be rendered by the engine.
  103379. * @see http://doc.babylonjs.com/features/scene
  103380. */
  103381. export class Scene extends AbstractScene implements IAnimatable {
  103382. /** The fog is deactivated */
  103383. static readonly FOGMODE_NONE: number;
  103384. /** The fog density is following an exponential function */
  103385. static readonly FOGMODE_EXP: number;
  103386. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103387. static readonly FOGMODE_EXP2: number;
  103388. /** The fog density is following a linear function. */
  103389. static readonly FOGMODE_LINEAR: number;
  103390. /**
  103391. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103393. */
  103394. static MinDeltaTime: number;
  103395. /**
  103396. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103397. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103398. */
  103399. static MaxDeltaTime: number;
  103400. /**
  103401. * Factory used to create the default material.
  103402. * @param name The name of the material to create
  103403. * @param scene The scene to create the material for
  103404. * @returns The default material
  103405. */
  103406. static DefaultMaterialFactory(scene: Scene): Material;
  103407. /**
  103408. * Factory used to create the a collision coordinator.
  103409. * @returns The collision coordinator
  103410. */
  103411. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103412. /** @hidden */
  103413. _inputManager: InputManager;
  103414. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103415. cameraToUseForPointers: Nullable<Camera>;
  103416. /** @hidden */
  103417. readonly _isScene: boolean;
  103418. /**
  103419. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103420. */
  103421. autoClear: boolean;
  103422. /**
  103423. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103424. */
  103425. autoClearDepthAndStencil: boolean;
  103426. /**
  103427. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103428. */
  103429. clearColor: Color4;
  103430. /**
  103431. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103432. */
  103433. ambientColor: Color3;
  103434. /**
  103435. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103436. * It should only be one of the following (if not the default embedded one):
  103437. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103438. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103439. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103440. * The material properties need to be setup according to the type of texture in use.
  103441. */
  103442. environmentBRDFTexture: BaseTexture;
  103443. /** @hidden */
  103444. protected _environmentTexture: Nullable<BaseTexture>;
  103445. /**
  103446. * Texture used in all pbr material as the reflection texture.
  103447. * As in the majority of the scene they are the same (exception for multi room and so on),
  103448. * this is easier to reference from here than from all the materials.
  103449. */
  103450. /**
  103451. * Texture used in all pbr material as the reflection texture.
  103452. * As in the majority of the scene they are the same (exception for multi room and so on),
  103453. * this is easier to set here than in all the materials.
  103454. */
  103455. environmentTexture: Nullable<BaseTexture>;
  103456. /** @hidden */
  103457. protected _environmentIntensity: number;
  103458. /**
  103459. * Intensity of the environment in all pbr material.
  103460. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103461. * As in the majority of the scene they are the same (exception for multi room and so on),
  103462. * this is easier to reference from here than from all the materials.
  103463. */
  103464. /**
  103465. * Intensity of the environment in all pbr material.
  103466. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103467. * As in the majority of the scene they are the same (exception for multi room and so on),
  103468. * this is easier to set here than in all the materials.
  103469. */
  103470. environmentIntensity: number;
  103471. /** @hidden */
  103472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103473. /**
  103474. * Default image processing configuration used either in the rendering
  103475. * Forward main pass or through the imageProcessingPostProcess if present.
  103476. * As in the majority of the scene they are the same (exception for multi camera),
  103477. * this is easier to reference from here than from all the materials and post process.
  103478. *
  103479. * No setter as we it is a shared configuration, you can set the values instead.
  103480. */
  103481. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103482. private _forceWireframe;
  103483. /**
  103484. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103485. */
  103486. forceWireframe: boolean;
  103487. private _forcePointsCloud;
  103488. /**
  103489. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103490. */
  103491. forcePointsCloud: boolean;
  103492. /**
  103493. * Gets or sets the active clipplane 1
  103494. */
  103495. clipPlane: Nullable<Plane>;
  103496. /**
  103497. * Gets or sets the active clipplane 2
  103498. */
  103499. clipPlane2: Nullable<Plane>;
  103500. /**
  103501. * Gets or sets the active clipplane 3
  103502. */
  103503. clipPlane3: Nullable<Plane>;
  103504. /**
  103505. * Gets or sets the active clipplane 4
  103506. */
  103507. clipPlane4: Nullable<Plane>;
  103508. /**
  103509. * Gets or sets a boolean indicating if animations are enabled
  103510. */
  103511. animationsEnabled: boolean;
  103512. private _animationPropertiesOverride;
  103513. /**
  103514. * Gets or sets the animation properties override
  103515. */
  103516. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  103517. /**
  103518. * Gets or sets a boolean indicating if a constant deltatime has to be used
  103519. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  103520. */
  103521. useConstantAnimationDeltaTime: boolean;
  103522. /**
  103523. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  103524. * Please note that it requires to run a ray cast through the scene on every frame
  103525. */
  103526. constantlyUpdateMeshUnderPointer: boolean;
  103527. /**
  103528. * Defines the HTML cursor to use when hovering over interactive elements
  103529. */
  103530. hoverCursor: string;
  103531. /**
  103532. * Defines the HTML default cursor to use (empty by default)
  103533. */
  103534. defaultCursor: string;
  103535. /**
  103536. * Defines wether cursors are handled by the scene.
  103537. */
  103538. doNotHandleCursors: boolean;
  103539. /**
  103540. * This is used to call preventDefault() on pointer down
  103541. * in order to block unwanted artifacts like system double clicks
  103542. */
  103543. preventDefaultOnPointerDown: boolean;
  103544. /**
  103545. * This is used to call preventDefault() on pointer up
  103546. * in order to block unwanted artifacts like system double clicks
  103547. */
  103548. preventDefaultOnPointerUp: boolean;
  103549. /**
  103550. * Gets or sets user defined metadata
  103551. */
  103552. metadata: any;
  103553. /**
  103554. * For internal use only. Please do not use.
  103555. */
  103556. reservedDataStore: any;
  103557. /**
  103558. * Gets the name of the plugin used to load this scene (null by default)
  103559. */
  103560. loadingPluginName: string;
  103561. /**
  103562. * Use this array to add regular expressions used to disable offline support for specific urls
  103563. */
  103564. disableOfflineSupportExceptionRules: RegExp[];
  103565. /**
  103566. * An event triggered when the scene is disposed.
  103567. */
  103568. onDisposeObservable: Observable<Scene>;
  103569. private _onDisposeObserver;
  103570. /** Sets a function to be executed when this scene is disposed. */
  103571. onDispose: () => void;
  103572. /**
  103573. * An event triggered before rendering the scene (right after animations and physics)
  103574. */
  103575. onBeforeRenderObservable: Observable<Scene>;
  103576. private _onBeforeRenderObserver;
  103577. /** Sets a function to be executed before rendering this scene */
  103578. beforeRender: Nullable<() => void>;
  103579. /**
  103580. * An event triggered after rendering the scene
  103581. */
  103582. onAfterRenderObservable: Observable<Scene>;
  103583. /**
  103584. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  103585. */
  103586. onAfterRenderCameraObservable: Observable<Camera>;
  103587. private _onAfterRenderObserver;
  103588. /** Sets a function to be executed after rendering this scene */
  103589. afterRender: Nullable<() => void>;
  103590. /**
  103591. * An event triggered before animating the scene
  103592. */
  103593. onBeforeAnimationsObservable: Observable<Scene>;
  103594. /**
  103595. * An event triggered after animations processing
  103596. */
  103597. onAfterAnimationsObservable: Observable<Scene>;
  103598. /**
  103599. * An event triggered before draw calls are ready to be sent
  103600. */
  103601. onBeforeDrawPhaseObservable: Observable<Scene>;
  103602. /**
  103603. * An event triggered after draw calls have been sent
  103604. */
  103605. onAfterDrawPhaseObservable: Observable<Scene>;
  103606. /**
  103607. * An event triggered when the scene is ready
  103608. */
  103609. onReadyObservable: Observable<Scene>;
  103610. /**
  103611. * An event triggered before rendering a camera
  103612. */
  103613. onBeforeCameraRenderObservable: Observable<Camera>;
  103614. private _onBeforeCameraRenderObserver;
  103615. /** Sets a function to be executed before rendering a camera*/
  103616. beforeCameraRender: () => void;
  103617. /**
  103618. * An event triggered after rendering a camera
  103619. */
  103620. onAfterCameraRenderObservable: Observable<Camera>;
  103621. private _onAfterCameraRenderObserver;
  103622. /** Sets a function to be executed after rendering a camera*/
  103623. afterCameraRender: () => void;
  103624. /**
  103625. * An event triggered when active meshes evaluation is about to start
  103626. */
  103627. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  103628. /**
  103629. * An event triggered when active meshes evaluation is done
  103630. */
  103631. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  103632. /**
  103633. * An event triggered when particles rendering is about to start
  103634. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103635. */
  103636. onBeforeParticlesRenderingObservable: Observable<Scene>;
  103637. /**
  103638. * An event triggered when particles rendering is done
  103639. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103640. */
  103641. onAfterParticlesRenderingObservable: Observable<Scene>;
  103642. /**
  103643. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  103644. */
  103645. onDataLoadedObservable: Observable<Scene>;
  103646. /**
  103647. * An event triggered when a camera is created
  103648. */
  103649. onNewCameraAddedObservable: Observable<Camera>;
  103650. /**
  103651. * An event triggered when a camera is removed
  103652. */
  103653. onCameraRemovedObservable: Observable<Camera>;
  103654. /**
  103655. * An event triggered when a light is created
  103656. */
  103657. onNewLightAddedObservable: Observable<Light>;
  103658. /**
  103659. * An event triggered when a light is removed
  103660. */
  103661. onLightRemovedObservable: Observable<Light>;
  103662. /**
  103663. * An event triggered when a geometry is created
  103664. */
  103665. onNewGeometryAddedObservable: Observable<Geometry>;
  103666. /**
  103667. * An event triggered when a geometry is removed
  103668. */
  103669. onGeometryRemovedObservable: Observable<Geometry>;
  103670. /**
  103671. * An event triggered when a transform node is created
  103672. */
  103673. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  103674. /**
  103675. * An event triggered when a transform node is removed
  103676. */
  103677. onTransformNodeRemovedObservable: Observable<TransformNode>;
  103678. /**
  103679. * An event triggered when a mesh is created
  103680. */
  103681. onNewMeshAddedObservable: Observable<AbstractMesh>;
  103682. /**
  103683. * An event triggered when a mesh is removed
  103684. */
  103685. onMeshRemovedObservable: Observable<AbstractMesh>;
  103686. /**
  103687. * An event triggered when a skeleton is created
  103688. */
  103689. onNewSkeletonAddedObservable: Observable<Skeleton>;
  103690. /**
  103691. * An event triggered when a skeleton is removed
  103692. */
  103693. onSkeletonRemovedObservable: Observable<Skeleton>;
  103694. /**
  103695. * An event triggered when a material is created
  103696. */
  103697. onNewMaterialAddedObservable: Observable<Material>;
  103698. /**
  103699. * An event triggered when a material is removed
  103700. */
  103701. onMaterialRemovedObservable: Observable<Material>;
  103702. /**
  103703. * An event triggered when a texture is created
  103704. */
  103705. onNewTextureAddedObservable: Observable<BaseTexture>;
  103706. /**
  103707. * An event triggered when a texture is removed
  103708. */
  103709. onTextureRemovedObservable: Observable<BaseTexture>;
  103710. /**
  103711. * An event triggered when render targets are about to be rendered
  103712. * Can happen multiple times per frame.
  103713. */
  103714. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  103715. /**
  103716. * An event triggered when render targets were rendered.
  103717. * Can happen multiple times per frame.
  103718. */
  103719. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  103720. /**
  103721. * An event triggered before calculating deterministic simulation step
  103722. */
  103723. onBeforeStepObservable: Observable<Scene>;
  103724. /**
  103725. * An event triggered after calculating deterministic simulation step
  103726. */
  103727. onAfterStepObservable: Observable<Scene>;
  103728. /**
  103729. * An event triggered when the activeCamera property is updated
  103730. */
  103731. onActiveCameraChanged: Observable<Scene>;
  103732. /**
  103733. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  103734. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103735. * 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)
  103736. */
  103737. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103738. /**
  103739. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  103740. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103741. * 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)
  103742. */
  103743. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103744. /**
  103745. * This Observable will when a mesh has been imported into the scene.
  103746. */
  103747. onMeshImportedObservable: Observable<AbstractMesh>;
  103748. /**
  103749. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  103750. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  103751. */
  103752. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  103753. /** @hidden */
  103754. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  103755. /**
  103756. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  103757. */
  103758. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  103759. /**
  103760. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  103761. */
  103762. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  103763. /**
  103764. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  103765. */
  103766. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  103767. /** Callback called when a pointer move is detected */
  103768. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103769. /** Callback called when a pointer down is detected */
  103770. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103771. /** Callback called when a pointer up is detected */
  103772. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  103773. /** Callback called when a pointer pick is detected */
  103774. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  103775. /**
  103776. * 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).
  103777. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  103778. */
  103779. onPrePointerObservable: Observable<PointerInfoPre>;
  103780. /**
  103781. * Observable event triggered each time an input event is received from the rendering canvas
  103782. */
  103783. onPointerObservable: Observable<PointerInfo>;
  103784. /**
  103785. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  103786. */
  103787. readonly unTranslatedPointer: Vector2;
  103788. /**
  103789. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  103790. */
  103791. static DragMovementThreshold: number;
  103792. /**
  103793. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  103794. */
  103795. static LongPressDelay: number;
  103796. /**
  103797. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  103798. */
  103799. static DoubleClickDelay: number;
  103800. /** If you need to check double click without raising a single click at first click, enable this flag */
  103801. static ExclusiveDoubleClickMode: boolean;
  103802. /** @hidden */
  103803. _mirroredCameraPosition: Nullable<Vector3>;
  103804. /**
  103805. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  103806. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  103807. */
  103808. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  103809. /**
  103810. * Observable event triggered each time an keyboard event is received from the hosting window
  103811. */
  103812. onKeyboardObservable: Observable<KeyboardInfo>;
  103813. private _useRightHandedSystem;
  103814. /**
  103815. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  103816. */
  103817. useRightHandedSystem: boolean;
  103818. private _timeAccumulator;
  103819. private _currentStepId;
  103820. private _currentInternalStep;
  103821. /**
  103822. * Sets the step Id used by deterministic lock step
  103823. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103824. * @param newStepId defines the step Id
  103825. */
  103826. setStepId(newStepId: number): void;
  103827. /**
  103828. * Gets the step Id used by deterministic lock step
  103829. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103830. * @returns the step Id
  103831. */
  103832. getStepId(): number;
  103833. /**
  103834. * Gets the internal step used by deterministic lock step
  103835. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103836. * @returns the internal step
  103837. */
  103838. getInternalStep(): number;
  103839. private _fogEnabled;
  103840. /**
  103841. * Gets or sets a boolean indicating if fog is enabled on this scene
  103842. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103843. * (Default is true)
  103844. */
  103845. fogEnabled: boolean;
  103846. private _fogMode;
  103847. /**
  103848. * Gets or sets the fog mode to use
  103849. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103850. * | mode | value |
  103851. * | --- | --- |
  103852. * | FOGMODE_NONE | 0 |
  103853. * | FOGMODE_EXP | 1 |
  103854. * | FOGMODE_EXP2 | 2 |
  103855. * | FOGMODE_LINEAR | 3 |
  103856. */
  103857. fogMode: number;
  103858. /**
  103859. * Gets or sets the fog color to use
  103860. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103861. * (Default is Color3(0.2, 0.2, 0.3))
  103862. */
  103863. fogColor: Color3;
  103864. /**
  103865. * Gets or sets the fog density to use
  103866. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103867. * (Default is 0.1)
  103868. */
  103869. fogDensity: number;
  103870. /**
  103871. * Gets or sets the fog start distance to use
  103872. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103873. * (Default is 0)
  103874. */
  103875. fogStart: number;
  103876. /**
  103877. * Gets or sets the fog end distance to use
  103878. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103879. * (Default is 1000)
  103880. */
  103881. fogEnd: number;
  103882. private _shadowsEnabled;
  103883. /**
  103884. * Gets or sets a boolean indicating if shadows are enabled on this scene
  103885. */
  103886. shadowsEnabled: boolean;
  103887. private _lightsEnabled;
  103888. /**
  103889. * Gets or sets a boolean indicating if lights are enabled on this scene
  103890. */
  103891. lightsEnabled: boolean;
  103892. /** All of the active cameras added to this scene. */
  103893. activeCameras: Camera[];
  103894. /** @hidden */
  103895. _activeCamera: Nullable<Camera>;
  103896. /** Gets or sets the current active camera */
  103897. activeCamera: Nullable<Camera>;
  103898. private _defaultMaterial;
  103899. /** The default material used on meshes when no material is affected */
  103900. /** The default material used on meshes when no material is affected */
  103901. defaultMaterial: Material;
  103902. private _texturesEnabled;
  103903. /**
  103904. * Gets or sets a boolean indicating if textures are enabled on this scene
  103905. */
  103906. texturesEnabled: boolean;
  103907. /**
  103908. * Gets or sets a boolean indicating if particles are enabled on this scene
  103909. */
  103910. particlesEnabled: boolean;
  103911. /**
  103912. * Gets or sets a boolean indicating if sprites are enabled on this scene
  103913. */
  103914. spritesEnabled: boolean;
  103915. private _skeletonsEnabled;
  103916. /**
  103917. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  103918. */
  103919. skeletonsEnabled: boolean;
  103920. /**
  103921. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  103922. */
  103923. lensFlaresEnabled: boolean;
  103924. /**
  103925. * Gets or sets a boolean indicating if collisions are enabled on this scene
  103926. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103927. */
  103928. collisionsEnabled: boolean;
  103929. private _collisionCoordinator;
  103930. /** @hidden */
  103931. readonly collisionCoordinator: ICollisionCoordinator;
  103932. /**
  103933. * Defines the gravity applied to this scene (used only for collisions)
  103934. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103935. */
  103936. gravity: Vector3;
  103937. /**
  103938. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  103939. */
  103940. postProcessesEnabled: boolean;
  103941. /**
  103942. * The list of postprocesses added to the scene
  103943. */
  103944. postProcesses: PostProcess[];
  103945. /**
  103946. * Gets the current postprocess manager
  103947. */
  103948. postProcessManager: PostProcessManager;
  103949. /**
  103950. * Gets or sets a boolean indicating if render targets are enabled on this scene
  103951. */
  103952. renderTargetsEnabled: boolean;
  103953. /**
  103954. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  103955. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  103956. */
  103957. dumpNextRenderTargets: boolean;
  103958. /**
  103959. * The list of user defined render targets added to the scene
  103960. */
  103961. customRenderTargets: RenderTargetTexture[];
  103962. /**
  103963. * Defines if texture loading must be delayed
  103964. * If true, textures will only be loaded when they need to be rendered
  103965. */
  103966. useDelayedTextureLoading: boolean;
  103967. /**
  103968. * Gets the list of meshes imported to the scene through SceneLoader
  103969. */
  103970. importedMeshesFiles: String[];
  103971. /**
  103972. * Gets or sets a boolean indicating if probes are enabled on this scene
  103973. */
  103974. probesEnabled: boolean;
  103975. /**
  103976. * Gets or sets the current offline provider to use to store scene data
  103977. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  103978. */
  103979. offlineProvider: IOfflineProvider;
  103980. /**
  103981. * Gets or sets the action manager associated with the scene
  103982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103983. */
  103984. actionManager: AbstractActionManager;
  103985. private _meshesForIntersections;
  103986. /**
  103987. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  103988. */
  103989. proceduralTexturesEnabled: boolean;
  103990. private _engine;
  103991. private _totalVertices;
  103992. /** @hidden */
  103993. _activeIndices: PerfCounter;
  103994. /** @hidden */
  103995. _activeParticles: PerfCounter;
  103996. /** @hidden */
  103997. _activeBones: PerfCounter;
  103998. private _animationRatio;
  103999. /** @hidden */
  104000. _animationTimeLast: number;
  104001. /** @hidden */
  104002. _animationTime: number;
  104003. /**
  104004. * Gets or sets a general scale for animation speed
  104005. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  104006. */
  104007. animationTimeScale: number;
  104008. /** @hidden */
  104009. _cachedMaterial: Nullable<Material>;
  104010. /** @hidden */
  104011. _cachedEffect: Nullable<Effect>;
  104012. /** @hidden */
  104013. _cachedVisibility: Nullable<number>;
  104014. private _renderId;
  104015. private _frameId;
  104016. private _executeWhenReadyTimeoutId;
  104017. private _intermediateRendering;
  104018. private _viewUpdateFlag;
  104019. private _projectionUpdateFlag;
  104020. /** @hidden */
  104021. _toBeDisposed: Nullable<IDisposable>[];
  104022. private _activeRequests;
  104023. /** @hidden */
  104024. _pendingData: any[];
  104025. private _isDisposed;
  104026. /**
  104027. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  104028. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  104029. */
  104030. dispatchAllSubMeshesOfActiveMeshes: boolean;
  104031. private _activeMeshes;
  104032. private _processedMaterials;
  104033. private _renderTargets;
  104034. /** @hidden */
  104035. _activeParticleSystems: SmartArray<IParticleSystem>;
  104036. private _activeSkeletons;
  104037. private _softwareSkinnedMeshes;
  104038. private _renderingManager;
  104039. /** @hidden */
  104040. _activeAnimatables: Animatable[];
  104041. private _transformMatrix;
  104042. private _sceneUbo;
  104043. /** @hidden */
  104044. _viewMatrix: Matrix;
  104045. private _projectionMatrix;
  104046. /** @hidden */
  104047. _forcedViewPosition: Nullable<Vector3>;
  104048. /** @hidden */
  104049. _frustumPlanes: Plane[];
  104050. /**
  104051. * Gets the list of frustum planes (built from the active camera)
  104052. */
  104053. readonly frustumPlanes: Plane[];
  104054. /**
  104055. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104056. * This is useful if there are more lights that the maximum simulteanous authorized
  104057. */
  104058. requireLightSorting: boolean;
  104059. /** @hidden */
  104060. readonly useMaterialMeshMap: boolean;
  104061. /** @hidden */
  104062. readonly useClonedMeshhMap: boolean;
  104063. private _externalData;
  104064. private _uid;
  104065. /**
  104066. * @hidden
  104067. * Backing store of defined scene components.
  104068. */
  104069. _components: ISceneComponent[];
  104070. /**
  104071. * @hidden
  104072. * Backing store of defined scene components.
  104073. */
  104074. _serializableComponents: ISceneSerializableComponent[];
  104075. /**
  104076. * List of components to register on the next registration step.
  104077. */
  104078. private _transientComponents;
  104079. /**
  104080. * Registers the transient components if needed.
  104081. */
  104082. private _registerTransientComponents;
  104083. /**
  104084. * @hidden
  104085. * Add a component to the scene.
  104086. * Note that the ccomponent could be registered on th next frame if this is called after
  104087. * the register component stage.
  104088. * @param component Defines the component to add to the scene
  104089. */
  104090. _addComponent(component: ISceneComponent): void;
  104091. /**
  104092. * @hidden
  104093. * Gets a component from the scene.
  104094. * @param name defines the name of the component to retrieve
  104095. * @returns the component or null if not present
  104096. */
  104097. _getComponent(name: string): Nullable<ISceneComponent>;
  104098. /**
  104099. * @hidden
  104100. * Defines the actions happening before camera updates.
  104101. */
  104102. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104103. /**
  104104. * @hidden
  104105. * Defines the actions happening before clear the canvas.
  104106. */
  104107. _beforeClearStage: Stage<SimpleStageAction>;
  104108. /**
  104109. * @hidden
  104110. * Defines the actions when collecting render targets for the frame.
  104111. */
  104112. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104113. /**
  104114. * @hidden
  104115. * Defines the actions happening for one camera in the frame.
  104116. */
  104117. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104118. /**
  104119. * @hidden
  104120. * Defines the actions happening during the per mesh ready checks.
  104121. */
  104122. _isReadyForMeshStage: Stage<MeshStageAction>;
  104123. /**
  104124. * @hidden
  104125. * Defines the actions happening before evaluate active mesh checks.
  104126. */
  104127. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104128. /**
  104129. * @hidden
  104130. * Defines the actions happening during the evaluate sub mesh checks.
  104131. */
  104132. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104133. /**
  104134. * @hidden
  104135. * Defines the actions happening during the active mesh stage.
  104136. */
  104137. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104138. /**
  104139. * @hidden
  104140. * Defines the actions happening during the per camera render target step.
  104141. */
  104142. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104143. /**
  104144. * @hidden
  104145. * Defines the actions happening just before the active camera is drawing.
  104146. */
  104147. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104148. /**
  104149. * @hidden
  104150. * Defines the actions happening just before a render target is drawing.
  104151. */
  104152. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104153. /**
  104154. * @hidden
  104155. * Defines the actions happening just before a rendering group is drawing.
  104156. */
  104157. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104158. /**
  104159. * @hidden
  104160. * Defines the actions happening just before a mesh is drawing.
  104161. */
  104162. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104163. /**
  104164. * @hidden
  104165. * Defines the actions happening just after a mesh has been drawn.
  104166. */
  104167. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104168. /**
  104169. * @hidden
  104170. * Defines the actions happening just after a rendering group has been drawn.
  104171. */
  104172. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104173. /**
  104174. * @hidden
  104175. * Defines the actions happening just after the active camera has been drawn.
  104176. */
  104177. _afterCameraDrawStage: Stage<CameraStageAction>;
  104178. /**
  104179. * @hidden
  104180. * Defines the actions happening just after a render target has been drawn.
  104181. */
  104182. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104183. /**
  104184. * @hidden
  104185. * Defines the actions happening just after rendering all cameras and computing intersections.
  104186. */
  104187. _afterRenderStage: Stage<SimpleStageAction>;
  104188. /**
  104189. * @hidden
  104190. * Defines the actions happening when a pointer move event happens.
  104191. */
  104192. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104193. /**
  104194. * @hidden
  104195. * Defines the actions happening when a pointer down event happens.
  104196. */
  104197. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104198. /**
  104199. * @hidden
  104200. * Defines the actions happening when a pointer up event happens.
  104201. */
  104202. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104203. /**
  104204. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104205. */
  104206. private geometriesByUniqueId;
  104207. /**
  104208. * Creates a new Scene
  104209. * @param engine defines the engine to use to render this scene
  104210. * @param options defines the scene options
  104211. */
  104212. constructor(engine: Engine, options?: SceneOptions);
  104213. /**
  104214. * Gets a string idenfifying the name of the class
  104215. * @returns "Scene" string
  104216. */
  104217. getClassName(): string;
  104218. private _defaultMeshCandidates;
  104219. /**
  104220. * @hidden
  104221. */
  104222. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104223. private _defaultSubMeshCandidates;
  104224. /**
  104225. * @hidden
  104226. */
  104227. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104228. /**
  104229. * Sets the default candidate providers for the scene.
  104230. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104231. * and getCollidingSubMeshCandidates to their default function
  104232. */
  104233. setDefaultCandidateProviders(): void;
  104234. /**
  104235. * Gets the mesh that is currently under the pointer
  104236. */
  104237. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104238. /**
  104239. * Gets or sets the current on-screen X position of the pointer
  104240. */
  104241. pointerX: number;
  104242. /**
  104243. * Gets or sets the current on-screen Y position of the pointer
  104244. */
  104245. pointerY: number;
  104246. /**
  104247. * Gets the cached material (ie. the latest rendered one)
  104248. * @returns the cached material
  104249. */
  104250. getCachedMaterial(): Nullable<Material>;
  104251. /**
  104252. * Gets the cached effect (ie. the latest rendered one)
  104253. * @returns the cached effect
  104254. */
  104255. getCachedEffect(): Nullable<Effect>;
  104256. /**
  104257. * Gets the cached visibility state (ie. the latest rendered one)
  104258. * @returns the cached visibility state
  104259. */
  104260. getCachedVisibility(): Nullable<number>;
  104261. /**
  104262. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104263. * @param material defines the current material
  104264. * @param effect defines the current effect
  104265. * @param visibility defines the current visibility state
  104266. * @returns true if one parameter is not cached
  104267. */
  104268. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104269. /**
  104270. * Gets the engine associated with the scene
  104271. * @returns an Engine
  104272. */
  104273. getEngine(): Engine;
  104274. /**
  104275. * Gets the total number of vertices rendered per frame
  104276. * @returns the total number of vertices rendered per frame
  104277. */
  104278. getTotalVertices(): number;
  104279. /**
  104280. * Gets the performance counter for total vertices
  104281. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104282. */
  104283. readonly totalVerticesPerfCounter: PerfCounter;
  104284. /**
  104285. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104286. * @returns the total number of active indices rendered per frame
  104287. */
  104288. getActiveIndices(): number;
  104289. /**
  104290. * Gets the performance counter for active indices
  104291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104292. */
  104293. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104294. /**
  104295. * Gets the total number of active particles rendered per frame
  104296. * @returns the total number of active particles rendered per frame
  104297. */
  104298. getActiveParticles(): number;
  104299. /**
  104300. * Gets the performance counter for active particles
  104301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104302. */
  104303. readonly activeParticlesPerfCounter: PerfCounter;
  104304. /**
  104305. * Gets the total number of active bones rendered per frame
  104306. * @returns the total number of active bones rendered per frame
  104307. */
  104308. getActiveBones(): number;
  104309. /**
  104310. * Gets the performance counter for active bones
  104311. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104312. */
  104313. readonly activeBonesPerfCounter: PerfCounter;
  104314. /**
  104315. * Gets the array of active meshes
  104316. * @returns an array of AbstractMesh
  104317. */
  104318. getActiveMeshes(): SmartArray<AbstractMesh>;
  104319. /**
  104320. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104321. * @returns a number
  104322. */
  104323. getAnimationRatio(): number;
  104324. /**
  104325. * Gets an unique Id for the current render phase
  104326. * @returns a number
  104327. */
  104328. getRenderId(): number;
  104329. /**
  104330. * Gets an unique Id for the current frame
  104331. * @returns a number
  104332. */
  104333. getFrameId(): number;
  104334. /** Call this function if you want to manually increment the render Id*/
  104335. incrementRenderId(): void;
  104336. private _createUbo;
  104337. /**
  104338. * Use this method to simulate a pointer move on a mesh
  104339. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104340. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104341. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104342. * @returns the current scene
  104343. */
  104344. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104345. /**
  104346. * Use this method to simulate a pointer down on a mesh
  104347. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104348. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104349. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104350. * @returns the current scene
  104351. */
  104352. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104353. /**
  104354. * Use this method to simulate a pointer up on a mesh
  104355. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104356. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104357. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104358. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104359. * @returns the current scene
  104360. */
  104361. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104362. /**
  104363. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104364. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104365. * @returns true if the pointer was captured
  104366. */
  104367. isPointerCaptured(pointerId?: number): boolean;
  104368. /**
  104369. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104370. * @param attachUp defines if you want to attach events to pointerup
  104371. * @param attachDown defines if you want to attach events to pointerdown
  104372. * @param attachMove defines if you want to attach events to pointermove
  104373. */
  104374. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104375. /** Detaches all event handlers*/
  104376. detachControl(): void;
  104377. /**
  104378. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104379. * Delay loaded resources are not taking in account
  104380. * @return true if all required resources are ready
  104381. */
  104382. isReady(): boolean;
  104383. /** Resets all cached information relative to material (including effect and visibility) */
  104384. resetCachedMaterial(): void;
  104385. /**
  104386. * Registers a function to be called before every frame render
  104387. * @param func defines the function to register
  104388. */
  104389. registerBeforeRender(func: () => void): void;
  104390. /**
  104391. * Unregisters a function called before every frame render
  104392. * @param func defines the function to unregister
  104393. */
  104394. unregisterBeforeRender(func: () => void): void;
  104395. /**
  104396. * Registers a function to be called after every frame render
  104397. * @param func defines the function to register
  104398. */
  104399. registerAfterRender(func: () => void): void;
  104400. /**
  104401. * Unregisters a function called after every frame render
  104402. * @param func defines the function to unregister
  104403. */
  104404. unregisterAfterRender(func: () => void): void;
  104405. private _executeOnceBeforeRender;
  104406. /**
  104407. * The provided function will run before render once and will be disposed afterwards.
  104408. * A timeout delay can be provided so that the function will be executed in N ms.
  104409. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104410. * @param func The function to be executed.
  104411. * @param timeout optional delay in ms
  104412. */
  104413. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104414. /** @hidden */
  104415. _addPendingData(data: any): void;
  104416. /** @hidden */
  104417. _removePendingData(data: any): void;
  104418. /**
  104419. * Returns the number of items waiting to be loaded
  104420. * @returns the number of items waiting to be loaded
  104421. */
  104422. getWaitingItemsCount(): number;
  104423. /**
  104424. * Returns a boolean indicating if the scene is still loading data
  104425. */
  104426. readonly isLoading: boolean;
  104427. /**
  104428. * Registers a function to be executed when the scene is ready
  104429. * @param {Function} func - the function to be executed
  104430. */
  104431. executeWhenReady(func: () => void): void;
  104432. /**
  104433. * Returns a promise that resolves when the scene is ready
  104434. * @returns A promise that resolves when the scene is ready
  104435. */
  104436. whenReadyAsync(): Promise<void>;
  104437. /** @hidden */
  104438. _checkIsReady(): void;
  104439. /**
  104440. * Gets all animatable attached to the scene
  104441. */
  104442. readonly animatables: Animatable[];
  104443. /**
  104444. * Resets the last animation time frame.
  104445. * Useful to override when animations start running when loading a scene for the first time.
  104446. */
  104447. resetLastAnimationTimeFrame(): void;
  104448. /**
  104449. * Gets the current view matrix
  104450. * @returns a Matrix
  104451. */
  104452. getViewMatrix(): Matrix;
  104453. /**
  104454. * Gets the current projection matrix
  104455. * @returns a Matrix
  104456. */
  104457. getProjectionMatrix(): Matrix;
  104458. /**
  104459. * Gets the current transform matrix
  104460. * @returns a Matrix made of View * Projection
  104461. */
  104462. getTransformMatrix(): Matrix;
  104463. /**
  104464. * Sets the current transform matrix
  104465. * @param viewL defines the View matrix to use
  104466. * @param projectionL defines the Projection matrix to use
  104467. * @param viewR defines the right View matrix to use (if provided)
  104468. * @param projectionR defines the right Projection matrix to use (if provided)
  104469. */
  104470. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104471. /**
  104472. * Gets the uniform buffer used to store scene data
  104473. * @returns a UniformBuffer
  104474. */
  104475. getSceneUniformBuffer(): UniformBuffer;
  104476. /**
  104477. * Gets an unique (relatively to the current scene) Id
  104478. * @returns an unique number for the scene
  104479. */
  104480. getUniqueId(): number;
  104481. /**
  104482. * Add a mesh to the list of scene's meshes
  104483. * @param newMesh defines the mesh to add
  104484. * @param recursive if all child meshes should also be added to the scene
  104485. */
  104486. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104487. /**
  104488. * Remove a mesh for the list of scene's meshes
  104489. * @param toRemove defines the mesh to remove
  104490. * @param recursive if all child meshes should also be removed from the scene
  104491. * @returns the index where the mesh was in the mesh list
  104492. */
  104493. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104494. /**
  104495. * Add a transform node to the list of scene's transform nodes
  104496. * @param newTransformNode defines the transform node to add
  104497. */
  104498. addTransformNode(newTransformNode: TransformNode): void;
  104499. /**
  104500. * Remove a transform node for the list of scene's transform nodes
  104501. * @param toRemove defines the transform node to remove
  104502. * @returns the index where the transform node was in the transform node list
  104503. */
  104504. removeTransformNode(toRemove: TransformNode): number;
  104505. /**
  104506. * Remove a skeleton for the list of scene's skeletons
  104507. * @param toRemove defines the skeleton to remove
  104508. * @returns the index where the skeleton was in the skeleton list
  104509. */
  104510. removeSkeleton(toRemove: Skeleton): number;
  104511. /**
  104512. * Remove a morph target for the list of scene's morph targets
  104513. * @param toRemove defines the morph target to remove
  104514. * @returns the index where the morph target was in the morph target list
  104515. */
  104516. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  104517. /**
  104518. * Remove a light for the list of scene's lights
  104519. * @param toRemove defines the light to remove
  104520. * @returns the index where the light was in the light list
  104521. */
  104522. removeLight(toRemove: Light): number;
  104523. /**
  104524. * Remove a camera for the list of scene's cameras
  104525. * @param toRemove defines the camera to remove
  104526. * @returns the index where the camera was in the camera list
  104527. */
  104528. removeCamera(toRemove: Camera): number;
  104529. /**
  104530. * Remove a particle system for the list of scene's particle systems
  104531. * @param toRemove defines the particle system to remove
  104532. * @returns the index where the particle system was in the particle system list
  104533. */
  104534. removeParticleSystem(toRemove: IParticleSystem): number;
  104535. /**
  104536. * Remove a animation for the list of scene's animations
  104537. * @param toRemove defines the animation to remove
  104538. * @returns the index where the animation was in the animation list
  104539. */
  104540. removeAnimation(toRemove: Animation): number;
  104541. /**
  104542. * Will stop the animation of the given target
  104543. * @param target - the target
  104544. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  104545. * @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)
  104546. */
  104547. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  104548. /**
  104549. * Removes the given animation group from this scene.
  104550. * @param toRemove The animation group to remove
  104551. * @returns The index of the removed animation group
  104552. */
  104553. removeAnimationGroup(toRemove: AnimationGroup): number;
  104554. /**
  104555. * Removes the given multi-material from this scene.
  104556. * @param toRemove The multi-material to remove
  104557. * @returns The index of the removed multi-material
  104558. */
  104559. removeMultiMaterial(toRemove: MultiMaterial): number;
  104560. /**
  104561. * Removes the given material from this scene.
  104562. * @param toRemove The material to remove
  104563. * @returns The index of the removed material
  104564. */
  104565. removeMaterial(toRemove: Material): number;
  104566. /**
  104567. * Removes the given action manager from this scene.
  104568. * @param toRemove The action manager to remove
  104569. * @returns The index of the removed action manager
  104570. */
  104571. removeActionManager(toRemove: AbstractActionManager): number;
  104572. /**
  104573. * Removes the given texture from this scene.
  104574. * @param toRemove The texture to remove
  104575. * @returns The index of the removed texture
  104576. */
  104577. removeTexture(toRemove: BaseTexture): number;
  104578. /**
  104579. * Adds the given light to this scene
  104580. * @param newLight The light to add
  104581. */
  104582. addLight(newLight: Light): void;
  104583. /**
  104584. * Sorts the list list based on light priorities
  104585. */
  104586. sortLightsByPriority(): void;
  104587. /**
  104588. * Adds the given camera to this scene
  104589. * @param newCamera The camera to add
  104590. */
  104591. addCamera(newCamera: Camera): void;
  104592. /**
  104593. * Adds the given skeleton to this scene
  104594. * @param newSkeleton The skeleton to add
  104595. */
  104596. addSkeleton(newSkeleton: Skeleton): void;
  104597. /**
  104598. * Adds the given particle system to this scene
  104599. * @param newParticleSystem The particle system to add
  104600. */
  104601. addParticleSystem(newParticleSystem: IParticleSystem): void;
  104602. /**
  104603. * Adds the given animation to this scene
  104604. * @param newAnimation The animation to add
  104605. */
  104606. addAnimation(newAnimation: Animation): void;
  104607. /**
  104608. * Adds the given animation group to this scene.
  104609. * @param newAnimationGroup The animation group to add
  104610. */
  104611. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  104612. /**
  104613. * Adds the given multi-material to this scene
  104614. * @param newMultiMaterial The multi-material to add
  104615. */
  104616. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  104617. /**
  104618. * Adds the given material to this scene
  104619. * @param newMaterial The material to add
  104620. */
  104621. addMaterial(newMaterial: Material): void;
  104622. /**
  104623. * Adds the given morph target to this scene
  104624. * @param newMorphTargetManager The morph target to add
  104625. */
  104626. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  104627. /**
  104628. * Adds the given geometry to this scene
  104629. * @param newGeometry The geometry to add
  104630. */
  104631. addGeometry(newGeometry: Geometry): void;
  104632. /**
  104633. * Adds the given action manager to this scene
  104634. * @param newActionManager The action manager to add
  104635. */
  104636. addActionManager(newActionManager: AbstractActionManager): void;
  104637. /**
  104638. * Adds the given texture to this scene.
  104639. * @param newTexture The texture to add
  104640. */
  104641. addTexture(newTexture: BaseTexture): void;
  104642. /**
  104643. * Switch active camera
  104644. * @param newCamera defines the new active camera
  104645. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  104646. */
  104647. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  104648. /**
  104649. * sets the active camera of the scene using its ID
  104650. * @param id defines the camera's ID
  104651. * @return the new active camera or null if none found.
  104652. */
  104653. setActiveCameraByID(id: string): Nullable<Camera>;
  104654. /**
  104655. * sets the active camera of the scene using its name
  104656. * @param name defines the camera's name
  104657. * @returns the new active camera or null if none found.
  104658. */
  104659. setActiveCameraByName(name: string): Nullable<Camera>;
  104660. /**
  104661. * get an animation group using its name
  104662. * @param name defines the material's name
  104663. * @return the animation group or null if none found.
  104664. */
  104665. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  104666. /**
  104667. * Get a material using its unique id
  104668. * @param uniqueId defines the material's unique id
  104669. * @return the material or null if none found.
  104670. */
  104671. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  104672. /**
  104673. * get a material using its id
  104674. * @param id defines the material's ID
  104675. * @return the material or null if none found.
  104676. */
  104677. getMaterialByID(id: string): Nullable<Material>;
  104678. /**
  104679. * Gets a the last added material using a given id
  104680. * @param id defines the material's ID
  104681. * @return the last material with the given id or null if none found.
  104682. */
  104683. getLastMaterialByID(id: string): Nullable<Material>;
  104684. /**
  104685. * Gets a material using its name
  104686. * @param name defines the material's name
  104687. * @return the material or null if none found.
  104688. */
  104689. getMaterialByName(name: string): Nullable<Material>;
  104690. /**
  104691. * Get a texture using its unique id
  104692. * @param uniqueId defines the texture's unique id
  104693. * @return the texture or null if none found.
  104694. */
  104695. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  104696. /**
  104697. * Gets a camera using its id
  104698. * @param id defines the id to look for
  104699. * @returns the camera or null if not found
  104700. */
  104701. getCameraByID(id: string): Nullable<Camera>;
  104702. /**
  104703. * Gets a camera using its unique id
  104704. * @param uniqueId defines the unique id to look for
  104705. * @returns the camera or null if not found
  104706. */
  104707. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  104708. /**
  104709. * Gets a camera using its name
  104710. * @param name defines the camera's name
  104711. * @return the camera or null if none found.
  104712. */
  104713. getCameraByName(name: string): Nullable<Camera>;
  104714. /**
  104715. * Gets a bone using its id
  104716. * @param id defines the bone's id
  104717. * @return the bone or null if not found
  104718. */
  104719. getBoneByID(id: string): Nullable<Bone>;
  104720. /**
  104721. * Gets a bone using its id
  104722. * @param name defines the bone's name
  104723. * @return the bone or null if not found
  104724. */
  104725. getBoneByName(name: string): Nullable<Bone>;
  104726. /**
  104727. * Gets a light node using its name
  104728. * @param name defines the the light's name
  104729. * @return the light or null if none found.
  104730. */
  104731. getLightByName(name: string): Nullable<Light>;
  104732. /**
  104733. * Gets a light node using its id
  104734. * @param id defines the light's id
  104735. * @return the light or null if none found.
  104736. */
  104737. getLightByID(id: string): Nullable<Light>;
  104738. /**
  104739. * Gets a light node using its scene-generated unique ID
  104740. * @param uniqueId defines the light's unique id
  104741. * @return the light or null if none found.
  104742. */
  104743. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  104744. /**
  104745. * Gets a particle system by id
  104746. * @param id defines the particle system id
  104747. * @return the corresponding system or null if none found
  104748. */
  104749. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  104750. /**
  104751. * Gets a geometry using its ID
  104752. * @param id defines the geometry's id
  104753. * @return the geometry or null if none found.
  104754. */
  104755. getGeometryByID(id: string): Nullable<Geometry>;
  104756. private _getGeometryByUniqueID;
  104757. /**
  104758. * Add a new geometry to this scene
  104759. * @param geometry defines the geometry to be added to the scene.
  104760. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  104761. * @return a boolean defining if the geometry was added or not
  104762. */
  104763. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  104764. /**
  104765. * Removes an existing geometry
  104766. * @param geometry defines the geometry to be removed from the scene
  104767. * @return a boolean defining if the geometry was removed or not
  104768. */
  104769. removeGeometry(geometry: Geometry): boolean;
  104770. /**
  104771. * Gets the list of geometries attached to the scene
  104772. * @returns an array of Geometry
  104773. */
  104774. getGeometries(): Geometry[];
  104775. /**
  104776. * Gets the first added mesh found of a given ID
  104777. * @param id defines the id to search for
  104778. * @return the mesh found or null if not found at all
  104779. */
  104780. getMeshByID(id: string): Nullable<AbstractMesh>;
  104781. /**
  104782. * Gets a list of meshes using their id
  104783. * @param id defines the id to search for
  104784. * @returns a list of meshes
  104785. */
  104786. getMeshesByID(id: string): Array<AbstractMesh>;
  104787. /**
  104788. * Gets the first added transform node found of a given ID
  104789. * @param id defines the id to search for
  104790. * @return the found transform node or null if not found at all.
  104791. */
  104792. getTransformNodeByID(id: string): Nullable<TransformNode>;
  104793. /**
  104794. * Gets a transform node with its auto-generated unique id
  104795. * @param uniqueId efines the unique id to search for
  104796. * @return the found transform node or null if not found at all.
  104797. */
  104798. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  104799. /**
  104800. * Gets a list of transform nodes using their id
  104801. * @param id defines the id to search for
  104802. * @returns a list of transform nodes
  104803. */
  104804. getTransformNodesByID(id: string): Array<TransformNode>;
  104805. /**
  104806. * Gets a mesh with its auto-generated unique id
  104807. * @param uniqueId defines the unique id to search for
  104808. * @return the found mesh or null if not found at all.
  104809. */
  104810. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  104811. /**
  104812. * Gets a the last added mesh using a given id
  104813. * @param id defines the id to search for
  104814. * @return the found mesh or null if not found at all.
  104815. */
  104816. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  104817. /**
  104818. * Gets a the last added node (Mesh, Camera, Light) using a given id
  104819. * @param id defines the id to search for
  104820. * @return the found node or null if not found at all
  104821. */
  104822. getLastEntryByID(id: string): Nullable<Node>;
  104823. /**
  104824. * Gets a node (Mesh, Camera, Light) using a given id
  104825. * @param id defines the id to search for
  104826. * @return the found node or null if not found at all
  104827. */
  104828. getNodeByID(id: string): Nullable<Node>;
  104829. /**
  104830. * Gets a node (Mesh, Camera, Light) using a given name
  104831. * @param name defines the name to search for
  104832. * @return the found node or null if not found at all.
  104833. */
  104834. getNodeByName(name: string): Nullable<Node>;
  104835. /**
  104836. * Gets a mesh using a given name
  104837. * @param name defines the name to search for
  104838. * @return the found mesh or null if not found at all.
  104839. */
  104840. getMeshByName(name: string): Nullable<AbstractMesh>;
  104841. /**
  104842. * Gets a transform node using a given name
  104843. * @param name defines the name to search for
  104844. * @return the found transform node or null if not found at all.
  104845. */
  104846. getTransformNodeByName(name: string): Nullable<TransformNode>;
  104847. /**
  104848. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  104849. * @param id defines the id to search for
  104850. * @return the found skeleton or null if not found at all.
  104851. */
  104852. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  104853. /**
  104854. * Gets a skeleton using a given auto generated unique id
  104855. * @param uniqueId defines the unique id to search for
  104856. * @return the found skeleton or null if not found at all.
  104857. */
  104858. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  104859. /**
  104860. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  104861. * @param id defines the id to search for
  104862. * @return the found skeleton or null if not found at all.
  104863. */
  104864. getSkeletonById(id: string): Nullable<Skeleton>;
  104865. /**
  104866. * Gets a skeleton using a given name
  104867. * @param name defines the name to search for
  104868. * @return the found skeleton or null if not found at all.
  104869. */
  104870. getSkeletonByName(name: string): Nullable<Skeleton>;
  104871. /**
  104872. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  104873. * @param id defines the id to search for
  104874. * @return the found morph target manager or null if not found at all.
  104875. */
  104876. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  104877. /**
  104878. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  104879. * @param id defines the id to search for
  104880. * @return the found morph target or null if not found at all.
  104881. */
  104882. getMorphTargetById(id: string): Nullable<MorphTarget>;
  104883. /**
  104884. * Gets a boolean indicating if the given mesh is active
  104885. * @param mesh defines the mesh to look for
  104886. * @returns true if the mesh is in the active list
  104887. */
  104888. isActiveMesh(mesh: AbstractMesh): boolean;
  104889. /**
  104890. * Return a unique id as a string which can serve as an identifier for the scene
  104891. */
  104892. readonly uid: string;
  104893. /**
  104894. * Add an externaly attached data from its key.
  104895. * This method call will fail and return false, if such key already exists.
  104896. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  104897. * @param key the unique key that identifies the data
  104898. * @param data the data object to associate to the key for this Engine instance
  104899. * @return true if no such key were already present and the data was added successfully, false otherwise
  104900. */
  104901. addExternalData<T>(key: string, data: T): boolean;
  104902. /**
  104903. * Get an externaly attached data from its key
  104904. * @param key the unique key that identifies the data
  104905. * @return the associated data, if present (can be null), or undefined if not present
  104906. */
  104907. getExternalData<T>(key: string): Nullable<T>;
  104908. /**
  104909. * Get an externaly attached data from its key, create it using a factory if it's not already present
  104910. * @param key the unique key that identifies the data
  104911. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  104912. * @return the associated data, can be null if the factory returned null.
  104913. */
  104914. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  104915. /**
  104916. * Remove an externaly attached data from the Engine instance
  104917. * @param key the unique key that identifies the data
  104918. * @return true if the data was successfully removed, false if it doesn't exist
  104919. */
  104920. removeExternalData(key: string): boolean;
  104921. private _evaluateSubMesh;
  104922. /**
  104923. * Clear the processed materials smart array preventing retention point in material dispose.
  104924. */
  104925. freeProcessedMaterials(): void;
  104926. private _preventFreeActiveMeshesAndRenderingGroups;
  104927. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  104928. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  104929. * when disposing several meshes in a row or a hierarchy of meshes.
  104930. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  104931. */
  104932. blockfreeActiveMeshesAndRenderingGroups: boolean;
  104933. /**
  104934. * Clear the active meshes smart array preventing retention point in mesh dispose.
  104935. */
  104936. freeActiveMeshes(): void;
  104937. /**
  104938. * Clear the info related to rendering groups preventing retention points during dispose.
  104939. */
  104940. freeRenderingGroups(): void;
  104941. /** @hidden */
  104942. _isInIntermediateRendering(): boolean;
  104943. /**
  104944. * Lambda returning the list of potentially active meshes.
  104945. */
  104946. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  104947. /**
  104948. * Lambda returning the list of potentially active sub meshes.
  104949. */
  104950. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  104951. /**
  104952. * Lambda returning the list of potentially intersecting sub meshes.
  104953. */
  104954. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  104955. /**
  104956. * Lambda returning the list of potentially colliding sub meshes.
  104957. */
  104958. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  104959. private _activeMeshesFrozen;
  104960. private _skipEvaluateActiveMeshesCompletely;
  104961. /**
  104962. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  104963. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  104964. * @returns the current scene
  104965. */
  104966. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  104967. /**
  104968. * Use this function to restart evaluating active meshes on every frame
  104969. * @returns the current scene
  104970. */
  104971. unfreezeActiveMeshes(): Scene;
  104972. private _evaluateActiveMeshes;
  104973. private _activeMesh;
  104974. /**
  104975. * Update the transform matrix to update from the current active camera
  104976. * @param force defines a boolean used to force the update even if cache is up to date
  104977. */
  104978. updateTransformMatrix(force?: boolean): void;
  104979. private _bindFrameBuffer;
  104980. /** @hidden */
  104981. _allowPostProcessClearColor: boolean;
  104982. /** @hidden */
  104983. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  104984. private _processSubCameras;
  104985. private _checkIntersections;
  104986. /** @hidden */
  104987. _advancePhysicsEngineStep(step: number): void;
  104988. /**
  104989. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  104990. */
  104991. getDeterministicFrameTime: () => number;
  104992. /** @hidden */
  104993. _animate(): void;
  104994. /** Execute all animations (for a frame) */
  104995. animate(): void;
  104996. /**
  104997. * Render the scene
  104998. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  104999. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  105000. */
  105001. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  105002. /**
  105003. * Freeze all materials
  105004. * A frozen material will not be updatable but should be faster to render
  105005. */
  105006. freezeMaterials(): void;
  105007. /**
  105008. * Unfreeze all materials
  105009. * A frozen material will not be updatable but should be faster to render
  105010. */
  105011. unfreezeMaterials(): void;
  105012. /**
  105013. * Releases all held ressources
  105014. */
  105015. dispose(): void;
  105016. /**
  105017. * Gets if the scene is already disposed
  105018. */
  105019. readonly isDisposed: boolean;
  105020. /**
  105021. * Call this function to reduce memory footprint of the scene.
  105022. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  105023. */
  105024. clearCachedVertexData(): void;
  105025. /**
  105026. * This function will remove the local cached buffer data from texture.
  105027. * It will save memory but will prevent the texture from being rebuilt
  105028. */
  105029. cleanCachedTextureBuffer(): void;
  105030. /**
  105031. * Get the world extend vectors with an optional filter
  105032. *
  105033. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  105034. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  105035. */
  105036. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  105037. min: Vector3;
  105038. max: Vector3;
  105039. };
  105040. /**
  105041. * Creates a ray that can be used to pick in the scene
  105042. * @param x defines the x coordinate of the origin (on-screen)
  105043. * @param y defines the y coordinate of the origin (on-screen)
  105044. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105045. * @param camera defines the camera to use for the picking
  105046. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105047. * @returns a Ray
  105048. */
  105049. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105050. /**
  105051. * Creates a ray that can be used to pick in the scene
  105052. * @param x defines the x coordinate of the origin (on-screen)
  105053. * @param y defines the y coordinate of the origin (on-screen)
  105054. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105055. * @param result defines the ray where to store the picking ray
  105056. * @param camera defines the camera to use for the picking
  105057. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105058. * @returns the current scene
  105059. */
  105060. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105061. /**
  105062. * Creates a ray that can be used to pick in the scene
  105063. * @param x defines the x coordinate of the origin (on-screen)
  105064. * @param y defines the y coordinate of the origin (on-screen)
  105065. * @param camera defines the camera to use for the picking
  105066. * @returns a Ray
  105067. */
  105068. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105069. /**
  105070. * Creates a ray that can be used to pick in the scene
  105071. * @param x defines the x coordinate of the origin (on-screen)
  105072. * @param y defines the y coordinate of the origin (on-screen)
  105073. * @param result defines the ray where to store the picking ray
  105074. * @param camera defines the camera to use for the picking
  105075. * @returns the current scene
  105076. */
  105077. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105078. /** Launch a ray to try to pick a mesh in the scene
  105079. * @param x position on screen
  105080. * @param y position on screen
  105081. * @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
  105082. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105083. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105084. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105085. * @returns a PickingInfo
  105086. */
  105087. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105088. /** Use the given ray to pick a mesh in the scene
  105089. * @param ray The ray to use to pick meshes
  105090. * @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
  105091. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105092. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105093. * @returns a PickingInfo
  105094. */
  105095. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105096. /**
  105097. * Launch a ray to try to pick a mesh in the scene
  105098. * @param x X position on screen
  105099. * @param y Y position on screen
  105100. * @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
  105101. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105102. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105103. * @returns an array of PickingInfo
  105104. */
  105105. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105106. /**
  105107. * Launch a ray to try to pick a mesh in the scene
  105108. * @param ray Ray to use
  105109. * @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
  105110. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105111. * @returns an array of PickingInfo
  105112. */
  105113. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105114. /**
  105115. * Force the value of meshUnderPointer
  105116. * @param mesh defines the mesh to use
  105117. */
  105118. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105119. /**
  105120. * Gets the mesh under the pointer
  105121. * @returns a Mesh or null if no mesh is under the pointer
  105122. */
  105123. getPointerOverMesh(): Nullable<AbstractMesh>;
  105124. /** @hidden */
  105125. _rebuildGeometries(): void;
  105126. /** @hidden */
  105127. _rebuildTextures(): void;
  105128. private _getByTags;
  105129. /**
  105130. * Get a list of meshes by tags
  105131. * @param tagsQuery defines the tags query to use
  105132. * @param forEach defines a predicate used to filter results
  105133. * @returns an array of Mesh
  105134. */
  105135. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105136. /**
  105137. * Get a list of cameras by tags
  105138. * @param tagsQuery defines the tags query to use
  105139. * @param forEach defines a predicate used to filter results
  105140. * @returns an array of Camera
  105141. */
  105142. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105143. /**
  105144. * Get a list of lights by tags
  105145. * @param tagsQuery defines the tags query to use
  105146. * @param forEach defines a predicate used to filter results
  105147. * @returns an array of Light
  105148. */
  105149. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105150. /**
  105151. * Get a list of materials by tags
  105152. * @param tagsQuery defines the tags query to use
  105153. * @param forEach defines a predicate used to filter results
  105154. * @returns an array of Material
  105155. */
  105156. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105157. /**
  105158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105159. * This allowed control for front to back rendering or reversly depending of the special needs.
  105160. *
  105161. * @param renderingGroupId The rendering group id corresponding to its index
  105162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105165. */
  105166. 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;
  105167. /**
  105168. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105169. *
  105170. * @param renderingGroupId The rendering group id corresponding to its index
  105171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105172. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105173. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105174. */
  105175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105176. /**
  105177. * Gets the current auto clear configuration for one rendering group of the rendering
  105178. * manager.
  105179. * @param index the rendering group index to get the information for
  105180. * @returns The auto clear setup for the requested rendering group
  105181. */
  105182. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105183. private _blockMaterialDirtyMechanism;
  105184. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105185. blockMaterialDirtyMechanism: boolean;
  105186. /**
  105187. * Will flag all materials as dirty to trigger new shader compilation
  105188. * @param flag defines the flag used to specify which material part must be marked as dirty
  105189. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105190. */
  105191. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105192. /** @hidden */
  105193. _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;
  105194. /** @hidden */
  105195. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105196. /** @hidden */
  105197. _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;
  105198. /** @hidden */
  105199. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105200. /** @hidden */
  105201. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105202. /** @hidden */
  105203. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105204. }
  105205. }
  105206. declare module BABYLON {
  105207. /**
  105208. * Set of assets to keep when moving a scene into an asset container.
  105209. */
  105210. export class KeepAssets extends AbstractScene {
  105211. }
  105212. /**
  105213. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105214. */
  105215. export class InstantiatedEntries {
  105216. /**
  105217. * List of new root nodes (eg. nodes with no parent)
  105218. */
  105219. rootNodes: TransformNode[];
  105220. /**
  105221. * List of new skeletons
  105222. */
  105223. skeletons: Skeleton[];
  105224. /**
  105225. * List of new animation groups
  105226. */
  105227. animationGroups: AnimationGroup[];
  105228. }
  105229. /**
  105230. * Container with a set of assets that can be added or removed from a scene.
  105231. */
  105232. export class AssetContainer extends AbstractScene {
  105233. /**
  105234. * The scene the AssetContainer belongs to.
  105235. */
  105236. scene: Scene;
  105237. /**
  105238. * Instantiates an AssetContainer.
  105239. * @param scene The scene the AssetContainer belongs to.
  105240. */
  105241. constructor(scene: Scene);
  105242. /**
  105243. * Instantiate or clone all meshes and add the new ones to the scene.
  105244. * Skeletons and animation groups will all be cloned
  105245. * @param nameFunction defines an optional function used to get new names for clones
  105246. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105247. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105248. */
  105249. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105250. /**
  105251. * Adds all the assets from the container to the scene.
  105252. */
  105253. addAllToScene(): void;
  105254. /**
  105255. * Removes all the assets in the container from the scene
  105256. */
  105257. removeAllFromScene(): void;
  105258. /**
  105259. * Disposes all the assets in the container
  105260. */
  105261. dispose(): void;
  105262. private _moveAssets;
  105263. /**
  105264. * Removes all the assets contained in the scene and adds them to the container.
  105265. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105266. */
  105267. moveAllFromScene(keepAssets?: KeepAssets): void;
  105268. /**
  105269. * 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.
  105270. * @returns the root mesh
  105271. */
  105272. createRootMesh(): Mesh;
  105273. }
  105274. }
  105275. declare module BABYLON {
  105276. /**
  105277. * Defines how the parser contract is defined.
  105278. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105279. */
  105280. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105281. /**
  105282. * Defines how the individual parser contract is defined.
  105283. * These parser can parse an individual asset
  105284. */
  105285. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105286. /**
  105287. * Base class of the scene acting as a container for the different elements composing a scene.
  105288. * This class is dynamically extended by the different components of the scene increasing
  105289. * flexibility and reducing coupling
  105290. */
  105291. export abstract class AbstractScene {
  105292. /**
  105293. * Stores the list of available parsers in the application.
  105294. */
  105295. private static _BabylonFileParsers;
  105296. /**
  105297. * Stores the list of available individual parsers in the application.
  105298. */
  105299. private static _IndividualBabylonFileParsers;
  105300. /**
  105301. * Adds a parser in the list of available ones
  105302. * @param name Defines the name of the parser
  105303. * @param parser Defines the parser to add
  105304. */
  105305. static AddParser(name: string, parser: BabylonFileParser): void;
  105306. /**
  105307. * Gets a general parser from the list of avaialble ones
  105308. * @param name Defines the name of the parser
  105309. * @returns the requested parser or null
  105310. */
  105311. static GetParser(name: string): Nullable<BabylonFileParser>;
  105312. /**
  105313. * Adds n individual parser in the list of available ones
  105314. * @param name Defines the name of the parser
  105315. * @param parser Defines the parser to add
  105316. */
  105317. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105318. /**
  105319. * Gets an individual parser from the list of avaialble ones
  105320. * @param name Defines the name of the parser
  105321. * @returns the requested parser or null
  105322. */
  105323. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105324. /**
  105325. * Parser json data and populate both a scene and its associated container object
  105326. * @param jsonData Defines the data to parse
  105327. * @param scene Defines the scene to parse the data for
  105328. * @param container Defines the container attached to the parsing sequence
  105329. * @param rootUrl Defines the root url of the data
  105330. */
  105331. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105332. /**
  105333. * Gets the list of root nodes (ie. nodes with no parent)
  105334. */
  105335. rootNodes: Node[];
  105336. /** All of the cameras added to this scene
  105337. * @see http://doc.babylonjs.com/babylon101/cameras
  105338. */
  105339. cameras: Camera[];
  105340. /**
  105341. * All of the lights added to this scene
  105342. * @see http://doc.babylonjs.com/babylon101/lights
  105343. */
  105344. lights: Light[];
  105345. /**
  105346. * All of the (abstract) meshes added to this scene
  105347. */
  105348. meshes: AbstractMesh[];
  105349. /**
  105350. * The list of skeletons added to the scene
  105351. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105352. */
  105353. skeletons: Skeleton[];
  105354. /**
  105355. * All of the particle systems added to this scene
  105356. * @see http://doc.babylonjs.com/babylon101/particles
  105357. */
  105358. particleSystems: IParticleSystem[];
  105359. /**
  105360. * Gets a list of Animations associated with the scene
  105361. */
  105362. animations: Animation[];
  105363. /**
  105364. * All of the animation groups added to this scene
  105365. * @see http://doc.babylonjs.com/how_to/group
  105366. */
  105367. animationGroups: AnimationGroup[];
  105368. /**
  105369. * All of the multi-materials added to this scene
  105370. * @see http://doc.babylonjs.com/how_to/multi_materials
  105371. */
  105372. multiMaterials: MultiMaterial[];
  105373. /**
  105374. * All of the materials added to this scene
  105375. * In the context of a Scene, it is not supposed to be modified manually.
  105376. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105377. * Note also that the order of the Material within the array is not significant and might change.
  105378. * @see http://doc.babylonjs.com/babylon101/materials
  105379. */
  105380. materials: Material[];
  105381. /**
  105382. * The list of morph target managers added to the scene
  105383. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105384. */
  105385. morphTargetManagers: MorphTargetManager[];
  105386. /**
  105387. * The list of geometries used in the scene.
  105388. */
  105389. geometries: Geometry[];
  105390. /**
  105391. * All of the tranform nodes added to this scene
  105392. * In the context of a Scene, it is not supposed to be modified manually.
  105393. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105394. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105395. * @see http://doc.babylonjs.com/how_to/transformnode
  105396. */
  105397. transformNodes: TransformNode[];
  105398. /**
  105399. * ActionManagers available on the scene.
  105400. */
  105401. actionManagers: AbstractActionManager[];
  105402. /**
  105403. * Textures to keep.
  105404. */
  105405. textures: BaseTexture[];
  105406. /**
  105407. * Environment texture for the scene
  105408. */
  105409. environmentTexture: Nullable<BaseTexture>;
  105410. }
  105411. }
  105412. declare module BABYLON {
  105413. /**
  105414. * Interface used to define options for Sound class
  105415. */
  105416. export interface ISoundOptions {
  105417. /**
  105418. * Does the sound autoplay once loaded.
  105419. */
  105420. autoplay?: boolean;
  105421. /**
  105422. * Does the sound loop after it finishes playing once.
  105423. */
  105424. loop?: boolean;
  105425. /**
  105426. * Sound's volume
  105427. */
  105428. volume?: number;
  105429. /**
  105430. * Is it a spatial sound?
  105431. */
  105432. spatialSound?: boolean;
  105433. /**
  105434. * Maximum distance to hear that sound
  105435. */
  105436. maxDistance?: number;
  105437. /**
  105438. * Uses user defined attenuation function
  105439. */
  105440. useCustomAttenuation?: boolean;
  105441. /**
  105442. * Define the roll off factor of spatial sounds.
  105443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105444. */
  105445. rolloffFactor?: number;
  105446. /**
  105447. * Define the reference distance the sound should be heard perfectly.
  105448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105449. */
  105450. refDistance?: number;
  105451. /**
  105452. * Define the distance attenuation model the sound will follow.
  105453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105454. */
  105455. distanceModel?: string;
  105456. /**
  105457. * Defines the playback speed (1 by default)
  105458. */
  105459. playbackRate?: number;
  105460. /**
  105461. * Defines if the sound is from a streaming source
  105462. */
  105463. streaming?: boolean;
  105464. /**
  105465. * Defines an optional length (in seconds) inside the sound file
  105466. */
  105467. length?: number;
  105468. /**
  105469. * Defines an optional offset (in seconds) inside the sound file
  105470. */
  105471. offset?: number;
  105472. /**
  105473. * If true, URLs will not be required to state the audio file codec to use.
  105474. */
  105475. skipCodecCheck?: boolean;
  105476. }
  105477. /**
  105478. * Defines a sound that can be played in the application.
  105479. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105481. */
  105482. export class Sound {
  105483. /**
  105484. * The name of the sound in the scene.
  105485. */
  105486. name: string;
  105487. /**
  105488. * Does the sound autoplay once loaded.
  105489. */
  105490. autoplay: boolean;
  105491. /**
  105492. * Does the sound loop after it finishes playing once.
  105493. */
  105494. loop: boolean;
  105495. /**
  105496. * Does the sound use a custom attenuation curve to simulate the falloff
  105497. * happening when the source gets further away from the camera.
  105498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105499. */
  105500. useCustomAttenuation: boolean;
  105501. /**
  105502. * The sound track id this sound belongs to.
  105503. */
  105504. soundTrackId: number;
  105505. /**
  105506. * Is this sound currently played.
  105507. */
  105508. isPlaying: boolean;
  105509. /**
  105510. * Is this sound currently paused.
  105511. */
  105512. isPaused: boolean;
  105513. /**
  105514. * Does this sound enables spatial sound.
  105515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105516. */
  105517. spatialSound: boolean;
  105518. /**
  105519. * Define the reference distance the sound should be heard perfectly.
  105520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105521. */
  105522. refDistance: number;
  105523. /**
  105524. * Define the roll off factor of spatial sounds.
  105525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105526. */
  105527. rolloffFactor: number;
  105528. /**
  105529. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  105530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105531. */
  105532. maxDistance: number;
  105533. /**
  105534. * Define the distance attenuation model the sound will follow.
  105535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105536. */
  105537. distanceModel: string;
  105538. /**
  105539. * @hidden
  105540. * Back Compat
  105541. **/
  105542. onended: () => any;
  105543. /**
  105544. * Observable event when the current playing sound finishes.
  105545. */
  105546. onEndedObservable: Observable<Sound>;
  105547. private _panningModel;
  105548. private _playbackRate;
  105549. private _streaming;
  105550. private _startTime;
  105551. private _startOffset;
  105552. private _position;
  105553. /** @hidden */
  105554. _positionInEmitterSpace: boolean;
  105555. private _localDirection;
  105556. private _volume;
  105557. private _isReadyToPlay;
  105558. private _isDirectional;
  105559. private _readyToPlayCallback;
  105560. private _audioBuffer;
  105561. private _soundSource;
  105562. private _streamingSource;
  105563. private _soundPanner;
  105564. private _soundGain;
  105565. private _inputAudioNode;
  105566. private _outputAudioNode;
  105567. private _coneInnerAngle;
  105568. private _coneOuterAngle;
  105569. private _coneOuterGain;
  105570. private _scene;
  105571. private _connectedTransformNode;
  105572. private _customAttenuationFunction;
  105573. private _registerFunc;
  105574. private _isOutputConnected;
  105575. private _htmlAudioElement;
  105576. private _urlType;
  105577. private _length?;
  105578. private _offset?;
  105579. /** @hidden */
  105580. static _SceneComponentInitialization: (scene: Scene) => void;
  105581. /**
  105582. * Create a sound and attach it to a scene
  105583. * @param name Name of your sound
  105584. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  105585. * @param scene defines the scene the sound belongs to
  105586. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  105587. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  105588. */
  105589. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  105590. /**
  105591. * Release the sound and its associated resources
  105592. */
  105593. dispose(): void;
  105594. /**
  105595. * Gets if the sounds is ready to be played or not.
  105596. * @returns true if ready, otherwise false
  105597. */
  105598. isReady(): boolean;
  105599. private _soundLoaded;
  105600. /**
  105601. * Sets the data of the sound from an audiobuffer
  105602. * @param audioBuffer The audioBuffer containing the data
  105603. */
  105604. setAudioBuffer(audioBuffer: AudioBuffer): void;
  105605. /**
  105606. * Updates the current sounds options such as maxdistance, loop...
  105607. * @param options A JSON object containing values named as the object properties
  105608. */
  105609. updateOptions(options: ISoundOptions): void;
  105610. private _createSpatialParameters;
  105611. private _updateSpatialParameters;
  105612. /**
  105613. * Switch the panning model to HRTF:
  105614. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105616. */
  105617. switchPanningModelToHRTF(): void;
  105618. /**
  105619. * Switch the panning model to Equal Power:
  105620. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105622. */
  105623. switchPanningModelToEqualPower(): void;
  105624. private _switchPanningModel;
  105625. /**
  105626. * Connect this sound to a sound track audio node like gain...
  105627. * @param soundTrackAudioNode the sound track audio node to connect to
  105628. */
  105629. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  105630. /**
  105631. * Transform this sound into a directional source
  105632. * @param coneInnerAngle Size of the inner cone in degree
  105633. * @param coneOuterAngle Size of the outer cone in degree
  105634. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  105635. */
  105636. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  105637. /**
  105638. * Gets or sets the inner angle for the directional cone.
  105639. */
  105640. /**
  105641. * Gets or sets the inner angle for the directional cone.
  105642. */
  105643. directionalConeInnerAngle: number;
  105644. /**
  105645. * Gets or sets the outer angle for the directional cone.
  105646. */
  105647. /**
  105648. * Gets or sets the outer angle for the directional cone.
  105649. */
  105650. directionalConeOuterAngle: number;
  105651. /**
  105652. * Sets the position of the emitter if spatial sound is enabled
  105653. * @param newPosition Defines the new posisiton
  105654. */
  105655. setPosition(newPosition: Vector3): void;
  105656. /**
  105657. * Sets the local direction of the emitter if spatial sound is enabled
  105658. * @param newLocalDirection Defines the new local direction
  105659. */
  105660. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  105661. private _updateDirection;
  105662. /** @hidden */
  105663. updateDistanceFromListener(): void;
  105664. /**
  105665. * Sets a new custom attenuation function for the sound.
  105666. * @param callback Defines the function used for the attenuation
  105667. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105668. */
  105669. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  105670. /**
  105671. * Play the sound
  105672. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  105673. * @param offset (optional) Start the sound at a specific time in seconds
  105674. * @param length (optional) Sound duration (in seconds)
  105675. */
  105676. play(time?: number, offset?: number, length?: number): void;
  105677. private _onended;
  105678. /**
  105679. * Stop the sound
  105680. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  105681. */
  105682. stop(time?: number): void;
  105683. /**
  105684. * Put the sound in pause
  105685. */
  105686. pause(): void;
  105687. /**
  105688. * Sets a dedicated volume for this sounds
  105689. * @param newVolume Define the new volume of the sound
  105690. * @param time Define time for gradual change to new volume
  105691. */
  105692. setVolume(newVolume: number, time?: number): void;
  105693. /**
  105694. * Set the sound play back rate
  105695. * @param newPlaybackRate Define the playback rate the sound should be played at
  105696. */
  105697. setPlaybackRate(newPlaybackRate: number): void;
  105698. /**
  105699. * Gets the volume of the sound.
  105700. * @returns the volume of the sound
  105701. */
  105702. getVolume(): number;
  105703. /**
  105704. * Attach the sound to a dedicated mesh
  105705. * @param transformNode The transform node to connect the sound with
  105706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105707. */
  105708. attachToMesh(transformNode: TransformNode): void;
  105709. /**
  105710. * Detach the sound from the previously attached mesh
  105711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105712. */
  105713. detachFromMesh(): void;
  105714. private _onRegisterAfterWorldMatrixUpdate;
  105715. /**
  105716. * Clone the current sound in the scene.
  105717. * @returns the new sound clone
  105718. */
  105719. clone(): Nullable<Sound>;
  105720. /**
  105721. * Gets the current underlying audio buffer containing the data
  105722. * @returns the audio buffer
  105723. */
  105724. getAudioBuffer(): Nullable<AudioBuffer>;
  105725. /**
  105726. * Serializes the Sound in a JSON representation
  105727. * @returns the JSON representation of the sound
  105728. */
  105729. serialize(): any;
  105730. /**
  105731. * Parse a JSON representation of a sound to innstantiate in a given scene
  105732. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  105733. * @param scene Define the scene the new parsed sound should be created in
  105734. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  105735. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  105736. * @returns the newly parsed sound
  105737. */
  105738. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  105739. }
  105740. }
  105741. declare module BABYLON {
  105742. /**
  105743. * This defines an action helpful to play a defined sound on a triggered action.
  105744. */
  105745. export class PlaySoundAction extends Action {
  105746. private _sound;
  105747. /**
  105748. * Instantiate the action
  105749. * @param triggerOptions defines the trigger options
  105750. * @param sound defines the sound to play
  105751. * @param condition defines the trigger related conditions
  105752. */
  105753. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105754. /** @hidden */
  105755. _prepare(): void;
  105756. /**
  105757. * Execute the action and play the sound.
  105758. */
  105759. execute(): void;
  105760. /**
  105761. * Serializes the actions and its related information.
  105762. * @param parent defines the object to serialize in
  105763. * @returns the serialized object
  105764. */
  105765. serialize(parent: any): any;
  105766. }
  105767. /**
  105768. * This defines an action helpful to stop a defined sound on a triggered action.
  105769. */
  105770. export class StopSoundAction extends Action {
  105771. private _sound;
  105772. /**
  105773. * Instantiate the action
  105774. * @param triggerOptions defines the trigger options
  105775. * @param sound defines the sound to stop
  105776. * @param condition defines the trigger related conditions
  105777. */
  105778. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105779. /** @hidden */
  105780. _prepare(): void;
  105781. /**
  105782. * Execute the action and stop the sound.
  105783. */
  105784. execute(): void;
  105785. /**
  105786. * Serializes the actions and its related information.
  105787. * @param parent defines the object to serialize in
  105788. * @returns the serialized object
  105789. */
  105790. serialize(parent: any): any;
  105791. }
  105792. }
  105793. declare module BABYLON {
  105794. /**
  105795. * This defines an action responsible to change the value of a property
  105796. * by interpolating between its current value and the newly set one once triggered.
  105797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105798. */
  105799. export class InterpolateValueAction extends Action {
  105800. /**
  105801. * Defines the path of the property where the value should be interpolated
  105802. */
  105803. propertyPath: string;
  105804. /**
  105805. * Defines the target value at the end of the interpolation.
  105806. */
  105807. value: any;
  105808. /**
  105809. * Defines the time it will take for the property to interpolate to the value.
  105810. */
  105811. duration: number;
  105812. /**
  105813. * Defines if the other scene animations should be stopped when the action has been triggered
  105814. */
  105815. stopOtherAnimations?: boolean;
  105816. /**
  105817. * Defines a callback raised once the interpolation animation has been done.
  105818. */
  105819. onInterpolationDone?: () => void;
  105820. /**
  105821. * Observable triggered once the interpolation animation has been done.
  105822. */
  105823. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  105824. private _target;
  105825. private _effectiveTarget;
  105826. private _property;
  105827. /**
  105828. * Instantiate the action
  105829. * @param triggerOptions defines the trigger options
  105830. * @param target defines the object containing the value to interpolate
  105831. * @param propertyPath defines the path to the property in the target object
  105832. * @param value defines the target value at the end of the interpolation
  105833. * @param duration deines the time it will take for the property to interpolate to the value.
  105834. * @param condition defines the trigger related conditions
  105835. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  105836. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  105837. */
  105838. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  105839. /** @hidden */
  105840. _prepare(): void;
  105841. /**
  105842. * Execute the action starts the value interpolation.
  105843. */
  105844. execute(): void;
  105845. /**
  105846. * Serializes the actions and its related information.
  105847. * @param parent defines the object to serialize in
  105848. * @returns the serialized object
  105849. */
  105850. serialize(parent: any): any;
  105851. }
  105852. }
  105853. declare module BABYLON {
  105854. /**
  105855. * Options allowed during the creation of a sound track.
  105856. */
  105857. export interface ISoundTrackOptions {
  105858. /**
  105859. * The volume the sound track should take during creation
  105860. */
  105861. volume?: number;
  105862. /**
  105863. * Define if the sound track is the main sound track of the scene
  105864. */
  105865. mainTrack?: boolean;
  105866. }
  105867. /**
  105868. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  105869. * It will be also used in a future release to apply effects on a specific track.
  105870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105871. */
  105872. export class SoundTrack {
  105873. /**
  105874. * The unique identifier of the sound track in the scene.
  105875. */
  105876. id: number;
  105877. /**
  105878. * The list of sounds included in the sound track.
  105879. */
  105880. soundCollection: Array<Sound>;
  105881. private _outputAudioNode;
  105882. private _scene;
  105883. private _connectedAnalyser;
  105884. private _options;
  105885. private _isInitialized;
  105886. /**
  105887. * Creates a new sound track.
  105888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105889. * @param scene Define the scene the sound track belongs to
  105890. * @param options
  105891. */
  105892. constructor(scene: Scene, options?: ISoundTrackOptions);
  105893. private _initializeSoundTrackAudioGraph;
  105894. /**
  105895. * Release the sound track and its associated resources
  105896. */
  105897. dispose(): void;
  105898. /**
  105899. * Adds a sound to this sound track
  105900. * @param sound define the cound to add
  105901. * @ignoreNaming
  105902. */
  105903. AddSound(sound: Sound): void;
  105904. /**
  105905. * Removes a sound to this sound track
  105906. * @param sound define the cound to remove
  105907. * @ignoreNaming
  105908. */
  105909. RemoveSound(sound: Sound): void;
  105910. /**
  105911. * Set a global volume for the full sound track.
  105912. * @param newVolume Define the new volume of the sound track
  105913. */
  105914. setVolume(newVolume: number): void;
  105915. /**
  105916. * Switch the panning model to HRTF:
  105917. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105919. */
  105920. switchPanningModelToHRTF(): void;
  105921. /**
  105922. * Switch the panning model to Equal Power:
  105923. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105925. */
  105926. switchPanningModelToEqualPower(): void;
  105927. /**
  105928. * Connect the sound track to an audio analyser allowing some amazing
  105929. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105931. * @param analyser The analyser to connect to the engine
  105932. */
  105933. connectToAnalyser(analyser: Analyser): void;
  105934. }
  105935. }
  105936. declare module BABYLON {
  105937. interface AbstractScene {
  105938. /**
  105939. * The list of sounds used in the scene.
  105940. */
  105941. sounds: Nullable<Array<Sound>>;
  105942. }
  105943. interface Scene {
  105944. /**
  105945. * @hidden
  105946. * Backing field
  105947. */
  105948. _mainSoundTrack: SoundTrack;
  105949. /**
  105950. * The main sound track played by the scene.
  105951. * It cotains your primary collection of sounds.
  105952. */
  105953. mainSoundTrack: SoundTrack;
  105954. /**
  105955. * The list of sound tracks added to the scene
  105956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105957. */
  105958. soundTracks: Nullable<Array<SoundTrack>>;
  105959. /**
  105960. * Gets a sound using a given name
  105961. * @param name defines the name to search for
  105962. * @return the found sound or null if not found at all.
  105963. */
  105964. getSoundByName(name: string): Nullable<Sound>;
  105965. /**
  105966. * Gets or sets if audio support is enabled
  105967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105968. */
  105969. audioEnabled: boolean;
  105970. /**
  105971. * Gets or sets if audio will be output to headphones
  105972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105973. */
  105974. headphone: boolean;
  105975. /**
  105976. * Gets or sets custom audio listener position provider
  105977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105978. */
  105979. audioListenerPositionProvider: Nullable<() => Vector3>;
  105980. /**
  105981. * Gets or sets a refresh rate when using 3D audio positioning
  105982. */
  105983. audioPositioningRefreshRate: number;
  105984. }
  105985. /**
  105986. * Defines the sound scene component responsible to manage any sounds
  105987. * in a given scene.
  105988. */
  105989. export class AudioSceneComponent implements ISceneSerializableComponent {
  105990. /**
  105991. * The component name helpfull to identify the component in the list of scene components.
  105992. */
  105993. readonly name: string;
  105994. /**
  105995. * The scene the component belongs to.
  105996. */
  105997. scene: Scene;
  105998. private _audioEnabled;
  105999. /**
  106000. * Gets whether audio is enabled or not.
  106001. * Please use related enable/disable method to switch state.
  106002. */
  106003. readonly audioEnabled: boolean;
  106004. private _headphone;
  106005. /**
  106006. * Gets whether audio is outputing to headphone or not.
  106007. * Please use the according Switch methods to change output.
  106008. */
  106009. readonly headphone: boolean;
  106010. /**
  106011. * Gets or sets a refresh rate when using 3D audio positioning
  106012. */
  106013. audioPositioningRefreshRate: number;
  106014. private _audioListenerPositionProvider;
  106015. /**
  106016. * Gets the current audio listener position provider
  106017. */
  106018. /**
  106019. * Sets a custom listener position for all sounds in the scene
  106020. * By default, this is the position of the first active camera
  106021. */
  106022. audioListenerPositionProvider: Nullable<() => Vector3>;
  106023. /**
  106024. * Creates a new instance of the component for the given scene
  106025. * @param scene Defines the scene to register the component in
  106026. */
  106027. constructor(scene: Scene);
  106028. /**
  106029. * Registers the component in a given scene
  106030. */
  106031. register(): void;
  106032. /**
  106033. * Rebuilds the elements related to this component in case of
  106034. * context lost for instance.
  106035. */
  106036. rebuild(): void;
  106037. /**
  106038. * Serializes the component data to the specified json object
  106039. * @param serializationObject The object to serialize to
  106040. */
  106041. serialize(serializationObject: any): void;
  106042. /**
  106043. * Adds all the elements from the container to the scene
  106044. * @param container the container holding the elements
  106045. */
  106046. addFromContainer(container: AbstractScene): void;
  106047. /**
  106048. * Removes all the elements in the container from the scene
  106049. * @param container contains the elements to remove
  106050. * @param dispose if the removed element should be disposed (default: false)
  106051. */
  106052. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106053. /**
  106054. * Disposes the component and the associated ressources.
  106055. */
  106056. dispose(): void;
  106057. /**
  106058. * Disables audio in the associated scene.
  106059. */
  106060. disableAudio(): void;
  106061. /**
  106062. * Enables audio in the associated scene.
  106063. */
  106064. enableAudio(): void;
  106065. /**
  106066. * Switch audio to headphone output.
  106067. */
  106068. switchAudioModeForHeadphones(): void;
  106069. /**
  106070. * Switch audio to normal speakers.
  106071. */
  106072. switchAudioModeForNormalSpeakers(): void;
  106073. private _cachedCameraDirection;
  106074. private _cachedCameraPosition;
  106075. private _lastCheck;
  106076. private _afterRender;
  106077. }
  106078. }
  106079. declare module BABYLON {
  106080. /**
  106081. * Wraps one or more Sound objects and selects one with random weight for playback.
  106082. */
  106083. export class WeightedSound {
  106084. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106085. loop: boolean;
  106086. private _coneInnerAngle;
  106087. private _coneOuterAngle;
  106088. private _volume;
  106089. /** A Sound is currently playing. */
  106090. isPlaying: boolean;
  106091. /** A Sound is currently paused. */
  106092. isPaused: boolean;
  106093. private _sounds;
  106094. private _weights;
  106095. private _currentIndex?;
  106096. /**
  106097. * Creates a new WeightedSound from the list of sounds given.
  106098. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106099. * @param sounds Array of Sounds that will be selected from.
  106100. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106101. */
  106102. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106103. /**
  106104. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106105. */
  106106. /**
  106107. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106108. */
  106109. directionalConeInnerAngle: number;
  106110. /**
  106111. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106112. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106113. */
  106114. /**
  106115. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106116. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106117. */
  106118. directionalConeOuterAngle: number;
  106119. /**
  106120. * Playback volume.
  106121. */
  106122. /**
  106123. * Playback volume.
  106124. */
  106125. volume: number;
  106126. private _onended;
  106127. /**
  106128. * Suspend playback
  106129. */
  106130. pause(): void;
  106131. /**
  106132. * Stop playback
  106133. */
  106134. stop(): void;
  106135. /**
  106136. * Start playback.
  106137. * @param startOffset Position the clip head at a specific time in seconds.
  106138. */
  106139. play(startOffset?: number): void;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106146. */
  106147. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106148. /**
  106149. * Gets the name of the behavior.
  106150. */
  106151. readonly name: string;
  106152. /**
  106153. * The easing function used by animations
  106154. */
  106155. static EasingFunction: BackEase;
  106156. /**
  106157. * The easing mode used by animations
  106158. */
  106159. static EasingMode: number;
  106160. /**
  106161. * The duration of the animation, in milliseconds
  106162. */
  106163. transitionDuration: number;
  106164. /**
  106165. * Length of the distance animated by the transition when lower radius is reached
  106166. */
  106167. lowerRadiusTransitionRange: number;
  106168. /**
  106169. * Length of the distance animated by the transition when upper radius is reached
  106170. */
  106171. upperRadiusTransitionRange: number;
  106172. private _autoTransitionRange;
  106173. /**
  106174. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106175. */
  106176. /**
  106177. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106178. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106179. */
  106180. autoTransitionRange: boolean;
  106181. private _attachedCamera;
  106182. private _onAfterCheckInputsObserver;
  106183. private _onMeshTargetChangedObserver;
  106184. /**
  106185. * Initializes the behavior.
  106186. */
  106187. init(): void;
  106188. /**
  106189. * Attaches the behavior to its arc rotate camera.
  106190. * @param camera Defines the camera to attach the behavior to
  106191. */
  106192. attach(camera: ArcRotateCamera): void;
  106193. /**
  106194. * Detaches the behavior from its current arc rotate camera.
  106195. */
  106196. detach(): void;
  106197. private _radiusIsAnimating;
  106198. private _radiusBounceTransition;
  106199. private _animatables;
  106200. private _cachedWheelPrecision;
  106201. /**
  106202. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106203. * @param radiusLimit The limit to check against.
  106204. * @return Bool to indicate if at limit.
  106205. */
  106206. private _isRadiusAtLimit;
  106207. /**
  106208. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106209. * @param radiusDelta The delta by which to animate to. Can be negative.
  106210. */
  106211. private _applyBoundRadiusAnimation;
  106212. /**
  106213. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106214. */
  106215. protected _clearAnimationLocks(): void;
  106216. /**
  106217. * Stops and removes all animations that have been applied to the camera
  106218. */
  106219. stopAllAnimations(): void;
  106220. }
  106221. }
  106222. declare module BABYLON {
  106223. /**
  106224. * 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.
  106225. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106226. */
  106227. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106228. /**
  106229. * Gets the name of the behavior.
  106230. */
  106231. readonly name: string;
  106232. private _mode;
  106233. private _radiusScale;
  106234. private _positionScale;
  106235. private _defaultElevation;
  106236. private _elevationReturnTime;
  106237. private _elevationReturnWaitTime;
  106238. private _zoomStopsAnimation;
  106239. private _framingTime;
  106240. /**
  106241. * The easing function used by animations
  106242. */
  106243. static EasingFunction: ExponentialEase;
  106244. /**
  106245. * The easing mode used by animations
  106246. */
  106247. static EasingMode: number;
  106248. /**
  106249. * Sets the current mode used by the behavior
  106250. */
  106251. /**
  106252. * Gets current mode used by the behavior.
  106253. */
  106254. mode: number;
  106255. /**
  106256. * Sets the scale applied to the radius (1 by default)
  106257. */
  106258. /**
  106259. * Gets the scale applied to the radius
  106260. */
  106261. radiusScale: number;
  106262. /**
  106263. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106264. */
  106265. /**
  106266. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106267. */
  106268. positionScale: number;
  106269. /**
  106270. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106271. * behaviour is triggered, in radians.
  106272. */
  106273. /**
  106274. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106275. * behaviour is triggered, in radians.
  106276. */
  106277. defaultElevation: number;
  106278. /**
  106279. * Sets the time (in milliseconds) taken to return to the default beta position.
  106280. * Negative value indicates camera should not return to default.
  106281. */
  106282. /**
  106283. * Gets the time (in milliseconds) taken to return to the default beta position.
  106284. * Negative value indicates camera should not return to default.
  106285. */
  106286. elevationReturnTime: number;
  106287. /**
  106288. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106289. */
  106290. /**
  106291. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106292. */
  106293. elevationReturnWaitTime: number;
  106294. /**
  106295. * Sets the flag that indicates if user zooming should stop animation.
  106296. */
  106297. /**
  106298. * Gets the flag that indicates if user zooming should stop animation.
  106299. */
  106300. zoomStopsAnimation: boolean;
  106301. /**
  106302. * Sets the transition time when framing the mesh, in milliseconds
  106303. */
  106304. /**
  106305. * Gets the transition time when framing the mesh, in milliseconds
  106306. */
  106307. framingTime: number;
  106308. /**
  106309. * Define if the behavior should automatically change the configured
  106310. * camera limits and sensibilities.
  106311. */
  106312. autoCorrectCameraLimitsAndSensibility: boolean;
  106313. private _onPrePointerObservableObserver;
  106314. private _onAfterCheckInputsObserver;
  106315. private _onMeshTargetChangedObserver;
  106316. private _attachedCamera;
  106317. private _isPointerDown;
  106318. private _lastInteractionTime;
  106319. /**
  106320. * Initializes the behavior.
  106321. */
  106322. init(): void;
  106323. /**
  106324. * Attaches the behavior to its arc rotate camera.
  106325. * @param camera Defines the camera to attach the behavior to
  106326. */
  106327. attach(camera: ArcRotateCamera): void;
  106328. /**
  106329. * Detaches the behavior from its current arc rotate camera.
  106330. */
  106331. detach(): void;
  106332. private _animatables;
  106333. private _betaIsAnimating;
  106334. private _betaTransition;
  106335. private _radiusTransition;
  106336. private _vectorTransition;
  106337. /**
  106338. * Targets the given mesh and updates zoom level accordingly.
  106339. * @param mesh The mesh to target.
  106340. * @param radius Optional. If a cached radius position already exists, overrides default.
  106341. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106342. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106343. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106344. */
  106345. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106346. /**
  106347. * Targets the given mesh with its children and updates zoom level accordingly.
  106348. * @param mesh The mesh to target.
  106349. * @param radius Optional. If a cached radius position already exists, overrides default.
  106350. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106351. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106352. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106353. */
  106354. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106355. /**
  106356. * Targets the given meshes with their children and updates zoom level accordingly.
  106357. * @param meshes The mesh to target.
  106358. * @param radius Optional. If a cached radius position already exists, overrides default.
  106359. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106360. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106361. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106362. */
  106363. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106364. /**
  106365. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106366. * @param minimumWorld Determines the smaller position of the bounding box extend
  106367. * @param maximumWorld Determines the bigger position of the bounding box extend
  106368. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106369. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106370. */
  106371. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106372. /**
  106373. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106374. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106375. * frustum width.
  106376. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106377. * to fully enclose the mesh in the viewing frustum.
  106378. */
  106379. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106380. /**
  106381. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106382. * is automatically returned to its default position (expected to be above ground plane).
  106383. */
  106384. private _maintainCameraAboveGround;
  106385. /**
  106386. * Returns the frustum slope based on the canvas ratio and camera FOV
  106387. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106388. */
  106389. private _getFrustumSlope;
  106390. /**
  106391. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106392. */
  106393. private _clearAnimationLocks;
  106394. /**
  106395. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106396. */
  106397. private _applyUserInteraction;
  106398. /**
  106399. * Stops and removes all animations that have been applied to the camera
  106400. */
  106401. stopAllAnimations(): void;
  106402. /**
  106403. * Gets a value indicating if the user is moving the camera
  106404. */
  106405. readonly isUserIsMoving: boolean;
  106406. /**
  106407. * The camera can move all the way towards the mesh.
  106408. */
  106409. static IgnoreBoundsSizeMode: number;
  106410. /**
  106411. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106412. */
  106413. static FitFrustumSidesMode: number;
  106414. }
  106415. }
  106416. declare module BABYLON {
  106417. /**
  106418. * Base class for Camera Pointer Inputs.
  106419. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106420. * for example usage.
  106421. */
  106422. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106423. /**
  106424. * Defines the camera the input is attached to.
  106425. */
  106426. abstract camera: Camera;
  106427. /**
  106428. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106429. */
  106430. protected _altKey: boolean;
  106431. protected _ctrlKey: boolean;
  106432. protected _metaKey: boolean;
  106433. protected _shiftKey: boolean;
  106434. /**
  106435. * Which mouse buttons were pressed at time of last mouse event.
  106436. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106437. */
  106438. protected _buttonsPressed: number;
  106439. /**
  106440. * Defines the buttons associated with the input to handle camera move.
  106441. */
  106442. buttons: number[];
  106443. /**
  106444. * Attach the input controls to a specific dom element to get the input from.
  106445. * @param element Defines the element the controls should be listened from
  106446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106447. */
  106448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106449. /**
  106450. * Detach the current controls from the specified dom element.
  106451. * @param element Defines the element to stop listening the inputs from
  106452. */
  106453. detachControl(element: Nullable<HTMLElement>): void;
  106454. /**
  106455. * Gets the class name of the current input.
  106456. * @returns the class name
  106457. */
  106458. getClassName(): string;
  106459. /**
  106460. * Get the friendly name associated with the input class.
  106461. * @returns the input friendly name
  106462. */
  106463. getSimpleName(): string;
  106464. /**
  106465. * Called on pointer POINTERDOUBLETAP event.
  106466. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106467. */
  106468. protected onDoubleTap(type: string): void;
  106469. /**
  106470. * Called on pointer POINTERMOVE event if only a single touch is active.
  106471. * Override this method to provide functionality.
  106472. */
  106473. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106474. /**
  106475. * Called on pointer POINTERMOVE event if multiple touches are active.
  106476. * Override this method to provide functionality.
  106477. */
  106478. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106479. /**
  106480. * Called on JS contextmenu event.
  106481. * Override this method to provide functionality.
  106482. */
  106483. protected onContextMenu(evt: PointerEvent): void;
  106484. /**
  106485. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106486. * press.
  106487. * Override this method to provide functionality.
  106488. */
  106489. protected onButtonDown(evt: PointerEvent): void;
  106490. /**
  106491. * Called each time a new POINTERUP event occurs. Ie, for each button
  106492. * release.
  106493. * Override this method to provide functionality.
  106494. */
  106495. protected onButtonUp(evt: PointerEvent): void;
  106496. /**
  106497. * Called when window becomes inactive.
  106498. * Override this method to provide functionality.
  106499. */
  106500. protected onLostFocus(): void;
  106501. private _pointerInput;
  106502. private _observer;
  106503. private _onLostFocus;
  106504. private pointA;
  106505. private pointB;
  106506. }
  106507. }
  106508. declare module BABYLON {
  106509. /**
  106510. * Manage the pointers inputs to control an arc rotate camera.
  106511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106512. */
  106513. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  106514. /**
  106515. * Defines the camera the input is attached to.
  106516. */
  106517. camera: ArcRotateCamera;
  106518. /**
  106519. * Gets the class name of the current input.
  106520. * @returns the class name
  106521. */
  106522. getClassName(): string;
  106523. /**
  106524. * Defines the buttons associated with the input to handle camera move.
  106525. */
  106526. buttons: number[];
  106527. /**
  106528. * Defines the pointer angular sensibility along the X axis or how fast is
  106529. * the camera rotating.
  106530. */
  106531. angularSensibilityX: number;
  106532. /**
  106533. * Defines the pointer angular sensibility along the Y axis or how fast is
  106534. * the camera rotating.
  106535. */
  106536. angularSensibilityY: number;
  106537. /**
  106538. * Defines the pointer pinch precision or how fast is the camera zooming.
  106539. */
  106540. pinchPrecision: number;
  106541. /**
  106542. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106543. * from 0.
  106544. * It defines the percentage of current camera.radius to use as delta when
  106545. * pinch zoom is used.
  106546. */
  106547. pinchDeltaPercentage: number;
  106548. /**
  106549. * Defines the pointer panning sensibility or how fast is the camera moving.
  106550. */
  106551. panningSensibility: number;
  106552. /**
  106553. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  106554. */
  106555. multiTouchPanning: boolean;
  106556. /**
  106557. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  106558. * zoom (pinch) through multitouch.
  106559. */
  106560. multiTouchPanAndZoom: boolean;
  106561. /**
  106562. * Revers pinch action direction.
  106563. */
  106564. pinchInwards: boolean;
  106565. private _isPanClick;
  106566. private _twoFingerActivityCount;
  106567. private _isPinching;
  106568. /**
  106569. * Called on pointer POINTERMOVE event if only a single touch is active.
  106570. */
  106571. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106572. /**
  106573. * Called on pointer POINTERDOUBLETAP event.
  106574. */
  106575. protected onDoubleTap(type: string): void;
  106576. /**
  106577. * Called on pointer POINTERMOVE event if multiple touches are active.
  106578. */
  106579. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106580. /**
  106581. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106582. * press.
  106583. */
  106584. protected onButtonDown(evt: PointerEvent): void;
  106585. /**
  106586. * Called each time a new POINTERUP event occurs. Ie, for each button
  106587. * release.
  106588. */
  106589. protected onButtonUp(evt: PointerEvent): void;
  106590. /**
  106591. * Called when window becomes inactive.
  106592. */
  106593. protected onLostFocus(): void;
  106594. }
  106595. }
  106596. declare module BABYLON {
  106597. /**
  106598. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  106599. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106600. */
  106601. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  106602. /**
  106603. * Defines the camera the input is attached to.
  106604. */
  106605. camera: ArcRotateCamera;
  106606. /**
  106607. * Defines the list of key codes associated with the up action (increase alpha)
  106608. */
  106609. keysUp: number[];
  106610. /**
  106611. * Defines the list of key codes associated with the down action (decrease alpha)
  106612. */
  106613. keysDown: number[];
  106614. /**
  106615. * Defines the list of key codes associated with the left action (increase beta)
  106616. */
  106617. keysLeft: number[];
  106618. /**
  106619. * Defines the list of key codes associated with the right action (decrease beta)
  106620. */
  106621. keysRight: number[];
  106622. /**
  106623. * Defines the list of key codes associated with the reset action.
  106624. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  106625. */
  106626. keysReset: number[];
  106627. /**
  106628. * Defines the panning sensibility of the inputs.
  106629. * (How fast is the camera paning)
  106630. */
  106631. panningSensibility: number;
  106632. /**
  106633. * Defines the zooming sensibility of the inputs.
  106634. * (How fast is the camera zooming)
  106635. */
  106636. zoomingSensibility: number;
  106637. /**
  106638. * Defines wether maintaining the alt key down switch the movement mode from
  106639. * orientation to zoom.
  106640. */
  106641. useAltToZoom: boolean;
  106642. /**
  106643. * Rotation speed of the camera
  106644. */
  106645. angularSpeed: number;
  106646. private _keys;
  106647. private _ctrlPressed;
  106648. private _altPressed;
  106649. private _onCanvasBlurObserver;
  106650. private _onKeyboardObserver;
  106651. private _engine;
  106652. private _scene;
  106653. /**
  106654. * Attach the input controls to a specific dom element to get the input from.
  106655. * @param element Defines the element the controls should be listened from
  106656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106657. */
  106658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106659. /**
  106660. * Detach the current controls from the specified dom element.
  106661. * @param element Defines the element to stop listening the inputs from
  106662. */
  106663. detachControl(element: Nullable<HTMLElement>): void;
  106664. /**
  106665. * Update the current camera state depending on the inputs that have been used this frame.
  106666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106667. */
  106668. checkInputs(): void;
  106669. /**
  106670. * Gets the class name of the current intput.
  106671. * @returns the class name
  106672. */
  106673. getClassName(): string;
  106674. /**
  106675. * Get the friendly name associated with the input class.
  106676. * @returns the input friendly name
  106677. */
  106678. getSimpleName(): string;
  106679. }
  106680. }
  106681. declare module BABYLON {
  106682. /**
  106683. * Manage the mouse wheel inputs to control an arc rotate camera.
  106684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106685. */
  106686. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  106687. /**
  106688. * Defines the camera the input is attached to.
  106689. */
  106690. camera: ArcRotateCamera;
  106691. /**
  106692. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106693. */
  106694. wheelPrecision: number;
  106695. /**
  106696. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106697. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106698. */
  106699. wheelDeltaPercentage: number;
  106700. private _wheel;
  106701. private _observer;
  106702. private computeDeltaFromMouseWheelLegacyEvent;
  106703. /**
  106704. * Attach the input controls to a specific dom element to get the input from.
  106705. * @param element Defines the element the controls should be listened from
  106706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106707. */
  106708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106709. /**
  106710. * Detach the current controls from the specified dom element.
  106711. * @param element Defines the element to stop listening the inputs from
  106712. */
  106713. detachControl(element: Nullable<HTMLElement>): void;
  106714. /**
  106715. * Gets the class name of the current intput.
  106716. * @returns the class name
  106717. */
  106718. getClassName(): string;
  106719. /**
  106720. * Get the friendly name associated with the input class.
  106721. * @returns the input friendly name
  106722. */
  106723. getSimpleName(): string;
  106724. }
  106725. }
  106726. declare module BABYLON {
  106727. /**
  106728. * Default Inputs manager for the ArcRotateCamera.
  106729. * It groups all the default supported inputs for ease of use.
  106730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106731. */
  106732. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  106733. /**
  106734. * Instantiates a new ArcRotateCameraInputsManager.
  106735. * @param camera Defines the camera the inputs belong to
  106736. */
  106737. constructor(camera: ArcRotateCamera);
  106738. /**
  106739. * Add mouse wheel input support to the input manager.
  106740. * @returns the current input manager
  106741. */
  106742. addMouseWheel(): ArcRotateCameraInputsManager;
  106743. /**
  106744. * Add pointers input support to the input manager.
  106745. * @returns the current input manager
  106746. */
  106747. addPointers(): ArcRotateCameraInputsManager;
  106748. /**
  106749. * Add keyboard input support to the input manager.
  106750. * @returns the current input manager
  106751. */
  106752. addKeyboard(): ArcRotateCameraInputsManager;
  106753. }
  106754. }
  106755. declare module BABYLON {
  106756. /**
  106757. * This represents an orbital type of camera.
  106758. *
  106759. * 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.
  106760. * 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.
  106761. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  106762. */
  106763. export class ArcRotateCamera extends TargetCamera {
  106764. /**
  106765. * Defines the rotation angle of the camera along the longitudinal axis.
  106766. */
  106767. alpha: number;
  106768. /**
  106769. * Defines the rotation angle of the camera along the latitudinal axis.
  106770. */
  106771. beta: number;
  106772. /**
  106773. * Defines the radius of the camera from it s target point.
  106774. */
  106775. radius: number;
  106776. protected _target: Vector3;
  106777. protected _targetHost: Nullable<AbstractMesh>;
  106778. /**
  106779. * Defines the target point of the camera.
  106780. * The camera looks towards it form the radius distance.
  106781. */
  106782. target: Vector3;
  106783. /**
  106784. * Define the current local position of the camera in the scene
  106785. */
  106786. position: Vector3;
  106787. protected _upVector: Vector3;
  106788. protected _upToYMatrix: Matrix;
  106789. protected _YToUpMatrix: Matrix;
  106790. /**
  106791. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  106792. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  106793. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  106794. */
  106795. upVector: Vector3;
  106796. /**
  106797. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  106798. */
  106799. setMatUp(): void;
  106800. /**
  106801. * Current inertia value on the longitudinal axis.
  106802. * The bigger this number the longer it will take for the camera to stop.
  106803. */
  106804. inertialAlphaOffset: number;
  106805. /**
  106806. * Current inertia value on the latitudinal axis.
  106807. * The bigger this number the longer it will take for the camera to stop.
  106808. */
  106809. inertialBetaOffset: number;
  106810. /**
  106811. * Current inertia value on the radius axis.
  106812. * The bigger this number the longer it will take for the camera to stop.
  106813. */
  106814. inertialRadiusOffset: number;
  106815. /**
  106816. * Minimum allowed angle on the longitudinal axis.
  106817. * This can help limiting how the Camera is able to move in the scene.
  106818. */
  106819. lowerAlphaLimit: Nullable<number>;
  106820. /**
  106821. * Maximum allowed angle on the longitudinal axis.
  106822. * This can help limiting how the Camera is able to move in the scene.
  106823. */
  106824. upperAlphaLimit: Nullable<number>;
  106825. /**
  106826. * Minimum allowed angle on the latitudinal axis.
  106827. * This can help limiting how the Camera is able to move in the scene.
  106828. */
  106829. lowerBetaLimit: number;
  106830. /**
  106831. * Maximum allowed angle on the latitudinal axis.
  106832. * This can help limiting how the Camera is able to move in the scene.
  106833. */
  106834. upperBetaLimit: number;
  106835. /**
  106836. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  106837. * This can help limiting how the Camera is able to move in the scene.
  106838. */
  106839. lowerRadiusLimit: Nullable<number>;
  106840. /**
  106841. * Maximum allowed distance of the camera to the target (The camera can not get further).
  106842. * This can help limiting how the Camera is able to move in the scene.
  106843. */
  106844. upperRadiusLimit: Nullable<number>;
  106845. /**
  106846. * Defines the current inertia value used during panning of the camera along the X axis.
  106847. */
  106848. inertialPanningX: number;
  106849. /**
  106850. * Defines the current inertia value used during panning of the camera along the Y axis.
  106851. */
  106852. inertialPanningY: number;
  106853. /**
  106854. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  106855. * Basically if your fingers moves away from more than this distance you will be considered
  106856. * in pinch mode.
  106857. */
  106858. pinchToPanMaxDistance: number;
  106859. /**
  106860. * Defines the maximum distance the camera can pan.
  106861. * This could help keeping the cammera always in your scene.
  106862. */
  106863. panningDistanceLimit: Nullable<number>;
  106864. /**
  106865. * Defines the target of the camera before paning.
  106866. */
  106867. panningOriginTarget: Vector3;
  106868. /**
  106869. * Defines the value of the inertia used during panning.
  106870. * 0 would mean stop inertia and one would mean no decelleration at all.
  106871. */
  106872. panningInertia: number;
  106873. /**
  106874. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  106875. */
  106876. angularSensibilityX: number;
  106877. /**
  106878. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  106879. */
  106880. angularSensibilityY: number;
  106881. /**
  106882. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  106883. */
  106884. pinchPrecision: number;
  106885. /**
  106886. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  106887. * It will be used instead of pinchDeltaPrecision if different from 0.
  106888. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106889. */
  106890. pinchDeltaPercentage: number;
  106891. /**
  106892. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  106893. */
  106894. panningSensibility: number;
  106895. /**
  106896. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  106897. */
  106898. keysUp: number[];
  106899. /**
  106900. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  106901. */
  106902. keysDown: number[];
  106903. /**
  106904. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  106905. */
  106906. keysLeft: number[];
  106907. /**
  106908. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  106909. */
  106910. keysRight: number[];
  106911. /**
  106912. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106913. */
  106914. wheelPrecision: number;
  106915. /**
  106916. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  106917. * It will be used instead of pinchDeltaPrecision if different from 0.
  106918. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106919. */
  106920. wheelDeltaPercentage: number;
  106921. /**
  106922. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  106923. */
  106924. zoomOnFactor: number;
  106925. /**
  106926. * Defines a screen offset for the camera position.
  106927. */
  106928. targetScreenOffset: Vector2;
  106929. /**
  106930. * Allows the camera to be completely reversed.
  106931. * If false the camera can not arrive upside down.
  106932. */
  106933. allowUpsideDown: boolean;
  106934. /**
  106935. * Define if double tap/click is used to restore the previously saved state of the camera.
  106936. */
  106937. useInputToRestoreState: boolean;
  106938. /** @hidden */
  106939. _viewMatrix: Matrix;
  106940. /** @hidden */
  106941. _useCtrlForPanning: boolean;
  106942. /** @hidden */
  106943. _panningMouseButton: number;
  106944. /**
  106945. * Defines the input associated to the camera.
  106946. */
  106947. inputs: ArcRotateCameraInputsManager;
  106948. /** @hidden */
  106949. _reset: () => void;
  106950. /**
  106951. * Defines the allowed panning axis.
  106952. */
  106953. panningAxis: Vector3;
  106954. protected _localDirection: Vector3;
  106955. protected _transformedDirection: Vector3;
  106956. private _bouncingBehavior;
  106957. /**
  106958. * Gets the bouncing behavior of the camera if it has been enabled.
  106959. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106960. */
  106961. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  106962. /**
  106963. * Defines if the bouncing behavior of the camera is enabled on the camera.
  106964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106965. */
  106966. useBouncingBehavior: boolean;
  106967. private _framingBehavior;
  106968. /**
  106969. * Gets the framing behavior of the camera if it has been enabled.
  106970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106971. */
  106972. readonly framingBehavior: Nullable<FramingBehavior>;
  106973. /**
  106974. * Defines if the framing behavior of the camera is enabled on the camera.
  106975. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106976. */
  106977. useFramingBehavior: boolean;
  106978. private _autoRotationBehavior;
  106979. /**
  106980. * Gets the auto rotation behavior of the camera if it has been enabled.
  106981. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  106982. */
  106983. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  106984. /**
  106985. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  106986. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  106987. */
  106988. useAutoRotationBehavior: boolean;
  106989. /**
  106990. * Observable triggered when the mesh target has been changed on the camera.
  106991. */
  106992. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  106993. /**
  106994. * Event raised when the camera is colliding with a mesh.
  106995. */
  106996. onCollide: (collidedMesh: AbstractMesh) => void;
  106997. /**
  106998. * Defines whether the camera should check collision with the objects oh the scene.
  106999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  107000. */
  107001. checkCollisions: boolean;
  107002. /**
  107003. * Defines the collision radius of the camera.
  107004. * This simulates a sphere around the camera.
  107005. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107006. */
  107007. collisionRadius: Vector3;
  107008. protected _collider: Collider;
  107009. protected _previousPosition: Vector3;
  107010. protected _collisionVelocity: Vector3;
  107011. protected _newPosition: Vector3;
  107012. protected _previousAlpha: number;
  107013. protected _previousBeta: number;
  107014. protected _previousRadius: number;
  107015. protected _collisionTriggered: boolean;
  107016. protected _targetBoundingCenter: Nullable<Vector3>;
  107017. private _computationVector;
  107018. /**
  107019. * Instantiates a new ArcRotateCamera in a given scene
  107020. * @param name Defines the name of the camera
  107021. * @param alpha Defines the camera rotation along the logitudinal axis
  107022. * @param beta Defines the camera rotation along the latitudinal axis
  107023. * @param radius Defines the camera distance from its target
  107024. * @param target Defines the camera target
  107025. * @param scene Defines the scene the camera belongs to
  107026. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  107027. */
  107028. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107029. /** @hidden */
  107030. _initCache(): void;
  107031. /** @hidden */
  107032. _updateCache(ignoreParentClass?: boolean): void;
  107033. protected _getTargetPosition(): Vector3;
  107034. private _storedAlpha;
  107035. private _storedBeta;
  107036. private _storedRadius;
  107037. private _storedTarget;
  107038. private _storedTargetScreenOffset;
  107039. /**
  107040. * Stores the current state of the camera (alpha, beta, radius and target)
  107041. * @returns the camera itself
  107042. */
  107043. storeState(): Camera;
  107044. /**
  107045. * @hidden
  107046. * Restored camera state. You must call storeState() first
  107047. */
  107048. _restoreStateValues(): boolean;
  107049. /** @hidden */
  107050. _isSynchronizedViewMatrix(): boolean;
  107051. /**
  107052. * Attached controls to the current camera.
  107053. * @param element Defines the element the controls should be listened from
  107054. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107055. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107056. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107057. */
  107058. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107059. /**
  107060. * Detach the current controls from the camera.
  107061. * The camera will stop reacting to inputs.
  107062. * @param element Defines the element to stop listening the inputs from
  107063. */
  107064. detachControl(element: HTMLElement): void;
  107065. /** @hidden */
  107066. _checkInputs(): void;
  107067. protected _checkLimits(): void;
  107068. /**
  107069. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107070. */
  107071. rebuildAnglesAndRadius(): void;
  107072. /**
  107073. * Use a position to define the current camera related information like alpha, beta and radius
  107074. * @param position Defines the position to set the camera at
  107075. */
  107076. setPosition(position: Vector3): void;
  107077. /**
  107078. * Defines the target the camera should look at.
  107079. * This will automatically adapt alpha beta and radius to fit within the new target.
  107080. * @param target Defines the new target as a Vector or a mesh
  107081. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107082. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107083. */
  107084. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107085. /** @hidden */
  107086. _getViewMatrix(): Matrix;
  107087. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107088. /**
  107089. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107090. * @param meshes Defines the mesh to zoom on
  107091. * @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)
  107092. */
  107093. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107094. /**
  107095. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107096. * The target will be changed but the radius
  107097. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107098. * @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)
  107099. */
  107100. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107101. min: Vector3;
  107102. max: Vector3;
  107103. distance: number;
  107104. }, doNotUpdateMaxZ?: boolean): void;
  107105. /**
  107106. * @override
  107107. * Override Camera.createRigCamera
  107108. */
  107109. createRigCamera(name: string, cameraIndex: number): Camera;
  107110. /**
  107111. * @hidden
  107112. * @override
  107113. * Override Camera._updateRigCameras
  107114. */
  107115. _updateRigCameras(): void;
  107116. /**
  107117. * Destroy the camera and release the current resources hold by it.
  107118. */
  107119. dispose(): void;
  107120. /**
  107121. * Gets the current object class name.
  107122. * @return the class name
  107123. */
  107124. getClassName(): string;
  107125. }
  107126. }
  107127. declare module BABYLON {
  107128. /**
  107129. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107131. */
  107132. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107133. /**
  107134. * Gets the name of the behavior.
  107135. */
  107136. readonly name: string;
  107137. private _zoomStopsAnimation;
  107138. private _idleRotationSpeed;
  107139. private _idleRotationWaitTime;
  107140. private _idleRotationSpinupTime;
  107141. /**
  107142. * Sets the flag that indicates if user zooming should stop animation.
  107143. */
  107144. /**
  107145. * Gets the flag that indicates if user zooming should stop animation.
  107146. */
  107147. zoomStopsAnimation: boolean;
  107148. /**
  107149. * Sets the default speed at which the camera rotates around the model.
  107150. */
  107151. /**
  107152. * Gets the default speed at which the camera rotates around the model.
  107153. */
  107154. idleRotationSpeed: number;
  107155. /**
  107156. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107157. */
  107158. /**
  107159. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107160. */
  107161. idleRotationWaitTime: number;
  107162. /**
  107163. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107164. */
  107165. /**
  107166. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107167. */
  107168. idleRotationSpinupTime: number;
  107169. /**
  107170. * Gets a value indicating if the camera is currently rotating because of this behavior
  107171. */
  107172. readonly rotationInProgress: boolean;
  107173. private _onPrePointerObservableObserver;
  107174. private _onAfterCheckInputsObserver;
  107175. private _attachedCamera;
  107176. private _isPointerDown;
  107177. private _lastFrameTime;
  107178. private _lastInteractionTime;
  107179. private _cameraRotationSpeed;
  107180. /**
  107181. * Initializes the behavior.
  107182. */
  107183. init(): void;
  107184. /**
  107185. * Attaches the behavior to its arc rotate camera.
  107186. * @param camera Defines the camera to attach the behavior to
  107187. */
  107188. attach(camera: ArcRotateCamera): void;
  107189. /**
  107190. * Detaches the behavior from its current arc rotate camera.
  107191. */
  107192. detach(): void;
  107193. /**
  107194. * Returns true if user is scrolling.
  107195. * @return true if user is scrolling.
  107196. */
  107197. private _userIsZooming;
  107198. private _lastFrameRadius;
  107199. private _shouldAnimationStopForInteraction;
  107200. /**
  107201. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107202. */
  107203. private _applyUserInteraction;
  107204. private _userIsMoving;
  107205. }
  107206. }
  107207. declare module BABYLON {
  107208. /**
  107209. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107210. */
  107211. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107212. private ui;
  107213. /**
  107214. * The name of the behavior
  107215. */
  107216. name: string;
  107217. /**
  107218. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107219. */
  107220. distanceAwayFromFace: number;
  107221. /**
  107222. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107223. */
  107224. distanceAwayFromBottomOfFace: number;
  107225. private _faceVectors;
  107226. private _target;
  107227. private _scene;
  107228. private _onRenderObserver;
  107229. private _tmpMatrix;
  107230. private _tmpVector;
  107231. /**
  107232. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107233. * @param ui The transform node that should be attched to the mesh
  107234. */
  107235. constructor(ui: TransformNode);
  107236. /**
  107237. * Initializes the behavior
  107238. */
  107239. init(): void;
  107240. private _closestFace;
  107241. private _zeroVector;
  107242. private _lookAtTmpMatrix;
  107243. private _lookAtToRef;
  107244. /**
  107245. * Attaches the AttachToBoxBehavior to the passed in mesh
  107246. * @param target The mesh that the specified node will be attached to
  107247. */
  107248. attach(target: Mesh): void;
  107249. /**
  107250. * Detaches the behavior from the mesh
  107251. */
  107252. detach(): void;
  107253. }
  107254. }
  107255. declare module BABYLON {
  107256. /**
  107257. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107258. */
  107259. export class FadeInOutBehavior implements Behavior<Mesh> {
  107260. /**
  107261. * Time in milliseconds to delay before fading in (Default: 0)
  107262. */
  107263. delay: number;
  107264. /**
  107265. * Time in milliseconds for the mesh to fade in (Default: 300)
  107266. */
  107267. fadeInTime: number;
  107268. private _millisecondsPerFrame;
  107269. private _hovered;
  107270. private _hoverValue;
  107271. private _ownerNode;
  107272. /**
  107273. * Instatiates the FadeInOutBehavior
  107274. */
  107275. constructor();
  107276. /**
  107277. * The name of the behavior
  107278. */
  107279. readonly name: string;
  107280. /**
  107281. * Initializes the behavior
  107282. */
  107283. init(): void;
  107284. /**
  107285. * Attaches the fade behavior on the passed in mesh
  107286. * @param ownerNode The mesh that will be faded in/out once attached
  107287. */
  107288. attach(ownerNode: Mesh): void;
  107289. /**
  107290. * Detaches the behavior from the mesh
  107291. */
  107292. detach(): void;
  107293. /**
  107294. * Triggers the mesh to begin fading in or out
  107295. * @param value if the object should fade in or out (true to fade in)
  107296. */
  107297. fadeIn(value: boolean): void;
  107298. private _update;
  107299. private _setAllVisibility;
  107300. }
  107301. }
  107302. declare module BABYLON {
  107303. /**
  107304. * Class containing a set of static utilities functions for managing Pivots
  107305. * @hidden
  107306. */
  107307. export class PivotTools {
  107308. private static _PivotCached;
  107309. private static _OldPivotPoint;
  107310. private static _PivotTranslation;
  107311. private static _PivotTmpVector;
  107312. /** @hidden */
  107313. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107314. /** @hidden */
  107315. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107316. }
  107317. }
  107318. declare module BABYLON {
  107319. /**
  107320. * Class containing static functions to help procedurally build meshes
  107321. */
  107322. export class PlaneBuilder {
  107323. /**
  107324. * Creates a plane mesh
  107325. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107326. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107327. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107331. * @param name defines the name of the mesh
  107332. * @param options defines the options used to create the mesh
  107333. * @param scene defines the hosting scene
  107334. * @returns the plane mesh
  107335. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107336. */
  107337. static CreatePlane(name: string, options: {
  107338. size?: number;
  107339. width?: number;
  107340. height?: number;
  107341. sideOrientation?: number;
  107342. frontUVs?: Vector4;
  107343. backUVs?: Vector4;
  107344. updatable?: boolean;
  107345. sourcePlane?: Plane;
  107346. }, scene?: Nullable<Scene>): Mesh;
  107347. }
  107348. }
  107349. declare module BABYLON {
  107350. /**
  107351. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107352. */
  107353. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107354. private static _AnyMouseID;
  107355. /**
  107356. * Abstract mesh the behavior is set on
  107357. */
  107358. attachedNode: AbstractMesh;
  107359. private _dragPlane;
  107360. private _scene;
  107361. private _pointerObserver;
  107362. private _beforeRenderObserver;
  107363. private static _planeScene;
  107364. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107365. /**
  107366. * 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)
  107367. */
  107368. maxDragAngle: number;
  107369. /**
  107370. * @hidden
  107371. */
  107372. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107373. /**
  107374. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107375. */
  107376. currentDraggingPointerID: number;
  107377. /**
  107378. * The last position where the pointer hit the drag plane in world space
  107379. */
  107380. lastDragPosition: Vector3;
  107381. /**
  107382. * If the behavior is currently in a dragging state
  107383. */
  107384. dragging: boolean;
  107385. /**
  107386. * 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)
  107387. */
  107388. dragDeltaRatio: number;
  107389. /**
  107390. * If the drag plane orientation should be updated during the dragging (Default: true)
  107391. */
  107392. updateDragPlane: boolean;
  107393. private _debugMode;
  107394. private _moving;
  107395. /**
  107396. * Fires each time the attached mesh is dragged with the pointer
  107397. * * delta between last drag position and current drag position in world space
  107398. * * dragDistance along the drag axis
  107399. * * dragPlaneNormal normal of the current drag plane used during the drag
  107400. * * dragPlanePoint in world space where the drag intersects the drag plane
  107401. */
  107402. onDragObservable: Observable<{
  107403. delta: Vector3;
  107404. dragPlanePoint: Vector3;
  107405. dragPlaneNormal: Vector3;
  107406. dragDistance: number;
  107407. pointerId: number;
  107408. }>;
  107409. /**
  107410. * Fires each time a drag begins (eg. mouse down on mesh)
  107411. */
  107412. onDragStartObservable: Observable<{
  107413. dragPlanePoint: Vector3;
  107414. pointerId: number;
  107415. }>;
  107416. /**
  107417. * Fires each time a drag ends (eg. mouse release after drag)
  107418. */
  107419. onDragEndObservable: Observable<{
  107420. dragPlanePoint: Vector3;
  107421. pointerId: number;
  107422. }>;
  107423. /**
  107424. * If the attached mesh should be moved when dragged
  107425. */
  107426. moveAttached: boolean;
  107427. /**
  107428. * If the drag behavior will react to drag events (Default: true)
  107429. */
  107430. enabled: boolean;
  107431. /**
  107432. * If pointer events should start and release the drag (Default: true)
  107433. */
  107434. startAndReleaseDragOnPointerEvents: boolean;
  107435. /**
  107436. * If camera controls should be detached during the drag
  107437. */
  107438. detachCameraControls: boolean;
  107439. /**
  107440. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107441. */
  107442. useObjectOrienationForDragging: boolean;
  107443. private _options;
  107444. /**
  107445. * Gets the options used by the behavior
  107446. */
  107447. /**
  107448. * Sets the options used by the behavior
  107449. */
  107450. options: {
  107451. dragAxis?: Vector3;
  107452. dragPlaneNormal?: Vector3;
  107453. };
  107454. /**
  107455. * Creates a pointer drag behavior that can be attached to a mesh
  107456. * @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)
  107457. */
  107458. constructor(options?: {
  107459. dragAxis?: Vector3;
  107460. dragPlaneNormal?: Vector3;
  107461. });
  107462. /**
  107463. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107464. */
  107465. validateDrag: (targetPosition: Vector3) => boolean;
  107466. /**
  107467. * The name of the behavior
  107468. */
  107469. readonly name: string;
  107470. /**
  107471. * Initializes the behavior
  107472. */
  107473. init(): void;
  107474. private _tmpVector;
  107475. private _alternatePickedPoint;
  107476. private _worldDragAxis;
  107477. private _targetPosition;
  107478. private _attachedElement;
  107479. /**
  107480. * Attaches the drag behavior the passed in mesh
  107481. * @param ownerNode The mesh that will be dragged around once attached
  107482. * @param predicate Predicate to use for pick filtering
  107483. */
  107484. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107485. /**
  107486. * Force relase the drag action by code.
  107487. */
  107488. releaseDrag(): void;
  107489. private _startDragRay;
  107490. private _lastPointerRay;
  107491. /**
  107492. * Simulates the start of a pointer drag event on the behavior
  107493. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  107494. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  107495. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  107496. */
  107497. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  107498. private _startDrag;
  107499. private _dragDelta;
  107500. private _moveDrag;
  107501. private _pickWithRayOnDragPlane;
  107502. private _pointA;
  107503. private _pointB;
  107504. private _pointC;
  107505. private _lineA;
  107506. private _lineB;
  107507. private _localAxis;
  107508. private _lookAt;
  107509. private _updateDragPlanePosition;
  107510. /**
  107511. * Detaches the behavior from the mesh
  107512. */
  107513. detach(): void;
  107514. }
  107515. }
  107516. declare module BABYLON {
  107517. /**
  107518. * A behavior that when attached to a mesh will allow the mesh to be scaled
  107519. */
  107520. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  107521. private _dragBehaviorA;
  107522. private _dragBehaviorB;
  107523. private _startDistance;
  107524. private _initialScale;
  107525. private _targetScale;
  107526. private _ownerNode;
  107527. private _sceneRenderObserver;
  107528. /**
  107529. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  107530. */
  107531. constructor();
  107532. /**
  107533. * The name of the behavior
  107534. */
  107535. readonly name: string;
  107536. /**
  107537. * Initializes the behavior
  107538. */
  107539. init(): void;
  107540. private _getCurrentDistance;
  107541. /**
  107542. * Attaches the scale behavior the passed in mesh
  107543. * @param ownerNode The mesh that will be scaled around once attached
  107544. */
  107545. attach(ownerNode: Mesh): void;
  107546. /**
  107547. * Detaches the behavior from the mesh
  107548. */
  107549. detach(): void;
  107550. }
  107551. }
  107552. declare module BABYLON {
  107553. /**
  107554. * 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
  107555. */
  107556. export class SixDofDragBehavior implements Behavior<Mesh> {
  107557. private static _virtualScene;
  107558. private _ownerNode;
  107559. private _sceneRenderObserver;
  107560. private _scene;
  107561. private _targetPosition;
  107562. private _virtualOriginMesh;
  107563. private _virtualDragMesh;
  107564. private _pointerObserver;
  107565. private _moving;
  107566. private _startingOrientation;
  107567. /**
  107568. * 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)
  107569. */
  107570. private zDragFactor;
  107571. /**
  107572. * If the object should rotate to face the drag origin
  107573. */
  107574. rotateDraggedObject: boolean;
  107575. /**
  107576. * If the behavior is currently in a dragging state
  107577. */
  107578. dragging: boolean;
  107579. /**
  107580. * 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)
  107581. */
  107582. dragDeltaRatio: number;
  107583. /**
  107584. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107585. */
  107586. currentDraggingPointerID: number;
  107587. /**
  107588. * If camera controls should be detached during the drag
  107589. */
  107590. detachCameraControls: boolean;
  107591. /**
  107592. * Fires each time a drag starts
  107593. */
  107594. onDragStartObservable: Observable<{}>;
  107595. /**
  107596. * Fires each time a drag ends (eg. mouse release after drag)
  107597. */
  107598. onDragEndObservable: Observable<{}>;
  107599. /**
  107600. * 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
  107601. */
  107602. constructor();
  107603. /**
  107604. * The name of the behavior
  107605. */
  107606. readonly name: string;
  107607. /**
  107608. * Initializes the behavior
  107609. */
  107610. init(): void;
  107611. /**
  107612. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  107613. */
  107614. private readonly _pointerCamera;
  107615. /**
  107616. * Attaches the scale behavior the passed in mesh
  107617. * @param ownerNode The mesh that will be scaled around once attached
  107618. */
  107619. attach(ownerNode: Mesh): void;
  107620. /**
  107621. * Detaches the behavior from the mesh
  107622. */
  107623. detach(): void;
  107624. }
  107625. }
  107626. declare module BABYLON {
  107627. /**
  107628. * Class used to apply inverse kinematics to bones
  107629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  107630. */
  107631. export class BoneIKController {
  107632. private static _tmpVecs;
  107633. private static _tmpQuat;
  107634. private static _tmpMats;
  107635. /**
  107636. * Gets or sets the target mesh
  107637. */
  107638. targetMesh: AbstractMesh;
  107639. /** Gets or sets the mesh used as pole */
  107640. poleTargetMesh: AbstractMesh;
  107641. /**
  107642. * Gets or sets the bone used as pole
  107643. */
  107644. poleTargetBone: Nullable<Bone>;
  107645. /**
  107646. * Gets or sets the target position
  107647. */
  107648. targetPosition: Vector3;
  107649. /**
  107650. * Gets or sets the pole target position
  107651. */
  107652. poleTargetPosition: Vector3;
  107653. /**
  107654. * Gets or sets the pole target local offset
  107655. */
  107656. poleTargetLocalOffset: Vector3;
  107657. /**
  107658. * Gets or sets the pole angle
  107659. */
  107660. poleAngle: number;
  107661. /**
  107662. * Gets or sets the mesh associated with the controller
  107663. */
  107664. mesh: AbstractMesh;
  107665. /**
  107666. * 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)
  107667. */
  107668. slerpAmount: number;
  107669. private _bone1Quat;
  107670. private _bone1Mat;
  107671. private _bone2Ang;
  107672. private _bone1;
  107673. private _bone2;
  107674. private _bone1Length;
  107675. private _bone2Length;
  107676. private _maxAngle;
  107677. private _maxReach;
  107678. private _rightHandedSystem;
  107679. private _bendAxis;
  107680. private _slerping;
  107681. private _adjustRoll;
  107682. /**
  107683. * Gets or sets maximum allowed angle
  107684. */
  107685. maxAngle: number;
  107686. /**
  107687. * Creates a new BoneIKController
  107688. * @param mesh defines the mesh to control
  107689. * @param bone defines the bone to control
  107690. * @param options defines options to set up the controller
  107691. */
  107692. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  107693. targetMesh?: AbstractMesh;
  107694. poleTargetMesh?: AbstractMesh;
  107695. poleTargetBone?: Bone;
  107696. poleTargetLocalOffset?: Vector3;
  107697. poleAngle?: number;
  107698. bendAxis?: Vector3;
  107699. maxAngle?: number;
  107700. slerpAmount?: number;
  107701. });
  107702. private _setMaxAngle;
  107703. /**
  107704. * Force the controller to update the bones
  107705. */
  107706. update(): void;
  107707. }
  107708. }
  107709. declare module BABYLON {
  107710. /**
  107711. * Class used to make a bone look toward a point in space
  107712. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  107713. */
  107714. export class BoneLookController {
  107715. private static _tmpVecs;
  107716. private static _tmpQuat;
  107717. private static _tmpMats;
  107718. /**
  107719. * The target Vector3 that the bone will look at
  107720. */
  107721. target: Vector3;
  107722. /**
  107723. * The mesh that the bone is attached to
  107724. */
  107725. mesh: AbstractMesh;
  107726. /**
  107727. * The bone that will be looking to the target
  107728. */
  107729. bone: Bone;
  107730. /**
  107731. * The up axis of the coordinate system that is used when the bone is rotated
  107732. */
  107733. upAxis: Vector3;
  107734. /**
  107735. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  107736. */
  107737. upAxisSpace: Space;
  107738. /**
  107739. * Used to make an adjustment to the yaw of the bone
  107740. */
  107741. adjustYaw: number;
  107742. /**
  107743. * Used to make an adjustment to the pitch of the bone
  107744. */
  107745. adjustPitch: number;
  107746. /**
  107747. * Used to make an adjustment to the roll of the bone
  107748. */
  107749. adjustRoll: number;
  107750. /**
  107751. * 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)
  107752. */
  107753. slerpAmount: number;
  107754. private _minYaw;
  107755. private _maxYaw;
  107756. private _minPitch;
  107757. private _maxPitch;
  107758. private _minYawSin;
  107759. private _minYawCos;
  107760. private _maxYawSin;
  107761. private _maxYawCos;
  107762. private _midYawConstraint;
  107763. private _minPitchTan;
  107764. private _maxPitchTan;
  107765. private _boneQuat;
  107766. private _slerping;
  107767. private _transformYawPitch;
  107768. private _transformYawPitchInv;
  107769. private _firstFrameSkipped;
  107770. private _yawRange;
  107771. private _fowardAxis;
  107772. /**
  107773. * Gets or sets the minimum yaw angle that the bone can look to
  107774. */
  107775. minYaw: number;
  107776. /**
  107777. * Gets or sets the maximum yaw angle that the bone can look to
  107778. */
  107779. maxYaw: number;
  107780. /**
  107781. * Gets or sets the minimum pitch angle that the bone can look to
  107782. */
  107783. minPitch: number;
  107784. /**
  107785. * Gets or sets the maximum pitch angle that the bone can look to
  107786. */
  107787. maxPitch: number;
  107788. /**
  107789. * Create a BoneLookController
  107790. * @param mesh the mesh that the bone belongs to
  107791. * @param bone the bone that will be looking to the target
  107792. * @param target the target Vector3 to look at
  107793. * @param options optional settings:
  107794. * * maxYaw: the maximum angle the bone will yaw to
  107795. * * minYaw: the minimum angle the bone will yaw to
  107796. * * maxPitch: the maximum angle the bone will pitch to
  107797. * * minPitch: the minimum angle the bone will yaw to
  107798. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  107799. * * upAxis: the up axis of the coordinate system
  107800. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  107801. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  107802. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  107803. * * adjustYaw: used to make an adjustment to the yaw of the bone
  107804. * * adjustPitch: used to make an adjustment to the pitch of the bone
  107805. * * adjustRoll: used to make an adjustment to the roll of the bone
  107806. **/
  107807. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  107808. maxYaw?: number;
  107809. minYaw?: number;
  107810. maxPitch?: number;
  107811. minPitch?: number;
  107812. slerpAmount?: number;
  107813. upAxis?: Vector3;
  107814. upAxisSpace?: Space;
  107815. yawAxis?: Vector3;
  107816. pitchAxis?: Vector3;
  107817. adjustYaw?: number;
  107818. adjustPitch?: number;
  107819. adjustRoll?: number;
  107820. });
  107821. /**
  107822. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  107823. */
  107824. update(): void;
  107825. private _getAngleDiff;
  107826. private _getAngleBetween;
  107827. private _isAngleBetween;
  107828. }
  107829. }
  107830. declare module BABYLON {
  107831. /**
  107832. * Manage the gamepad inputs to control an arc rotate camera.
  107833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107834. */
  107835. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  107836. /**
  107837. * Defines the camera the input is attached to.
  107838. */
  107839. camera: ArcRotateCamera;
  107840. /**
  107841. * Defines the gamepad the input is gathering event from.
  107842. */
  107843. gamepad: Nullable<Gamepad>;
  107844. /**
  107845. * Defines the gamepad rotation sensiblity.
  107846. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107847. */
  107848. gamepadRotationSensibility: number;
  107849. /**
  107850. * Defines the gamepad move sensiblity.
  107851. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107852. */
  107853. gamepadMoveSensibility: number;
  107854. private _yAxisScale;
  107855. /**
  107856. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107857. */
  107858. invertYAxis: boolean;
  107859. private _onGamepadConnectedObserver;
  107860. private _onGamepadDisconnectedObserver;
  107861. /**
  107862. * Attach the input controls to a specific dom element to get the input from.
  107863. * @param element Defines the element the controls should be listened from
  107864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107865. */
  107866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107867. /**
  107868. * Detach the current controls from the specified dom element.
  107869. * @param element Defines the element to stop listening the inputs from
  107870. */
  107871. detachControl(element: Nullable<HTMLElement>): void;
  107872. /**
  107873. * Update the current camera state depending on the inputs that have been used this frame.
  107874. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107875. */
  107876. checkInputs(): void;
  107877. /**
  107878. * Gets the class name of the current intput.
  107879. * @returns the class name
  107880. */
  107881. getClassName(): string;
  107882. /**
  107883. * Get the friendly name associated with the input class.
  107884. * @returns the input friendly name
  107885. */
  107886. getSimpleName(): string;
  107887. }
  107888. }
  107889. declare module BABYLON {
  107890. interface ArcRotateCameraInputsManager {
  107891. /**
  107892. * Add orientation input support to the input manager.
  107893. * @returns the current input manager
  107894. */
  107895. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  107896. }
  107897. /**
  107898. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  107899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107900. */
  107901. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  107902. /**
  107903. * Defines the camera the input is attached to.
  107904. */
  107905. camera: ArcRotateCamera;
  107906. /**
  107907. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  107908. */
  107909. alphaCorrection: number;
  107910. /**
  107911. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  107912. */
  107913. gammaCorrection: number;
  107914. private _alpha;
  107915. private _gamma;
  107916. private _dirty;
  107917. private _deviceOrientationHandler;
  107918. /**
  107919. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  107920. */
  107921. constructor();
  107922. /**
  107923. * Attach the input controls to a specific dom element to get the input from.
  107924. * @param element Defines the element the controls should be listened from
  107925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107926. */
  107927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107928. /** @hidden */
  107929. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  107930. /**
  107931. * Update the current camera state depending on the inputs that have been used this frame.
  107932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107933. */
  107934. checkInputs(): void;
  107935. /**
  107936. * Detach the current controls from the specified dom element.
  107937. * @param element Defines the element to stop listening the inputs from
  107938. */
  107939. detachControl(element: Nullable<HTMLElement>): void;
  107940. /**
  107941. * Gets the class name of the current intput.
  107942. * @returns the class name
  107943. */
  107944. getClassName(): string;
  107945. /**
  107946. * Get the friendly name associated with the input class.
  107947. * @returns the input friendly name
  107948. */
  107949. getSimpleName(): string;
  107950. }
  107951. }
  107952. declare module BABYLON {
  107953. /**
  107954. * Listen to mouse events to control the camera.
  107955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107956. */
  107957. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  107958. /**
  107959. * Defines the camera the input is attached to.
  107960. */
  107961. camera: FlyCamera;
  107962. /**
  107963. * Defines if touch is enabled. (Default is true.)
  107964. */
  107965. touchEnabled: boolean;
  107966. /**
  107967. * Defines the buttons associated with the input to handle camera rotation.
  107968. */
  107969. buttons: number[];
  107970. /**
  107971. * Assign buttons for Yaw control.
  107972. */
  107973. buttonsYaw: number[];
  107974. /**
  107975. * Assign buttons for Pitch control.
  107976. */
  107977. buttonsPitch: number[];
  107978. /**
  107979. * Assign buttons for Roll control.
  107980. */
  107981. buttonsRoll: number[];
  107982. /**
  107983. * Detect if any button is being pressed while mouse is moved.
  107984. * -1 = Mouse locked.
  107985. * 0 = Left button.
  107986. * 1 = Middle Button.
  107987. * 2 = Right Button.
  107988. */
  107989. activeButton: number;
  107990. /**
  107991. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  107992. * Higher values reduce its sensitivity.
  107993. */
  107994. angularSensibility: number;
  107995. private _mousemoveCallback;
  107996. private _observer;
  107997. private _rollObserver;
  107998. private previousPosition;
  107999. private noPreventDefault;
  108000. private element;
  108001. /**
  108002. * Listen to mouse events to control the camera.
  108003. * @param touchEnabled Define if touch is enabled. (Default is true.)
  108004. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108005. */
  108006. constructor(touchEnabled?: boolean);
  108007. /**
  108008. * Attach the mouse control to the HTML DOM element.
  108009. * @param element Defines the element that listens to the input events.
  108010. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  108011. */
  108012. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108013. /**
  108014. * Detach the current controls from the specified dom element.
  108015. * @param element Defines the element to stop listening the inputs from
  108016. */
  108017. detachControl(element: Nullable<HTMLElement>): void;
  108018. /**
  108019. * Gets the class name of the current input.
  108020. * @returns the class name.
  108021. */
  108022. getClassName(): string;
  108023. /**
  108024. * Get the friendly name associated with the input class.
  108025. * @returns the input's friendly name.
  108026. */
  108027. getSimpleName(): string;
  108028. private _pointerInput;
  108029. private _onMouseMove;
  108030. /**
  108031. * Rotate camera by mouse offset.
  108032. */
  108033. private rotateCamera;
  108034. }
  108035. }
  108036. declare module BABYLON {
  108037. /**
  108038. * Default Inputs manager for the FlyCamera.
  108039. * It groups all the default supported inputs for ease of use.
  108040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108041. */
  108042. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108043. /**
  108044. * Instantiates a new FlyCameraInputsManager.
  108045. * @param camera Defines the camera the inputs belong to.
  108046. */
  108047. constructor(camera: FlyCamera);
  108048. /**
  108049. * Add keyboard input support to the input manager.
  108050. * @returns the new FlyCameraKeyboardMoveInput().
  108051. */
  108052. addKeyboard(): FlyCameraInputsManager;
  108053. /**
  108054. * Add mouse input support to the input manager.
  108055. * @param touchEnabled Enable touch screen support.
  108056. * @returns the new FlyCameraMouseInput().
  108057. */
  108058. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108059. }
  108060. }
  108061. declare module BABYLON {
  108062. /**
  108063. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108064. * such as in a 3D Space Shooter or a Flight Simulator.
  108065. */
  108066. export class FlyCamera extends TargetCamera {
  108067. /**
  108068. * Define the collision ellipsoid of the camera.
  108069. * This is helpful for simulating a camera body, like a player's body.
  108070. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108071. */
  108072. ellipsoid: Vector3;
  108073. /**
  108074. * Define an offset for the position of the ellipsoid around the camera.
  108075. * This can be helpful if the camera is attached away from the player's body center,
  108076. * such as at its head.
  108077. */
  108078. ellipsoidOffset: Vector3;
  108079. /**
  108080. * Enable or disable collisions of the camera with the rest of the scene objects.
  108081. */
  108082. checkCollisions: boolean;
  108083. /**
  108084. * Enable or disable gravity on the camera.
  108085. */
  108086. applyGravity: boolean;
  108087. /**
  108088. * Define the current direction the camera is moving to.
  108089. */
  108090. cameraDirection: Vector3;
  108091. /**
  108092. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108093. * This overrides and empties cameraRotation.
  108094. */
  108095. rotationQuaternion: Quaternion;
  108096. /**
  108097. * Track Roll to maintain the wanted Rolling when looking around.
  108098. */
  108099. _trackRoll: number;
  108100. /**
  108101. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108102. */
  108103. rollCorrect: number;
  108104. /**
  108105. * Mimic a banked turn, Rolling the camera when Yawing.
  108106. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108107. */
  108108. bankedTurn: boolean;
  108109. /**
  108110. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108111. */
  108112. bankedTurnLimit: number;
  108113. /**
  108114. * Value of 0 disables the banked Roll.
  108115. * Value of 1 is equal to the Yaw angle in radians.
  108116. */
  108117. bankedTurnMultiplier: number;
  108118. /**
  108119. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108120. */
  108121. inputs: FlyCameraInputsManager;
  108122. /**
  108123. * Gets the input sensibility for mouse input.
  108124. * Higher values reduce sensitivity.
  108125. */
  108126. /**
  108127. * Sets the input sensibility for a mouse input.
  108128. * Higher values reduce sensitivity.
  108129. */
  108130. angularSensibility: number;
  108131. /**
  108132. * Get the keys for camera movement forward.
  108133. */
  108134. /**
  108135. * Set the keys for camera movement forward.
  108136. */
  108137. keysForward: number[];
  108138. /**
  108139. * Get the keys for camera movement backward.
  108140. */
  108141. keysBackward: number[];
  108142. /**
  108143. * Get the keys for camera movement up.
  108144. */
  108145. /**
  108146. * Set the keys for camera movement up.
  108147. */
  108148. keysUp: number[];
  108149. /**
  108150. * Get the keys for camera movement down.
  108151. */
  108152. /**
  108153. * Set the keys for camera movement down.
  108154. */
  108155. keysDown: number[];
  108156. /**
  108157. * Get the keys for camera movement left.
  108158. */
  108159. /**
  108160. * Set the keys for camera movement left.
  108161. */
  108162. keysLeft: number[];
  108163. /**
  108164. * Set the keys for camera movement right.
  108165. */
  108166. /**
  108167. * Set the keys for camera movement right.
  108168. */
  108169. keysRight: number[];
  108170. /**
  108171. * Event raised when the camera collides with a mesh in the scene.
  108172. */
  108173. onCollide: (collidedMesh: AbstractMesh) => void;
  108174. private _collider;
  108175. private _needMoveForGravity;
  108176. private _oldPosition;
  108177. private _diffPosition;
  108178. private _newPosition;
  108179. /** @hidden */
  108180. _localDirection: Vector3;
  108181. /** @hidden */
  108182. _transformedDirection: Vector3;
  108183. /**
  108184. * Instantiates a FlyCamera.
  108185. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108186. * such as in a 3D Space Shooter or a Flight Simulator.
  108187. * @param name Define the name of the camera in the scene.
  108188. * @param position Define the starting position of the camera in the scene.
  108189. * @param scene Define the scene the camera belongs to.
  108190. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108191. */
  108192. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108193. /**
  108194. * Attach a control to the HTML DOM element.
  108195. * @param element Defines the element that listens to the input events.
  108196. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108197. */
  108198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108199. /**
  108200. * Detach a control from the HTML DOM element.
  108201. * The camera will stop reacting to that input.
  108202. * @param element Defines the element that listens to the input events.
  108203. */
  108204. detachControl(element: HTMLElement): void;
  108205. private _collisionMask;
  108206. /**
  108207. * Get the mask that the camera ignores in collision events.
  108208. */
  108209. /**
  108210. * Set the mask that the camera ignores in collision events.
  108211. */
  108212. collisionMask: number;
  108213. /** @hidden */
  108214. _collideWithWorld(displacement: Vector3): void;
  108215. /** @hidden */
  108216. private _onCollisionPositionChange;
  108217. /** @hidden */
  108218. _checkInputs(): void;
  108219. /** @hidden */
  108220. _decideIfNeedsToMove(): boolean;
  108221. /** @hidden */
  108222. _updatePosition(): void;
  108223. /**
  108224. * Restore the Roll to its target value at the rate specified.
  108225. * @param rate - Higher means slower restoring.
  108226. * @hidden
  108227. */
  108228. restoreRoll(rate: number): void;
  108229. /**
  108230. * Destroy the camera and release the current resources held by it.
  108231. */
  108232. dispose(): void;
  108233. /**
  108234. * Get the current object class name.
  108235. * @returns the class name.
  108236. */
  108237. getClassName(): string;
  108238. }
  108239. }
  108240. declare module BABYLON {
  108241. /**
  108242. * Listen to keyboard events to control the camera.
  108243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108244. */
  108245. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108246. /**
  108247. * Defines the camera the input is attached to.
  108248. */
  108249. camera: FlyCamera;
  108250. /**
  108251. * The list of keyboard keys used to control the forward move of the camera.
  108252. */
  108253. keysForward: number[];
  108254. /**
  108255. * The list of keyboard keys used to control the backward move of the camera.
  108256. */
  108257. keysBackward: number[];
  108258. /**
  108259. * The list of keyboard keys used to control the forward move of the camera.
  108260. */
  108261. keysUp: number[];
  108262. /**
  108263. * The list of keyboard keys used to control the backward move of the camera.
  108264. */
  108265. keysDown: number[];
  108266. /**
  108267. * The list of keyboard keys used to control the right strafe move of the camera.
  108268. */
  108269. keysRight: number[];
  108270. /**
  108271. * The list of keyboard keys used to control the left strafe move of the camera.
  108272. */
  108273. keysLeft: number[];
  108274. private _keys;
  108275. private _onCanvasBlurObserver;
  108276. private _onKeyboardObserver;
  108277. private _engine;
  108278. private _scene;
  108279. /**
  108280. * Attach the input controls to a specific dom element to get the input from.
  108281. * @param element Defines the element the controls should be listened from
  108282. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108283. */
  108284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108285. /**
  108286. * Detach the current controls from the specified dom element.
  108287. * @param element Defines the element to stop listening the inputs from
  108288. */
  108289. detachControl(element: Nullable<HTMLElement>): void;
  108290. /**
  108291. * Gets the class name of the current intput.
  108292. * @returns the class name
  108293. */
  108294. getClassName(): string;
  108295. /** @hidden */
  108296. _onLostFocus(e: FocusEvent): void;
  108297. /**
  108298. * Get the friendly name associated with the input class.
  108299. * @returns the input friendly name
  108300. */
  108301. getSimpleName(): string;
  108302. /**
  108303. * Update the current camera state depending on the inputs that have been used this frame.
  108304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108305. */
  108306. checkInputs(): void;
  108307. }
  108308. }
  108309. declare module BABYLON {
  108310. /**
  108311. * Manage the mouse wheel inputs to control a follow camera.
  108312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108313. */
  108314. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108315. /**
  108316. * Defines the camera the input is attached to.
  108317. */
  108318. camera: FollowCamera;
  108319. /**
  108320. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108321. */
  108322. axisControlRadius: boolean;
  108323. /**
  108324. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108325. */
  108326. axisControlHeight: boolean;
  108327. /**
  108328. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108329. */
  108330. axisControlRotation: boolean;
  108331. /**
  108332. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108333. * relation to mouseWheel events.
  108334. */
  108335. wheelPrecision: number;
  108336. /**
  108337. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108338. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108339. */
  108340. wheelDeltaPercentage: number;
  108341. private _wheel;
  108342. private _observer;
  108343. /**
  108344. * Attach the input controls to a specific dom element to get the input from.
  108345. * @param element Defines the element the controls should be listened from
  108346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108347. */
  108348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108349. /**
  108350. * Detach the current controls from the specified dom element.
  108351. * @param element Defines the element to stop listening the inputs from
  108352. */
  108353. detachControl(element: Nullable<HTMLElement>): void;
  108354. /**
  108355. * Gets the class name of the current intput.
  108356. * @returns the class name
  108357. */
  108358. getClassName(): string;
  108359. /**
  108360. * Get the friendly name associated with the input class.
  108361. * @returns the input friendly name
  108362. */
  108363. getSimpleName(): string;
  108364. }
  108365. }
  108366. declare module BABYLON {
  108367. /**
  108368. * Manage the pointers inputs to control an follow camera.
  108369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108370. */
  108371. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108372. /**
  108373. * Defines the camera the input is attached to.
  108374. */
  108375. camera: FollowCamera;
  108376. /**
  108377. * Gets the class name of the current input.
  108378. * @returns the class name
  108379. */
  108380. getClassName(): string;
  108381. /**
  108382. * Defines the pointer angular sensibility along the X axis or how fast is
  108383. * the camera rotating.
  108384. * A negative number will reverse the axis direction.
  108385. */
  108386. angularSensibilityX: number;
  108387. /**
  108388. * Defines the pointer angular sensibility along the Y axis or how fast is
  108389. * the camera rotating.
  108390. * A negative number will reverse the axis direction.
  108391. */
  108392. angularSensibilityY: number;
  108393. /**
  108394. * Defines the pointer pinch precision or how fast is the camera zooming.
  108395. * A negative number will reverse the axis direction.
  108396. */
  108397. pinchPrecision: number;
  108398. /**
  108399. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108400. * from 0.
  108401. * It defines the percentage of current camera.radius to use as delta when
  108402. * pinch zoom is used.
  108403. */
  108404. pinchDeltaPercentage: number;
  108405. /**
  108406. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108407. */
  108408. axisXControlRadius: boolean;
  108409. /**
  108410. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108411. */
  108412. axisXControlHeight: boolean;
  108413. /**
  108414. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108415. */
  108416. axisXControlRotation: boolean;
  108417. /**
  108418. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108419. */
  108420. axisYControlRadius: boolean;
  108421. /**
  108422. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108423. */
  108424. axisYControlHeight: boolean;
  108425. /**
  108426. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108427. */
  108428. axisYControlRotation: boolean;
  108429. /**
  108430. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108431. */
  108432. axisPinchControlRadius: boolean;
  108433. /**
  108434. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108435. */
  108436. axisPinchControlHeight: boolean;
  108437. /**
  108438. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108439. */
  108440. axisPinchControlRotation: boolean;
  108441. /**
  108442. * Log error messages if basic misconfiguration has occurred.
  108443. */
  108444. warningEnable: boolean;
  108445. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108446. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108447. private _warningCounter;
  108448. private _warning;
  108449. }
  108450. }
  108451. declare module BABYLON {
  108452. /**
  108453. * Default Inputs manager for the FollowCamera.
  108454. * It groups all the default supported inputs for ease of use.
  108455. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108456. */
  108457. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108458. /**
  108459. * Instantiates a new FollowCameraInputsManager.
  108460. * @param camera Defines the camera the inputs belong to
  108461. */
  108462. constructor(camera: FollowCamera);
  108463. /**
  108464. * Add keyboard input support to the input manager.
  108465. * @returns the current input manager
  108466. */
  108467. addKeyboard(): FollowCameraInputsManager;
  108468. /**
  108469. * Add mouse wheel input support to the input manager.
  108470. * @returns the current input manager
  108471. */
  108472. addMouseWheel(): FollowCameraInputsManager;
  108473. /**
  108474. * Add pointers input support to the input manager.
  108475. * @returns the current input manager
  108476. */
  108477. addPointers(): FollowCameraInputsManager;
  108478. /**
  108479. * Add orientation input support to the input manager.
  108480. * @returns the current input manager
  108481. */
  108482. addVRDeviceOrientation(): FollowCameraInputsManager;
  108483. }
  108484. }
  108485. declare module BABYLON {
  108486. /**
  108487. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108488. * an arc rotate version arcFollowCamera are available.
  108489. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108490. */
  108491. export class FollowCamera extends TargetCamera {
  108492. /**
  108493. * Distance the follow camera should follow an object at
  108494. */
  108495. radius: number;
  108496. /**
  108497. * Minimum allowed distance of the camera to the axis of rotation
  108498. * (The camera can not get closer).
  108499. * This can help limiting how the Camera is able to move in the scene.
  108500. */
  108501. lowerRadiusLimit: Nullable<number>;
  108502. /**
  108503. * Maximum allowed distance of the camera to the axis of rotation
  108504. * (The camera can not get further).
  108505. * This can help limiting how the Camera is able to move in the scene.
  108506. */
  108507. upperRadiusLimit: Nullable<number>;
  108508. /**
  108509. * Define a rotation offset between the camera and the object it follows
  108510. */
  108511. rotationOffset: number;
  108512. /**
  108513. * Minimum allowed angle to camera position relative to target object.
  108514. * This can help limiting how the Camera is able to move in the scene.
  108515. */
  108516. lowerRotationOffsetLimit: Nullable<number>;
  108517. /**
  108518. * Maximum allowed angle to camera position relative to target object.
  108519. * This can help limiting how the Camera is able to move in the scene.
  108520. */
  108521. upperRotationOffsetLimit: Nullable<number>;
  108522. /**
  108523. * Define a height offset between the camera and the object it follows.
  108524. * It can help following an object from the top (like a car chaing a plane)
  108525. */
  108526. heightOffset: number;
  108527. /**
  108528. * Minimum allowed height of camera position relative to target object.
  108529. * This can help limiting how the Camera is able to move in the scene.
  108530. */
  108531. lowerHeightOffsetLimit: Nullable<number>;
  108532. /**
  108533. * Maximum allowed height of camera position relative to target object.
  108534. * This can help limiting how the Camera is able to move in the scene.
  108535. */
  108536. upperHeightOffsetLimit: Nullable<number>;
  108537. /**
  108538. * Define how fast the camera can accelerate to follow it s target.
  108539. */
  108540. cameraAcceleration: number;
  108541. /**
  108542. * Define the speed limit of the camera following an object.
  108543. */
  108544. maxCameraSpeed: number;
  108545. /**
  108546. * Define the target of the camera.
  108547. */
  108548. lockedTarget: Nullable<AbstractMesh>;
  108549. /**
  108550. * Defines the input associated with the camera.
  108551. */
  108552. inputs: FollowCameraInputsManager;
  108553. /**
  108554. * Instantiates the follow camera.
  108555. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108556. * @param name Define the name of the camera in the scene
  108557. * @param position Define the position of the camera
  108558. * @param scene Define the scene the camera belong to
  108559. * @param lockedTarget Define the target of the camera
  108560. */
  108561. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  108562. private _follow;
  108563. /**
  108564. * Attached controls to the current camera.
  108565. * @param element Defines the element the controls should be listened from
  108566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108567. */
  108568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108569. /**
  108570. * Detach the current controls from the camera.
  108571. * The camera will stop reacting to inputs.
  108572. * @param element Defines the element to stop listening the inputs from
  108573. */
  108574. detachControl(element: HTMLElement): void;
  108575. /** @hidden */
  108576. _checkInputs(): void;
  108577. private _checkLimits;
  108578. /**
  108579. * Gets the camera class name.
  108580. * @returns the class name
  108581. */
  108582. getClassName(): string;
  108583. }
  108584. /**
  108585. * Arc Rotate version of the follow camera.
  108586. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  108587. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108588. */
  108589. export class ArcFollowCamera extends TargetCamera {
  108590. /** The longitudinal angle of the camera */
  108591. alpha: number;
  108592. /** The latitudinal angle of the camera */
  108593. beta: number;
  108594. /** The radius of the camera from its target */
  108595. radius: number;
  108596. /** Define the camera target (the messh it should follow) */
  108597. target: Nullable<AbstractMesh>;
  108598. private _cartesianCoordinates;
  108599. /**
  108600. * Instantiates a new ArcFollowCamera
  108601. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108602. * @param name Define the name of the camera
  108603. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  108604. * @param beta Define the rotation angle of the camera around the elevation axis
  108605. * @param radius Define the radius of the camera from its target point
  108606. * @param target Define the target of the camera
  108607. * @param scene Define the scene the camera belongs to
  108608. */
  108609. constructor(name: string,
  108610. /** The longitudinal angle of the camera */
  108611. alpha: number,
  108612. /** The latitudinal angle of the camera */
  108613. beta: number,
  108614. /** The radius of the camera from its target */
  108615. radius: number,
  108616. /** Define the camera target (the messh it should follow) */
  108617. target: Nullable<AbstractMesh>, scene: Scene);
  108618. private _follow;
  108619. /** @hidden */
  108620. _checkInputs(): void;
  108621. /**
  108622. * Returns the class name of the object.
  108623. * It is mostly used internally for serialization purposes.
  108624. */
  108625. getClassName(): string;
  108626. }
  108627. }
  108628. declare module BABYLON {
  108629. /**
  108630. * Manage the keyboard inputs to control the movement of a follow camera.
  108631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108632. */
  108633. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  108634. /**
  108635. * Defines the camera the input is attached to.
  108636. */
  108637. camera: FollowCamera;
  108638. /**
  108639. * Defines the list of key codes associated with the up action (increase heightOffset)
  108640. */
  108641. keysHeightOffsetIncr: number[];
  108642. /**
  108643. * Defines the list of key codes associated with the down action (decrease heightOffset)
  108644. */
  108645. keysHeightOffsetDecr: number[];
  108646. /**
  108647. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  108648. */
  108649. keysHeightOffsetModifierAlt: boolean;
  108650. /**
  108651. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  108652. */
  108653. keysHeightOffsetModifierCtrl: boolean;
  108654. /**
  108655. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  108656. */
  108657. keysHeightOffsetModifierShift: boolean;
  108658. /**
  108659. * Defines the list of key codes associated with the left action (increase rotationOffset)
  108660. */
  108661. keysRotationOffsetIncr: number[];
  108662. /**
  108663. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  108664. */
  108665. keysRotationOffsetDecr: number[];
  108666. /**
  108667. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  108668. */
  108669. keysRotationOffsetModifierAlt: boolean;
  108670. /**
  108671. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  108672. */
  108673. keysRotationOffsetModifierCtrl: boolean;
  108674. /**
  108675. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  108676. */
  108677. keysRotationOffsetModifierShift: boolean;
  108678. /**
  108679. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  108680. */
  108681. keysRadiusIncr: number[];
  108682. /**
  108683. * Defines the list of key codes associated with the zoom-out action (increase radius)
  108684. */
  108685. keysRadiusDecr: number[];
  108686. /**
  108687. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  108688. */
  108689. keysRadiusModifierAlt: boolean;
  108690. /**
  108691. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  108692. */
  108693. keysRadiusModifierCtrl: boolean;
  108694. /**
  108695. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  108696. */
  108697. keysRadiusModifierShift: boolean;
  108698. /**
  108699. * Defines the rate of change of heightOffset.
  108700. */
  108701. heightSensibility: number;
  108702. /**
  108703. * Defines the rate of change of rotationOffset.
  108704. */
  108705. rotationSensibility: number;
  108706. /**
  108707. * Defines the rate of change of radius.
  108708. */
  108709. radiusSensibility: number;
  108710. private _keys;
  108711. private _ctrlPressed;
  108712. private _altPressed;
  108713. private _shiftPressed;
  108714. private _onCanvasBlurObserver;
  108715. private _onKeyboardObserver;
  108716. private _engine;
  108717. private _scene;
  108718. /**
  108719. * Attach the input controls to a specific dom element to get the input from.
  108720. * @param element Defines the element the controls should be listened from
  108721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108722. */
  108723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108724. /**
  108725. * Detach the current controls from the specified dom element.
  108726. * @param element Defines the element to stop listening the inputs from
  108727. */
  108728. detachControl(element: Nullable<HTMLElement>): void;
  108729. /**
  108730. * Update the current camera state depending on the inputs that have been used this frame.
  108731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108732. */
  108733. checkInputs(): void;
  108734. /**
  108735. * Gets the class name of the current input.
  108736. * @returns the class name
  108737. */
  108738. getClassName(): string;
  108739. /**
  108740. * Get the friendly name associated with the input class.
  108741. * @returns the input friendly name
  108742. */
  108743. getSimpleName(): string;
  108744. /**
  108745. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108746. * allow modification of the heightOffset value.
  108747. */
  108748. private _modifierHeightOffset;
  108749. /**
  108750. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108751. * allow modification of the rotationOffset value.
  108752. */
  108753. private _modifierRotationOffset;
  108754. /**
  108755. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108756. * allow modification of the radius value.
  108757. */
  108758. private _modifierRadius;
  108759. }
  108760. }
  108761. declare module BABYLON {
  108762. interface FreeCameraInputsManager {
  108763. /**
  108764. * @hidden
  108765. */
  108766. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  108767. /**
  108768. * Add orientation input support to the input manager.
  108769. * @returns the current input manager
  108770. */
  108771. addDeviceOrientation(): FreeCameraInputsManager;
  108772. }
  108773. /**
  108774. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  108775. * Screen rotation is taken into account.
  108776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108777. */
  108778. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  108779. private _camera;
  108780. private _screenOrientationAngle;
  108781. private _constantTranform;
  108782. private _screenQuaternion;
  108783. private _alpha;
  108784. private _beta;
  108785. private _gamma;
  108786. /**
  108787. * Can be used to detect if a device orientation sensor is availible on a device
  108788. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  108789. * @returns a promise that will resolve on orientation change
  108790. */
  108791. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  108792. /**
  108793. * @hidden
  108794. */
  108795. _onDeviceOrientationChangedObservable: Observable<void>;
  108796. /**
  108797. * Instantiates a new input
  108798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108799. */
  108800. constructor();
  108801. /**
  108802. * Define the camera controlled by the input.
  108803. */
  108804. camera: FreeCamera;
  108805. /**
  108806. * Attach the input controls to a specific dom element to get the input from.
  108807. * @param element Defines the element the controls should be listened from
  108808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108809. */
  108810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108811. private _orientationChanged;
  108812. private _deviceOrientation;
  108813. /**
  108814. * Detach the current controls from the specified dom element.
  108815. * @param element Defines the element to stop listening the inputs from
  108816. */
  108817. detachControl(element: Nullable<HTMLElement>): void;
  108818. /**
  108819. * Update the current camera state depending on the inputs that have been used this frame.
  108820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108821. */
  108822. checkInputs(): void;
  108823. /**
  108824. * Gets the class name of the current intput.
  108825. * @returns the class name
  108826. */
  108827. getClassName(): string;
  108828. /**
  108829. * Get the friendly name associated with the input class.
  108830. * @returns the input friendly name
  108831. */
  108832. getSimpleName(): string;
  108833. }
  108834. }
  108835. declare module BABYLON {
  108836. /**
  108837. * Manage the gamepad inputs to control a free camera.
  108838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108839. */
  108840. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  108841. /**
  108842. * Define the camera the input is attached to.
  108843. */
  108844. camera: FreeCamera;
  108845. /**
  108846. * Define the Gamepad controlling the input
  108847. */
  108848. gamepad: Nullable<Gamepad>;
  108849. /**
  108850. * Defines the gamepad rotation sensiblity.
  108851. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108852. */
  108853. gamepadAngularSensibility: number;
  108854. /**
  108855. * Defines the gamepad move sensiblity.
  108856. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108857. */
  108858. gamepadMoveSensibility: number;
  108859. private _yAxisScale;
  108860. /**
  108861. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108862. */
  108863. invertYAxis: boolean;
  108864. private _onGamepadConnectedObserver;
  108865. private _onGamepadDisconnectedObserver;
  108866. private _cameraTransform;
  108867. private _deltaTransform;
  108868. private _vector3;
  108869. private _vector2;
  108870. /**
  108871. * Attach the input controls to a specific dom element to get the input from.
  108872. * @param element Defines the element the controls should be listened from
  108873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108874. */
  108875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108876. /**
  108877. * Detach the current controls from the specified dom element.
  108878. * @param element Defines the element to stop listening the inputs from
  108879. */
  108880. detachControl(element: Nullable<HTMLElement>): void;
  108881. /**
  108882. * Update the current camera state depending on the inputs that have been used this frame.
  108883. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108884. */
  108885. checkInputs(): void;
  108886. /**
  108887. * Gets the class name of the current intput.
  108888. * @returns the class name
  108889. */
  108890. getClassName(): string;
  108891. /**
  108892. * Get the friendly name associated with the input class.
  108893. * @returns the input friendly name
  108894. */
  108895. getSimpleName(): string;
  108896. }
  108897. }
  108898. declare module BABYLON {
  108899. /**
  108900. * Defines the potential axis of a Joystick
  108901. */
  108902. export enum JoystickAxis {
  108903. /** X axis */
  108904. X = 0,
  108905. /** Y axis */
  108906. Y = 1,
  108907. /** Z axis */
  108908. Z = 2
  108909. }
  108910. /**
  108911. * Class used to define virtual joystick (used in touch mode)
  108912. */
  108913. export class VirtualJoystick {
  108914. /**
  108915. * Gets or sets a boolean indicating that left and right values must be inverted
  108916. */
  108917. reverseLeftRight: boolean;
  108918. /**
  108919. * Gets or sets a boolean indicating that up and down values must be inverted
  108920. */
  108921. reverseUpDown: boolean;
  108922. /**
  108923. * Gets the offset value for the position (ie. the change of the position value)
  108924. */
  108925. deltaPosition: Vector3;
  108926. /**
  108927. * Gets a boolean indicating if the virtual joystick was pressed
  108928. */
  108929. pressed: boolean;
  108930. /**
  108931. * Canvas the virtual joystick will render onto, default z-index of this is 5
  108932. */
  108933. static Canvas: Nullable<HTMLCanvasElement>;
  108934. private static _globalJoystickIndex;
  108935. private static vjCanvasContext;
  108936. private static vjCanvasWidth;
  108937. private static vjCanvasHeight;
  108938. private static halfWidth;
  108939. private _action;
  108940. private _axisTargetedByLeftAndRight;
  108941. private _axisTargetedByUpAndDown;
  108942. private _joystickSensibility;
  108943. private _inversedSensibility;
  108944. private _joystickPointerID;
  108945. private _joystickColor;
  108946. private _joystickPointerPos;
  108947. private _joystickPreviousPointerPos;
  108948. private _joystickPointerStartPos;
  108949. private _deltaJoystickVector;
  108950. private _leftJoystick;
  108951. private _touches;
  108952. private _onPointerDownHandlerRef;
  108953. private _onPointerMoveHandlerRef;
  108954. private _onPointerUpHandlerRef;
  108955. private _onResize;
  108956. /**
  108957. * Creates a new virtual joystick
  108958. * @param leftJoystick defines that the joystick is for left hand (false by default)
  108959. */
  108960. constructor(leftJoystick?: boolean);
  108961. /**
  108962. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  108963. * @param newJoystickSensibility defines the new sensibility
  108964. */
  108965. setJoystickSensibility(newJoystickSensibility: number): void;
  108966. private _onPointerDown;
  108967. private _onPointerMove;
  108968. private _onPointerUp;
  108969. /**
  108970. * Change the color of the virtual joystick
  108971. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  108972. */
  108973. setJoystickColor(newColor: string): void;
  108974. /**
  108975. * Defines a callback to call when the joystick is touched
  108976. * @param action defines the callback
  108977. */
  108978. setActionOnTouch(action: () => any): void;
  108979. /**
  108980. * Defines which axis you'd like to control for left & right
  108981. * @param axis defines the axis to use
  108982. */
  108983. setAxisForLeftRight(axis: JoystickAxis): void;
  108984. /**
  108985. * Defines which axis you'd like to control for up & down
  108986. * @param axis defines the axis to use
  108987. */
  108988. setAxisForUpDown(axis: JoystickAxis): void;
  108989. private _drawVirtualJoystick;
  108990. /**
  108991. * Release internal HTML canvas
  108992. */
  108993. releaseCanvas(): void;
  108994. }
  108995. }
  108996. declare module BABYLON {
  108997. interface FreeCameraInputsManager {
  108998. /**
  108999. * Add virtual joystick input support to the input manager.
  109000. * @returns the current input manager
  109001. */
  109002. addVirtualJoystick(): FreeCameraInputsManager;
  109003. }
  109004. /**
  109005. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  109006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109007. */
  109008. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  109009. /**
  109010. * Defines the camera the input is attached to.
  109011. */
  109012. camera: FreeCamera;
  109013. private _leftjoystick;
  109014. private _rightjoystick;
  109015. /**
  109016. * Gets the left stick of the virtual joystick.
  109017. * @returns The virtual Joystick
  109018. */
  109019. getLeftJoystick(): VirtualJoystick;
  109020. /**
  109021. * Gets the right stick of the virtual joystick.
  109022. * @returns The virtual Joystick
  109023. */
  109024. getRightJoystick(): VirtualJoystick;
  109025. /**
  109026. * Update the current camera state depending on the inputs that have been used this frame.
  109027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109028. */
  109029. checkInputs(): void;
  109030. /**
  109031. * Attach the input controls to a specific dom element to get the input from.
  109032. * @param element Defines the element the controls should be listened from
  109033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109034. */
  109035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109036. /**
  109037. * Detach the current controls from the specified dom element.
  109038. * @param element Defines the element to stop listening the inputs from
  109039. */
  109040. detachControl(element: Nullable<HTMLElement>): void;
  109041. /**
  109042. * Gets the class name of the current intput.
  109043. * @returns the class name
  109044. */
  109045. getClassName(): string;
  109046. /**
  109047. * Get the friendly name associated with the input class.
  109048. * @returns the input friendly name
  109049. */
  109050. getSimpleName(): string;
  109051. }
  109052. }
  109053. declare module BABYLON {
  109054. /**
  109055. * This represents a FPS type of camera controlled by touch.
  109056. * This is like a universal camera minus the Gamepad controls.
  109057. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109058. */
  109059. export class TouchCamera extends FreeCamera {
  109060. /**
  109061. * Defines the touch sensibility for rotation.
  109062. * The higher the faster.
  109063. */
  109064. touchAngularSensibility: number;
  109065. /**
  109066. * Defines the touch sensibility for move.
  109067. * The higher the faster.
  109068. */
  109069. touchMoveSensibility: number;
  109070. /**
  109071. * Instantiates a new touch camera.
  109072. * This represents a FPS type of camera controlled by touch.
  109073. * This is like a universal camera minus the Gamepad controls.
  109074. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109075. * @param name Define the name of the camera in the scene
  109076. * @param position Define the start position of the camera in the scene
  109077. * @param scene Define the scene the camera belongs to
  109078. */
  109079. constructor(name: string, position: Vector3, scene: Scene);
  109080. /**
  109081. * Gets the current object class name.
  109082. * @return the class name
  109083. */
  109084. getClassName(): string;
  109085. /** @hidden */
  109086. _setupInputs(): void;
  109087. }
  109088. }
  109089. declare module BABYLON {
  109090. /**
  109091. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109092. * being tilted forward or back and left or right.
  109093. */
  109094. export class DeviceOrientationCamera extends FreeCamera {
  109095. private _initialQuaternion;
  109096. private _quaternionCache;
  109097. private _tmpDragQuaternion;
  109098. private _disablePointerInputWhenUsingDeviceOrientation;
  109099. /**
  109100. * Creates a new device orientation camera
  109101. * @param name The name of the camera
  109102. * @param position The start position camera
  109103. * @param scene The scene the camera belongs to
  109104. */
  109105. constructor(name: string, position: Vector3, scene: Scene);
  109106. /**
  109107. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109108. */
  109109. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109110. private _dragFactor;
  109111. /**
  109112. * Enabled turning on the y axis when the orientation sensor is active
  109113. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109114. */
  109115. enableHorizontalDragging(dragFactor?: number): void;
  109116. /**
  109117. * Gets the current instance class name ("DeviceOrientationCamera").
  109118. * This helps avoiding instanceof at run time.
  109119. * @returns the class name
  109120. */
  109121. getClassName(): string;
  109122. /**
  109123. * @hidden
  109124. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109125. */
  109126. _checkInputs(): void;
  109127. /**
  109128. * Reset the camera to its default orientation on the specified axis only.
  109129. * @param axis The axis to reset
  109130. */
  109131. resetToCurrentRotation(axis?: Axis): void;
  109132. }
  109133. }
  109134. declare module BABYLON {
  109135. /**
  109136. * Defines supported buttons for XBox360 compatible gamepads
  109137. */
  109138. export enum Xbox360Button {
  109139. /** A */
  109140. A = 0,
  109141. /** B */
  109142. B = 1,
  109143. /** X */
  109144. X = 2,
  109145. /** Y */
  109146. Y = 3,
  109147. /** Start */
  109148. Start = 4,
  109149. /** Back */
  109150. Back = 5,
  109151. /** Left button */
  109152. LB = 6,
  109153. /** Right button */
  109154. RB = 7,
  109155. /** Left stick */
  109156. LeftStick = 8,
  109157. /** Right stick */
  109158. RightStick = 9
  109159. }
  109160. /** Defines values for XBox360 DPad */
  109161. export enum Xbox360Dpad {
  109162. /** Up */
  109163. Up = 0,
  109164. /** Down */
  109165. Down = 1,
  109166. /** Left */
  109167. Left = 2,
  109168. /** Right */
  109169. Right = 3
  109170. }
  109171. /**
  109172. * Defines a XBox360 gamepad
  109173. */
  109174. export class Xbox360Pad extends Gamepad {
  109175. private _leftTrigger;
  109176. private _rightTrigger;
  109177. private _onlefttriggerchanged;
  109178. private _onrighttriggerchanged;
  109179. private _onbuttondown;
  109180. private _onbuttonup;
  109181. private _ondpaddown;
  109182. private _ondpadup;
  109183. /** Observable raised when a button is pressed */
  109184. onButtonDownObservable: Observable<Xbox360Button>;
  109185. /** Observable raised when a button is released */
  109186. onButtonUpObservable: Observable<Xbox360Button>;
  109187. /** Observable raised when a pad is pressed */
  109188. onPadDownObservable: Observable<Xbox360Dpad>;
  109189. /** Observable raised when a pad is released */
  109190. onPadUpObservable: Observable<Xbox360Dpad>;
  109191. private _buttonA;
  109192. private _buttonB;
  109193. private _buttonX;
  109194. private _buttonY;
  109195. private _buttonBack;
  109196. private _buttonStart;
  109197. private _buttonLB;
  109198. private _buttonRB;
  109199. private _buttonLeftStick;
  109200. private _buttonRightStick;
  109201. private _dPadUp;
  109202. private _dPadDown;
  109203. private _dPadLeft;
  109204. private _dPadRight;
  109205. private _isXboxOnePad;
  109206. /**
  109207. * Creates a new XBox360 gamepad object
  109208. * @param id defines the id of this gamepad
  109209. * @param index defines its index
  109210. * @param gamepad defines the internal HTML gamepad object
  109211. * @param xboxOne defines if it is a XBox One gamepad
  109212. */
  109213. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109214. /**
  109215. * Defines the callback to call when left trigger is pressed
  109216. * @param callback defines the callback to use
  109217. */
  109218. onlefttriggerchanged(callback: (value: number) => void): void;
  109219. /**
  109220. * Defines the callback to call when right trigger is pressed
  109221. * @param callback defines the callback to use
  109222. */
  109223. onrighttriggerchanged(callback: (value: number) => void): void;
  109224. /**
  109225. * Gets the left trigger value
  109226. */
  109227. /**
  109228. * Sets the left trigger value
  109229. */
  109230. leftTrigger: number;
  109231. /**
  109232. * Gets the right trigger value
  109233. */
  109234. /**
  109235. * Sets the right trigger value
  109236. */
  109237. rightTrigger: number;
  109238. /**
  109239. * Defines the callback to call when a button is pressed
  109240. * @param callback defines the callback to use
  109241. */
  109242. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109243. /**
  109244. * Defines the callback to call when a button is released
  109245. * @param callback defines the callback to use
  109246. */
  109247. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109248. /**
  109249. * Defines the callback to call when a pad is pressed
  109250. * @param callback defines the callback to use
  109251. */
  109252. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109253. /**
  109254. * Defines the callback to call when a pad is released
  109255. * @param callback defines the callback to use
  109256. */
  109257. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109258. private _setButtonValue;
  109259. private _setDPadValue;
  109260. /**
  109261. * Gets the value of the `A` button
  109262. */
  109263. /**
  109264. * Sets the value of the `A` button
  109265. */
  109266. buttonA: number;
  109267. /**
  109268. * Gets the value of the `B` button
  109269. */
  109270. /**
  109271. * Sets the value of the `B` button
  109272. */
  109273. buttonB: number;
  109274. /**
  109275. * Gets the value of the `X` button
  109276. */
  109277. /**
  109278. * Sets the value of the `X` button
  109279. */
  109280. buttonX: number;
  109281. /**
  109282. * Gets the value of the `Y` button
  109283. */
  109284. /**
  109285. * Sets the value of the `Y` button
  109286. */
  109287. buttonY: number;
  109288. /**
  109289. * Gets the value of the `Start` button
  109290. */
  109291. /**
  109292. * Sets the value of the `Start` button
  109293. */
  109294. buttonStart: number;
  109295. /**
  109296. * Gets the value of the `Back` button
  109297. */
  109298. /**
  109299. * Sets the value of the `Back` button
  109300. */
  109301. buttonBack: number;
  109302. /**
  109303. * Gets the value of the `Left` button
  109304. */
  109305. /**
  109306. * Sets the value of the `Left` button
  109307. */
  109308. buttonLB: number;
  109309. /**
  109310. * Gets the value of the `Right` button
  109311. */
  109312. /**
  109313. * Sets the value of the `Right` button
  109314. */
  109315. buttonRB: number;
  109316. /**
  109317. * Gets the value of the Left joystick
  109318. */
  109319. /**
  109320. * Sets the value of the Left joystick
  109321. */
  109322. buttonLeftStick: number;
  109323. /**
  109324. * Gets the value of the Right joystick
  109325. */
  109326. /**
  109327. * Sets the value of the Right joystick
  109328. */
  109329. buttonRightStick: number;
  109330. /**
  109331. * Gets the value of D-pad up
  109332. */
  109333. /**
  109334. * Sets the value of D-pad up
  109335. */
  109336. dPadUp: number;
  109337. /**
  109338. * Gets the value of D-pad down
  109339. */
  109340. /**
  109341. * Sets the value of D-pad down
  109342. */
  109343. dPadDown: number;
  109344. /**
  109345. * Gets the value of D-pad left
  109346. */
  109347. /**
  109348. * Sets the value of D-pad left
  109349. */
  109350. dPadLeft: number;
  109351. /**
  109352. * Gets the value of D-pad right
  109353. */
  109354. /**
  109355. * Sets the value of D-pad right
  109356. */
  109357. dPadRight: number;
  109358. /**
  109359. * Force the gamepad to synchronize with device values
  109360. */
  109361. update(): void;
  109362. /**
  109363. * Disposes the gamepad
  109364. */
  109365. dispose(): void;
  109366. }
  109367. }
  109368. declare module BABYLON {
  109369. /**
  109370. * Defines supported buttons for DualShock compatible gamepads
  109371. */
  109372. export enum DualShockButton {
  109373. /** Cross */
  109374. Cross = 0,
  109375. /** Circle */
  109376. Circle = 1,
  109377. /** Square */
  109378. Square = 2,
  109379. /** Triangle */
  109380. Triangle = 3,
  109381. /** Options */
  109382. Options = 4,
  109383. /** Share */
  109384. Share = 5,
  109385. /** L1 */
  109386. L1 = 6,
  109387. /** R1 */
  109388. R1 = 7,
  109389. /** Left stick */
  109390. LeftStick = 8,
  109391. /** Right stick */
  109392. RightStick = 9
  109393. }
  109394. /** Defines values for DualShock DPad */
  109395. export enum DualShockDpad {
  109396. /** Up */
  109397. Up = 0,
  109398. /** Down */
  109399. Down = 1,
  109400. /** Left */
  109401. Left = 2,
  109402. /** Right */
  109403. Right = 3
  109404. }
  109405. /**
  109406. * Defines a DualShock gamepad
  109407. */
  109408. export class DualShockPad extends Gamepad {
  109409. private _leftTrigger;
  109410. private _rightTrigger;
  109411. private _onlefttriggerchanged;
  109412. private _onrighttriggerchanged;
  109413. private _onbuttondown;
  109414. private _onbuttonup;
  109415. private _ondpaddown;
  109416. private _ondpadup;
  109417. /** Observable raised when a button is pressed */
  109418. onButtonDownObservable: Observable<DualShockButton>;
  109419. /** Observable raised when a button is released */
  109420. onButtonUpObservable: Observable<DualShockButton>;
  109421. /** Observable raised when a pad is pressed */
  109422. onPadDownObservable: Observable<DualShockDpad>;
  109423. /** Observable raised when a pad is released */
  109424. onPadUpObservable: Observable<DualShockDpad>;
  109425. private _buttonCross;
  109426. private _buttonCircle;
  109427. private _buttonSquare;
  109428. private _buttonTriangle;
  109429. private _buttonShare;
  109430. private _buttonOptions;
  109431. private _buttonL1;
  109432. private _buttonR1;
  109433. private _buttonLeftStick;
  109434. private _buttonRightStick;
  109435. private _dPadUp;
  109436. private _dPadDown;
  109437. private _dPadLeft;
  109438. private _dPadRight;
  109439. /**
  109440. * Creates a new DualShock gamepad object
  109441. * @param id defines the id of this gamepad
  109442. * @param index defines its index
  109443. * @param gamepad defines the internal HTML gamepad object
  109444. */
  109445. constructor(id: string, index: number, gamepad: any);
  109446. /**
  109447. * Defines the callback to call when left trigger is pressed
  109448. * @param callback defines the callback to use
  109449. */
  109450. onlefttriggerchanged(callback: (value: number) => void): void;
  109451. /**
  109452. * Defines the callback to call when right trigger is pressed
  109453. * @param callback defines the callback to use
  109454. */
  109455. onrighttriggerchanged(callback: (value: number) => void): void;
  109456. /**
  109457. * Gets the left trigger value
  109458. */
  109459. /**
  109460. * Sets the left trigger value
  109461. */
  109462. leftTrigger: number;
  109463. /**
  109464. * Gets the right trigger value
  109465. */
  109466. /**
  109467. * Sets the right trigger value
  109468. */
  109469. rightTrigger: number;
  109470. /**
  109471. * Defines the callback to call when a button is pressed
  109472. * @param callback defines the callback to use
  109473. */
  109474. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109475. /**
  109476. * Defines the callback to call when a button is released
  109477. * @param callback defines the callback to use
  109478. */
  109479. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109480. /**
  109481. * Defines the callback to call when a pad is pressed
  109482. * @param callback defines the callback to use
  109483. */
  109484. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109485. /**
  109486. * Defines the callback to call when a pad is released
  109487. * @param callback defines the callback to use
  109488. */
  109489. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  109490. private _setButtonValue;
  109491. private _setDPadValue;
  109492. /**
  109493. * Gets the value of the `Cross` button
  109494. */
  109495. /**
  109496. * Sets the value of the `Cross` button
  109497. */
  109498. buttonCross: number;
  109499. /**
  109500. * Gets the value of the `Circle` button
  109501. */
  109502. /**
  109503. * Sets the value of the `Circle` button
  109504. */
  109505. buttonCircle: number;
  109506. /**
  109507. * Gets the value of the `Square` button
  109508. */
  109509. /**
  109510. * Sets the value of the `Square` button
  109511. */
  109512. buttonSquare: number;
  109513. /**
  109514. * Gets the value of the `Triangle` button
  109515. */
  109516. /**
  109517. * Sets the value of the `Triangle` button
  109518. */
  109519. buttonTriangle: number;
  109520. /**
  109521. * Gets the value of the `Options` button
  109522. */
  109523. /**
  109524. * Sets the value of the `Options` button
  109525. */
  109526. buttonOptions: number;
  109527. /**
  109528. * Gets the value of the `Share` button
  109529. */
  109530. /**
  109531. * Sets the value of the `Share` button
  109532. */
  109533. buttonShare: number;
  109534. /**
  109535. * Gets the value of the `L1` button
  109536. */
  109537. /**
  109538. * Sets the value of the `L1` button
  109539. */
  109540. buttonL1: number;
  109541. /**
  109542. * Gets the value of the `R1` button
  109543. */
  109544. /**
  109545. * Sets the value of the `R1` button
  109546. */
  109547. buttonR1: number;
  109548. /**
  109549. * Gets the value of the Left joystick
  109550. */
  109551. /**
  109552. * Sets the value of the Left joystick
  109553. */
  109554. buttonLeftStick: number;
  109555. /**
  109556. * Gets the value of the Right joystick
  109557. */
  109558. /**
  109559. * Sets the value of the Right joystick
  109560. */
  109561. buttonRightStick: number;
  109562. /**
  109563. * Gets the value of D-pad up
  109564. */
  109565. /**
  109566. * Sets the value of D-pad up
  109567. */
  109568. dPadUp: number;
  109569. /**
  109570. * Gets the value of D-pad down
  109571. */
  109572. /**
  109573. * Sets the value of D-pad down
  109574. */
  109575. dPadDown: number;
  109576. /**
  109577. * Gets the value of D-pad left
  109578. */
  109579. /**
  109580. * Sets the value of D-pad left
  109581. */
  109582. dPadLeft: number;
  109583. /**
  109584. * Gets the value of D-pad right
  109585. */
  109586. /**
  109587. * Sets the value of D-pad right
  109588. */
  109589. dPadRight: number;
  109590. /**
  109591. * Force the gamepad to synchronize with device values
  109592. */
  109593. update(): void;
  109594. /**
  109595. * Disposes the gamepad
  109596. */
  109597. dispose(): void;
  109598. }
  109599. }
  109600. declare module BABYLON {
  109601. /**
  109602. * Manager for handling gamepads
  109603. */
  109604. export class GamepadManager {
  109605. private _scene?;
  109606. private _babylonGamepads;
  109607. private _oneGamepadConnected;
  109608. /** @hidden */
  109609. _isMonitoring: boolean;
  109610. private _gamepadEventSupported;
  109611. private _gamepadSupport;
  109612. /**
  109613. * observable to be triggered when the gamepad controller has been connected
  109614. */
  109615. onGamepadConnectedObservable: Observable<Gamepad>;
  109616. /**
  109617. * observable to be triggered when the gamepad controller has been disconnected
  109618. */
  109619. onGamepadDisconnectedObservable: Observable<Gamepad>;
  109620. private _onGamepadConnectedEvent;
  109621. private _onGamepadDisconnectedEvent;
  109622. /**
  109623. * Initializes the gamepad manager
  109624. * @param _scene BabylonJS scene
  109625. */
  109626. constructor(_scene?: Scene | undefined);
  109627. /**
  109628. * The gamepads in the game pad manager
  109629. */
  109630. readonly gamepads: Gamepad[];
  109631. /**
  109632. * Get the gamepad controllers based on type
  109633. * @param type The type of gamepad controller
  109634. * @returns Nullable gamepad
  109635. */
  109636. getGamepadByType(type?: number): Nullable<Gamepad>;
  109637. /**
  109638. * Disposes the gamepad manager
  109639. */
  109640. dispose(): void;
  109641. private _addNewGamepad;
  109642. private _startMonitoringGamepads;
  109643. private _stopMonitoringGamepads;
  109644. /** @hidden */
  109645. _checkGamepadsStatus(): void;
  109646. private _updateGamepadObjects;
  109647. }
  109648. }
  109649. declare module BABYLON {
  109650. interface Scene {
  109651. /** @hidden */
  109652. _gamepadManager: Nullable<GamepadManager>;
  109653. /**
  109654. * Gets the gamepad manager associated with the scene
  109655. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  109656. */
  109657. gamepadManager: GamepadManager;
  109658. }
  109659. /**
  109660. * Interface representing a free camera inputs manager
  109661. */
  109662. interface FreeCameraInputsManager {
  109663. /**
  109664. * Adds gamepad input support to the FreeCameraInputsManager.
  109665. * @returns the FreeCameraInputsManager
  109666. */
  109667. addGamepad(): FreeCameraInputsManager;
  109668. }
  109669. /**
  109670. * Interface representing an arc rotate camera inputs manager
  109671. */
  109672. interface ArcRotateCameraInputsManager {
  109673. /**
  109674. * Adds gamepad input support to the ArcRotateCamera InputManager.
  109675. * @returns the camera inputs manager
  109676. */
  109677. addGamepad(): ArcRotateCameraInputsManager;
  109678. }
  109679. /**
  109680. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  109681. */
  109682. export class GamepadSystemSceneComponent implements ISceneComponent {
  109683. /**
  109684. * The component name helpfull to identify the component in the list of scene components.
  109685. */
  109686. readonly name: string;
  109687. /**
  109688. * The scene the component belongs to.
  109689. */
  109690. scene: Scene;
  109691. /**
  109692. * Creates a new instance of the component for the given scene
  109693. * @param scene Defines the scene to register the component in
  109694. */
  109695. constructor(scene: Scene);
  109696. /**
  109697. * Registers the component in a given scene
  109698. */
  109699. register(): void;
  109700. /**
  109701. * Rebuilds the elements related to this component in case of
  109702. * context lost for instance.
  109703. */
  109704. rebuild(): void;
  109705. /**
  109706. * Disposes the component and the associated ressources
  109707. */
  109708. dispose(): void;
  109709. private _beforeCameraUpdate;
  109710. }
  109711. }
  109712. declare module BABYLON {
  109713. /**
  109714. * 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,
  109715. * which still works and will still be found in many Playgrounds.
  109716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109717. */
  109718. export class UniversalCamera extends TouchCamera {
  109719. /**
  109720. * Defines the gamepad rotation sensiblity.
  109721. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109722. */
  109723. gamepadAngularSensibility: number;
  109724. /**
  109725. * Defines the gamepad move sensiblity.
  109726. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109727. */
  109728. gamepadMoveSensibility: number;
  109729. /**
  109730. * 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,
  109731. * which still works and will still be found in many Playgrounds.
  109732. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109733. * @param name Define the name of the camera in the scene
  109734. * @param position Define the start position of the camera in the scene
  109735. * @param scene Define the scene the camera belongs to
  109736. */
  109737. constructor(name: string, position: Vector3, scene: Scene);
  109738. /**
  109739. * Gets the current object class name.
  109740. * @return the class name
  109741. */
  109742. getClassName(): string;
  109743. }
  109744. }
  109745. declare module BABYLON {
  109746. /**
  109747. * This represents a FPS type of camera. This is only here for back compat purpose.
  109748. * Please use the UniversalCamera instead as both are identical.
  109749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109750. */
  109751. export class GamepadCamera extends UniversalCamera {
  109752. /**
  109753. * Instantiates a new Gamepad Camera
  109754. * This represents a FPS type of camera. This is only here for back compat purpose.
  109755. * Please use the UniversalCamera instead as both are identical.
  109756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109757. * @param name Define the name of the camera in the scene
  109758. * @param position Define the start position of the camera in the scene
  109759. * @param scene Define the scene the camera belongs to
  109760. */
  109761. constructor(name: string, position: Vector3, scene: Scene);
  109762. /**
  109763. * Gets the current object class name.
  109764. * @return the class name
  109765. */
  109766. getClassName(): string;
  109767. }
  109768. }
  109769. declare module BABYLON {
  109770. /** @hidden */
  109771. export var passPixelShader: {
  109772. name: string;
  109773. shader: string;
  109774. };
  109775. }
  109776. declare module BABYLON {
  109777. /** @hidden */
  109778. export var passCubePixelShader: {
  109779. name: string;
  109780. shader: string;
  109781. };
  109782. }
  109783. declare module BABYLON {
  109784. /**
  109785. * PassPostProcess which produces an output the same as it's input
  109786. */
  109787. export class PassPostProcess extends PostProcess {
  109788. /**
  109789. * Creates the PassPostProcess
  109790. * @param name The name of the effect.
  109791. * @param options The required width/height ratio to downsize to before computing the render pass.
  109792. * @param camera The camera to apply the render pass to.
  109793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109794. * @param engine The engine which the post process will be applied. (default: current engine)
  109795. * @param reusable If the post process can be reused on the same frame. (default: false)
  109796. * @param textureType The type of texture to be used when performing the post processing.
  109797. * @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)
  109798. */
  109799. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109800. }
  109801. /**
  109802. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  109803. */
  109804. export class PassCubePostProcess extends PostProcess {
  109805. private _face;
  109806. /**
  109807. * Gets or sets the cube face to display.
  109808. * * 0 is +X
  109809. * * 1 is -X
  109810. * * 2 is +Y
  109811. * * 3 is -Y
  109812. * * 4 is +Z
  109813. * * 5 is -Z
  109814. */
  109815. face: number;
  109816. /**
  109817. * Creates the PassCubePostProcess
  109818. * @param name The name of the effect.
  109819. * @param options The required width/height ratio to downsize to before computing the render pass.
  109820. * @param camera The camera to apply the render pass to.
  109821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109822. * @param engine The engine which the post process will be applied. (default: current engine)
  109823. * @param reusable If the post process can be reused on the same frame. (default: false)
  109824. * @param textureType The type of texture to be used when performing the post processing.
  109825. * @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)
  109826. */
  109827. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109828. }
  109829. }
  109830. declare module BABYLON {
  109831. /** @hidden */
  109832. export var anaglyphPixelShader: {
  109833. name: string;
  109834. shader: string;
  109835. };
  109836. }
  109837. declare module BABYLON {
  109838. /**
  109839. * Postprocess used to generate anaglyphic rendering
  109840. */
  109841. export class AnaglyphPostProcess extends PostProcess {
  109842. private _passedProcess;
  109843. /**
  109844. * Creates a new AnaglyphPostProcess
  109845. * @param name defines postprocess name
  109846. * @param options defines creation options or target ratio scale
  109847. * @param rigCameras defines cameras using this postprocess
  109848. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  109849. * @param engine defines hosting engine
  109850. * @param reusable defines if the postprocess will be reused multiple times per frame
  109851. */
  109852. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  109853. }
  109854. }
  109855. declare module BABYLON {
  109856. /**
  109857. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  109858. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109859. */
  109860. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  109861. /**
  109862. * Creates a new AnaglyphArcRotateCamera
  109863. * @param name defines camera name
  109864. * @param alpha defines alpha angle (in radians)
  109865. * @param beta defines beta angle (in radians)
  109866. * @param radius defines radius
  109867. * @param target defines camera target
  109868. * @param interaxialDistance defines distance between each color axis
  109869. * @param scene defines the hosting scene
  109870. */
  109871. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  109872. /**
  109873. * Gets camera class name
  109874. * @returns AnaglyphArcRotateCamera
  109875. */
  109876. getClassName(): string;
  109877. }
  109878. }
  109879. declare module BABYLON {
  109880. /**
  109881. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  109882. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109883. */
  109884. export class AnaglyphFreeCamera extends FreeCamera {
  109885. /**
  109886. * Creates a new AnaglyphFreeCamera
  109887. * @param name defines camera name
  109888. * @param position defines initial position
  109889. * @param interaxialDistance defines distance between each color axis
  109890. * @param scene defines the hosting scene
  109891. */
  109892. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109893. /**
  109894. * Gets camera class name
  109895. * @returns AnaglyphFreeCamera
  109896. */
  109897. getClassName(): string;
  109898. }
  109899. }
  109900. declare module BABYLON {
  109901. /**
  109902. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  109903. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109904. */
  109905. export class AnaglyphGamepadCamera extends GamepadCamera {
  109906. /**
  109907. * Creates a new AnaglyphGamepadCamera
  109908. * @param name defines camera name
  109909. * @param position defines initial position
  109910. * @param interaxialDistance defines distance between each color axis
  109911. * @param scene defines the hosting scene
  109912. */
  109913. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109914. /**
  109915. * Gets camera class name
  109916. * @returns AnaglyphGamepadCamera
  109917. */
  109918. getClassName(): string;
  109919. }
  109920. }
  109921. declare module BABYLON {
  109922. /**
  109923. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  109924. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109925. */
  109926. export class AnaglyphUniversalCamera extends UniversalCamera {
  109927. /**
  109928. * Creates a new AnaglyphUniversalCamera
  109929. * @param name defines camera name
  109930. * @param position defines initial position
  109931. * @param interaxialDistance defines distance between each color axis
  109932. * @param scene defines the hosting scene
  109933. */
  109934. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109935. /**
  109936. * Gets camera class name
  109937. * @returns AnaglyphUniversalCamera
  109938. */
  109939. getClassName(): string;
  109940. }
  109941. }
  109942. declare module BABYLON {
  109943. /** @hidden */
  109944. export var stereoscopicInterlacePixelShader: {
  109945. name: string;
  109946. shader: string;
  109947. };
  109948. }
  109949. declare module BABYLON {
  109950. /**
  109951. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  109952. */
  109953. export class StereoscopicInterlacePostProcess extends PostProcess {
  109954. private _stepSize;
  109955. private _passedProcess;
  109956. /**
  109957. * Initializes a StereoscopicInterlacePostProcess
  109958. * @param name The name of the effect.
  109959. * @param rigCameras The rig cameras to be appled to the post process
  109960. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  109961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109962. * @param engine The engine which the post process will be applied. (default: current engine)
  109963. * @param reusable If the post process can be reused on the same frame. (default: false)
  109964. */
  109965. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109966. }
  109967. }
  109968. declare module BABYLON {
  109969. /**
  109970. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  109971. * @see http://doc.babylonjs.com/features/cameras
  109972. */
  109973. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  109974. /**
  109975. * Creates a new StereoscopicArcRotateCamera
  109976. * @param name defines camera name
  109977. * @param alpha defines alpha angle (in radians)
  109978. * @param beta defines beta angle (in radians)
  109979. * @param radius defines radius
  109980. * @param target defines camera target
  109981. * @param interaxialDistance defines distance between each color axis
  109982. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109983. * @param scene defines the hosting scene
  109984. */
  109985. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109986. /**
  109987. * Gets camera class name
  109988. * @returns StereoscopicArcRotateCamera
  109989. */
  109990. getClassName(): string;
  109991. }
  109992. }
  109993. declare module BABYLON {
  109994. /**
  109995. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  109996. * @see http://doc.babylonjs.com/features/cameras
  109997. */
  109998. export class StereoscopicFreeCamera extends FreeCamera {
  109999. /**
  110000. * Creates a new StereoscopicFreeCamera
  110001. * @param name defines camera name
  110002. * @param position defines initial position
  110003. * @param interaxialDistance defines distance between each color axis
  110004. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110005. * @param scene defines the hosting scene
  110006. */
  110007. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110008. /**
  110009. * Gets camera class name
  110010. * @returns StereoscopicFreeCamera
  110011. */
  110012. getClassName(): string;
  110013. }
  110014. }
  110015. declare module BABYLON {
  110016. /**
  110017. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  110018. * @see http://doc.babylonjs.com/features/cameras
  110019. */
  110020. export class StereoscopicGamepadCamera extends GamepadCamera {
  110021. /**
  110022. * Creates a new StereoscopicGamepadCamera
  110023. * @param name defines camera name
  110024. * @param position defines initial position
  110025. * @param interaxialDistance defines distance between each color axis
  110026. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110027. * @param scene defines the hosting scene
  110028. */
  110029. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110030. /**
  110031. * Gets camera class name
  110032. * @returns StereoscopicGamepadCamera
  110033. */
  110034. getClassName(): string;
  110035. }
  110036. }
  110037. declare module BABYLON {
  110038. /**
  110039. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110040. * @see http://doc.babylonjs.com/features/cameras
  110041. */
  110042. export class StereoscopicUniversalCamera extends UniversalCamera {
  110043. /**
  110044. * Creates a new StereoscopicUniversalCamera
  110045. * @param name defines camera name
  110046. * @param position defines initial position
  110047. * @param interaxialDistance defines distance between each color axis
  110048. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110049. * @param scene defines the hosting scene
  110050. */
  110051. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110052. /**
  110053. * Gets camera class name
  110054. * @returns StereoscopicUniversalCamera
  110055. */
  110056. getClassName(): string;
  110057. }
  110058. }
  110059. declare module BABYLON {
  110060. /**
  110061. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110062. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110063. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110064. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110065. */
  110066. export class VirtualJoysticksCamera extends FreeCamera {
  110067. /**
  110068. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110069. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110070. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110071. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110072. * @param name Define the name of the camera in the scene
  110073. * @param position Define the start position of the camera in the scene
  110074. * @param scene Define the scene the camera belongs to
  110075. */
  110076. constructor(name: string, position: Vector3, scene: Scene);
  110077. /**
  110078. * Gets the current object class name.
  110079. * @return the class name
  110080. */
  110081. getClassName(): string;
  110082. }
  110083. }
  110084. declare module BABYLON {
  110085. /**
  110086. * This represents all the required metrics to create a VR camera.
  110087. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110088. */
  110089. export class VRCameraMetrics {
  110090. /**
  110091. * Define the horizontal resolution off the screen.
  110092. */
  110093. hResolution: number;
  110094. /**
  110095. * Define the vertical resolution off the screen.
  110096. */
  110097. vResolution: number;
  110098. /**
  110099. * Define the horizontal screen size.
  110100. */
  110101. hScreenSize: number;
  110102. /**
  110103. * Define the vertical screen size.
  110104. */
  110105. vScreenSize: number;
  110106. /**
  110107. * Define the vertical screen center position.
  110108. */
  110109. vScreenCenter: number;
  110110. /**
  110111. * Define the distance of the eyes to the screen.
  110112. */
  110113. eyeToScreenDistance: number;
  110114. /**
  110115. * Define the distance between both lenses
  110116. */
  110117. lensSeparationDistance: number;
  110118. /**
  110119. * Define the distance between both viewer's eyes.
  110120. */
  110121. interpupillaryDistance: number;
  110122. /**
  110123. * Define the distortion factor of the VR postprocess.
  110124. * Please, touch with care.
  110125. */
  110126. distortionK: number[];
  110127. /**
  110128. * Define the chromatic aberration correction factors for the VR post process.
  110129. */
  110130. chromaAbCorrection: number[];
  110131. /**
  110132. * Define the scale factor of the post process.
  110133. * The smaller the better but the slower.
  110134. */
  110135. postProcessScaleFactor: number;
  110136. /**
  110137. * Define an offset for the lens center.
  110138. */
  110139. lensCenterOffset: number;
  110140. /**
  110141. * Define if the current vr camera should compensate the distortion of the lense or not.
  110142. */
  110143. compensateDistortion: boolean;
  110144. /**
  110145. * Defines if multiview should be enabled when rendering (Default: false)
  110146. */
  110147. multiviewEnabled: boolean;
  110148. /**
  110149. * Gets the rendering aspect ratio based on the provided resolutions.
  110150. */
  110151. readonly aspectRatio: number;
  110152. /**
  110153. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110154. */
  110155. readonly aspectRatioFov: number;
  110156. /**
  110157. * @hidden
  110158. */
  110159. readonly leftHMatrix: Matrix;
  110160. /**
  110161. * @hidden
  110162. */
  110163. readonly rightHMatrix: Matrix;
  110164. /**
  110165. * @hidden
  110166. */
  110167. readonly leftPreViewMatrix: Matrix;
  110168. /**
  110169. * @hidden
  110170. */
  110171. readonly rightPreViewMatrix: Matrix;
  110172. /**
  110173. * Get the default VRMetrics based on the most generic setup.
  110174. * @returns the default vr metrics
  110175. */
  110176. static GetDefault(): VRCameraMetrics;
  110177. }
  110178. }
  110179. declare module BABYLON {
  110180. /** @hidden */
  110181. export var vrDistortionCorrectionPixelShader: {
  110182. name: string;
  110183. shader: string;
  110184. };
  110185. }
  110186. declare module BABYLON {
  110187. /**
  110188. * VRDistortionCorrectionPostProcess used for mobile VR
  110189. */
  110190. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110191. private _isRightEye;
  110192. private _distortionFactors;
  110193. private _postProcessScaleFactor;
  110194. private _lensCenterOffset;
  110195. private _scaleIn;
  110196. private _scaleFactor;
  110197. private _lensCenter;
  110198. /**
  110199. * Initializes the VRDistortionCorrectionPostProcess
  110200. * @param name The name of the effect.
  110201. * @param camera The camera to apply the render pass to.
  110202. * @param isRightEye If this is for the right eye distortion
  110203. * @param vrMetrics All the required metrics for the VR camera
  110204. */
  110205. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110206. }
  110207. }
  110208. declare module BABYLON {
  110209. /**
  110210. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110211. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110212. */
  110213. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110214. /**
  110215. * Creates a new VRDeviceOrientationArcRotateCamera
  110216. * @param name defines camera name
  110217. * @param alpha defines the camera rotation along the logitudinal axis
  110218. * @param beta defines the camera rotation along the latitudinal axis
  110219. * @param radius defines the camera distance from its target
  110220. * @param target defines the camera target
  110221. * @param scene defines the scene the camera belongs to
  110222. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110223. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110224. */
  110225. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110226. /**
  110227. * Gets camera class name
  110228. * @returns VRDeviceOrientationArcRotateCamera
  110229. */
  110230. getClassName(): string;
  110231. }
  110232. }
  110233. declare module BABYLON {
  110234. /**
  110235. * Camera used to simulate VR rendering (based on FreeCamera)
  110236. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110237. */
  110238. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110239. /**
  110240. * Creates a new VRDeviceOrientationFreeCamera
  110241. * @param name defines camera name
  110242. * @param position defines the start position of the camera
  110243. * @param scene defines the scene the camera belongs to
  110244. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110245. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110246. */
  110247. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110248. /**
  110249. * Gets camera class name
  110250. * @returns VRDeviceOrientationFreeCamera
  110251. */
  110252. getClassName(): string;
  110253. }
  110254. }
  110255. declare module BABYLON {
  110256. /**
  110257. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110258. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110259. */
  110260. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110261. /**
  110262. * Creates a new VRDeviceOrientationGamepadCamera
  110263. * @param name defines camera name
  110264. * @param position defines the start position of the camera
  110265. * @param scene defines the scene the camera belongs to
  110266. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110267. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110268. */
  110269. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110270. /**
  110271. * Gets camera class name
  110272. * @returns VRDeviceOrientationGamepadCamera
  110273. */
  110274. getClassName(): string;
  110275. }
  110276. }
  110277. declare module BABYLON {
  110278. /** @hidden */
  110279. export var imageProcessingPixelShader: {
  110280. name: string;
  110281. shader: string;
  110282. };
  110283. }
  110284. declare module BABYLON {
  110285. /**
  110286. * ImageProcessingPostProcess
  110287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110288. */
  110289. export class ImageProcessingPostProcess extends PostProcess {
  110290. /**
  110291. * Default configuration related to image processing available in the PBR Material.
  110292. */
  110293. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110294. /**
  110295. * Gets the image processing configuration used either in this material.
  110296. */
  110297. /**
  110298. * Sets the Default image processing configuration used either in the this material.
  110299. *
  110300. * If sets to null, the scene one is in use.
  110301. */
  110302. imageProcessingConfiguration: ImageProcessingConfiguration;
  110303. /**
  110304. * Keep track of the image processing observer to allow dispose and replace.
  110305. */
  110306. private _imageProcessingObserver;
  110307. /**
  110308. * Attaches a new image processing configuration to the PBR Material.
  110309. * @param configuration
  110310. */
  110311. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110312. /**
  110313. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110314. */
  110315. /**
  110316. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110317. */
  110318. colorCurves: Nullable<ColorCurves>;
  110319. /**
  110320. * Gets wether the color curves effect is enabled.
  110321. */
  110322. /**
  110323. * Sets wether the color curves effect is enabled.
  110324. */
  110325. colorCurvesEnabled: boolean;
  110326. /**
  110327. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110328. */
  110329. /**
  110330. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110331. */
  110332. colorGradingTexture: Nullable<BaseTexture>;
  110333. /**
  110334. * Gets wether the color grading effect is enabled.
  110335. */
  110336. /**
  110337. * Gets wether the color grading effect is enabled.
  110338. */
  110339. colorGradingEnabled: boolean;
  110340. /**
  110341. * Gets exposure used in the effect.
  110342. */
  110343. /**
  110344. * Sets exposure used in the effect.
  110345. */
  110346. exposure: number;
  110347. /**
  110348. * Gets wether tonemapping is enabled or not.
  110349. */
  110350. /**
  110351. * Sets wether tonemapping is enabled or not
  110352. */
  110353. toneMappingEnabled: boolean;
  110354. /**
  110355. * Gets the type of tone mapping effect.
  110356. */
  110357. /**
  110358. * Sets the type of tone mapping effect.
  110359. */
  110360. toneMappingType: number;
  110361. /**
  110362. * Gets contrast used in the effect.
  110363. */
  110364. /**
  110365. * Sets contrast used in the effect.
  110366. */
  110367. contrast: number;
  110368. /**
  110369. * Gets Vignette stretch size.
  110370. */
  110371. /**
  110372. * Sets Vignette stretch size.
  110373. */
  110374. vignetteStretch: number;
  110375. /**
  110376. * Gets Vignette centre X Offset.
  110377. */
  110378. /**
  110379. * Sets Vignette centre X Offset.
  110380. */
  110381. vignetteCentreX: number;
  110382. /**
  110383. * Gets Vignette centre Y Offset.
  110384. */
  110385. /**
  110386. * Sets Vignette centre Y Offset.
  110387. */
  110388. vignetteCentreY: number;
  110389. /**
  110390. * Gets Vignette weight or intensity of the vignette effect.
  110391. */
  110392. /**
  110393. * Sets Vignette weight or intensity of the vignette effect.
  110394. */
  110395. vignetteWeight: number;
  110396. /**
  110397. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110398. * if vignetteEnabled is set to true.
  110399. */
  110400. /**
  110401. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110402. * if vignetteEnabled is set to true.
  110403. */
  110404. vignetteColor: Color4;
  110405. /**
  110406. * Gets Camera field of view used by the Vignette effect.
  110407. */
  110408. /**
  110409. * Sets Camera field of view used by the Vignette effect.
  110410. */
  110411. vignetteCameraFov: number;
  110412. /**
  110413. * Gets the vignette blend mode allowing different kind of effect.
  110414. */
  110415. /**
  110416. * Sets the vignette blend mode allowing different kind of effect.
  110417. */
  110418. vignetteBlendMode: number;
  110419. /**
  110420. * Gets wether the vignette effect is enabled.
  110421. */
  110422. /**
  110423. * Sets wether the vignette effect is enabled.
  110424. */
  110425. vignetteEnabled: boolean;
  110426. private _fromLinearSpace;
  110427. /**
  110428. * Gets wether the input of the processing is in Gamma or Linear Space.
  110429. */
  110430. /**
  110431. * Sets wether the input of the processing is in Gamma or Linear Space.
  110432. */
  110433. fromLinearSpace: boolean;
  110434. /**
  110435. * Defines cache preventing GC.
  110436. */
  110437. private _defines;
  110438. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110439. /**
  110440. * "ImageProcessingPostProcess"
  110441. * @returns "ImageProcessingPostProcess"
  110442. */
  110443. getClassName(): string;
  110444. protected _updateParameters(): void;
  110445. dispose(camera?: Camera): void;
  110446. }
  110447. }
  110448. declare module BABYLON {
  110449. /**
  110450. * Class containing static functions to help procedurally build meshes
  110451. */
  110452. export class GroundBuilder {
  110453. /**
  110454. * Creates a ground mesh
  110455. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110456. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110458. * @param name defines the name of the mesh
  110459. * @param options defines the options used to create the mesh
  110460. * @param scene defines the hosting scene
  110461. * @returns the ground mesh
  110462. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110463. */
  110464. static CreateGround(name: string, options: {
  110465. width?: number;
  110466. height?: number;
  110467. subdivisions?: number;
  110468. subdivisionsX?: number;
  110469. subdivisionsY?: number;
  110470. updatable?: boolean;
  110471. }, scene: any): Mesh;
  110472. /**
  110473. * Creates a tiled ground mesh
  110474. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110475. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110476. * * 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
  110477. * * 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
  110478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110479. * @param name defines the name of the mesh
  110480. * @param options defines the options used to create the mesh
  110481. * @param scene defines the hosting scene
  110482. * @returns the tiled ground mesh
  110483. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110484. */
  110485. static CreateTiledGround(name: string, options: {
  110486. xmin: number;
  110487. zmin: number;
  110488. xmax: number;
  110489. zmax: number;
  110490. subdivisions?: {
  110491. w: number;
  110492. h: number;
  110493. };
  110494. precision?: {
  110495. w: number;
  110496. h: number;
  110497. };
  110498. updatable?: boolean;
  110499. }, scene?: Nullable<Scene>): Mesh;
  110500. /**
  110501. * Creates a ground mesh from a height map
  110502. * * The parameter `url` sets the URL of the height map image resource.
  110503. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110504. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110505. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110506. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110507. * * 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.
  110508. * * 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).
  110509. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110511. * @param name defines the name of the mesh
  110512. * @param url defines the url to the height map
  110513. * @param options defines the options used to create the mesh
  110514. * @param scene defines the hosting scene
  110515. * @returns the ground mesh
  110516. * @see https://doc.babylonjs.com/babylon101/height_map
  110517. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110518. */
  110519. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110520. width?: number;
  110521. height?: number;
  110522. subdivisions?: number;
  110523. minHeight?: number;
  110524. maxHeight?: number;
  110525. colorFilter?: Color3;
  110526. alphaFilter?: number;
  110527. updatable?: boolean;
  110528. onReady?: (mesh: GroundMesh) => void;
  110529. }, scene?: Nullable<Scene>): GroundMesh;
  110530. }
  110531. }
  110532. declare module BABYLON {
  110533. /**
  110534. * Class containing static functions to help procedurally build meshes
  110535. */
  110536. export class TorusBuilder {
  110537. /**
  110538. * Creates a torus mesh
  110539. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110540. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110541. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110545. * @param name defines the name of the mesh
  110546. * @param options defines the options used to create the mesh
  110547. * @param scene defines the hosting scene
  110548. * @returns the torus mesh
  110549. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110550. */
  110551. static CreateTorus(name: string, options: {
  110552. diameter?: number;
  110553. thickness?: number;
  110554. tessellation?: number;
  110555. updatable?: boolean;
  110556. sideOrientation?: number;
  110557. frontUVs?: Vector4;
  110558. backUVs?: Vector4;
  110559. }, scene: any): Mesh;
  110560. }
  110561. }
  110562. declare module BABYLON {
  110563. /**
  110564. * Class containing static functions to help procedurally build meshes
  110565. */
  110566. export class CylinderBuilder {
  110567. /**
  110568. * Creates a cylinder or a cone mesh
  110569. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110570. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110571. * * 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.
  110572. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110573. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110574. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110575. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110576. * * 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).
  110577. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110578. * * 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).
  110579. * * 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
  110580. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110581. * * 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
  110582. * * 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.
  110583. * * If `enclose` is false, a ring surface is one element.
  110584. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110585. * * 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
  110586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110589. * @param name defines the name of the mesh
  110590. * @param options defines the options used to create the mesh
  110591. * @param scene defines the hosting scene
  110592. * @returns the cylinder mesh
  110593. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110594. */
  110595. static CreateCylinder(name: string, options: {
  110596. height?: number;
  110597. diameterTop?: number;
  110598. diameterBottom?: number;
  110599. diameter?: number;
  110600. tessellation?: number;
  110601. subdivisions?: number;
  110602. arc?: number;
  110603. faceColors?: Color4[];
  110604. faceUV?: Vector4[];
  110605. updatable?: boolean;
  110606. hasRings?: boolean;
  110607. enclose?: boolean;
  110608. cap?: number;
  110609. sideOrientation?: number;
  110610. frontUVs?: Vector4;
  110611. backUVs?: Vector4;
  110612. }, scene: any): Mesh;
  110613. }
  110614. }
  110615. declare module BABYLON {
  110616. /**
  110617. * States of the webXR experience
  110618. */
  110619. export enum WebXRState {
  110620. /**
  110621. * Transitioning to being in XR mode
  110622. */
  110623. ENTERING_XR = 0,
  110624. /**
  110625. * Transitioning to non XR mode
  110626. */
  110627. EXITING_XR = 1,
  110628. /**
  110629. * In XR mode and presenting
  110630. */
  110631. IN_XR = 2,
  110632. /**
  110633. * Not entered XR mode
  110634. */
  110635. NOT_IN_XR = 3
  110636. }
  110637. /**
  110638. * Abstraction of the XR render target
  110639. */
  110640. export interface WebXRRenderTarget extends IDisposable {
  110641. /**
  110642. * xrpresent context of the canvas which can be used to display/mirror xr content
  110643. */
  110644. canvasContext: WebGLRenderingContext;
  110645. /**
  110646. * xr layer for the canvas
  110647. */
  110648. xrLayer: Nullable<XRWebGLLayer>;
  110649. /**
  110650. * Initializes the xr layer for the session
  110651. * @param xrSession xr session
  110652. * @returns a promise that will resolve once the XR Layer has been created
  110653. */
  110654. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110655. }
  110656. }
  110657. declare module BABYLON {
  110658. /**
  110659. * COnfiguration object for WebXR output canvas
  110660. */
  110661. export class WebXRManagedOutputCanvasOptions {
  110662. /**
  110663. * Options for this XR Layer output
  110664. */
  110665. canvasOptions: XRWebGLLayerOptions;
  110666. /**
  110667. * CSS styling for a newly created canvas (if not provided)
  110668. */
  110669. newCanvasCssStyle?: string;
  110670. /**
  110671. * Get the default values of the configuration object
  110672. * @returns default values of this configuration object
  110673. */
  110674. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110675. }
  110676. /**
  110677. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110678. */
  110679. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110680. private configuration;
  110681. private _engine;
  110682. private _canvas;
  110683. /**
  110684. * xrpresent context of the canvas which can be used to display/mirror xr content
  110685. */
  110686. canvasContext: WebGLRenderingContext;
  110687. /**
  110688. * xr layer for the canvas
  110689. */
  110690. xrLayer: Nullable<XRWebGLLayer>;
  110691. /**
  110692. * Initializes the xr layer for the session
  110693. * @param xrSession xr session
  110694. * @returns a promise that will resolve once the XR Layer has been created
  110695. */
  110696. initializeXRLayerAsync(xrSession: any): any;
  110697. /**
  110698. * Initializes the canvas to be added/removed upon entering/exiting xr
  110699. * @param engine the Babylon engine
  110700. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110701. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110702. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110703. */
  110704. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110705. /**
  110706. * Disposes of the object
  110707. */
  110708. dispose(): void;
  110709. private _setManagedOutputCanvas;
  110710. private _addCanvas;
  110711. private _removeCanvas;
  110712. }
  110713. }
  110714. declare module BABYLON {
  110715. /**
  110716. * Manages an XRSession to work with Babylon's engine
  110717. * @see https://doc.babylonjs.com/how_to/webxr
  110718. */
  110719. export class WebXRSessionManager implements IDisposable {
  110720. private scene;
  110721. /**
  110722. * Fires every time a new xrFrame arrives which can be used to update the camera
  110723. */
  110724. onXRFrameObservable: Observable<any>;
  110725. /**
  110726. * Fires when the xr session is ended either by the device or manually done
  110727. */
  110728. onXRSessionEnded: Observable<any>;
  110729. /**
  110730. * Underlying xr session
  110731. */
  110732. session: XRSession;
  110733. /**
  110734. * Type of reference space used when creating the session
  110735. */
  110736. referenceSpace: XRReferenceSpace;
  110737. /**
  110738. * Current XR frame
  110739. */
  110740. currentFrame: Nullable<XRFrame>;
  110741. private _xrNavigator;
  110742. private baseLayer;
  110743. private _rttProvider;
  110744. private _sessionEnded;
  110745. /**
  110746. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110747. * @param scene The scene which the session should be created for
  110748. */
  110749. constructor(scene: Scene);
  110750. /**
  110751. * Initializes the manager
  110752. * After initialization enterXR can be called to start an XR session
  110753. * @returns Promise which resolves after it is initialized
  110754. */
  110755. initializeAsync(): Promise<void>;
  110756. /**
  110757. * Initializes an xr session
  110758. * @param xrSessionMode mode to initialize
  110759. * @param optionalFeatures defines optional values to pass to the session builder
  110760. * @returns a promise which will resolve once the session has been initialized
  110761. */
  110762. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110763. /**
  110764. * Sets the reference space on the xr session
  110765. * @param referenceSpace space to set
  110766. * @returns a promise that will resolve once the reference space has been set
  110767. */
  110768. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110769. /**
  110770. * Updates the render state of the session
  110771. * @param state state to set
  110772. * @returns a promise that resolves once the render state has been updated
  110773. */
  110774. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110775. /**
  110776. * Starts rendering to the xr layer
  110777. * @returns a promise that will resolve once rendering has started
  110778. */
  110779. startRenderingToXRAsync(): Promise<void>;
  110780. /**
  110781. * Gets the correct render target texture to be rendered this frame for this eye
  110782. * @param eye the eye for which to get the render target
  110783. * @returns the render target for the specified eye
  110784. */
  110785. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110786. /**
  110787. * Stops the xrSession and restores the renderloop
  110788. * @returns Promise which resolves after it exits XR
  110789. */
  110790. exitXRAsync(): Promise<void>;
  110791. /**
  110792. * Checks if a session would be supported for the creation options specified
  110793. * @param sessionMode session mode to check if supported eg. immersive-vr
  110794. * @returns true if supported
  110795. */
  110796. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110797. /**
  110798. * Creates a WebXRRenderTarget object for the XR session
  110799. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110800. * @param options optional options to provide when creating a new render target
  110801. * @returns a WebXR render target to which the session can render
  110802. */
  110803. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110804. /**
  110805. * @hidden
  110806. * Converts the render layer of xrSession to a render target
  110807. * @param session session to create render target for
  110808. * @param scene scene the new render target should be created for
  110809. */
  110810. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110811. /**
  110812. * Disposes of the session manager
  110813. */
  110814. dispose(): void;
  110815. /**
  110816. * Gets a promise returning true when fullfiled if the given session mode is supported
  110817. * @param sessionMode defines the session to test
  110818. * @returns a promise
  110819. */
  110820. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110821. }
  110822. }
  110823. declare module BABYLON {
  110824. /**
  110825. * WebXR Camera which holds the views for the xrSession
  110826. * @see https://doc.babylonjs.com/how_to/webxr
  110827. */
  110828. export class WebXRCamera extends FreeCamera {
  110829. /**
  110830. * Is the camera in debug mode. Used when using an emulator
  110831. */
  110832. debugMode: boolean;
  110833. /**
  110834. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110835. * @param name the name of the camera
  110836. * @param scene the scene to add the camera to
  110837. */
  110838. constructor(name: string, scene: Scene);
  110839. private _updateNumberOfRigCameras;
  110840. /** @hidden */
  110841. _updateForDualEyeDebugging(): void;
  110842. /**
  110843. * Updates the cameras position from the current pose information of the XR session
  110844. * @param xrSessionManager the session containing pose information
  110845. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110846. */
  110847. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110848. }
  110849. }
  110850. declare module BABYLON {
  110851. /**
  110852. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110853. * @see https://doc.babylonjs.com/how_to/webxr
  110854. */
  110855. export class WebXRExperienceHelper implements IDisposable {
  110856. private scene;
  110857. /**
  110858. * 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
  110859. */
  110860. container: AbstractMesh;
  110861. /**
  110862. * Camera used to render xr content
  110863. */
  110864. camera: WebXRCamera;
  110865. /**
  110866. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110867. */
  110868. state: WebXRState;
  110869. private _setState;
  110870. private static _TmpVector;
  110871. /**
  110872. * Fires when the state of the experience helper has changed
  110873. */
  110874. onStateChangedObservable: Observable<WebXRState>;
  110875. /** Session manager used to keep track of xr session */
  110876. sessionManager: WebXRSessionManager;
  110877. private _nonVRCamera;
  110878. private _originalSceneAutoClear;
  110879. private _supported;
  110880. /**
  110881. * Creates the experience helper
  110882. * @param scene the scene to attach the experience helper to
  110883. * @returns a promise for the experience helper
  110884. */
  110885. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110886. /**
  110887. * Creates a WebXRExperienceHelper
  110888. * @param scene The scene the helper should be created in
  110889. */
  110890. private constructor();
  110891. /**
  110892. * Exits XR mode and returns the scene to its original state
  110893. * @returns promise that resolves after xr mode has exited
  110894. */
  110895. exitXRAsync(): Promise<void>;
  110896. /**
  110897. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110898. * @param sessionMode options for the XR session
  110899. * @param referenceSpaceType frame of reference of the XR session
  110900. * @param renderTarget the output canvas that will be used to enter XR mode
  110901. * @returns promise that resolves after xr mode has entered
  110902. */
  110903. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110904. /**
  110905. * Updates the global position of the camera by moving the camera's container
  110906. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110907. * @param position The desired global position of the camera
  110908. */
  110909. setPositionOfCameraUsingContainer(position: Vector3): void;
  110910. /**
  110911. * Rotates the xr camera by rotating the camera's container around the camera's position
  110912. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110913. * @param rotation the desired quaternion rotation to apply to the camera
  110914. */
  110915. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110916. /**
  110917. * Disposes of the experience helper
  110918. */
  110919. dispose(): void;
  110920. }
  110921. }
  110922. declare module BABYLON {
  110923. /**
  110924. * Represents an XR input
  110925. */
  110926. export class WebXRController {
  110927. private scene;
  110928. /** The underlying input source for the controller */
  110929. inputSource: XRInputSource;
  110930. private parentContainer;
  110931. /**
  110932. * 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
  110933. */
  110934. grip?: AbstractMesh;
  110935. /**
  110936. * Pointer which can be used to select objects or attach a visible laser to
  110937. */
  110938. pointer: AbstractMesh;
  110939. private _gamepadMode;
  110940. /**
  110941. * If available, this is the gamepad object related to this controller.
  110942. * Using this object it is possible to get click events and trackpad changes of the
  110943. * webxr controller that is currently being used.
  110944. */
  110945. gamepadController?: WebVRController;
  110946. /**
  110947. * Event that fires when the controller is removed/disposed
  110948. */
  110949. onDisposeObservable: Observable<{}>;
  110950. private _tmpQuaternion;
  110951. private _tmpVector;
  110952. /**
  110953. * Creates the controller
  110954. * @see https://doc.babylonjs.com/how_to/webxr
  110955. * @param scene the scene which the controller should be associated to
  110956. * @param inputSource the underlying input source for the controller
  110957. * @param parentContainer parent that the controller meshes should be children of
  110958. */
  110959. constructor(scene: Scene,
  110960. /** The underlying input source for the controller */
  110961. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110962. /**
  110963. * Updates the controller pose based on the given XRFrame
  110964. * @param xrFrame xr frame to update the pose with
  110965. * @param referenceSpace reference space to use
  110966. */
  110967. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110968. /**
  110969. * Gets a world space ray coming from the controller
  110970. * @param result the resulting ray
  110971. */
  110972. getWorldPointerRayToRef(result: Ray): void;
  110973. /**
  110974. * Get the scene associated with this controller
  110975. * @returns the scene object
  110976. */
  110977. getScene(): Scene;
  110978. /**
  110979. * Disposes of the object
  110980. */
  110981. dispose(): void;
  110982. }
  110983. }
  110984. declare module BABYLON {
  110985. /**
  110986. * XR input used to track XR inputs such as controllers/rays
  110987. */
  110988. export class WebXRInput implements IDisposable {
  110989. /**
  110990. * Base experience the input listens to
  110991. */
  110992. baseExperience: WebXRExperienceHelper;
  110993. /**
  110994. * XR controllers being tracked
  110995. */
  110996. controllers: Array<WebXRController>;
  110997. private _frameObserver;
  110998. private _stateObserver;
  110999. /**
  111000. * Event when a controller has been connected/added
  111001. */
  111002. onControllerAddedObservable: Observable<WebXRController>;
  111003. /**
  111004. * Event when a controller has been removed/disconnected
  111005. */
  111006. onControllerRemovedObservable: Observable<WebXRController>;
  111007. /**
  111008. * Initializes the WebXRInput
  111009. * @param baseExperience experience helper which the input should be created for
  111010. */
  111011. constructor(
  111012. /**
  111013. * Base experience the input listens to
  111014. */
  111015. baseExperience: WebXRExperienceHelper);
  111016. private _onInputSourcesChange;
  111017. private _addAndRemoveControllers;
  111018. /**
  111019. * Disposes of the object
  111020. */
  111021. dispose(): void;
  111022. }
  111023. }
  111024. declare module BABYLON {
  111025. /**
  111026. * Class used to represent data loading progression
  111027. */
  111028. export class SceneLoaderProgressEvent {
  111029. /** defines if data length to load can be evaluated */
  111030. readonly lengthComputable: boolean;
  111031. /** defines the loaded data length */
  111032. readonly loaded: number;
  111033. /** defines the data length to load */
  111034. readonly total: number;
  111035. /**
  111036. * Create a new progress event
  111037. * @param lengthComputable defines if data length to load can be evaluated
  111038. * @param loaded defines the loaded data length
  111039. * @param total defines the data length to load
  111040. */
  111041. constructor(
  111042. /** defines if data length to load can be evaluated */
  111043. lengthComputable: boolean,
  111044. /** defines the loaded data length */
  111045. loaded: number,
  111046. /** defines the data length to load */
  111047. total: number);
  111048. /**
  111049. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111050. * @param event defines the source event
  111051. * @returns a new SceneLoaderProgressEvent
  111052. */
  111053. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111054. }
  111055. /**
  111056. * Interface used by SceneLoader plugins to define supported file extensions
  111057. */
  111058. export interface ISceneLoaderPluginExtensions {
  111059. /**
  111060. * Defines the list of supported extensions
  111061. */
  111062. [extension: string]: {
  111063. isBinary: boolean;
  111064. };
  111065. }
  111066. /**
  111067. * Interface used by SceneLoader plugin factory
  111068. */
  111069. export interface ISceneLoaderPluginFactory {
  111070. /**
  111071. * Defines the name of the factory
  111072. */
  111073. name: string;
  111074. /**
  111075. * Function called to create a new plugin
  111076. * @return the new plugin
  111077. */
  111078. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111079. /**
  111080. * The callback that returns true if the data can be directly loaded.
  111081. * @param data string containing the file data
  111082. * @returns if the data can be loaded directly
  111083. */
  111084. canDirectLoad?(data: string): boolean;
  111085. }
  111086. /**
  111087. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111088. */
  111089. export interface ISceneLoaderPluginBase {
  111090. /**
  111091. * The friendly name of this plugin.
  111092. */
  111093. name: string;
  111094. /**
  111095. * The file extensions supported by this plugin.
  111096. */
  111097. extensions: string | ISceneLoaderPluginExtensions;
  111098. /**
  111099. * The callback called when loading from a url.
  111100. * @param scene scene loading this url
  111101. * @param url url to load
  111102. * @param onSuccess callback called when the file successfully loads
  111103. * @param onProgress callback called while file is loading (if the server supports this mode)
  111104. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111105. * @param onError callback called when the file fails to load
  111106. * @returns a file request object
  111107. */
  111108. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111109. /**
  111110. * The callback called when loading from a file object.
  111111. * @param scene scene loading this file
  111112. * @param file defines the file to load
  111113. * @param onSuccess defines the callback to call when data is loaded
  111114. * @param onProgress defines the callback to call during loading process
  111115. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111116. * @param onError defines the callback to call when an error occurs
  111117. * @returns a file request object
  111118. */
  111119. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111120. /**
  111121. * The callback that returns true if the data can be directly loaded.
  111122. * @param data string containing the file data
  111123. * @returns if the data can be loaded directly
  111124. */
  111125. canDirectLoad?(data: string): boolean;
  111126. /**
  111127. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111128. * @param scene scene loading this data
  111129. * @param data string containing the data
  111130. * @returns data to pass to the plugin
  111131. */
  111132. directLoad?(scene: Scene, data: string): any;
  111133. /**
  111134. * The callback that allows custom handling of the root url based on the response url.
  111135. * @param rootUrl the original root url
  111136. * @param responseURL the response url if available
  111137. * @returns the new root url
  111138. */
  111139. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111140. }
  111141. /**
  111142. * Interface used to define a SceneLoader plugin
  111143. */
  111144. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111145. /**
  111146. * Import meshes into a scene.
  111147. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111148. * @param scene The scene to import into
  111149. * @param data The data to import
  111150. * @param rootUrl The root url for scene and resources
  111151. * @param meshes The meshes array to import into
  111152. * @param particleSystems The particle systems array to import into
  111153. * @param skeletons The skeletons array to import into
  111154. * @param onError The callback when import fails
  111155. * @returns True if successful or false otherwise
  111156. */
  111157. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111158. /**
  111159. * Load into a scene.
  111160. * @param scene The scene to load into
  111161. * @param data The data to import
  111162. * @param rootUrl The root url for scene and resources
  111163. * @param onError The callback when import fails
  111164. * @returns True if successful or false otherwise
  111165. */
  111166. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111167. /**
  111168. * Load into an asset container.
  111169. * @param scene The scene to load into
  111170. * @param data The data to import
  111171. * @param rootUrl The root url for scene and resources
  111172. * @param onError The callback when import fails
  111173. * @returns The loaded asset container
  111174. */
  111175. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111176. }
  111177. /**
  111178. * Interface used to define an async SceneLoader plugin
  111179. */
  111180. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111181. /**
  111182. * Import meshes into a scene.
  111183. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111184. * @param scene The scene to import into
  111185. * @param data The data to import
  111186. * @param rootUrl The root url for scene and resources
  111187. * @param onProgress The callback when the load progresses
  111188. * @param fileName Defines the name of the file to load
  111189. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111190. */
  111191. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111192. meshes: AbstractMesh[];
  111193. particleSystems: IParticleSystem[];
  111194. skeletons: Skeleton[];
  111195. animationGroups: AnimationGroup[];
  111196. }>;
  111197. /**
  111198. * Load into a scene.
  111199. * @param scene The scene to load into
  111200. * @param data The data to import
  111201. * @param rootUrl The root url for scene and resources
  111202. * @param onProgress The callback when the load progresses
  111203. * @param fileName Defines the name of the file to load
  111204. * @returns Nothing
  111205. */
  111206. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111207. /**
  111208. * Load into an asset container.
  111209. * @param scene The scene to load into
  111210. * @param data The data to import
  111211. * @param rootUrl The root url for scene and resources
  111212. * @param onProgress The callback when the load progresses
  111213. * @param fileName Defines the name of the file to load
  111214. * @returns The loaded asset container
  111215. */
  111216. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111217. }
  111218. /**
  111219. * Class used to load scene from various file formats using registered plugins
  111220. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111221. */
  111222. export class SceneLoader {
  111223. /**
  111224. * No logging while loading
  111225. */
  111226. static readonly NO_LOGGING: number;
  111227. /**
  111228. * Minimal logging while loading
  111229. */
  111230. static readonly MINIMAL_LOGGING: number;
  111231. /**
  111232. * Summary logging while loading
  111233. */
  111234. static readonly SUMMARY_LOGGING: number;
  111235. /**
  111236. * Detailled logging while loading
  111237. */
  111238. static readonly DETAILED_LOGGING: number;
  111239. /**
  111240. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111241. */
  111242. static ForceFullSceneLoadingForIncremental: boolean;
  111243. /**
  111244. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111245. */
  111246. static ShowLoadingScreen: boolean;
  111247. /**
  111248. * Defines the current logging level (while loading the scene)
  111249. * @ignorenaming
  111250. */
  111251. static loggingLevel: number;
  111252. /**
  111253. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111254. */
  111255. static CleanBoneMatrixWeights: boolean;
  111256. /**
  111257. * Event raised when a plugin is used to load a scene
  111258. */
  111259. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111260. private static _registeredPlugins;
  111261. private static _getDefaultPlugin;
  111262. private static _getPluginForExtension;
  111263. private static _getPluginForDirectLoad;
  111264. private static _getPluginForFilename;
  111265. private static _getDirectLoad;
  111266. private static _loadData;
  111267. private static _getFileInfo;
  111268. /**
  111269. * Gets a plugin that can load the given extension
  111270. * @param extension defines the extension to load
  111271. * @returns a plugin or null if none works
  111272. */
  111273. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111274. /**
  111275. * Gets a boolean indicating that the given extension can be loaded
  111276. * @param extension defines the extension to load
  111277. * @returns true if the extension is supported
  111278. */
  111279. static IsPluginForExtensionAvailable(extension: string): boolean;
  111280. /**
  111281. * Adds a new plugin to the list of registered plugins
  111282. * @param plugin defines the plugin to add
  111283. */
  111284. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111285. /**
  111286. * Import meshes into a scene
  111287. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111288. * @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)
  111289. * @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)
  111290. * @param scene the instance of BABYLON.Scene to append to
  111291. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111292. * @param onProgress a callback with a progress event for each file being loaded
  111293. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111294. * @param pluginExtension the extension used to determine the plugin
  111295. * @returns The loaded plugin
  111296. */
  111297. 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>;
  111298. /**
  111299. * Import meshes into a scene
  111300. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111301. * @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)
  111302. * @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)
  111303. * @param scene the instance of BABYLON.Scene to append to
  111304. * @param onProgress a callback with a progress event for each file being loaded
  111305. * @param pluginExtension the extension used to determine the plugin
  111306. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111307. */
  111308. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111309. meshes: AbstractMesh[];
  111310. particleSystems: IParticleSystem[];
  111311. skeletons: Skeleton[];
  111312. animationGroups: AnimationGroup[];
  111313. }>;
  111314. /**
  111315. * Load a scene
  111316. * @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)
  111317. * @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)
  111318. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111319. * @param onSuccess a callback with the scene when import succeeds
  111320. * @param onProgress a callback with a progress event for each file being loaded
  111321. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111322. * @param pluginExtension the extension used to determine the plugin
  111323. * @returns The loaded plugin
  111324. */
  111325. 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>;
  111326. /**
  111327. * Load a scene
  111328. * @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)
  111329. * @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)
  111330. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111331. * @param onProgress a callback with a progress event for each file being loaded
  111332. * @param pluginExtension the extension used to determine the plugin
  111333. * @returns The loaded scene
  111334. */
  111335. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111336. /**
  111337. * Append a scene
  111338. * @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)
  111339. * @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)
  111340. * @param scene is the instance of BABYLON.Scene to append to
  111341. * @param onSuccess a callback with the scene when import succeeds
  111342. * @param onProgress a callback with a progress event for each file being loaded
  111343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111344. * @param pluginExtension the extension used to determine the plugin
  111345. * @returns The loaded plugin
  111346. */
  111347. 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>;
  111348. /**
  111349. * Append a scene
  111350. * @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)
  111351. * @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)
  111352. * @param scene is the instance of BABYLON.Scene to append to
  111353. * @param onProgress a callback with a progress event for each file being loaded
  111354. * @param pluginExtension the extension used to determine the plugin
  111355. * @returns The given scene
  111356. */
  111357. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111358. /**
  111359. * Load a scene into an asset container
  111360. * @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)
  111361. * @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)
  111362. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111363. * @param onSuccess a callback with the scene when import succeeds
  111364. * @param onProgress a callback with a progress event for each file being loaded
  111365. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111366. * @param pluginExtension the extension used to determine the plugin
  111367. * @returns The loaded plugin
  111368. */
  111369. 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>;
  111370. /**
  111371. * Load a scene into an asset container
  111372. * @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)
  111373. * @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)
  111374. * @param scene is the instance of Scene to append to
  111375. * @param onProgress a callback with a progress event for each file being loaded
  111376. * @param pluginExtension the extension used to determine the plugin
  111377. * @returns The loaded asset container
  111378. */
  111379. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111380. }
  111381. }
  111382. declare module BABYLON {
  111383. /**
  111384. * Generic Controller
  111385. */
  111386. export class GenericController extends WebVRController {
  111387. /**
  111388. * Base Url for the controller model.
  111389. */
  111390. static readonly MODEL_BASE_URL: string;
  111391. /**
  111392. * File name for the controller model.
  111393. */
  111394. static readonly MODEL_FILENAME: string;
  111395. /**
  111396. * Creates a new GenericController from a gamepad
  111397. * @param vrGamepad the gamepad that the controller should be created from
  111398. */
  111399. constructor(vrGamepad: any);
  111400. /**
  111401. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111402. * @param scene scene in which to add meshes
  111403. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111404. */
  111405. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111406. /**
  111407. * Called once for each button that changed state since the last frame
  111408. * @param buttonIdx Which button index changed
  111409. * @param state New state of the button
  111410. * @param changes Which properties on the state changed since last frame
  111411. */
  111412. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111413. }
  111414. }
  111415. declare module BABYLON {
  111416. /**
  111417. * Defines the WindowsMotionController object that the state of the windows motion controller
  111418. */
  111419. export class WindowsMotionController extends WebVRController {
  111420. /**
  111421. * The base url used to load the left and right controller models
  111422. */
  111423. static MODEL_BASE_URL: string;
  111424. /**
  111425. * The name of the left controller model file
  111426. */
  111427. static MODEL_LEFT_FILENAME: string;
  111428. /**
  111429. * The name of the right controller model file
  111430. */
  111431. static MODEL_RIGHT_FILENAME: string;
  111432. /**
  111433. * The controller name prefix for this controller type
  111434. */
  111435. static readonly GAMEPAD_ID_PREFIX: string;
  111436. /**
  111437. * The controller id pattern for this controller type
  111438. */
  111439. private static readonly GAMEPAD_ID_PATTERN;
  111440. private _loadedMeshInfo;
  111441. protected readonly _mapping: {
  111442. buttons: string[];
  111443. buttonMeshNames: {
  111444. 'trigger': string;
  111445. 'menu': string;
  111446. 'grip': string;
  111447. 'thumbstick': string;
  111448. 'trackpad': string;
  111449. };
  111450. buttonObservableNames: {
  111451. 'trigger': string;
  111452. 'menu': string;
  111453. 'grip': string;
  111454. 'thumbstick': string;
  111455. 'trackpad': string;
  111456. };
  111457. axisMeshNames: string[];
  111458. pointingPoseMeshName: string;
  111459. };
  111460. /**
  111461. * Fired when the trackpad on this controller is clicked
  111462. */
  111463. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111464. /**
  111465. * Fired when the trackpad on this controller is modified
  111466. */
  111467. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111468. /**
  111469. * The current x and y values of this controller's trackpad
  111470. */
  111471. trackpad: StickValues;
  111472. /**
  111473. * Creates a new WindowsMotionController from a gamepad
  111474. * @param vrGamepad the gamepad that the controller should be created from
  111475. */
  111476. constructor(vrGamepad: any);
  111477. /**
  111478. * Fired when the trigger on this controller is modified
  111479. */
  111480. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111481. /**
  111482. * Fired when the menu button on this controller is modified
  111483. */
  111484. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111485. /**
  111486. * Fired when the grip button on this controller is modified
  111487. */
  111488. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111489. /**
  111490. * Fired when the thumbstick button on this controller is modified
  111491. */
  111492. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111493. /**
  111494. * Fired when the touchpad button on this controller is modified
  111495. */
  111496. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111497. /**
  111498. * Fired when the touchpad values on this controller are modified
  111499. */
  111500. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111501. protected _updateTrackpad(): void;
  111502. /**
  111503. * Called once per frame by the engine.
  111504. */
  111505. update(): void;
  111506. /**
  111507. * Called once for each button that changed state since the last frame
  111508. * @param buttonIdx Which button index changed
  111509. * @param state New state of the button
  111510. * @param changes Which properties on the state changed since last frame
  111511. */
  111512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111513. /**
  111514. * Moves the buttons on the controller mesh based on their current state
  111515. * @param buttonName the name of the button to move
  111516. * @param buttonValue the value of the button which determines the buttons new position
  111517. */
  111518. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111519. /**
  111520. * Moves the axis on the controller mesh based on its current state
  111521. * @param axis the index of the axis
  111522. * @param axisValue the value of the axis which determines the meshes new position
  111523. * @hidden
  111524. */
  111525. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111526. /**
  111527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111528. * @param scene scene in which to add meshes
  111529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111530. */
  111531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111532. /**
  111533. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111534. * can be transformed by button presses and axes values, based on this._mapping.
  111535. *
  111536. * @param scene scene in which the meshes exist
  111537. * @param meshes list of meshes that make up the controller model to process
  111538. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111539. */
  111540. private processModel;
  111541. private createMeshInfo;
  111542. /**
  111543. * Gets the ray of the controller in the direction the controller is pointing
  111544. * @param length the length the resulting ray should be
  111545. * @returns a ray in the direction the controller is pointing
  111546. */
  111547. getForwardRay(length?: number): Ray;
  111548. /**
  111549. * Disposes of the controller
  111550. */
  111551. dispose(): void;
  111552. }
  111553. /**
  111554. * This class represents a new windows motion controller in XR.
  111555. */
  111556. export class XRWindowsMotionController extends WindowsMotionController {
  111557. /**
  111558. * Changing the original WIndowsMotionController mapping to fir the new mapping
  111559. */
  111560. protected readonly _mapping: {
  111561. buttons: string[];
  111562. buttonMeshNames: {
  111563. 'trigger': string;
  111564. 'menu': string;
  111565. 'grip': string;
  111566. 'thumbstick': string;
  111567. 'trackpad': string;
  111568. };
  111569. buttonObservableNames: {
  111570. 'trigger': string;
  111571. 'menu': string;
  111572. 'grip': string;
  111573. 'thumbstick': string;
  111574. 'trackpad': string;
  111575. };
  111576. axisMeshNames: string[];
  111577. pointingPoseMeshName: string;
  111578. };
  111579. /**
  111580. * Construct a new XR-Based windows motion controller
  111581. *
  111582. * @param gamepadInfo the gamepad object from the browser
  111583. */
  111584. constructor(gamepadInfo: any);
  111585. /**
  111586. * holds the thumbstick values (X,Y)
  111587. */
  111588. thumbstickValues: StickValues;
  111589. /**
  111590. * Fired when the thumbstick on this controller is clicked
  111591. */
  111592. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  111593. /**
  111594. * Fired when the thumbstick on this controller is modified
  111595. */
  111596. onThumbstickValuesChangedObservable: Observable<StickValues>;
  111597. /**
  111598. * Fired when the touchpad button on this controller is modified
  111599. */
  111600. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111601. /**
  111602. * Fired when the touchpad values on this controller are modified
  111603. */
  111604. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111605. /**
  111606. * Fired when the thumbstick button on this controller is modified
  111607. * here to prevent breaking changes
  111608. */
  111609. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111610. /**
  111611. * updating the thumbstick(!) and not the trackpad.
  111612. * This is named this way due to the difference between WebVR and XR and to avoid
  111613. * changing the parent class.
  111614. */
  111615. protected _updateTrackpad(): void;
  111616. /**
  111617. * Disposes the class with joy
  111618. */
  111619. dispose(): void;
  111620. }
  111621. }
  111622. declare module BABYLON {
  111623. /**
  111624. * Oculus Touch Controller
  111625. */
  111626. export class OculusTouchController extends WebVRController {
  111627. /**
  111628. * Base Url for the controller model.
  111629. */
  111630. static MODEL_BASE_URL: string;
  111631. /**
  111632. * File name for the left controller model.
  111633. */
  111634. static MODEL_LEFT_FILENAME: string;
  111635. /**
  111636. * File name for the right controller model.
  111637. */
  111638. static MODEL_RIGHT_FILENAME: string;
  111639. /**
  111640. * Base Url for the Quest controller model.
  111641. */
  111642. static QUEST_MODEL_BASE_URL: string;
  111643. /**
  111644. * @hidden
  111645. * If the controllers are running on a device that needs the updated Quest controller models
  111646. */
  111647. static _IsQuest: boolean;
  111648. /**
  111649. * Fired when the secondary trigger on this controller is modified
  111650. */
  111651. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111652. /**
  111653. * Fired when the thumb rest on this controller is modified
  111654. */
  111655. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111656. /**
  111657. * Creates a new OculusTouchController from a gamepad
  111658. * @param vrGamepad the gamepad that the controller should be created from
  111659. */
  111660. constructor(vrGamepad: any);
  111661. /**
  111662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111663. * @param scene scene in which to add meshes
  111664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111665. */
  111666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111667. /**
  111668. * Fired when the A button on this controller is modified
  111669. */
  111670. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111671. /**
  111672. * Fired when the B button on this controller is modified
  111673. */
  111674. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111675. /**
  111676. * Fired when the X button on this controller is modified
  111677. */
  111678. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111679. /**
  111680. * Fired when the Y button on this controller is modified
  111681. */
  111682. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111683. /**
  111684. * Called once for each button that changed state since the last frame
  111685. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111686. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111687. * 2) secondary trigger (same)
  111688. * 3) A (right) X (left), touch, pressed = value
  111689. * 4) B / Y
  111690. * 5) thumb rest
  111691. * @param buttonIdx Which button index changed
  111692. * @param state New state of the button
  111693. * @param changes Which properties on the state changed since last frame
  111694. */
  111695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111696. }
  111697. }
  111698. declare module BABYLON {
  111699. /**
  111700. * Vive Controller
  111701. */
  111702. export class ViveController extends WebVRController {
  111703. /**
  111704. * Base Url for the controller model.
  111705. */
  111706. static MODEL_BASE_URL: string;
  111707. /**
  111708. * File name for the controller model.
  111709. */
  111710. static MODEL_FILENAME: string;
  111711. /**
  111712. * Creates a new ViveController from a gamepad
  111713. * @param vrGamepad the gamepad that the controller should be created from
  111714. */
  111715. constructor(vrGamepad: any);
  111716. /**
  111717. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111718. * @param scene scene in which to add meshes
  111719. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111720. */
  111721. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111722. /**
  111723. * Fired when the left button on this controller is modified
  111724. */
  111725. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111726. /**
  111727. * Fired when the right button on this controller is modified
  111728. */
  111729. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111730. /**
  111731. * Fired when the menu button on this controller is modified
  111732. */
  111733. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111734. /**
  111735. * Called once for each button that changed state since the last frame
  111736. * Vive mapping:
  111737. * 0: touchpad
  111738. * 1: trigger
  111739. * 2: left AND right buttons
  111740. * 3: menu button
  111741. * @param buttonIdx Which button index changed
  111742. * @param state New state of the button
  111743. * @param changes Which properties on the state changed since last frame
  111744. */
  111745. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111746. }
  111747. }
  111748. declare module BABYLON {
  111749. /**
  111750. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111751. */
  111752. export class WebXRControllerModelLoader {
  111753. /**
  111754. * an observable that triggers when a new model (the mesh itself) was initialized.
  111755. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111756. */
  111757. onControllerModelLoaded: Observable<WebXRController>;
  111758. /**
  111759. * Creates the WebXRControllerModelLoader
  111760. * @param input xr input that creates the controllers
  111761. */
  111762. constructor(input: WebXRInput);
  111763. }
  111764. }
  111765. declare module BABYLON {
  111766. /**
  111767. * Handles pointer input automatically for the pointer of XR controllers
  111768. */
  111769. export class WebXRControllerPointerSelection {
  111770. private static _idCounter;
  111771. private _tmpRay;
  111772. /**
  111773. * Creates a WebXRControllerPointerSelection
  111774. * @param input input manager to setup pointer selection
  111775. */
  111776. constructor(input: WebXRInput);
  111777. private _convertNormalToDirectionOfRay;
  111778. private _updatePointerDistance;
  111779. }
  111780. }
  111781. declare module BABYLON {
  111782. /**
  111783. * Enables teleportation
  111784. */
  111785. export class WebXRControllerTeleportation {
  111786. private _teleportationFillColor;
  111787. private _teleportationBorderColor;
  111788. private _tmpRay;
  111789. private _tmpVector;
  111790. /**
  111791. * Creates a WebXRControllerTeleportation
  111792. * @param input input manager to add teleportation to
  111793. * @param floorMeshes floormeshes which can be teleported to
  111794. */
  111795. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  111796. }
  111797. }
  111798. declare module BABYLON {
  111799. /**
  111800. * Button which can be used to enter a different mode of XR
  111801. */
  111802. export class WebXREnterExitUIButton {
  111803. /** button element */
  111804. element: HTMLElement;
  111805. /** XR initialization options for the button */
  111806. sessionMode: XRSessionMode;
  111807. /** Reference space type */
  111808. referenceSpaceType: XRReferenceSpaceType;
  111809. /**
  111810. * Creates a WebXREnterExitUIButton
  111811. * @param element button element
  111812. * @param sessionMode XR initialization session mode
  111813. * @param referenceSpaceType the type of reference space to be used
  111814. */
  111815. constructor(
  111816. /** button element */
  111817. element: HTMLElement,
  111818. /** XR initialization options for the button */
  111819. sessionMode: XRSessionMode,
  111820. /** Reference space type */
  111821. referenceSpaceType: XRReferenceSpaceType);
  111822. /**
  111823. * Overwritable function which can be used to update the button's visuals when the state changes
  111824. * @param activeButton the current active button in the UI
  111825. */
  111826. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  111827. }
  111828. /**
  111829. * Options to create the webXR UI
  111830. */
  111831. export class WebXREnterExitUIOptions {
  111832. /**
  111833. * Context to enter xr with
  111834. */
  111835. renderTarget?: Nullable<WebXRRenderTarget>;
  111836. /**
  111837. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  111838. */
  111839. customButtons?: Array<WebXREnterExitUIButton>;
  111840. /**
  111841. * A session mode to use when creating the default button.
  111842. * Default is immersive-vr
  111843. */
  111844. sessionMode?: XRSessionMode;
  111845. /**
  111846. * A reference space type to use when creating the default button.
  111847. * Default is local-floor
  111848. */
  111849. referenceSpaceType?: XRReferenceSpaceType;
  111850. }
  111851. /**
  111852. * UI to allow the user to enter/exit XR mode
  111853. */
  111854. export class WebXREnterExitUI implements IDisposable {
  111855. private scene;
  111856. private _overlay;
  111857. private _buttons;
  111858. private _activeButton;
  111859. /**
  111860. * Fired every time the active button is changed.
  111861. *
  111862. * When xr is entered via a button that launches xr that button will be the callback parameter
  111863. *
  111864. * When exiting xr the callback parameter will be null)
  111865. */
  111866. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  111867. /**
  111868. * Creates UI to allow the user to enter/exit XR mode
  111869. * @param scene the scene to add the ui to
  111870. * @param helper the xr experience helper to enter/exit xr with
  111871. * @param options options to configure the UI
  111872. * @returns the created ui
  111873. */
  111874. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  111875. private constructor();
  111876. private _updateButtons;
  111877. /**
  111878. * Disposes of the object
  111879. */
  111880. dispose(): void;
  111881. }
  111882. }
  111883. declare module BABYLON {
  111884. /**
  111885. * Options for the default xr helper
  111886. */
  111887. export class WebXRDefaultExperienceOptions {
  111888. /**
  111889. * Floor meshes that should be used for teleporting
  111890. */
  111891. floorMeshes: Array<AbstractMesh>;
  111892. /**
  111893. * Enable or disable default UI to enter XR
  111894. */
  111895. disableDefaultUI?: boolean;
  111896. /**
  111897. * optional configuration for the output canvas
  111898. */
  111899. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111900. }
  111901. /**
  111902. * Default experience which provides a similar setup to the previous webVRExperience
  111903. */
  111904. export class WebXRDefaultExperience {
  111905. /**
  111906. * Base experience
  111907. */
  111908. baseExperience: WebXRExperienceHelper;
  111909. /**
  111910. * Input experience extension
  111911. */
  111912. input: WebXRInput;
  111913. /**
  111914. * Loads the controller models
  111915. */
  111916. controllerModelLoader: WebXRControllerModelLoader;
  111917. /**
  111918. * Enables laser pointer and selection
  111919. */
  111920. pointerSelection: WebXRControllerPointerSelection;
  111921. /**
  111922. * Enables teleportation
  111923. */
  111924. teleportation: WebXRControllerTeleportation;
  111925. /**
  111926. * Enables ui for enetering/exiting xr
  111927. */
  111928. enterExitUI: WebXREnterExitUI;
  111929. /**
  111930. * Default target xr should render to
  111931. */
  111932. renderTarget: WebXRRenderTarget;
  111933. /**
  111934. * Creates the default xr experience
  111935. * @param scene scene
  111936. * @param options options for basic configuration
  111937. * @returns resulting WebXRDefaultExperience
  111938. */
  111939. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111940. private constructor();
  111941. /**
  111942. * DIsposes of the experience helper
  111943. */
  111944. dispose(): void;
  111945. }
  111946. }
  111947. declare module BABYLON {
  111948. /**
  111949. * Options to modify the vr teleportation behavior.
  111950. */
  111951. export interface VRTeleportationOptions {
  111952. /**
  111953. * The name of the mesh which should be used as the teleportation floor. (default: null)
  111954. */
  111955. floorMeshName?: string;
  111956. /**
  111957. * A list of meshes to be used as the teleportation floor. (default: empty)
  111958. */
  111959. floorMeshes?: Mesh[];
  111960. /**
  111961. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  111962. */
  111963. teleportationMode?: number;
  111964. /**
  111965. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  111966. */
  111967. teleportationTime?: number;
  111968. /**
  111969. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  111970. */
  111971. teleportationSpeed?: number;
  111972. /**
  111973. * The easing function used in the animation or null for Linear. (default CircleEase)
  111974. */
  111975. easingFunction?: EasingFunction;
  111976. }
  111977. /**
  111978. * Options to modify the vr experience helper's behavior.
  111979. */
  111980. export interface VRExperienceHelperOptions extends WebVROptions {
  111981. /**
  111982. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  111983. */
  111984. createDeviceOrientationCamera?: boolean;
  111985. /**
  111986. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  111987. */
  111988. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  111989. /**
  111990. * Uses the main button on the controller to toggle the laser casted. (default: true)
  111991. */
  111992. laserToggle?: boolean;
  111993. /**
  111994. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  111995. */
  111996. floorMeshes?: Mesh[];
  111997. /**
  111998. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  111999. */
  112000. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  112001. /**
  112002. * Defines if WebXR should be used instead of WebVR (if available)
  112003. */
  112004. useXR?: boolean;
  112005. }
  112006. /**
  112007. * Event containing information after VR has been entered
  112008. */
  112009. export class OnAfterEnteringVRObservableEvent {
  112010. /**
  112011. * If entering vr was successful
  112012. */
  112013. success: boolean;
  112014. }
  112015. /**
  112016. * Helps to quickly add VR support to an existing scene.
  112017. * See http://doc.babylonjs.com/how_to/webvr_helper
  112018. */
  112019. export class VRExperienceHelper {
  112020. /** Options to modify the vr experience helper's behavior. */
  112021. webVROptions: VRExperienceHelperOptions;
  112022. private _scene;
  112023. private _position;
  112024. private _btnVR;
  112025. private _btnVRDisplayed;
  112026. private _webVRsupported;
  112027. private _webVRready;
  112028. private _webVRrequesting;
  112029. private _webVRpresenting;
  112030. private _hasEnteredVR;
  112031. private _fullscreenVRpresenting;
  112032. private _inputElement;
  112033. private _webVRCamera;
  112034. private _vrDeviceOrientationCamera;
  112035. private _deviceOrientationCamera;
  112036. private _existingCamera;
  112037. private _onKeyDown;
  112038. private _onVrDisplayPresentChange;
  112039. private _onVRDisplayChanged;
  112040. private _onVRRequestPresentStart;
  112041. private _onVRRequestPresentComplete;
  112042. /**
  112043. * 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)
  112044. */
  112045. enableGazeEvenWhenNoPointerLock: boolean;
  112046. /**
  112047. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112048. */
  112049. exitVROnDoubleTap: boolean;
  112050. /**
  112051. * Observable raised right before entering VR.
  112052. */
  112053. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112054. /**
  112055. * Observable raised when entering VR has completed.
  112056. */
  112057. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112058. /**
  112059. * Observable raised when exiting VR.
  112060. */
  112061. onExitingVRObservable: Observable<VRExperienceHelper>;
  112062. /**
  112063. * Observable raised when controller mesh is loaded.
  112064. */
  112065. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112066. /** Return this.onEnteringVRObservable
  112067. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112068. */
  112069. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112070. /** Return this.onExitingVRObservable
  112071. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112072. */
  112073. readonly onExitingVR: Observable<VRExperienceHelper>;
  112074. /** Return this.onControllerMeshLoadedObservable
  112075. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112076. */
  112077. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112078. private _rayLength;
  112079. private _useCustomVRButton;
  112080. private _teleportationRequested;
  112081. private _teleportActive;
  112082. private _floorMeshName;
  112083. private _floorMeshesCollection;
  112084. private _teleportationMode;
  112085. private _teleportationTime;
  112086. private _teleportationSpeed;
  112087. private _teleportationEasing;
  112088. private _rotationAllowed;
  112089. private _teleportBackwardsVector;
  112090. private _teleportationTarget;
  112091. private _isDefaultTeleportationTarget;
  112092. private _postProcessMove;
  112093. private _teleportationFillColor;
  112094. private _teleportationBorderColor;
  112095. private _rotationAngle;
  112096. private _haloCenter;
  112097. private _cameraGazer;
  112098. private _padSensibilityUp;
  112099. private _padSensibilityDown;
  112100. private _leftController;
  112101. private _rightController;
  112102. /**
  112103. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112104. */
  112105. onNewMeshSelected: Observable<AbstractMesh>;
  112106. /**
  112107. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112108. * This observable will provide the mesh and the controller used to select the mesh
  112109. */
  112110. onMeshSelectedWithController: Observable<{
  112111. mesh: AbstractMesh;
  112112. controller: WebVRController;
  112113. }>;
  112114. /**
  112115. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112116. */
  112117. onNewMeshPicked: Observable<PickingInfo>;
  112118. private _circleEase;
  112119. /**
  112120. * Observable raised before camera teleportation
  112121. */
  112122. onBeforeCameraTeleport: Observable<Vector3>;
  112123. /**
  112124. * Observable raised after camera teleportation
  112125. */
  112126. onAfterCameraTeleport: Observable<Vector3>;
  112127. /**
  112128. * Observable raised when current selected mesh gets unselected
  112129. */
  112130. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112131. private _raySelectionPredicate;
  112132. /**
  112133. * To be optionaly changed by user to define custom ray selection
  112134. */
  112135. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112136. /**
  112137. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112138. */
  112139. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112140. /**
  112141. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112142. */
  112143. teleportationEnabled: boolean;
  112144. private _defaultHeight;
  112145. private _teleportationInitialized;
  112146. private _interactionsEnabled;
  112147. private _interactionsRequested;
  112148. private _displayGaze;
  112149. private _displayLaserPointer;
  112150. /**
  112151. * The mesh used to display where the user is going to teleport.
  112152. */
  112153. /**
  112154. * Sets the mesh to be used to display where the user is going to teleport.
  112155. */
  112156. teleportationTarget: Mesh;
  112157. /**
  112158. * 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
  112159. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112160. * See http://doc.babylonjs.com/resources/baking_transformations
  112161. */
  112162. gazeTrackerMesh: Mesh;
  112163. /**
  112164. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112165. */
  112166. updateGazeTrackerScale: boolean;
  112167. /**
  112168. * If the gaze trackers color should be updated when selecting meshes
  112169. */
  112170. updateGazeTrackerColor: boolean;
  112171. /**
  112172. * If the controller laser color should be updated when selecting meshes
  112173. */
  112174. updateControllerLaserColor: boolean;
  112175. /**
  112176. * The gaze tracking mesh corresponding to the left controller
  112177. */
  112178. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112179. /**
  112180. * The gaze tracking mesh corresponding to the right controller
  112181. */
  112182. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112183. /**
  112184. * If the ray of the gaze should be displayed.
  112185. */
  112186. /**
  112187. * Sets if the ray of the gaze should be displayed.
  112188. */
  112189. displayGaze: boolean;
  112190. /**
  112191. * If the ray of the LaserPointer should be displayed.
  112192. */
  112193. /**
  112194. * Sets if the ray of the LaserPointer should be displayed.
  112195. */
  112196. displayLaserPointer: boolean;
  112197. /**
  112198. * The deviceOrientationCamera used as the camera when not in VR.
  112199. */
  112200. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112201. /**
  112202. * Based on the current WebVR support, returns the current VR camera used.
  112203. */
  112204. readonly currentVRCamera: Nullable<Camera>;
  112205. /**
  112206. * The webVRCamera which is used when in VR.
  112207. */
  112208. readonly webVRCamera: WebVRFreeCamera;
  112209. /**
  112210. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112211. */
  112212. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112213. /**
  112214. * The html button that is used to trigger entering into VR.
  112215. */
  112216. readonly vrButton: Nullable<HTMLButtonElement>;
  112217. private readonly _teleportationRequestInitiated;
  112218. /**
  112219. * Defines wether or not Pointer lock should be requested when switching to
  112220. * full screen.
  112221. */
  112222. requestPointerLockOnFullScreen: boolean;
  112223. /**
  112224. * If asking to force XR, this will be populated with the default xr experience
  112225. */
  112226. xr: WebXRDefaultExperience;
  112227. /**
  112228. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112229. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112230. */
  112231. xrTestDone: boolean;
  112232. /**
  112233. * Instantiates a VRExperienceHelper.
  112234. * Helps to quickly add VR support to an existing scene.
  112235. * @param scene The scene the VRExperienceHelper belongs to.
  112236. * @param webVROptions Options to modify the vr experience helper's behavior.
  112237. */
  112238. constructor(scene: Scene,
  112239. /** Options to modify the vr experience helper's behavior. */
  112240. webVROptions?: VRExperienceHelperOptions);
  112241. private completeVRInit;
  112242. private _onDefaultMeshLoaded;
  112243. private _onResize;
  112244. private _onFullscreenChange;
  112245. /**
  112246. * Gets a value indicating if we are currently in VR mode.
  112247. */
  112248. readonly isInVRMode: boolean;
  112249. private onVrDisplayPresentChange;
  112250. private onVRDisplayChanged;
  112251. private moveButtonToBottomRight;
  112252. private displayVRButton;
  112253. private updateButtonVisibility;
  112254. private _cachedAngularSensibility;
  112255. /**
  112256. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112257. * Otherwise, will use the fullscreen API.
  112258. */
  112259. enterVR(): void;
  112260. /**
  112261. * Attempt to exit VR, or fullscreen.
  112262. */
  112263. exitVR(): void;
  112264. /**
  112265. * The position of the vr experience helper.
  112266. */
  112267. /**
  112268. * Sets the position of the vr experience helper.
  112269. */
  112270. position: Vector3;
  112271. /**
  112272. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112273. */
  112274. enableInteractions(): void;
  112275. private readonly _noControllerIsActive;
  112276. private beforeRender;
  112277. private _isTeleportationFloor;
  112278. /**
  112279. * Adds a floor mesh to be used for teleportation.
  112280. * @param floorMesh the mesh to be used for teleportation.
  112281. */
  112282. addFloorMesh(floorMesh: Mesh): void;
  112283. /**
  112284. * Removes a floor mesh from being used for teleportation.
  112285. * @param floorMesh the mesh to be removed.
  112286. */
  112287. removeFloorMesh(floorMesh: Mesh): void;
  112288. /**
  112289. * Enables interactions and teleportation using the VR controllers and gaze.
  112290. * @param vrTeleportationOptions options to modify teleportation behavior.
  112291. */
  112292. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112293. private _onNewGamepadConnected;
  112294. private _tryEnableInteractionOnController;
  112295. private _onNewGamepadDisconnected;
  112296. private _enableInteractionOnController;
  112297. private _checkTeleportWithRay;
  112298. private _checkRotate;
  112299. private _checkTeleportBackwards;
  112300. private _enableTeleportationOnController;
  112301. private _createTeleportationCircles;
  112302. private _displayTeleportationTarget;
  112303. private _hideTeleportationTarget;
  112304. private _rotateCamera;
  112305. private _moveTeleportationSelectorTo;
  112306. private _workingVector;
  112307. private _workingQuaternion;
  112308. private _workingMatrix;
  112309. /**
  112310. * Time Constant Teleportation Mode
  112311. */
  112312. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112313. /**
  112314. * Speed Constant Teleportation Mode
  112315. */
  112316. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112317. /**
  112318. * Teleports the users feet to the desired location
  112319. * @param location The location where the user's feet should be placed
  112320. */
  112321. teleportCamera(location: Vector3): void;
  112322. private _convertNormalToDirectionOfRay;
  112323. private _castRayAndSelectObject;
  112324. private _notifySelectedMeshUnselected;
  112325. /**
  112326. * Sets the color of the laser ray from the vr controllers.
  112327. * @param color new color for the ray.
  112328. */
  112329. changeLaserColor(color: Color3): void;
  112330. /**
  112331. * Sets the color of the ray from the vr headsets gaze.
  112332. * @param color new color for the ray.
  112333. */
  112334. changeGazeColor(color: Color3): void;
  112335. /**
  112336. * Exits VR and disposes of the vr experience helper
  112337. */
  112338. dispose(): void;
  112339. /**
  112340. * Gets the name of the VRExperienceHelper class
  112341. * @returns "VRExperienceHelper"
  112342. */
  112343. getClassName(): string;
  112344. }
  112345. }
  112346. declare module BABYLON {
  112347. /**
  112348. * Contains an array of blocks representing the octree
  112349. */
  112350. export interface IOctreeContainer<T> {
  112351. /**
  112352. * Blocks within the octree
  112353. */
  112354. blocks: Array<OctreeBlock<T>>;
  112355. }
  112356. /**
  112357. * Class used to store a cell in an octree
  112358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112359. */
  112360. export class OctreeBlock<T> {
  112361. /**
  112362. * Gets the content of the current block
  112363. */
  112364. entries: T[];
  112365. /**
  112366. * Gets the list of block children
  112367. */
  112368. blocks: Array<OctreeBlock<T>>;
  112369. private _depth;
  112370. private _maxDepth;
  112371. private _capacity;
  112372. private _minPoint;
  112373. private _maxPoint;
  112374. private _boundingVectors;
  112375. private _creationFunc;
  112376. /**
  112377. * Creates a new block
  112378. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112379. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112380. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112381. * @param depth defines the current depth of this block in the octree
  112382. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112383. * @param creationFunc defines a callback to call when an element is added to the block
  112384. */
  112385. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112386. /**
  112387. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112388. */
  112389. readonly capacity: number;
  112390. /**
  112391. * Gets the minimum vector (in world space) of the block's bounding box
  112392. */
  112393. readonly minPoint: Vector3;
  112394. /**
  112395. * Gets the maximum vector (in world space) of the block's bounding box
  112396. */
  112397. readonly maxPoint: Vector3;
  112398. /**
  112399. * Add a new element to this block
  112400. * @param entry defines the element to add
  112401. */
  112402. addEntry(entry: T): void;
  112403. /**
  112404. * Remove an element from this block
  112405. * @param entry defines the element to remove
  112406. */
  112407. removeEntry(entry: T): void;
  112408. /**
  112409. * Add an array of elements to this block
  112410. * @param entries defines the array of elements to add
  112411. */
  112412. addEntries(entries: T[]): void;
  112413. /**
  112414. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  112415. * @param frustumPlanes defines the frustum planes to test
  112416. * @param selection defines the array to store current content if selection is positive
  112417. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112418. */
  112419. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112420. /**
  112421. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  112422. * @param sphereCenter defines the bounding sphere center
  112423. * @param sphereRadius defines the bounding sphere radius
  112424. * @param selection defines the array to store current content if selection is positive
  112425. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112426. */
  112427. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112428. /**
  112429. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  112430. * @param ray defines the ray to test with
  112431. * @param selection defines the array to store current content if selection is positive
  112432. */
  112433. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  112434. /**
  112435. * Subdivide the content into child blocks (this block will then be empty)
  112436. */
  112437. createInnerBlocks(): void;
  112438. /**
  112439. * @hidden
  112440. */
  112441. 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;
  112442. }
  112443. }
  112444. declare module BABYLON {
  112445. /**
  112446. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  112447. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112448. */
  112449. export class Octree<T> {
  112450. /** 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.) */
  112451. maxDepth: number;
  112452. /**
  112453. * Blocks within the octree containing objects
  112454. */
  112455. blocks: Array<OctreeBlock<T>>;
  112456. /**
  112457. * Content stored in the octree
  112458. */
  112459. dynamicContent: T[];
  112460. private _maxBlockCapacity;
  112461. private _selectionContent;
  112462. private _creationFunc;
  112463. /**
  112464. * Creates a octree
  112465. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112466. * @param creationFunc function to be used to instatiate the octree
  112467. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  112468. * @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.)
  112469. */
  112470. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  112471. /** 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.) */
  112472. maxDepth?: number);
  112473. /**
  112474. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  112475. * @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);
  112476. * @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);
  112477. * @param entries meshes to be added to the octree blocks
  112478. */
  112479. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  112480. /**
  112481. * Adds a mesh to the octree
  112482. * @param entry Mesh to add to the octree
  112483. */
  112484. addMesh(entry: T): void;
  112485. /**
  112486. * Remove an element from the octree
  112487. * @param entry defines the element to remove
  112488. */
  112489. removeMesh(entry: T): void;
  112490. /**
  112491. * Selects an array of meshes within the frustum
  112492. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112493. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112494. * @returns array of meshes within the frustum
  112495. */
  112496. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112497. /**
  112498. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112499. * @param sphereCenter defines the bounding sphere center
  112500. * @param sphereRadius defines the bounding sphere radius
  112501. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112502. * @returns an array of objects that intersect the sphere
  112503. */
  112504. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112505. /**
  112506. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112507. * @param ray defines the ray to test with
  112508. * @returns array of intersected objects
  112509. */
  112510. intersectsRay(ray: Ray): SmartArray<T>;
  112511. /**
  112512. * Adds a mesh into the octree block if it intersects the block
  112513. */
  112514. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112515. /**
  112516. * Adds a submesh into the octree block if it intersects the block
  112517. */
  112518. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112519. }
  112520. }
  112521. declare module BABYLON {
  112522. interface Scene {
  112523. /**
  112524. * @hidden
  112525. * Backing Filed
  112526. */
  112527. _selectionOctree: Octree<AbstractMesh>;
  112528. /**
  112529. * Gets the octree used to boost mesh selection (picking)
  112530. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112531. */
  112532. selectionOctree: Octree<AbstractMesh>;
  112533. /**
  112534. * Creates or updates the octree used to boost selection (picking)
  112535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112536. * @param maxCapacity defines the maximum capacity per leaf
  112537. * @param maxDepth defines the maximum depth of the octree
  112538. * @returns an octree of AbstractMesh
  112539. */
  112540. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112541. }
  112542. interface AbstractMesh {
  112543. /**
  112544. * @hidden
  112545. * Backing Field
  112546. */
  112547. _submeshesOctree: Octree<SubMesh>;
  112548. /**
  112549. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112550. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112551. * @param maxCapacity defines the maximum size of each block (64 by default)
  112552. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112553. * @returns the new octree
  112554. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112555. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112556. */
  112557. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112558. }
  112559. /**
  112560. * Defines the octree scene component responsible to manage any octrees
  112561. * in a given scene.
  112562. */
  112563. export class OctreeSceneComponent {
  112564. /**
  112565. * The component name help to identify the component in the list of scene components.
  112566. */
  112567. readonly name: string;
  112568. /**
  112569. * The scene the component belongs to.
  112570. */
  112571. scene: Scene;
  112572. /**
  112573. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112574. */
  112575. readonly checksIsEnabled: boolean;
  112576. /**
  112577. * Creates a new instance of the component for the given scene
  112578. * @param scene Defines the scene to register the component in
  112579. */
  112580. constructor(scene: Scene);
  112581. /**
  112582. * Registers the component in a given scene
  112583. */
  112584. register(): void;
  112585. /**
  112586. * Return the list of active meshes
  112587. * @returns the list of active meshes
  112588. */
  112589. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112590. /**
  112591. * Return the list of active sub meshes
  112592. * @param mesh The mesh to get the candidates sub meshes from
  112593. * @returns the list of active sub meshes
  112594. */
  112595. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112596. private _tempRay;
  112597. /**
  112598. * Return the list of sub meshes intersecting with a given local ray
  112599. * @param mesh defines the mesh to find the submesh for
  112600. * @param localRay defines the ray in local space
  112601. * @returns the list of intersecting sub meshes
  112602. */
  112603. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112604. /**
  112605. * Return the list of sub meshes colliding with a collider
  112606. * @param mesh defines the mesh to find the submesh for
  112607. * @param collider defines the collider to evaluate the collision against
  112608. * @returns the list of colliding sub meshes
  112609. */
  112610. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112611. /**
  112612. * Rebuilds the elements related to this component in case of
  112613. * context lost for instance.
  112614. */
  112615. rebuild(): void;
  112616. /**
  112617. * Disposes the component and the associated ressources.
  112618. */
  112619. dispose(): void;
  112620. }
  112621. }
  112622. declare module BABYLON {
  112623. /**
  112624. * Renders a layer on top of an existing scene
  112625. */
  112626. export class UtilityLayerRenderer implements IDisposable {
  112627. /** the original scene that will be rendered on top of */
  112628. originalScene: Scene;
  112629. private _pointerCaptures;
  112630. private _lastPointerEvents;
  112631. private static _DefaultUtilityLayer;
  112632. private static _DefaultKeepDepthUtilityLayer;
  112633. private _sharedGizmoLight;
  112634. private _renderCamera;
  112635. /**
  112636. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112637. * @returns the camera that is used when rendering the utility layer
  112638. */
  112639. getRenderCamera(): Nullable<Camera>;
  112640. /**
  112641. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112642. * @param cam the camera that should be used when rendering the utility layer
  112643. */
  112644. setRenderCamera(cam: Nullable<Camera>): void;
  112645. /**
  112646. * @hidden
  112647. * Light which used by gizmos to get light shading
  112648. */
  112649. _getSharedGizmoLight(): HemisphericLight;
  112650. /**
  112651. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112652. */
  112653. pickUtilitySceneFirst: boolean;
  112654. /**
  112655. * 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)
  112656. */
  112657. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  112658. /**
  112659. * 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)
  112660. */
  112661. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112662. /**
  112663. * The scene that is rendered on top of the original scene
  112664. */
  112665. utilityLayerScene: Scene;
  112666. /**
  112667. * If the utility layer should automatically be rendered on top of existing scene
  112668. */
  112669. shouldRender: boolean;
  112670. /**
  112671. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112672. */
  112673. onlyCheckPointerDownEvents: boolean;
  112674. /**
  112675. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112676. */
  112677. processAllEvents: boolean;
  112678. /**
  112679. * Observable raised when the pointer move from the utility layer scene to the main scene
  112680. */
  112681. onPointerOutObservable: Observable<number>;
  112682. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112683. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112684. private _afterRenderObserver;
  112685. private _sceneDisposeObserver;
  112686. private _originalPointerObserver;
  112687. /**
  112688. * Instantiates a UtilityLayerRenderer
  112689. * @param originalScene the original scene that will be rendered on top of
  112690. * @param handleEvents boolean indicating if the utility layer should handle events
  112691. */
  112692. constructor(
  112693. /** the original scene that will be rendered on top of */
  112694. originalScene: Scene, handleEvents?: boolean);
  112695. private _notifyObservers;
  112696. /**
  112697. * Renders the utility layers scene on top of the original scene
  112698. */
  112699. render(): void;
  112700. /**
  112701. * Disposes of the renderer
  112702. */
  112703. dispose(): void;
  112704. private _updateCamera;
  112705. }
  112706. }
  112707. declare module BABYLON {
  112708. /**
  112709. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112710. */
  112711. export class Gizmo implements IDisposable {
  112712. /** The utility layer the gizmo will be added to */
  112713. gizmoLayer: UtilityLayerRenderer;
  112714. /**
  112715. * The root mesh of the gizmo
  112716. */
  112717. _rootMesh: Mesh;
  112718. private _attachedMesh;
  112719. /**
  112720. * Ratio for the scale of the gizmo (Default: 1)
  112721. */
  112722. scaleRatio: number;
  112723. /**
  112724. * If a custom mesh has been set (Default: false)
  112725. */
  112726. protected _customMeshSet: boolean;
  112727. /**
  112728. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112729. * * When set, interactions will be enabled
  112730. */
  112731. attachedMesh: Nullable<AbstractMesh>;
  112732. /**
  112733. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112734. * @param mesh The mesh to replace the default mesh of the gizmo
  112735. */
  112736. setCustomMesh(mesh: Mesh): void;
  112737. /**
  112738. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112739. */
  112740. updateGizmoRotationToMatchAttachedMesh: boolean;
  112741. /**
  112742. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112743. */
  112744. updateGizmoPositionToMatchAttachedMesh: boolean;
  112745. /**
  112746. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112747. */
  112748. updateScale: boolean;
  112749. protected _interactionsEnabled: boolean;
  112750. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112751. private _beforeRenderObserver;
  112752. private _tempVector;
  112753. /**
  112754. * Creates a gizmo
  112755. * @param gizmoLayer The utility layer the gizmo will be added to
  112756. */
  112757. constructor(
  112758. /** The utility layer the gizmo will be added to */
  112759. gizmoLayer?: UtilityLayerRenderer);
  112760. /**
  112761. * Updates the gizmo to match the attached mesh's position/rotation
  112762. */
  112763. protected _update(): void;
  112764. /**
  112765. * Disposes of the gizmo
  112766. */
  112767. dispose(): void;
  112768. }
  112769. }
  112770. declare module BABYLON {
  112771. /**
  112772. * Single plane drag gizmo
  112773. */
  112774. export class PlaneDragGizmo extends Gizmo {
  112775. /**
  112776. * Drag behavior responsible for the gizmos dragging interactions
  112777. */
  112778. dragBehavior: PointerDragBehavior;
  112779. private _pointerObserver;
  112780. /**
  112781. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112782. */
  112783. snapDistance: number;
  112784. /**
  112785. * Event that fires each time the gizmo snaps to a new location.
  112786. * * snapDistance is the the change in distance
  112787. */
  112788. onSnapObservable: Observable<{
  112789. snapDistance: number;
  112790. }>;
  112791. private _plane;
  112792. private _coloredMaterial;
  112793. private _hoverMaterial;
  112794. private _isEnabled;
  112795. private _parent;
  112796. /** @hidden */
  112797. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112798. /** @hidden */
  112799. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112800. /**
  112801. * Creates a PlaneDragGizmo
  112802. * @param gizmoLayer The utility layer the gizmo will be added to
  112803. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112804. * @param color The color of the gizmo
  112805. */
  112806. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112807. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112808. /**
  112809. * If the gizmo is enabled
  112810. */
  112811. isEnabled: boolean;
  112812. /**
  112813. * Disposes of the gizmo
  112814. */
  112815. dispose(): void;
  112816. }
  112817. }
  112818. declare module BABYLON {
  112819. /**
  112820. * Gizmo that enables dragging a mesh along 3 axis
  112821. */
  112822. export class PositionGizmo extends Gizmo {
  112823. /**
  112824. * Internal gizmo used for interactions on the x axis
  112825. */
  112826. xGizmo: AxisDragGizmo;
  112827. /**
  112828. * Internal gizmo used for interactions on the y axis
  112829. */
  112830. yGizmo: AxisDragGizmo;
  112831. /**
  112832. * Internal gizmo used for interactions on the z axis
  112833. */
  112834. zGizmo: AxisDragGizmo;
  112835. /**
  112836. * Internal gizmo used for interactions on the yz plane
  112837. */
  112838. xPlaneGizmo: PlaneDragGizmo;
  112839. /**
  112840. * Internal gizmo used for interactions on the xz plane
  112841. */
  112842. yPlaneGizmo: PlaneDragGizmo;
  112843. /**
  112844. * Internal gizmo used for interactions on the xy plane
  112845. */
  112846. zPlaneGizmo: PlaneDragGizmo;
  112847. /**
  112848. * private variables
  112849. */
  112850. private _meshAttached;
  112851. private _updateGizmoRotationToMatchAttachedMesh;
  112852. private _snapDistance;
  112853. private _scaleRatio;
  112854. /** Fires an event when any of it's sub gizmos are dragged */
  112855. onDragStartObservable: Observable<unknown>;
  112856. /** Fires an event when any of it's sub gizmos are released from dragging */
  112857. onDragEndObservable: Observable<unknown>;
  112858. /**
  112859. * If set to true, planar drag is enabled
  112860. */
  112861. private _planarGizmoEnabled;
  112862. attachedMesh: Nullable<AbstractMesh>;
  112863. /**
  112864. * Creates a PositionGizmo
  112865. * @param gizmoLayer The utility layer the gizmo will be added to
  112866. */
  112867. constructor(gizmoLayer?: UtilityLayerRenderer);
  112868. /**
  112869. * If the planar drag gizmo is enabled
  112870. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112871. */
  112872. planarGizmoEnabled: boolean;
  112873. updateGizmoRotationToMatchAttachedMesh: boolean;
  112874. /**
  112875. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112876. */
  112877. snapDistance: number;
  112878. /**
  112879. * Ratio for the scale of the gizmo (Default: 1)
  112880. */
  112881. scaleRatio: number;
  112882. /**
  112883. * Disposes of the gizmo
  112884. */
  112885. dispose(): void;
  112886. /**
  112887. * CustomMeshes are not supported by this gizmo
  112888. * @param mesh The mesh to replace the default mesh of the gizmo
  112889. */
  112890. setCustomMesh(mesh: Mesh): void;
  112891. }
  112892. }
  112893. declare module BABYLON {
  112894. /**
  112895. * Single axis drag gizmo
  112896. */
  112897. export class AxisDragGizmo extends Gizmo {
  112898. /**
  112899. * Drag behavior responsible for the gizmos dragging interactions
  112900. */
  112901. dragBehavior: PointerDragBehavior;
  112902. private _pointerObserver;
  112903. /**
  112904. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112905. */
  112906. snapDistance: number;
  112907. /**
  112908. * Event that fires each time the gizmo snaps to a new location.
  112909. * * snapDistance is the the change in distance
  112910. */
  112911. onSnapObservable: Observable<{
  112912. snapDistance: number;
  112913. }>;
  112914. private _isEnabled;
  112915. private _parent;
  112916. private _arrow;
  112917. private _coloredMaterial;
  112918. private _hoverMaterial;
  112919. /** @hidden */
  112920. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112921. /** @hidden */
  112922. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112923. /**
  112924. * Creates an AxisDragGizmo
  112925. * @param gizmoLayer The utility layer the gizmo will be added to
  112926. * @param dragAxis The axis which the gizmo will be able to drag on
  112927. * @param color The color of the gizmo
  112928. */
  112929. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112930. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112931. /**
  112932. * If the gizmo is enabled
  112933. */
  112934. isEnabled: boolean;
  112935. /**
  112936. * Disposes of the gizmo
  112937. */
  112938. dispose(): void;
  112939. }
  112940. }
  112941. declare module BABYLON.Debug {
  112942. /**
  112943. * The Axes viewer will show 3 axes in a specific point in space
  112944. */
  112945. export class AxesViewer {
  112946. private _xAxis;
  112947. private _yAxis;
  112948. private _zAxis;
  112949. private _scaleLinesFactor;
  112950. private _instanced;
  112951. /**
  112952. * Gets the hosting scene
  112953. */
  112954. scene: Scene;
  112955. /**
  112956. * Gets or sets a number used to scale line length
  112957. */
  112958. scaleLines: number;
  112959. /** Gets the node hierarchy used to render x-axis */
  112960. readonly xAxis: TransformNode;
  112961. /** Gets the node hierarchy used to render y-axis */
  112962. readonly yAxis: TransformNode;
  112963. /** Gets the node hierarchy used to render z-axis */
  112964. readonly zAxis: TransformNode;
  112965. /**
  112966. * Creates a new AxesViewer
  112967. * @param scene defines the hosting scene
  112968. * @param scaleLines defines a number used to scale line length (1 by default)
  112969. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112970. * @param xAxis defines the node hierarchy used to render the x-axis
  112971. * @param yAxis defines the node hierarchy used to render the y-axis
  112972. * @param zAxis defines the node hierarchy used to render the z-axis
  112973. */
  112974. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112975. /**
  112976. * Force the viewer to update
  112977. * @param position defines the position of the viewer
  112978. * @param xaxis defines the x axis of the viewer
  112979. * @param yaxis defines the y axis of the viewer
  112980. * @param zaxis defines the z axis of the viewer
  112981. */
  112982. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112983. /**
  112984. * Creates an instance of this axes viewer.
  112985. * @returns a new axes viewer with instanced meshes
  112986. */
  112987. createInstance(): AxesViewer;
  112988. /** Releases resources */
  112989. dispose(): void;
  112990. private static _SetRenderingGroupId;
  112991. }
  112992. }
  112993. declare module BABYLON.Debug {
  112994. /**
  112995. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112996. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112997. */
  112998. export class BoneAxesViewer extends AxesViewer {
  112999. /**
  113000. * Gets or sets the target mesh where to display the axes viewer
  113001. */
  113002. mesh: Nullable<Mesh>;
  113003. /**
  113004. * Gets or sets the target bone where to display the axes viewer
  113005. */
  113006. bone: Nullable<Bone>;
  113007. /** Gets current position */
  113008. pos: Vector3;
  113009. /** Gets direction of X axis */
  113010. xaxis: Vector3;
  113011. /** Gets direction of Y axis */
  113012. yaxis: Vector3;
  113013. /** Gets direction of Z axis */
  113014. zaxis: Vector3;
  113015. /**
  113016. * Creates a new BoneAxesViewer
  113017. * @param scene defines the hosting scene
  113018. * @param bone defines the target bone
  113019. * @param mesh defines the target mesh
  113020. * @param scaleLines defines a scaling factor for line length (1 by default)
  113021. */
  113022. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  113023. /**
  113024. * Force the viewer to update
  113025. */
  113026. update(): void;
  113027. /** Releases resources */
  113028. dispose(): void;
  113029. }
  113030. }
  113031. declare module BABYLON {
  113032. /**
  113033. * Interface used to define scene explorer extensibility option
  113034. */
  113035. export interface IExplorerExtensibilityOption {
  113036. /**
  113037. * Define the option label
  113038. */
  113039. label: string;
  113040. /**
  113041. * Defines the action to execute on click
  113042. */
  113043. action: (entity: any) => void;
  113044. }
  113045. /**
  113046. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113047. */
  113048. export interface IExplorerExtensibilityGroup {
  113049. /**
  113050. * Defines a predicate to test if a given type mut be extended
  113051. */
  113052. predicate: (entity: any) => boolean;
  113053. /**
  113054. * Gets the list of options added to a type
  113055. */
  113056. entries: IExplorerExtensibilityOption[];
  113057. }
  113058. /**
  113059. * Interface used to define the options to use to create the Inspector
  113060. */
  113061. export interface IInspectorOptions {
  113062. /**
  113063. * Display in overlay mode (default: false)
  113064. */
  113065. overlay?: boolean;
  113066. /**
  113067. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113068. */
  113069. globalRoot?: HTMLElement;
  113070. /**
  113071. * Display the Scene explorer
  113072. */
  113073. showExplorer?: boolean;
  113074. /**
  113075. * Display the property inspector
  113076. */
  113077. showInspector?: boolean;
  113078. /**
  113079. * Display in embed mode (both panes on the right)
  113080. */
  113081. embedMode?: boolean;
  113082. /**
  113083. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113084. */
  113085. handleResize?: boolean;
  113086. /**
  113087. * Allow the panes to popup (default: true)
  113088. */
  113089. enablePopup?: boolean;
  113090. /**
  113091. * Allow the panes to be closed by users (default: true)
  113092. */
  113093. enableClose?: boolean;
  113094. /**
  113095. * Optional list of extensibility entries
  113096. */
  113097. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113098. /**
  113099. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113100. */
  113101. inspectorURL?: string;
  113102. }
  113103. interface Scene {
  113104. /**
  113105. * @hidden
  113106. * Backing field
  113107. */
  113108. _debugLayer: DebugLayer;
  113109. /**
  113110. * Gets the debug layer (aka Inspector) associated with the scene
  113111. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113112. */
  113113. debugLayer: DebugLayer;
  113114. }
  113115. /**
  113116. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113117. * what is happening in your scene
  113118. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113119. */
  113120. export class DebugLayer {
  113121. /**
  113122. * Define the url to get the inspector script from.
  113123. * By default it uses the babylonjs CDN.
  113124. * @ignoreNaming
  113125. */
  113126. static InspectorURL: string;
  113127. private _scene;
  113128. private BJSINSPECTOR;
  113129. private _onPropertyChangedObservable?;
  113130. /**
  113131. * Observable triggered when a property is changed through the inspector.
  113132. */
  113133. readonly onPropertyChangedObservable: any;
  113134. /**
  113135. * Instantiates a new debug layer.
  113136. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113137. * what is happening in your scene
  113138. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113139. * @param scene Defines the scene to inspect
  113140. */
  113141. constructor(scene: Scene);
  113142. /** Creates the inspector window. */
  113143. private _createInspector;
  113144. /**
  113145. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113146. * @param entity defines the entity to select
  113147. * @param lineContainerTitle defines the specific block to highlight
  113148. */
  113149. select(entity: any, lineContainerTitle?: string): void;
  113150. /** Get the inspector from bundle or global */
  113151. private _getGlobalInspector;
  113152. /**
  113153. * Get if the inspector is visible or not.
  113154. * @returns true if visible otherwise, false
  113155. */
  113156. isVisible(): boolean;
  113157. /**
  113158. * Hide the inspector and close its window.
  113159. */
  113160. hide(): void;
  113161. /**
  113162. * Launch the debugLayer.
  113163. * @param config Define the configuration of the inspector
  113164. * @return a promise fulfilled when the debug layer is visible
  113165. */
  113166. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113167. }
  113168. }
  113169. declare module BABYLON {
  113170. /**
  113171. * Class containing static functions to help procedurally build meshes
  113172. */
  113173. export class BoxBuilder {
  113174. /**
  113175. * Creates a box mesh
  113176. * * The parameter `size` sets the size (float) of each box side (default 1)
  113177. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113178. * * 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)
  113179. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113183. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113184. * @param name defines the name of the mesh
  113185. * @param options defines the options used to create the mesh
  113186. * @param scene defines the hosting scene
  113187. * @returns the box mesh
  113188. */
  113189. static CreateBox(name: string, options: {
  113190. size?: number;
  113191. width?: number;
  113192. height?: number;
  113193. depth?: number;
  113194. faceUV?: Vector4[];
  113195. faceColors?: Color4[];
  113196. sideOrientation?: number;
  113197. frontUVs?: Vector4;
  113198. backUVs?: Vector4;
  113199. wrap?: boolean;
  113200. topBaseAt?: number;
  113201. bottomBaseAt?: number;
  113202. updatable?: boolean;
  113203. }, scene?: Nullable<Scene>): Mesh;
  113204. }
  113205. }
  113206. declare module BABYLON {
  113207. /**
  113208. * Class containing static functions to help procedurally build meshes
  113209. */
  113210. export class SphereBuilder {
  113211. /**
  113212. * Creates a sphere mesh
  113213. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113214. * * 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`)
  113215. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113216. * * 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
  113217. * * 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)
  113218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113221. * @param name defines the name of the mesh
  113222. * @param options defines the options used to create the mesh
  113223. * @param scene defines the hosting scene
  113224. * @returns the sphere mesh
  113225. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113226. */
  113227. static CreateSphere(name: string, options: {
  113228. segments?: number;
  113229. diameter?: number;
  113230. diameterX?: number;
  113231. diameterY?: number;
  113232. diameterZ?: number;
  113233. arc?: number;
  113234. slice?: number;
  113235. sideOrientation?: number;
  113236. frontUVs?: Vector4;
  113237. backUVs?: Vector4;
  113238. updatable?: boolean;
  113239. }, scene?: Nullable<Scene>): Mesh;
  113240. }
  113241. }
  113242. declare module BABYLON.Debug {
  113243. /**
  113244. * Used to show the physics impostor around the specific mesh
  113245. */
  113246. export class PhysicsViewer {
  113247. /** @hidden */
  113248. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113249. /** @hidden */
  113250. protected _meshes: Array<Nullable<AbstractMesh>>;
  113251. /** @hidden */
  113252. protected _scene: Nullable<Scene>;
  113253. /** @hidden */
  113254. protected _numMeshes: number;
  113255. /** @hidden */
  113256. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113257. private _renderFunction;
  113258. private _utilityLayer;
  113259. private _debugBoxMesh;
  113260. private _debugSphereMesh;
  113261. private _debugCylinderMesh;
  113262. private _debugMaterial;
  113263. private _debugMeshMeshes;
  113264. /**
  113265. * Creates a new PhysicsViewer
  113266. * @param scene defines the hosting scene
  113267. */
  113268. constructor(scene: Scene);
  113269. /** @hidden */
  113270. protected _updateDebugMeshes(): void;
  113271. /**
  113272. * Renders a specified physic impostor
  113273. * @param impostor defines the impostor to render
  113274. * @param targetMesh defines the mesh represented by the impostor
  113275. * @returns the new debug mesh used to render the impostor
  113276. */
  113277. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113278. /**
  113279. * Hides a specified physic impostor
  113280. * @param impostor defines the impostor to hide
  113281. */
  113282. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113283. private _getDebugMaterial;
  113284. private _getDebugBoxMesh;
  113285. private _getDebugSphereMesh;
  113286. private _getDebugCylinderMesh;
  113287. private _getDebugMeshMesh;
  113288. private _getDebugMesh;
  113289. /** Releases all resources */
  113290. dispose(): void;
  113291. }
  113292. }
  113293. declare module BABYLON {
  113294. /**
  113295. * Class containing static functions to help procedurally build meshes
  113296. */
  113297. export class LinesBuilder {
  113298. /**
  113299. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113300. * * 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
  113301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113302. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113303. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113304. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113305. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113306. * * 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
  113307. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113310. * @param name defines the name of the new line system
  113311. * @param options defines the options used to create the line system
  113312. * @param scene defines the hosting scene
  113313. * @returns a new line system mesh
  113314. */
  113315. static CreateLineSystem(name: string, options: {
  113316. lines: Vector3[][];
  113317. updatable?: boolean;
  113318. instance?: Nullable<LinesMesh>;
  113319. colors?: Nullable<Color4[][]>;
  113320. useVertexAlpha?: boolean;
  113321. }, scene: Nullable<Scene>): LinesMesh;
  113322. /**
  113323. * Creates a line mesh
  113324. * 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
  113325. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113326. * * The parameter `points` is an array successive Vector3
  113327. * * 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
  113328. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113329. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113330. * * When updating an instance, remember that only point positions can change, not the number of points
  113331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113333. * @param name defines the name of the new line system
  113334. * @param options defines the options used to create the line system
  113335. * @param scene defines the hosting scene
  113336. * @returns a new line mesh
  113337. */
  113338. static CreateLines(name: string, options: {
  113339. points: Vector3[];
  113340. updatable?: boolean;
  113341. instance?: Nullable<LinesMesh>;
  113342. colors?: Color4[];
  113343. useVertexAlpha?: boolean;
  113344. }, scene?: Nullable<Scene>): LinesMesh;
  113345. /**
  113346. * Creates a dashed line mesh
  113347. * * 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
  113348. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113349. * * The parameter `points` is an array successive Vector3
  113350. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113351. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113352. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113353. * * 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
  113354. * * When updating an instance, remember that only point positions can change, not the number of points
  113355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113356. * @param name defines the name of the mesh
  113357. * @param options defines the options used to create the mesh
  113358. * @param scene defines the hosting scene
  113359. * @returns the dashed line mesh
  113360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113361. */
  113362. static CreateDashedLines(name: string, options: {
  113363. points: Vector3[];
  113364. dashSize?: number;
  113365. gapSize?: number;
  113366. dashNb?: number;
  113367. updatable?: boolean;
  113368. instance?: LinesMesh;
  113369. }, scene?: Nullable<Scene>): LinesMesh;
  113370. }
  113371. }
  113372. declare module BABYLON {
  113373. /**
  113374. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113375. * in order to better appreciate the issue one might have.
  113376. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113377. */
  113378. export class RayHelper {
  113379. /**
  113380. * Defines the ray we are currently tryin to visualize.
  113381. */
  113382. ray: Nullable<Ray>;
  113383. private _renderPoints;
  113384. private _renderLine;
  113385. private _renderFunction;
  113386. private _scene;
  113387. private _updateToMeshFunction;
  113388. private _attachedToMesh;
  113389. private _meshSpaceDirection;
  113390. private _meshSpaceOrigin;
  113391. /**
  113392. * Helper function to create a colored helper in a scene in one line.
  113393. * @param ray Defines the ray we are currently tryin to visualize
  113394. * @param scene Defines the scene the ray is used in
  113395. * @param color Defines the color we want to see the ray in
  113396. * @returns The newly created ray helper.
  113397. */
  113398. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  113399. /**
  113400. * Instantiate a new ray helper.
  113401. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113402. * in order to better appreciate the issue one might have.
  113403. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113404. * @param ray Defines the ray we are currently tryin to visualize
  113405. */
  113406. constructor(ray: Ray);
  113407. /**
  113408. * Shows the ray we are willing to debug.
  113409. * @param scene Defines the scene the ray needs to be rendered in
  113410. * @param color Defines the color the ray needs to be rendered in
  113411. */
  113412. show(scene: Scene, color?: Color3): void;
  113413. /**
  113414. * Hides the ray we are debugging.
  113415. */
  113416. hide(): void;
  113417. private _render;
  113418. /**
  113419. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  113420. * @param mesh Defines the mesh we want the helper attached to
  113421. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  113422. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  113423. * @param length Defines the length of the ray
  113424. */
  113425. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  113426. /**
  113427. * Detach the ray helper from the mesh it has previously been attached to.
  113428. */
  113429. detachFromMesh(): void;
  113430. private _updateToMesh;
  113431. /**
  113432. * Dispose the helper and release its associated resources.
  113433. */
  113434. dispose(): void;
  113435. }
  113436. }
  113437. declare module BABYLON.Debug {
  113438. /**
  113439. * Class used to render a debug view of a given skeleton
  113440. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  113441. */
  113442. export class SkeletonViewer {
  113443. /** defines the skeleton to render */
  113444. skeleton: Skeleton;
  113445. /** defines the mesh attached to the skeleton */
  113446. mesh: AbstractMesh;
  113447. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113448. autoUpdateBonesMatrices: boolean;
  113449. /** defines the rendering group id to use with the viewer */
  113450. renderingGroupId: number;
  113451. /** Gets or sets the color used to render the skeleton */
  113452. color: Color3;
  113453. private _scene;
  113454. private _debugLines;
  113455. private _debugMesh;
  113456. private _isEnabled;
  113457. private _renderFunction;
  113458. private _utilityLayer;
  113459. /**
  113460. * Returns the mesh used to render the bones
  113461. */
  113462. readonly debugMesh: Nullable<LinesMesh>;
  113463. /**
  113464. * Creates a new SkeletonViewer
  113465. * @param skeleton defines the skeleton to render
  113466. * @param mesh defines the mesh attached to the skeleton
  113467. * @param scene defines the hosting scene
  113468. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  113469. * @param renderingGroupId defines the rendering group id to use with the viewer
  113470. */
  113471. constructor(
  113472. /** defines the skeleton to render */
  113473. skeleton: Skeleton,
  113474. /** defines the mesh attached to the skeleton */
  113475. mesh: AbstractMesh, scene: Scene,
  113476. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113477. autoUpdateBonesMatrices?: boolean,
  113478. /** defines the rendering group id to use with the viewer */
  113479. renderingGroupId?: number);
  113480. /** Gets or sets a boolean indicating if the viewer is enabled */
  113481. isEnabled: boolean;
  113482. private _getBonePosition;
  113483. private _getLinesForBonesWithLength;
  113484. private _getLinesForBonesNoLength;
  113485. /** Update the viewer to sync with current skeleton state */
  113486. update(): void;
  113487. /** Release associated resources */
  113488. dispose(): void;
  113489. }
  113490. }
  113491. declare module BABYLON {
  113492. /**
  113493. * Options to create the null engine
  113494. */
  113495. export class NullEngineOptions {
  113496. /**
  113497. * Render width (Default: 512)
  113498. */
  113499. renderWidth: number;
  113500. /**
  113501. * Render height (Default: 256)
  113502. */
  113503. renderHeight: number;
  113504. /**
  113505. * Texture size (Default: 512)
  113506. */
  113507. textureSize: number;
  113508. /**
  113509. * If delta time between frames should be constant
  113510. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113511. */
  113512. deterministicLockstep: boolean;
  113513. /**
  113514. * Maximum about of steps between frames (Default: 4)
  113515. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113516. */
  113517. lockstepMaxSteps: number;
  113518. }
  113519. /**
  113520. * The null engine class provides support for headless version of babylon.js.
  113521. * This can be used in server side scenario or for testing purposes
  113522. */
  113523. export class NullEngine extends Engine {
  113524. private _options;
  113525. /**
  113526. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113527. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113528. * @returns true if engine is in deterministic lock step mode
  113529. */
  113530. isDeterministicLockStep(): boolean;
  113531. /**
  113532. * Gets the max steps when engine is running in deterministic lock step
  113533. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113534. * @returns the max steps
  113535. */
  113536. getLockstepMaxSteps(): number;
  113537. /**
  113538. * Gets the current hardware scaling level.
  113539. * By default the hardware scaling level is computed from the window device ratio.
  113540. * 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.
  113541. * @returns a number indicating the current hardware scaling level
  113542. */
  113543. getHardwareScalingLevel(): number;
  113544. constructor(options?: NullEngineOptions);
  113545. /**
  113546. * Creates a vertex buffer
  113547. * @param vertices the data for the vertex buffer
  113548. * @returns the new WebGL static buffer
  113549. */
  113550. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113551. /**
  113552. * Creates a new index buffer
  113553. * @param indices defines the content of the index buffer
  113554. * @param updatable defines if the index buffer must be updatable
  113555. * @returns a new webGL buffer
  113556. */
  113557. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113558. /**
  113559. * Clear the current render buffer or the current render target (if any is set up)
  113560. * @param color defines the color to use
  113561. * @param backBuffer defines if the back buffer must be cleared
  113562. * @param depth defines if the depth buffer must be cleared
  113563. * @param stencil defines if the stencil buffer must be cleared
  113564. */
  113565. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113566. /**
  113567. * Gets the current render width
  113568. * @param useScreen defines if screen size must be used (or the current render target if any)
  113569. * @returns a number defining the current render width
  113570. */
  113571. getRenderWidth(useScreen?: boolean): number;
  113572. /**
  113573. * Gets the current render height
  113574. * @param useScreen defines if screen size must be used (or the current render target if any)
  113575. * @returns a number defining the current render height
  113576. */
  113577. getRenderHeight(useScreen?: boolean): number;
  113578. /**
  113579. * Set the WebGL's viewport
  113580. * @param viewport defines the viewport element to be used
  113581. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113582. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113583. */
  113584. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113585. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113586. /**
  113587. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113588. * @param pipelineContext defines the pipeline context to use
  113589. * @param uniformsNames defines the list of uniform names
  113590. * @returns an array of webGL uniform locations
  113591. */
  113592. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113593. /**
  113594. * Gets the lsit of active attributes for a given webGL program
  113595. * @param pipelineContext defines the pipeline context to use
  113596. * @param attributesNames defines the list of attribute names to get
  113597. * @returns an array of indices indicating the offset of each attribute
  113598. */
  113599. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113600. /**
  113601. * Binds an effect to the webGL context
  113602. * @param effect defines the effect to bind
  113603. */
  113604. bindSamplers(effect: Effect): void;
  113605. /**
  113606. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113607. * @param effect defines the effect to activate
  113608. */
  113609. enableEffect(effect: Effect): void;
  113610. /**
  113611. * Set various states to the webGL context
  113612. * @param culling defines backface culling state
  113613. * @param zOffset defines the value to apply to zOffset (0 by default)
  113614. * @param force defines if states must be applied even if cache is up to date
  113615. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113616. */
  113617. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113618. /**
  113619. * Set the value of an uniform to an array of int32
  113620. * @param uniform defines the webGL uniform location where to store the value
  113621. * @param array defines the array of int32 to store
  113622. */
  113623. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113624. /**
  113625. * Set the value of an uniform to an array of int32 (stored as vec2)
  113626. * @param uniform defines the webGL uniform location where to store the value
  113627. * @param array defines the array of int32 to store
  113628. */
  113629. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113630. /**
  113631. * Set the value of an uniform to an array of int32 (stored as vec3)
  113632. * @param uniform defines the webGL uniform location where to store the value
  113633. * @param array defines the array of int32 to store
  113634. */
  113635. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113636. /**
  113637. * Set the value of an uniform to an array of int32 (stored as vec4)
  113638. * @param uniform defines the webGL uniform location where to store the value
  113639. * @param array defines the array of int32 to store
  113640. */
  113641. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113642. /**
  113643. * Set the value of an uniform to an array of float32
  113644. * @param uniform defines the webGL uniform location where to store the value
  113645. * @param array defines the array of float32 to store
  113646. */
  113647. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113648. /**
  113649. * Set the value of an uniform to an array of float32 (stored as vec2)
  113650. * @param uniform defines the webGL uniform location where to store the value
  113651. * @param array defines the array of float32 to store
  113652. */
  113653. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113654. /**
  113655. * Set the value of an uniform to an array of float32 (stored as vec3)
  113656. * @param uniform defines the webGL uniform location where to store the value
  113657. * @param array defines the array of float32 to store
  113658. */
  113659. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113660. /**
  113661. * Set the value of an uniform to an array of float32 (stored as vec4)
  113662. * @param uniform defines the webGL uniform location where to store the value
  113663. * @param array defines the array of float32 to store
  113664. */
  113665. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113666. /**
  113667. * Set the value of an uniform to an array of number
  113668. * @param uniform defines the webGL uniform location where to store the value
  113669. * @param array defines the array of number to store
  113670. */
  113671. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113672. /**
  113673. * Set the value of an uniform to an array of number (stored as vec2)
  113674. * @param uniform defines the webGL uniform location where to store the value
  113675. * @param array defines the array of number to store
  113676. */
  113677. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113678. /**
  113679. * Set the value of an uniform to an array of number (stored as vec3)
  113680. * @param uniform defines the webGL uniform location where to store the value
  113681. * @param array defines the array of number to store
  113682. */
  113683. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113684. /**
  113685. * Set the value of an uniform to an array of number (stored as vec4)
  113686. * @param uniform defines the webGL uniform location where to store the value
  113687. * @param array defines the array of number to store
  113688. */
  113689. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113690. /**
  113691. * Set the value of an uniform to an array of float32 (stored as matrices)
  113692. * @param uniform defines the webGL uniform location where to store the value
  113693. * @param matrices defines the array of float32 to store
  113694. */
  113695. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113696. /**
  113697. * Set the value of an uniform to a matrix (3x3)
  113698. * @param uniform defines the webGL uniform location where to store the value
  113699. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113700. */
  113701. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113702. /**
  113703. * Set the value of an uniform to a matrix (2x2)
  113704. * @param uniform defines the webGL uniform location where to store the value
  113705. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113706. */
  113707. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113708. /**
  113709. * Set the value of an uniform to a number (float)
  113710. * @param uniform defines the webGL uniform location where to store the value
  113711. * @param value defines the float number to store
  113712. */
  113713. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113714. /**
  113715. * Set the value of an uniform to a vec2
  113716. * @param uniform defines the webGL uniform location where to store the value
  113717. * @param x defines the 1st component of the value
  113718. * @param y defines the 2nd component of the value
  113719. */
  113720. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113721. /**
  113722. * Set the value of an uniform to a vec3
  113723. * @param uniform defines the webGL uniform location where to store the value
  113724. * @param x defines the 1st component of the value
  113725. * @param y defines the 2nd component of the value
  113726. * @param z defines the 3rd component of the value
  113727. */
  113728. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113729. /**
  113730. * Set the value of an uniform to a boolean
  113731. * @param uniform defines the webGL uniform location where to store the value
  113732. * @param bool defines the boolean to store
  113733. */
  113734. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113735. /**
  113736. * Set the value of an uniform to a vec4
  113737. * @param uniform defines the webGL uniform location where to store the value
  113738. * @param x defines the 1st component of the value
  113739. * @param y defines the 2nd component of the value
  113740. * @param z defines the 3rd component of the value
  113741. * @param w defines the 4th component of the value
  113742. */
  113743. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113744. /**
  113745. * Sets the current alpha mode
  113746. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113747. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113748. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113749. */
  113750. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113751. /**
  113752. * Bind webGl buffers directly to the webGL context
  113753. * @param vertexBuffers defines the vertex buffer to bind
  113754. * @param indexBuffer defines the index buffer to bind
  113755. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113756. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113757. * @param effect defines the effect associated with the vertex buffer
  113758. */
  113759. bindBuffers(vertexBuffers: {
  113760. [key: string]: VertexBuffer;
  113761. }, indexBuffer: DataBuffer, effect: Effect): void;
  113762. /**
  113763. * Force the entire cache to be cleared
  113764. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113765. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113766. */
  113767. wipeCaches(bruteForce?: boolean): void;
  113768. /**
  113769. * Send a draw order
  113770. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113771. * @param indexStart defines the starting index
  113772. * @param indexCount defines the number of index to draw
  113773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113774. */
  113775. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113776. /**
  113777. * Draw a list of indexed primitives
  113778. * @param fillMode defines the primitive to use
  113779. * @param indexStart defines the starting index
  113780. * @param indexCount defines the number of index to draw
  113781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113782. */
  113783. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113784. /**
  113785. * Draw a list of unindexed primitives
  113786. * @param fillMode defines the primitive to use
  113787. * @param verticesStart defines the index of first vertex to draw
  113788. * @param verticesCount defines the count of vertices to draw
  113789. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113790. */
  113791. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113792. /** @hidden */
  113793. _createTexture(): WebGLTexture;
  113794. /** @hidden */
  113795. _releaseTexture(texture: InternalTexture): void;
  113796. /**
  113797. * Usually called from Texture.ts.
  113798. * Passed information to create a WebGLTexture
  113799. * @param urlArg defines a value which contains one of the following:
  113800. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113801. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113802. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113803. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113804. * @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)
  113805. * @param scene needed for loading to the correct scene
  113806. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113807. * @param onLoad optional callback to be called upon successful completion
  113808. * @param onError optional callback to be called upon failure
  113809. * @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
  113810. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113811. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113812. * @param forcedExtension defines the extension to use to pick the right loader
  113813. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113814. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113815. */
  113816. 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;
  113817. /**
  113818. * Creates a new render target texture
  113819. * @param size defines the size of the texture
  113820. * @param options defines the options used to create the texture
  113821. * @returns a new render target texture stored in an InternalTexture
  113822. */
  113823. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113824. /**
  113825. * Update the sampling mode of a given texture
  113826. * @param samplingMode defines the required sampling mode
  113827. * @param texture defines the texture to update
  113828. */
  113829. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113830. /**
  113831. * Binds the frame buffer to the specified texture.
  113832. * @param texture The texture to render to or null for the default canvas
  113833. * @param faceIndex The face of the texture to render to in case of cube texture
  113834. * @param requiredWidth The width of the target to render to
  113835. * @param requiredHeight The height of the target to render to
  113836. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113837. * @param depthStencilTexture The depth stencil texture to use to render
  113838. * @param lodLevel defines le lod level to bind to the frame buffer
  113839. */
  113840. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113841. /**
  113842. * Unbind the current render target texture from the webGL context
  113843. * @param texture defines the render target texture to unbind
  113844. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113845. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113846. */
  113847. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113848. /**
  113849. * Creates a dynamic vertex buffer
  113850. * @param vertices the data for the dynamic vertex buffer
  113851. * @returns the new WebGL dynamic buffer
  113852. */
  113853. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113854. /**
  113855. * Update the content of a dynamic texture
  113856. * @param texture defines the texture to update
  113857. * @param canvas defines the canvas containing the source
  113858. * @param invertY defines if data must be stored with Y axis inverted
  113859. * @param premulAlpha defines if alpha is stored as premultiplied
  113860. * @param format defines the format of the data
  113861. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113862. */
  113863. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113864. /**
  113865. * Gets a boolean indicating if all created effects are ready
  113866. * @returns true if all effects are ready
  113867. */
  113868. areAllEffectsReady(): boolean;
  113869. /**
  113870. * @hidden
  113871. * Get the current error code of the webGL context
  113872. * @returns the error code
  113873. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113874. */
  113875. getError(): number;
  113876. /** @hidden */
  113877. _getUnpackAlignement(): number;
  113878. /** @hidden */
  113879. _unpackFlipY(value: boolean): void;
  113880. /**
  113881. * Update a dynamic index buffer
  113882. * @param indexBuffer defines the target index buffer
  113883. * @param indices defines the data to update
  113884. * @param offset defines the offset in the target index buffer where update should start
  113885. */
  113886. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113887. /**
  113888. * Updates a dynamic vertex buffer.
  113889. * @param vertexBuffer the vertex buffer to update
  113890. * @param vertices the data used to update the vertex buffer
  113891. * @param byteOffset the byte offset of the data (optional)
  113892. * @param byteLength the byte length of the data (optional)
  113893. */
  113894. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113895. /** @hidden */
  113896. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113897. /** @hidden */
  113898. _bindTexture(channel: number, texture: InternalTexture): void;
  113899. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113900. /**
  113901. * 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
  113902. */
  113903. releaseEffects(): void;
  113904. displayLoadingUI(): void;
  113905. hideLoadingUI(): void;
  113906. /** @hidden */
  113907. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113908. /** @hidden */
  113909. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113910. /** @hidden */
  113911. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113912. /** @hidden */
  113913. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113914. }
  113915. }
  113916. declare module BABYLON {
  113917. /** @hidden */
  113918. export class _OcclusionDataStorage {
  113919. /** @hidden */
  113920. occlusionInternalRetryCounter: number;
  113921. /** @hidden */
  113922. isOcclusionQueryInProgress: boolean;
  113923. /** @hidden */
  113924. isOccluded: boolean;
  113925. /** @hidden */
  113926. occlusionRetryCount: number;
  113927. /** @hidden */
  113928. occlusionType: number;
  113929. /** @hidden */
  113930. occlusionQueryAlgorithmType: number;
  113931. }
  113932. interface Engine {
  113933. /**
  113934. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113935. * @return the new query
  113936. */
  113937. createQuery(): WebGLQuery;
  113938. /**
  113939. * Delete and release a webGL query
  113940. * @param query defines the query to delete
  113941. * @return the current engine
  113942. */
  113943. deleteQuery(query: WebGLQuery): Engine;
  113944. /**
  113945. * Check if a given query has resolved and got its value
  113946. * @param query defines the query to check
  113947. * @returns true if the query got its value
  113948. */
  113949. isQueryResultAvailable(query: WebGLQuery): boolean;
  113950. /**
  113951. * Gets the value of a given query
  113952. * @param query defines the query to check
  113953. * @returns the value of the query
  113954. */
  113955. getQueryResult(query: WebGLQuery): number;
  113956. /**
  113957. * Initiates an occlusion query
  113958. * @param algorithmType defines the algorithm to use
  113959. * @param query defines the query to use
  113960. * @returns the current engine
  113961. * @see http://doc.babylonjs.com/features/occlusionquery
  113962. */
  113963. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  113964. /**
  113965. * Ends an occlusion query
  113966. * @see http://doc.babylonjs.com/features/occlusionquery
  113967. * @param algorithmType defines the algorithm to use
  113968. * @returns the current engine
  113969. */
  113970. endOcclusionQuery(algorithmType: number): Engine;
  113971. /**
  113972. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113973. * Please note that only one query can be issued at a time
  113974. * @returns a time token used to track the time span
  113975. */
  113976. startTimeQuery(): Nullable<_TimeToken>;
  113977. /**
  113978. * Ends a time query
  113979. * @param token defines the token used to measure the time span
  113980. * @returns the time spent (in ns)
  113981. */
  113982. endTimeQuery(token: _TimeToken): int;
  113983. /** @hidden */
  113984. _currentNonTimestampToken: Nullable<_TimeToken>;
  113985. /** @hidden */
  113986. _createTimeQuery(): WebGLQuery;
  113987. /** @hidden */
  113988. _deleteTimeQuery(query: WebGLQuery): void;
  113989. /** @hidden */
  113990. _getGlAlgorithmType(algorithmType: number): number;
  113991. /** @hidden */
  113992. _getTimeQueryResult(query: WebGLQuery): any;
  113993. /** @hidden */
  113994. _getTimeQueryAvailability(query: WebGLQuery): any;
  113995. }
  113996. interface AbstractMesh {
  113997. /**
  113998. * Backing filed
  113999. * @hidden
  114000. */
  114001. __occlusionDataStorage: _OcclusionDataStorage;
  114002. /**
  114003. * Access property
  114004. * @hidden
  114005. */
  114006. _occlusionDataStorage: _OcclusionDataStorage;
  114007. /**
  114008. * 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.
  114009. * The default value is -1 which means don't break the query and wait till the result
  114010. * @see http://doc.babylonjs.com/features/occlusionquery
  114011. */
  114012. occlusionRetryCount: number;
  114013. /**
  114014. * 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:
  114015. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  114016. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  114017. * * 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.
  114018. * @see http://doc.babylonjs.com/features/occlusionquery
  114019. */
  114020. occlusionType: number;
  114021. /**
  114022. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  114023. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  114024. * * 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.
  114025. * @see http://doc.babylonjs.com/features/occlusionquery
  114026. */
  114027. occlusionQueryAlgorithmType: number;
  114028. /**
  114029. * 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
  114030. * @see http://doc.babylonjs.com/features/occlusionquery
  114031. */
  114032. isOccluded: boolean;
  114033. /**
  114034. * Flag to check the progress status of the query
  114035. * @see http://doc.babylonjs.com/features/occlusionquery
  114036. */
  114037. isOcclusionQueryInProgress: boolean;
  114038. }
  114039. }
  114040. declare module BABYLON {
  114041. /** @hidden */
  114042. export var _forceTransformFeedbackToBundle: boolean;
  114043. interface Engine {
  114044. /**
  114045. * Creates a webGL transform feedback object
  114046. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114047. * @returns the webGL transform feedback object
  114048. */
  114049. createTransformFeedback(): WebGLTransformFeedback;
  114050. /**
  114051. * Delete a webGL transform feedback object
  114052. * @param value defines the webGL transform feedback object to delete
  114053. */
  114054. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114055. /**
  114056. * Bind a webGL transform feedback object to the webgl context
  114057. * @param value defines the webGL transform feedback object to bind
  114058. */
  114059. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114060. /**
  114061. * Begins a transform feedback operation
  114062. * @param usePoints defines if points or triangles must be used
  114063. */
  114064. beginTransformFeedback(usePoints: boolean): void;
  114065. /**
  114066. * Ends a transform feedback operation
  114067. */
  114068. endTransformFeedback(): void;
  114069. /**
  114070. * Specify the varyings to use with transform feedback
  114071. * @param program defines the associated webGL program
  114072. * @param value defines the list of strings representing the varying names
  114073. */
  114074. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114075. /**
  114076. * Bind a webGL buffer for a transform feedback operation
  114077. * @param value defines the webGL buffer to bind
  114078. */
  114079. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114080. }
  114081. }
  114082. declare module BABYLON {
  114083. /**
  114084. * Creation options of the multi render target texture.
  114085. */
  114086. export interface IMultiRenderTargetOptions {
  114087. /**
  114088. * Define if the texture needs to create mip maps after render.
  114089. */
  114090. generateMipMaps?: boolean;
  114091. /**
  114092. * Define the types of all the draw buffers we want to create
  114093. */
  114094. types?: number[];
  114095. /**
  114096. * Define the sampling modes of all the draw buffers we want to create
  114097. */
  114098. samplingModes?: number[];
  114099. /**
  114100. * Define if a depth buffer is required
  114101. */
  114102. generateDepthBuffer?: boolean;
  114103. /**
  114104. * Define if a stencil buffer is required
  114105. */
  114106. generateStencilBuffer?: boolean;
  114107. /**
  114108. * Define if a depth texture is required instead of a depth buffer
  114109. */
  114110. generateDepthTexture?: boolean;
  114111. /**
  114112. * Define the number of desired draw buffers
  114113. */
  114114. textureCount?: number;
  114115. /**
  114116. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114117. */
  114118. doNotChangeAspectRatio?: boolean;
  114119. /**
  114120. * Define the default type of the buffers we are creating
  114121. */
  114122. defaultType?: number;
  114123. }
  114124. /**
  114125. * A multi render target, like a render target provides the ability to render to a texture.
  114126. * Unlike the render target, it can render to several draw buffers in one draw.
  114127. * This is specially interesting in deferred rendering or for any effects requiring more than
  114128. * just one color from a single pass.
  114129. */
  114130. export class MultiRenderTarget extends RenderTargetTexture {
  114131. private _internalTextures;
  114132. private _textures;
  114133. private _multiRenderTargetOptions;
  114134. /**
  114135. * Get if draw buffers are currently supported by the used hardware and browser.
  114136. */
  114137. readonly isSupported: boolean;
  114138. /**
  114139. * Get the list of textures generated by the multi render target.
  114140. */
  114141. readonly textures: Texture[];
  114142. /**
  114143. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114144. */
  114145. readonly depthTexture: Texture;
  114146. /**
  114147. * Set the wrapping mode on U of all the textures we are rendering to.
  114148. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114149. */
  114150. wrapU: number;
  114151. /**
  114152. * Set the wrapping mode on V of all the textures we are rendering to.
  114153. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114154. */
  114155. wrapV: number;
  114156. /**
  114157. * Instantiate a new multi render target texture.
  114158. * A multi render target, like a render target provides the ability to render to a texture.
  114159. * Unlike the render target, it can render to several draw buffers in one draw.
  114160. * This is specially interesting in deferred rendering or for any effects requiring more than
  114161. * just one color from a single pass.
  114162. * @param name Define the name of the texture
  114163. * @param size Define the size of the buffers to render to
  114164. * @param count Define the number of target we are rendering into
  114165. * @param scene Define the scene the texture belongs to
  114166. * @param options Define the options used to create the multi render target
  114167. */
  114168. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114169. /** @hidden */
  114170. _rebuild(): void;
  114171. private _createInternalTextures;
  114172. private _createTextures;
  114173. /**
  114174. * Define the number of samples used if MSAA is enabled.
  114175. */
  114176. samples: number;
  114177. /**
  114178. * Resize all the textures in the multi render target.
  114179. * Be carrefull as it will recreate all the data in the new texture.
  114180. * @param size Define the new size
  114181. */
  114182. resize(size: any): void;
  114183. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114184. /**
  114185. * Dispose the render targets and their associated resources
  114186. */
  114187. dispose(): void;
  114188. /**
  114189. * Release all the underlying texture used as draw buffers.
  114190. */
  114191. releaseInternalTextures(): void;
  114192. }
  114193. }
  114194. declare module BABYLON {
  114195. interface ThinEngine {
  114196. /**
  114197. * Unbind a list of render target textures from the webGL context
  114198. * This is used only when drawBuffer extension or webGL2 are active
  114199. * @param textures defines the render target textures to unbind
  114200. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114201. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114202. */
  114203. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114204. /**
  114205. * Create a multi render target texture
  114206. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114207. * @param size defines the size of the texture
  114208. * @param options defines the creation options
  114209. * @returns the cube texture as an InternalTexture
  114210. */
  114211. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114212. /**
  114213. * Update the sample count for a given multiple render target texture
  114214. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114215. * @param textures defines the textures to update
  114216. * @param samples defines the sample count to set
  114217. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114218. */
  114219. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114220. }
  114221. }
  114222. declare module BABYLON {
  114223. /**
  114224. * Class used to define an additional view for the engine
  114225. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114226. */
  114227. export class EngineView {
  114228. /** Defines the canvas where to render the view */
  114229. target: HTMLCanvasElement;
  114230. /** Defines an optional camera used to render the view (will use active camera else) */
  114231. camera?: Camera;
  114232. }
  114233. interface Engine {
  114234. /**
  114235. * Gets or sets the HTML element to use for attaching events
  114236. */
  114237. inputElement: Nullable<HTMLElement>;
  114238. /**
  114239. * Gets the current engine view
  114240. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114241. */
  114242. activeView: Nullable<EngineView>;
  114243. /** Gets or sets the list of views */
  114244. views: EngineView[];
  114245. /**
  114246. * Register a new child canvas
  114247. * @param canvas defines the canvas to register
  114248. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114249. * @returns the associated view
  114250. */
  114251. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114252. /**
  114253. * Remove a registered child canvas
  114254. * @param canvas defines the canvas to remove
  114255. * @returns the current engine
  114256. */
  114257. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114258. }
  114259. }
  114260. declare module BABYLON {
  114261. /**
  114262. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114263. */
  114264. export interface CubeMapInfo {
  114265. /**
  114266. * The pixel array for the front face.
  114267. * This is stored in format, left to right, up to down format.
  114268. */
  114269. front: Nullable<ArrayBufferView>;
  114270. /**
  114271. * The pixel array for the back face.
  114272. * This is stored in format, left to right, up to down format.
  114273. */
  114274. back: Nullable<ArrayBufferView>;
  114275. /**
  114276. * The pixel array for the left face.
  114277. * This is stored in format, left to right, up to down format.
  114278. */
  114279. left: Nullable<ArrayBufferView>;
  114280. /**
  114281. * The pixel array for the right face.
  114282. * This is stored in format, left to right, up to down format.
  114283. */
  114284. right: Nullable<ArrayBufferView>;
  114285. /**
  114286. * The pixel array for the up face.
  114287. * This is stored in format, left to right, up to down format.
  114288. */
  114289. up: Nullable<ArrayBufferView>;
  114290. /**
  114291. * The pixel array for the down face.
  114292. * This is stored in format, left to right, up to down format.
  114293. */
  114294. down: Nullable<ArrayBufferView>;
  114295. /**
  114296. * The size of the cubemap stored.
  114297. *
  114298. * Each faces will be size * size pixels.
  114299. */
  114300. size: number;
  114301. /**
  114302. * The format of the texture.
  114303. *
  114304. * RGBA, RGB.
  114305. */
  114306. format: number;
  114307. /**
  114308. * The type of the texture data.
  114309. *
  114310. * UNSIGNED_INT, FLOAT.
  114311. */
  114312. type: number;
  114313. /**
  114314. * Specifies whether the texture is in gamma space.
  114315. */
  114316. gammaSpace: boolean;
  114317. }
  114318. /**
  114319. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114320. */
  114321. export class PanoramaToCubeMapTools {
  114322. private static FACE_FRONT;
  114323. private static FACE_BACK;
  114324. private static FACE_RIGHT;
  114325. private static FACE_LEFT;
  114326. private static FACE_DOWN;
  114327. private static FACE_UP;
  114328. /**
  114329. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114330. *
  114331. * @param float32Array The source data.
  114332. * @param inputWidth The width of the input panorama.
  114333. * @param inputHeight The height of the input panorama.
  114334. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114335. * @return The cubemap data
  114336. */
  114337. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114338. private static CreateCubemapTexture;
  114339. private static CalcProjectionSpherical;
  114340. }
  114341. }
  114342. declare module BABYLON {
  114343. /**
  114344. * Helper class dealing with the extraction of spherical polynomial dataArray
  114345. * from a cube map.
  114346. */
  114347. export class CubeMapToSphericalPolynomialTools {
  114348. private static FileFaces;
  114349. /**
  114350. * Converts a texture to the according Spherical Polynomial data.
  114351. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114352. *
  114353. * @param texture The texture to extract the information from.
  114354. * @return The Spherical Polynomial data.
  114355. */
  114356. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114357. /**
  114358. * Converts a cubemap to the according Spherical Polynomial data.
  114359. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114360. *
  114361. * @param cubeInfo The Cube map to extract the information from.
  114362. * @return The Spherical Polynomial data.
  114363. */
  114364. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114365. }
  114366. }
  114367. declare module BABYLON {
  114368. interface BaseTexture {
  114369. /**
  114370. * Get the polynomial representation of the texture data.
  114371. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114372. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114373. */
  114374. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114375. }
  114376. }
  114377. declare module BABYLON {
  114378. /** @hidden */
  114379. export var rgbdEncodePixelShader: {
  114380. name: string;
  114381. shader: string;
  114382. };
  114383. }
  114384. declare module BABYLON {
  114385. /** @hidden */
  114386. export var rgbdDecodePixelShader: {
  114387. name: string;
  114388. shader: string;
  114389. };
  114390. }
  114391. declare module BABYLON {
  114392. /**
  114393. * Raw texture data and descriptor sufficient for WebGL texture upload
  114394. */
  114395. export interface EnvironmentTextureInfo {
  114396. /**
  114397. * Version of the environment map
  114398. */
  114399. version: number;
  114400. /**
  114401. * Width of image
  114402. */
  114403. width: number;
  114404. /**
  114405. * Irradiance information stored in the file.
  114406. */
  114407. irradiance: any;
  114408. /**
  114409. * Specular information stored in the file.
  114410. */
  114411. specular: any;
  114412. }
  114413. /**
  114414. * Defines One Image in the file. It requires only the position in the file
  114415. * as well as the length.
  114416. */
  114417. interface BufferImageData {
  114418. /**
  114419. * Length of the image data.
  114420. */
  114421. length: number;
  114422. /**
  114423. * Position of the data from the null terminator delimiting the end of the JSON.
  114424. */
  114425. position: number;
  114426. }
  114427. /**
  114428. * Defines the specular data enclosed in the file.
  114429. * This corresponds to the version 1 of the data.
  114430. */
  114431. export interface EnvironmentTextureSpecularInfoV1 {
  114432. /**
  114433. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  114434. */
  114435. specularDataPosition?: number;
  114436. /**
  114437. * This contains all the images data needed to reconstruct the cubemap.
  114438. */
  114439. mipmaps: Array<BufferImageData>;
  114440. /**
  114441. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  114442. */
  114443. lodGenerationScale: number;
  114444. }
  114445. /**
  114446. * Sets of helpers addressing the serialization and deserialization of environment texture
  114447. * stored in a BabylonJS env file.
  114448. * Those files are usually stored as .env files.
  114449. */
  114450. export class EnvironmentTextureTools {
  114451. /**
  114452. * Magic number identifying the env file.
  114453. */
  114454. private static _MagicBytes;
  114455. /**
  114456. * Gets the environment info from an env file.
  114457. * @param data The array buffer containing the .env bytes.
  114458. * @returns the environment file info (the json header) if successfully parsed.
  114459. */
  114460. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  114461. /**
  114462. * Creates an environment texture from a loaded cube texture.
  114463. * @param texture defines the cube texture to convert in env file
  114464. * @return a promise containing the environment data if succesfull.
  114465. */
  114466. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  114467. /**
  114468. * Creates a JSON representation of the spherical data.
  114469. * @param texture defines the texture containing the polynomials
  114470. * @return the JSON representation of the spherical info
  114471. */
  114472. private static _CreateEnvTextureIrradiance;
  114473. /**
  114474. * Creates the ArrayBufferViews used for initializing environment texture image data.
  114475. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  114476. * @param info parameters that determine what views will be created for accessing the underlying buffer
  114477. * @return the views described by info providing access to the underlying buffer
  114478. */
  114479. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  114480. /**
  114481. * Uploads the texture info contained in the env file to the GPU.
  114482. * @param texture defines the internal texture to upload to
  114483. * @param arrayBuffer defines the buffer cotaining the data to load
  114484. * @param info defines the texture info retrieved through the GetEnvInfo method
  114485. * @returns a promise
  114486. */
  114487. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114488. private static _OnImageReadyAsync;
  114489. /**
  114490. * Uploads the levels of image data to the GPU.
  114491. * @param texture defines the internal texture to upload to
  114492. * @param imageData defines the array buffer views of image data [mipmap][face]
  114493. * @returns a promise
  114494. */
  114495. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114496. /**
  114497. * Uploads spherical polynomials information to the texture.
  114498. * @param texture defines the texture we are trying to upload the information to
  114499. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114500. */
  114501. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114502. /** @hidden */
  114503. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114504. }
  114505. }
  114506. declare module BABYLON {
  114507. /**
  114508. * Contains position and normal vectors for a vertex
  114509. */
  114510. export class PositionNormalVertex {
  114511. /** the position of the vertex (defaut: 0,0,0) */
  114512. position: Vector3;
  114513. /** the normal of the vertex (defaut: 0,1,0) */
  114514. normal: Vector3;
  114515. /**
  114516. * Creates a PositionNormalVertex
  114517. * @param position the position of the vertex (defaut: 0,0,0)
  114518. * @param normal the normal of the vertex (defaut: 0,1,0)
  114519. */
  114520. constructor(
  114521. /** the position of the vertex (defaut: 0,0,0) */
  114522. position?: Vector3,
  114523. /** the normal of the vertex (defaut: 0,1,0) */
  114524. normal?: Vector3);
  114525. /**
  114526. * Clones the PositionNormalVertex
  114527. * @returns the cloned PositionNormalVertex
  114528. */
  114529. clone(): PositionNormalVertex;
  114530. }
  114531. /**
  114532. * Contains position, normal and uv vectors for a vertex
  114533. */
  114534. export class PositionNormalTextureVertex {
  114535. /** the position of the vertex (defaut: 0,0,0) */
  114536. position: Vector3;
  114537. /** the normal of the vertex (defaut: 0,1,0) */
  114538. normal: Vector3;
  114539. /** the uv of the vertex (default: 0,0) */
  114540. uv: Vector2;
  114541. /**
  114542. * Creates a PositionNormalTextureVertex
  114543. * @param position the position of the vertex (defaut: 0,0,0)
  114544. * @param normal the normal of the vertex (defaut: 0,1,0)
  114545. * @param uv the uv of the vertex (default: 0,0)
  114546. */
  114547. constructor(
  114548. /** the position of the vertex (defaut: 0,0,0) */
  114549. position?: Vector3,
  114550. /** the normal of the vertex (defaut: 0,1,0) */
  114551. normal?: Vector3,
  114552. /** the uv of the vertex (default: 0,0) */
  114553. uv?: Vector2);
  114554. /**
  114555. * Clones the PositionNormalTextureVertex
  114556. * @returns the cloned PositionNormalTextureVertex
  114557. */
  114558. clone(): PositionNormalTextureVertex;
  114559. }
  114560. }
  114561. declare module BABYLON {
  114562. /** @hidden */
  114563. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114564. private _genericAttributeLocation;
  114565. private _varyingLocationCount;
  114566. private _varyingLocationMap;
  114567. private _replacements;
  114568. private _textureCount;
  114569. private _uniforms;
  114570. lineProcessor(line: string): string;
  114571. attributeProcessor(attribute: string): string;
  114572. varyingProcessor(varying: string, isFragment: boolean): string;
  114573. uniformProcessor(uniform: string): string;
  114574. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114575. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114576. }
  114577. }
  114578. declare module BABYLON {
  114579. /**
  114580. * Container for accessors for natively-stored mesh data buffers.
  114581. */
  114582. class NativeDataBuffer extends DataBuffer {
  114583. /**
  114584. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114585. */
  114586. nativeIndexBuffer?: any;
  114587. /**
  114588. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114589. */
  114590. nativeVertexBuffer?: any;
  114591. }
  114592. /** @hidden */
  114593. class NativeTexture extends InternalTexture {
  114594. getInternalTexture(): InternalTexture;
  114595. getViewCount(): number;
  114596. }
  114597. /** @hidden */
  114598. export class NativeEngine extends Engine {
  114599. private readonly _native;
  114600. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114601. private readonly INVALID_HANDLE;
  114602. getHardwareScalingLevel(): number;
  114603. constructor();
  114604. /**
  114605. * Can be used to override the current requestAnimationFrame requester.
  114606. * @hidden
  114607. */
  114608. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114609. /**
  114610. * Override default engine behavior.
  114611. * @param color
  114612. * @param backBuffer
  114613. * @param depth
  114614. * @param stencil
  114615. */
  114616. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114617. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114618. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114619. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114620. recordVertexArrayObject(vertexBuffers: {
  114621. [key: string]: VertexBuffer;
  114622. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114623. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114624. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114625. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114626. /**
  114627. * Draw a list of indexed primitives
  114628. * @param fillMode defines the primitive to use
  114629. * @param indexStart defines the starting index
  114630. * @param indexCount defines the number of index to draw
  114631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114632. */
  114633. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114634. /**
  114635. * Draw a list of unindexed primitives
  114636. * @param fillMode defines the primitive to use
  114637. * @param verticesStart defines the index of first vertex to draw
  114638. * @param verticesCount defines the count of vertices to draw
  114639. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114640. */
  114641. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114642. createPipelineContext(): IPipelineContext;
  114643. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114644. /** @hidden */
  114645. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114646. /** @hidden */
  114647. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114648. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114649. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114650. protected _setProgram(program: WebGLProgram): void;
  114651. _releaseEffect(effect: Effect): void;
  114652. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114653. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  114654. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  114655. bindSamplers(effect: Effect): void;
  114656. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  114657. getRenderWidth(useScreen?: boolean): number;
  114658. getRenderHeight(useScreen?: boolean): number;
  114659. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114660. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114661. /**
  114662. * Set the z offset to apply to current rendering
  114663. * @param value defines the offset to apply
  114664. */
  114665. setZOffset(value: number): void;
  114666. /**
  114667. * Gets the current value of the zOffset
  114668. * @returns the current zOffset state
  114669. */
  114670. getZOffset(): number;
  114671. /**
  114672. * Enable or disable depth buffering
  114673. * @param enable defines the state to set
  114674. */
  114675. setDepthBuffer(enable: boolean): void;
  114676. /**
  114677. * Gets a boolean indicating if depth writing is enabled
  114678. * @returns the current depth writing state
  114679. */
  114680. getDepthWrite(): boolean;
  114681. /**
  114682. * Enable or disable depth writing
  114683. * @param enable defines the state to set
  114684. */
  114685. setDepthWrite(enable: boolean): void;
  114686. /**
  114687. * Enable or disable color writing
  114688. * @param enable defines the state to set
  114689. */
  114690. setColorWrite(enable: boolean): void;
  114691. /**
  114692. * Gets a boolean indicating if color writing is enabled
  114693. * @returns the current color writing state
  114694. */
  114695. getColorWrite(): boolean;
  114696. /**
  114697. * Sets alpha constants used by some alpha blending modes
  114698. * @param r defines the red component
  114699. * @param g defines the green component
  114700. * @param b defines the blue component
  114701. * @param a defines the alpha component
  114702. */
  114703. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114704. /**
  114705. * Sets the current alpha mode
  114706. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114707. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114708. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114709. */
  114710. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114711. /**
  114712. * Gets the current alpha mode
  114713. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114714. * @returns the current alpha mode
  114715. */
  114716. getAlphaMode(): number;
  114717. setInt(uniform: WebGLUniformLocation, int: number): void;
  114718. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114719. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114720. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114721. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114722. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114723. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114724. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114725. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114726. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114727. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114728. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114729. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114730. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114731. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114732. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114733. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114734. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114735. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114736. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114737. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114738. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114739. wipeCaches(bruteForce?: boolean): void;
  114740. _createTexture(): WebGLTexture;
  114741. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114742. /**
  114743. * Usually called from BABYLON.Texture.ts.
  114744. * Passed information to create a WebGLTexture
  114745. * @param urlArg defines a value which contains one of the following:
  114746. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114747. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114748. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114750. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114751. * @param scene needed for loading to the correct scene
  114752. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114753. * @param onLoad optional callback to be called upon successful completion
  114754. * @param onError optional callback to be called upon failure
  114755. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114756. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114757. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114758. * @param forcedExtension defines the extension to use to pick the right loader
  114759. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114760. */
  114761. 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;
  114762. /**
  114763. * Creates a cube texture
  114764. * @param rootUrl defines the url where the files to load is located
  114765. * @param scene defines the current scene
  114766. * @param files defines the list of files to load (1 per face)
  114767. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114768. * @param onLoad defines an optional callback raised when the texture is loaded
  114769. * @param onError defines an optional callback raised if there is an issue to load the texture
  114770. * @param format defines the format of the data
  114771. * @param forcedExtension defines the extension to use to pick the right loader
  114772. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114773. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114774. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114775. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114776. * @returns the cube texture as an InternalTexture
  114777. */
  114778. 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;
  114779. private _getSamplingFilter;
  114780. private static _GetNativeTextureFormat;
  114781. createRenderTargetTexture(size: number | {
  114782. width: number;
  114783. height: number;
  114784. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114785. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114786. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114787. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114788. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114789. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114790. /**
  114791. * Updates a dynamic vertex buffer.
  114792. * @param vertexBuffer the vertex buffer to update
  114793. * @param data the data used to update the vertex buffer
  114794. * @param byteOffset the byte offset of the data (optional)
  114795. * @param byteLength the byte length of the data (optional)
  114796. */
  114797. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114798. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114799. private _updateAnisotropicLevel;
  114800. private _getAddressMode;
  114801. /** @hidden */
  114802. _bindTexture(channel: number, texture: InternalTexture): void;
  114803. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114804. releaseEffects(): void;
  114805. /** @hidden */
  114806. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114807. /** @hidden */
  114808. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114809. /** @hidden */
  114810. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114811. /** @hidden */
  114812. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114813. }
  114814. }
  114815. declare module BABYLON {
  114816. /**
  114817. * Gather the list of clipboard event types as constants.
  114818. */
  114819. export class ClipboardEventTypes {
  114820. /**
  114821. * The clipboard event is fired when a copy command is active (pressed).
  114822. */
  114823. static readonly COPY: number;
  114824. /**
  114825. * The clipboard event is fired when a cut command is active (pressed).
  114826. */
  114827. static readonly CUT: number;
  114828. /**
  114829. * The clipboard event is fired when a paste command is active (pressed).
  114830. */
  114831. static readonly PASTE: number;
  114832. }
  114833. /**
  114834. * This class is used to store clipboard related info for the onClipboardObservable event.
  114835. */
  114836. export class ClipboardInfo {
  114837. /**
  114838. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114839. */
  114840. type: number;
  114841. /**
  114842. * Defines the related dom event
  114843. */
  114844. event: ClipboardEvent;
  114845. /**
  114846. *Creates an instance of ClipboardInfo.
  114847. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114848. * @param event Defines the related dom event
  114849. */
  114850. constructor(
  114851. /**
  114852. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114853. */
  114854. type: number,
  114855. /**
  114856. * Defines the related dom event
  114857. */
  114858. event: ClipboardEvent);
  114859. /**
  114860. * Get the clipboard event's type from the keycode.
  114861. * @param keyCode Defines the keyCode for the current keyboard event.
  114862. * @return {number}
  114863. */
  114864. static GetTypeFromCharacter(keyCode: number): number;
  114865. }
  114866. }
  114867. declare module BABYLON {
  114868. /**
  114869. * Google Daydream controller
  114870. */
  114871. export class DaydreamController extends WebVRController {
  114872. /**
  114873. * Base Url for the controller model.
  114874. */
  114875. static MODEL_BASE_URL: string;
  114876. /**
  114877. * File name for the controller model.
  114878. */
  114879. static MODEL_FILENAME: string;
  114880. /**
  114881. * Gamepad Id prefix used to identify Daydream Controller.
  114882. */
  114883. static readonly GAMEPAD_ID_PREFIX: string;
  114884. /**
  114885. * Creates a new DaydreamController from a gamepad
  114886. * @param vrGamepad the gamepad that the controller should be created from
  114887. */
  114888. constructor(vrGamepad: any);
  114889. /**
  114890. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114891. * @param scene scene in which to add meshes
  114892. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114893. */
  114894. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114895. /**
  114896. * Called once for each button that changed state since the last frame
  114897. * @param buttonIdx Which button index changed
  114898. * @param state New state of the button
  114899. * @param changes Which properties on the state changed since last frame
  114900. */
  114901. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114902. }
  114903. }
  114904. declare module BABYLON {
  114905. /**
  114906. * Gear VR Controller
  114907. */
  114908. export class GearVRController extends WebVRController {
  114909. /**
  114910. * Base Url for the controller model.
  114911. */
  114912. static MODEL_BASE_URL: string;
  114913. /**
  114914. * File name for the controller model.
  114915. */
  114916. static MODEL_FILENAME: string;
  114917. /**
  114918. * Gamepad Id prefix used to identify this controller.
  114919. */
  114920. static readonly GAMEPAD_ID_PREFIX: string;
  114921. private readonly _buttonIndexToObservableNameMap;
  114922. /**
  114923. * Creates a new GearVRController from a gamepad
  114924. * @param vrGamepad the gamepad that the controller should be created from
  114925. */
  114926. constructor(vrGamepad: any);
  114927. /**
  114928. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114929. * @param scene scene in which to add meshes
  114930. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114931. */
  114932. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114933. /**
  114934. * Called once for each button that changed state since the last frame
  114935. * @param buttonIdx Which button index changed
  114936. * @param state New state of the button
  114937. * @param changes Which properties on the state changed since last frame
  114938. */
  114939. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114940. }
  114941. }
  114942. declare module BABYLON {
  114943. /**
  114944. * Class containing static functions to help procedurally build meshes
  114945. */
  114946. export class PolyhedronBuilder {
  114947. /**
  114948. * Creates a polyhedron mesh
  114949. * * 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
  114950. * * The parameter `size` (positive float, default 1) sets the polygon size
  114951. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114952. * * 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`
  114953. * * 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
  114954. * * 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)`)
  114955. * * 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
  114956. * * 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
  114957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114960. * @param name defines the name of the mesh
  114961. * @param options defines the options used to create the mesh
  114962. * @param scene defines the hosting scene
  114963. * @returns the polyhedron mesh
  114964. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114965. */
  114966. static CreatePolyhedron(name: string, options: {
  114967. type?: number;
  114968. size?: number;
  114969. sizeX?: number;
  114970. sizeY?: number;
  114971. sizeZ?: number;
  114972. custom?: any;
  114973. faceUV?: Vector4[];
  114974. faceColors?: Color4[];
  114975. flat?: boolean;
  114976. updatable?: boolean;
  114977. sideOrientation?: number;
  114978. frontUVs?: Vector4;
  114979. backUVs?: Vector4;
  114980. }, scene?: Nullable<Scene>): Mesh;
  114981. }
  114982. }
  114983. declare module BABYLON {
  114984. /**
  114985. * Gizmo that enables scaling a mesh along 3 axis
  114986. */
  114987. export class ScaleGizmo extends Gizmo {
  114988. /**
  114989. * Internal gizmo used for interactions on the x axis
  114990. */
  114991. xGizmo: AxisScaleGizmo;
  114992. /**
  114993. * Internal gizmo used for interactions on the y axis
  114994. */
  114995. yGizmo: AxisScaleGizmo;
  114996. /**
  114997. * Internal gizmo used for interactions on the z axis
  114998. */
  114999. zGizmo: AxisScaleGizmo;
  115000. /**
  115001. * Internal gizmo used to scale all axis equally
  115002. */
  115003. uniformScaleGizmo: AxisScaleGizmo;
  115004. private _meshAttached;
  115005. private _updateGizmoRotationToMatchAttachedMesh;
  115006. private _snapDistance;
  115007. private _scaleRatio;
  115008. private _uniformScalingMesh;
  115009. private _octahedron;
  115010. private _sensitivity;
  115011. /** Fires an event when any of it's sub gizmos are dragged */
  115012. onDragStartObservable: Observable<unknown>;
  115013. /** Fires an event when any of it's sub gizmos are released from dragging */
  115014. onDragEndObservable: Observable<unknown>;
  115015. attachedMesh: Nullable<AbstractMesh>;
  115016. /**
  115017. * Creates a ScaleGizmo
  115018. * @param gizmoLayer The utility layer the gizmo will be added to
  115019. */
  115020. constructor(gizmoLayer?: UtilityLayerRenderer);
  115021. updateGizmoRotationToMatchAttachedMesh: boolean;
  115022. /**
  115023. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115024. */
  115025. snapDistance: number;
  115026. /**
  115027. * Ratio for the scale of the gizmo (Default: 1)
  115028. */
  115029. scaleRatio: number;
  115030. /**
  115031. * Sensitivity factor for dragging (Default: 1)
  115032. */
  115033. sensitivity: number;
  115034. /**
  115035. * Disposes of the gizmo
  115036. */
  115037. dispose(): void;
  115038. }
  115039. }
  115040. declare module BABYLON {
  115041. /**
  115042. * Single axis scale gizmo
  115043. */
  115044. export class AxisScaleGizmo extends Gizmo {
  115045. /**
  115046. * Drag behavior responsible for the gizmos dragging interactions
  115047. */
  115048. dragBehavior: PointerDragBehavior;
  115049. private _pointerObserver;
  115050. /**
  115051. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115052. */
  115053. snapDistance: number;
  115054. /**
  115055. * Event that fires each time the gizmo snaps to a new location.
  115056. * * snapDistance is the the change in distance
  115057. */
  115058. onSnapObservable: Observable<{
  115059. snapDistance: number;
  115060. }>;
  115061. /**
  115062. * If the scaling operation should be done on all axis (default: false)
  115063. */
  115064. uniformScaling: boolean;
  115065. /**
  115066. * Custom sensitivity value for the drag strength
  115067. */
  115068. sensitivity: number;
  115069. private _isEnabled;
  115070. private _parent;
  115071. private _arrow;
  115072. private _coloredMaterial;
  115073. private _hoverMaterial;
  115074. /**
  115075. * Creates an AxisScaleGizmo
  115076. * @param gizmoLayer The utility layer the gizmo will be added to
  115077. * @param dragAxis The axis which the gizmo will be able to scale on
  115078. * @param color The color of the gizmo
  115079. */
  115080. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115081. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115082. /**
  115083. * If the gizmo is enabled
  115084. */
  115085. isEnabled: boolean;
  115086. /**
  115087. * Disposes of the gizmo
  115088. */
  115089. dispose(): void;
  115090. /**
  115091. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115092. * @param mesh The mesh to replace the default mesh of the gizmo
  115093. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115094. */
  115095. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115096. }
  115097. }
  115098. declare module BABYLON {
  115099. /**
  115100. * Bounding box gizmo
  115101. */
  115102. export class BoundingBoxGizmo extends Gizmo {
  115103. private _lineBoundingBox;
  115104. private _rotateSpheresParent;
  115105. private _scaleBoxesParent;
  115106. private _boundingDimensions;
  115107. private _renderObserver;
  115108. private _pointerObserver;
  115109. private _scaleDragSpeed;
  115110. private _tmpQuaternion;
  115111. private _tmpVector;
  115112. private _tmpRotationMatrix;
  115113. /**
  115114. * 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)
  115115. */
  115116. ignoreChildren: boolean;
  115117. /**
  115118. * 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)
  115119. */
  115120. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115121. /**
  115122. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115123. */
  115124. rotationSphereSize: number;
  115125. /**
  115126. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115127. */
  115128. scaleBoxSize: number;
  115129. /**
  115130. * 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)
  115131. */
  115132. fixedDragMeshScreenSize: boolean;
  115133. /**
  115134. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115135. */
  115136. fixedDragMeshScreenSizeDistanceFactor: number;
  115137. /**
  115138. * Fired when a rotation sphere or scale box is dragged
  115139. */
  115140. onDragStartObservable: Observable<{}>;
  115141. /**
  115142. * Fired when a scale box is dragged
  115143. */
  115144. onScaleBoxDragObservable: Observable<{}>;
  115145. /**
  115146. * Fired when a scale box drag is ended
  115147. */
  115148. onScaleBoxDragEndObservable: Observable<{}>;
  115149. /**
  115150. * Fired when a rotation sphere is dragged
  115151. */
  115152. onRotationSphereDragObservable: Observable<{}>;
  115153. /**
  115154. * Fired when a rotation sphere drag is ended
  115155. */
  115156. onRotationSphereDragEndObservable: Observable<{}>;
  115157. /**
  115158. * 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)
  115159. */
  115160. scalePivot: Nullable<Vector3>;
  115161. /**
  115162. * Mesh used as a pivot to rotate the attached mesh
  115163. */
  115164. private _anchorMesh;
  115165. private _existingMeshScale;
  115166. private _dragMesh;
  115167. private pointerDragBehavior;
  115168. private coloredMaterial;
  115169. private hoverColoredMaterial;
  115170. /**
  115171. * Sets the color of the bounding box gizmo
  115172. * @param color the color to set
  115173. */
  115174. setColor(color: Color3): void;
  115175. /**
  115176. * Creates an BoundingBoxGizmo
  115177. * @param gizmoLayer The utility layer the gizmo will be added to
  115178. * @param color The color of the gizmo
  115179. */
  115180. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115181. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115182. private _selectNode;
  115183. /**
  115184. * Updates the bounding box information for the Gizmo
  115185. */
  115186. updateBoundingBox(): void;
  115187. private _updateRotationSpheres;
  115188. private _updateScaleBoxes;
  115189. /**
  115190. * Enables rotation on the specified axis and disables rotation on the others
  115191. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115192. */
  115193. setEnabledRotationAxis(axis: string): void;
  115194. /**
  115195. * Enables/disables scaling
  115196. * @param enable if scaling should be enabled
  115197. */
  115198. setEnabledScaling(enable: boolean): void;
  115199. private _updateDummy;
  115200. /**
  115201. * Enables a pointer drag behavior on the bounding box of the gizmo
  115202. */
  115203. enableDragBehavior(): void;
  115204. /**
  115205. * Disposes of the gizmo
  115206. */
  115207. dispose(): void;
  115208. /**
  115209. * 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)
  115210. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115211. * @returns the bounding box mesh with the passed in mesh as a child
  115212. */
  115213. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115214. /**
  115215. * CustomMeshes are not supported by this gizmo
  115216. * @param mesh The mesh to replace the default mesh of the gizmo
  115217. */
  115218. setCustomMesh(mesh: Mesh): void;
  115219. }
  115220. }
  115221. declare module BABYLON {
  115222. /**
  115223. * Single plane rotation gizmo
  115224. */
  115225. export class PlaneRotationGizmo extends Gizmo {
  115226. /**
  115227. * Drag behavior responsible for the gizmos dragging interactions
  115228. */
  115229. dragBehavior: PointerDragBehavior;
  115230. private _pointerObserver;
  115231. /**
  115232. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115233. */
  115234. snapDistance: number;
  115235. /**
  115236. * Event that fires each time the gizmo snaps to a new location.
  115237. * * snapDistance is the the change in distance
  115238. */
  115239. onSnapObservable: Observable<{
  115240. snapDistance: number;
  115241. }>;
  115242. private _isEnabled;
  115243. private _parent;
  115244. /**
  115245. * Creates a PlaneRotationGizmo
  115246. * @param gizmoLayer The utility layer the gizmo will be added to
  115247. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115248. * @param color The color of the gizmo
  115249. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115250. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115251. */
  115252. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115254. /**
  115255. * If the gizmo is enabled
  115256. */
  115257. isEnabled: boolean;
  115258. /**
  115259. * Disposes of the gizmo
  115260. */
  115261. dispose(): void;
  115262. }
  115263. }
  115264. declare module BABYLON {
  115265. /**
  115266. * Gizmo that enables rotating a mesh along 3 axis
  115267. */
  115268. export class RotationGizmo extends Gizmo {
  115269. /**
  115270. * Internal gizmo used for interactions on the x axis
  115271. */
  115272. xGizmo: PlaneRotationGizmo;
  115273. /**
  115274. * Internal gizmo used for interactions on the y axis
  115275. */
  115276. yGizmo: PlaneRotationGizmo;
  115277. /**
  115278. * Internal gizmo used for interactions on the z axis
  115279. */
  115280. zGizmo: PlaneRotationGizmo;
  115281. /** Fires an event when any of it's sub gizmos are dragged */
  115282. onDragStartObservable: Observable<unknown>;
  115283. /** Fires an event when any of it's sub gizmos are released from dragging */
  115284. onDragEndObservable: Observable<unknown>;
  115285. private _meshAttached;
  115286. attachedMesh: Nullable<AbstractMesh>;
  115287. /**
  115288. * Creates a RotationGizmo
  115289. * @param gizmoLayer The utility layer the gizmo will be added to
  115290. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115291. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115292. */
  115293. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115294. updateGizmoRotationToMatchAttachedMesh: boolean;
  115295. /**
  115296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115297. */
  115298. snapDistance: number;
  115299. /**
  115300. * Ratio for the scale of the gizmo (Default: 1)
  115301. */
  115302. scaleRatio: number;
  115303. /**
  115304. * Disposes of the gizmo
  115305. */
  115306. dispose(): void;
  115307. /**
  115308. * CustomMeshes are not supported by this gizmo
  115309. * @param mesh The mesh to replace the default mesh of the gizmo
  115310. */
  115311. setCustomMesh(mesh: Mesh): void;
  115312. }
  115313. }
  115314. declare module BABYLON {
  115315. /**
  115316. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115317. */
  115318. export class GizmoManager implements IDisposable {
  115319. private scene;
  115320. /**
  115321. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115322. */
  115323. gizmos: {
  115324. positionGizmo: Nullable<PositionGizmo>;
  115325. rotationGizmo: Nullable<RotationGizmo>;
  115326. scaleGizmo: Nullable<ScaleGizmo>;
  115327. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115328. };
  115329. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115330. clearGizmoOnEmptyPointerEvent: boolean;
  115331. /** Fires an event when the manager is attached to a mesh */
  115332. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115333. private _gizmosEnabled;
  115334. private _pointerObserver;
  115335. private _attachedMesh;
  115336. private _boundingBoxColor;
  115337. private _defaultUtilityLayer;
  115338. private _defaultKeepDepthUtilityLayer;
  115339. /**
  115340. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115341. */
  115342. boundingBoxDragBehavior: SixDofDragBehavior;
  115343. /**
  115344. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115345. */
  115346. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115347. /**
  115348. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115349. */
  115350. usePointerToAttachGizmos: boolean;
  115351. /**
  115352. * Utility layer that the bounding box gizmo belongs to
  115353. */
  115354. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115355. /**
  115356. * Utility layer that all gizmos besides bounding box belong to
  115357. */
  115358. readonly utilityLayer: UtilityLayerRenderer;
  115359. /**
  115360. * Instatiates a gizmo manager
  115361. * @param scene the scene to overlay the gizmos on top of
  115362. */
  115363. constructor(scene: Scene);
  115364. /**
  115365. * Attaches a set of gizmos to the specified mesh
  115366. * @param mesh The mesh the gizmo's should be attached to
  115367. */
  115368. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115369. /**
  115370. * If the position gizmo is enabled
  115371. */
  115372. positionGizmoEnabled: boolean;
  115373. /**
  115374. * If the rotation gizmo is enabled
  115375. */
  115376. rotationGizmoEnabled: boolean;
  115377. /**
  115378. * If the scale gizmo is enabled
  115379. */
  115380. scaleGizmoEnabled: boolean;
  115381. /**
  115382. * If the boundingBox gizmo is enabled
  115383. */
  115384. boundingBoxGizmoEnabled: boolean;
  115385. /**
  115386. * Disposes of the gizmo manager
  115387. */
  115388. dispose(): void;
  115389. }
  115390. }
  115391. declare module BABYLON {
  115392. /**
  115393. * A directional light is defined by a direction (what a surprise!).
  115394. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  115395. * 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.
  115396. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115397. */
  115398. export class DirectionalLight extends ShadowLight {
  115399. private _shadowFrustumSize;
  115400. /**
  115401. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  115402. */
  115403. /**
  115404. * Specifies a fix frustum size for the shadow generation.
  115405. */
  115406. shadowFrustumSize: number;
  115407. private _shadowOrthoScale;
  115408. /**
  115409. * Gets the shadow projection scale against the optimal computed one.
  115410. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115411. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115412. */
  115413. /**
  115414. * Sets the shadow projection scale against the optimal computed one.
  115415. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115416. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115417. */
  115418. shadowOrthoScale: number;
  115419. /**
  115420. * Automatically compute the projection matrix to best fit (including all the casters)
  115421. * on each frame.
  115422. */
  115423. autoUpdateExtends: boolean;
  115424. private _orthoLeft;
  115425. private _orthoRight;
  115426. private _orthoTop;
  115427. private _orthoBottom;
  115428. /**
  115429. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  115430. * The directional light is emitted from everywhere in the given direction.
  115431. * It can cast shadows.
  115432. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115433. * @param name The friendly name of the light
  115434. * @param direction The direction of the light
  115435. * @param scene The scene the light belongs to
  115436. */
  115437. constructor(name: string, direction: Vector3, scene: Scene);
  115438. /**
  115439. * Returns the string "DirectionalLight".
  115440. * @return The class name
  115441. */
  115442. getClassName(): string;
  115443. /**
  115444. * Returns the integer 1.
  115445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115446. */
  115447. getTypeID(): number;
  115448. /**
  115449. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  115450. * Returns the DirectionalLight Shadow projection matrix.
  115451. */
  115452. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115453. /**
  115454. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  115455. * Returns the DirectionalLight Shadow projection matrix.
  115456. */
  115457. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  115458. /**
  115459. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  115460. * Returns the DirectionalLight Shadow projection matrix.
  115461. */
  115462. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115463. protected _buildUniformLayout(): void;
  115464. /**
  115465. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  115466. * @param effect The effect to update
  115467. * @param lightIndex The index of the light in the effect to update
  115468. * @returns The directional light
  115469. */
  115470. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  115471. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  115472. /**
  115473. * Gets the minZ used for shadow according to both the scene and the light.
  115474. *
  115475. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115476. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115477. * @param activeCamera The camera we are returning the min for
  115478. * @returns the depth min z
  115479. */
  115480. getDepthMinZ(activeCamera: Camera): number;
  115481. /**
  115482. * Gets the maxZ used for shadow according to both the scene and the light.
  115483. *
  115484. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115485. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115486. * @param activeCamera The camera we are returning the max for
  115487. * @returns the depth max z
  115488. */
  115489. getDepthMaxZ(activeCamera: Camera): number;
  115490. /**
  115491. * Prepares the list of defines specific to the light type.
  115492. * @param defines the list of defines
  115493. * @param lightIndex defines the index of the light for the effect
  115494. */
  115495. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115496. }
  115497. }
  115498. declare module BABYLON {
  115499. /**
  115500. * Class containing static functions to help procedurally build meshes
  115501. */
  115502. export class HemisphereBuilder {
  115503. /**
  115504. * Creates a hemisphere mesh
  115505. * @param name defines the name of the mesh
  115506. * @param options defines the options used to create the mesh
  115507. * @param scene defines the hosting scene
  115508. * @returns the hemisphere mesh
  115509. */
  115510. static CreateHemisphere(name: string, options: {
  115511. segments?: number;
  115512. diameter?: number;
  115513. sideOrientation?: number;
  115514. }, scene: any): Mesh;
  115515. }
  115516. }
  115517. declare module BABYLON {
  115518. /**
  115519. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115520. * These values define a cone of light starting from the position, emitting toward the direction.
  115521. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115522. * and the exponent defines the speed of the decay of the light with distance (reach).
  115523. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115524. */
  115525. export class SpotLight extends ShadowLight {
  115526. private _angle;
  115527. private _innerAngle;
  115528. private _cosHalfAngle;
  115529. private _lightAngleScale;
  115530. private _lightAngleOffset;
  115531. /**
  115532. * Gets the cone angle of the spot light in Radians.
  115533. */
  115534. /**
  115535. * Sets the cone angle of the spot light in Radians.
  115536. */
  115537. angle: number;
  115538. /**
  115539. * Only used in gltf falloff mode, this defines the angle where
  115540. * the directional falloff will start before cutting at angle which could be seen
  115541. * as outer angle.
  115542. */
  115543. /**
  115544. * Only used in gltf falloff mode, this defines the angle where
  115545. * the directional falloff will start before cutting at angle which could be seen
  115546. * as outer angle.
  115547. */
  115548. innerAngle: number;
  115549. private _shadowAngleScale;
  115550. /**
  115551. * Allows scaling the angle of the light for shadow generation only.
  115552. */
  115553. /**
  115554. * Allows scaling the angle of the light for shadow generation only.
  115555. */
  115556. shadowAngleScale: number;
  115557. /**
  115558. * The light decay speed with the distance from the emission spot.
  115559. */
  115560. exponent: number;
  115561. private _projectionTextureMatrix;
  115562. /**
  115563. * Allows reading the projecton texture
  115564. */
  115565. readonly projectionTextureMatrix: Matrix;
  115566. protected _projectionTextureLightNear: number;
  115567. /**
  115568. * Gets the near clip of the Spotlight for texture projection.
  115569. */
  115570. /**
  115571. * Sets the near clip of the Spotlight for texture projection.
  115572. */
  115573. projectionTextureLightNear: number;
  115574. protected _projectionTextureLightFar: number;
  115575. /**
  115576. * Gets the far clip of the Spotlight for texture projection.
  115577. */
  115578. /**
  115579. * Sets the far clip of the Spotlight for texture projection.
  115580. */
  115581. projectionTextureLightFar: number;
  115582. protected _projectionTextureUpDirection: Vector3;
  115583. /**
  115584. * Gets the Up vector of the Spotlight for texture projection.
  115585. */
  115586. /**
  115587. * Sets the Up vector of the Spotlight for texture projection.
  115588. */
  115589. projectionTextureUpDirection: Vector3;
  115590. private _projectionTexture;
  115591. /**
  115592. * Gets the projection texture of the light.
  115593. */
  115594. /**
  115595. * Sets the projection texture of the light.
  115596. */
  115597. projectionTexture: Nullable<BaseTexture>;
  115598. private _projectionTextureViewLightDirty;
  115599. private _projectionTextureProjectionLightDirty;
  115600. private _projectionTextureDirty;
  115601. private _projectionTextureViewTargetVector;
  115602. private _projectionTextureViewLightMatrix;
  115603. private _projectionTextureProjectionLightMatrix;
  115604. private _projectionTextureScalingMatrix;
  115605. /**
  115606. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115607. * It can cast shadows.
  115608. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115609. * @param name The light friendly name
  115610. * @param position The position of the spot light in the scene
  115611. * @param direction The direction of the light in the scene
  115612. * @param angle The cone angle of the light in Radians
  115613. * @param exponent The light decay speed with the distance from the emission spot
  115614. * @param scene The scene the lights belongs to
  115615. */
  115616. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115617. /**
  115618. * Returns the string "SpotLight".
  115619. * @returns the class name
  115620. */
  115621. getClassName(): string;
  115622. /**
  115623. * Returns the integer 2.
  115624. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115625. */
  115626. getTypeID(): number;
  115627. /**
  115628. * Overrides the direction setter to recompute the projection texture view light Matrix.
  115629. */
  115630. protected _setDirection(value: Vector3): void;
  115631. /**
  115632. * Overrides the position setter to recompute the projection texture view light Matrix.
  115633. */
  115634. protected _setPosition(value: Vector3): void;
  115635. /**
  115636. * 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.
  115637. * Returns the SpotLight.
  115638. */
  115639. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115640. protected _computeProjectionTextureViewLightMatrix(): void;
  115641. protected _computeProjectionTextureProjectionLightMatrix(): void;
  115642. /**
  115643. * Main function for light texture projection matrix computing.
  115644. */
  115645. protected _computeProjectionTextureMatrix(): void;
  115646. protected _buildUniformLayout(): void;
  115647. private _computeAngleValues;
  115648. /**
  115649. * Sets the passed Effect "effect" with the Light textures.
  115650. * @param effect The effect to update
  115651. * @param lightIndex The index of the light in the effect to update
  115652. * @returns The light
  115653. */
  115654. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  115655. /**
  115656. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  115657. * @param effect The effect to update
  115658. * @param lightIndex The index of the light in the effect to update
  115659. * @returns The spot light
  115660. */
  115661. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  115662. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115663. /**
  115664. * Disposes the light and the associated resources.
  115665. */
  115666. dispose(): void;
  115667. /**
  115668. * Prepares the list of defines specific to the light type.
  115669. * @param defines the list of defines
  115670. * @param lightIndex defines the index of the light for the effect
  115671. */
  115672. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115673. }
  115674. }
  115675. declare module BABYLON {
  115676. /**
  115677. * Gizmo that enables viewing a light
  115678. */
  115679. export class LightGizmo extends Gizmo {
  115680. private _lightMesh;
  115681. private _material;
  115682. private _cachedPosition;
  115683. private _cachedForward;
  115684. private _attachedMeshParent;
  115685. /**
  115686. * Creates a LightGizmo
  115687. * @param gizmoLayer The utility layer the gizmo will be added to
  115688. */
  115689. constructor(gizmoLayer?: UtilityLayerRenderer);
  115690. private _light;
  115691. /**
  115692. * The light that the gizmo is attached to
  115693. */
  115694. light: Nullable<Light>;
  115695. /**
  115696. * Gets the material used to render the light gizmo
  115697. */
  115698. readonly material: StandardMaterial;
  115699. /**
  115700. * @hidden
  115701. * Updates the gizmo to match the attached mesh's position/rotation
  115702. */
  115703. protected _update(): void;
  115704. private static _Scale;
  115705. /**
  115706. * Creates the lines for a light mesh
  115707. */
  115708. private static _CreateLightLines;
  115709. /**
  115710. * Disposes of the light gizmo
  115711. */
  115712. dispose(): void;
  115713. private static _CreateHemisphericLightMesh;
  115714. private static _CreatePointLightMesh;
  115715. private static _CreateSpotLightMesh;
  115716. private static _CreateDirectionalLightMesh;
  115717. }
  115718. }
  115719. declare module BABYLON {
  115720. /** @hidden */
  115721. export var backgroundFragmentDeclaration: {
  115722. name: string;
  115723. shader: string;
  115724. };
  115725. }
  115726. declare module BABYLON {
  115727. /** @hidden */
  115728. export var backgroundUboDeclaration: {
  115729. name: string;
  115730. shader: string;
  115731. };
  115732. }
  115733. declare module BABYLON {
  115734. /** @hidden */
  115735. export var backgroundPixelShader: {
  115736. name: string;
  115737. shader: string;
  115738. };
  115739. }
  115740. declare module BABYLON {
  115741. /** @hidden */
  115742. export var backgroundVertexDeclaration: {
  115743. name: string;
  115744. shader: string;
  115745. };
  115746. }
  115747. declare module BABYLON {
  115748. /** @hidden */
  115749. export var backgroundVertexShader: {
  115750. name: string;
  115751. shader: string;
  115752. };
  115753. }
  115754. declare module BABYLON {
  115755. /**
  115756. * Background material used to create an efficient environement around your scene.
  115757. */
  115758. export class BackgroundMaterial extends PushMaterial {
  115759. /**
  115760. * Standard reflectance value at parallel view angle.
  115761. */
  115762. static StandardReflectance0: number;
  115763. /**
  115764. * Standard reflectance value at grazing angle.
  115765. */
  115766. static StandardReflectance90: number;
  115767. protected _primaryColor: Color3;
  115768. /**
  115769. * Key light Color (multiply against the environement texture)
  115770. */
  115771. primaryColor: Color3;
  115772. protected __perceptualColor: Nullable<Color3>;
  115773. /**
  115774. * Experimental Internal Use Only.
  115775. *
  115776. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115777. * This acts as a helper to set the primary color to a more "human friendly" value.
  115778. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115779. * output color as close as possible from the chosen value.
  115780. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115781. * part of lighting setup.)
  115782. */
  115783. _perceptualColor: Nullable<Color3>;
  115784. protected _primaryColorShadowLevel: float;
  115785. /**
  115786. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115787. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115788. */
  115789. primaryColorShadowLevel: float;
  115790. protected _primaryColorHighlightLevel: float;
  115791. /**
  115792. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115793. * The primary color is used at the level chosen to define what the white area would look.
  115794. */
  115795. primaryColorHighlightLevel: float;
  115796. protected _reflectionTexture: Nullable<BaseTexture>;
  115797. /**
  115798. * Reflection Texture used in the material.
  115799. * Should be author in a specific way for the best result (refer to the documentation).
  115800. */
  115801. reflectionTexture: Nullable<BaseTexture>;
  115802. protected _reflectionBlur: float;
  115803. /**
  115804. * Reflection Texture level of blur.
  115805. *
  115806. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115807. * texture twice.
  115808. */
  115809. reflectionBlur: float;
  115810. protected _diffuseTexture: Nullable<BaseTexture>;
  115811. /**
  115812. * Diffuse Texture used in the material.
  115813. * Should be author in a specific way for the best result (refer to the documentation).
  115814. */
  115815. diffuseTexture: Nullable<BaseTexture>;
  115816. protected _shadowLights: Nullable<IShadowLight[]>;
  115817. /**
  115818. * Specify the list of lights casting shadow on the material.
  115819. * All scene shadow lights will be included if null.
  115820. */
  115821. shadowLights: Nullable<IShadowLight[]>;
  115822. protected _shadowLevel: float;
  115823. /**
  115824. * Helps adjusting the shadow to a softer level if required.
  115825. * 0 means black shadows and 1 means no shadows.
  115826. */
  115827. shadowLevel: float;
  115828. protected _sceneCenter: Vector3;
  115829. /**
  115830. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115831. * It is usually zero but might be interesting to modify according to your setup.
  115832. */
  115833. sceneCenter: Vector3;
  115834. protected _opacityFresnel: boolean;
  115835. /**
  115836. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115837. * This helps ensuring a nice transition when the camera goes under the ground.
  115838. */
  115839. opacityFresnel: boolean;
  115840. protected _reflectionFresnel: boolean;
  115841. /**
  115842. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115843. * This helps adding a mirror texture on the ground.
  115844. */
  115845. reflectionFresnel: boolean;
  115846. protected _reflectionFalloffDistance: number;
  115847. /**
  115848. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115849. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115850. */
  115851. reflectionFalloffDistance: number;
  115852. protected _reflectionAmount: number;
  115853. /**
  115854. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115855. */
  115856. reflectionAmount: number;
  115857. protected _reflectionReflectance0: number;
  115858. /**
  115859. * This specifies the weight of the reflection at grazing angle.
  115860. */
  115861. reflectionReflectance0: number;
  115862. protected _reflectionReflectance90: number;
  115863. /**
  115864. * This specifies the weight of the reflection at a perpendicular point of view.
  115865. */
  115866. reflectionReflectance90: number;
  115867. /**
  115868. * Sets the reflection reflectance fresnel values according to the default standard
  115869. * empirically know to work well :-)
  115870. */
  115871. reflectionStandardFresnelWeight: number;
  115872. protected _useRGBColor: boolean;
  115873. /**
  115874. * Helps to directly use the maps channels instead of their level.
  115875. */
  115876. useRGBColor: boolean;
  115877. protected _enableNoise: boolean;
  115878. /**
  115879. * This helps reducing the banding effect that could occur on the background.
  115880. */
  115881. enableNoise: boolean;
  115882. /**
  115883. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115884. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115885. * Recommended to be keep at 1.0 except for special cases.
  115886. */
  115887. fovMultiplier: number;
  115888. private _fovMultiplier;
  115889. /**
  115890. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115891. */
  115892. useEquirectangularFOV: boolean;
  115893. private _maxSimultaneousLights;
  115894. /**
  115895. * Number of Simultaneous lights allowed on the material.
  115896. */
  115897. maxSimultaneousLights: int;
  115898. /**
  115899. * Default configuration related to image processing available in the Background Material.
  115900. */
  115901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115902. /**
  115903. * Keep track of the image processing observer to allow dispose and replace.
  115904. */
  115905. private _imageProcessingObserver;
  115906. /**
  115907. * Attaches a new image processing configuration to the PBR Material.
  115908. * @param configuration (if null the scene configuration will be use)
  115909. */
  115910. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115911. /**
  115912. * Gets the image processing configuration used either in this material.
  115913. */
  115914. /**
  115915. * Sets the Default image processing configuration used either in the this material.
  115916. *
  115917. * If sets to null, the scene one is in use.
  115918. */
  115919. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115920. /**
  115921. * Gets wether the color curves effect is enabled.
  115922. */
  115923. /**
  115924. * Sets wether the color curves effect is enabled.
  115925. */
  115926. cameraColorCurvesEnabled: boolean;
  115927. /**
  115928. * Gets wether the color grading effect is enabled.
  115929. */
  115930. /**
  115931. * Gets wether the color grading effect is enabled.
  115932. */
  115933. cameraColorGradingEnabled: boolean;
  115934. /**
  115935. * Gets wether tonemapping is enabled or not.
  115936. */
  115937. /**
  115938. * Sets wether tonemapping is enabled or not
  115939. */
  115940. cameraToneMappingEnabled: boolean;
  115941. /**
  115942. * The camera exposure used on this material.
  115943. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115944. * This corresponds to a photographic exposure.
  115945. */
  115946. /**
  115947. * The camera exposure used on this material.
  115948. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115949. * This corresponds to a photographic exposure.
  115950. */
  115951. cameraExposure: float;
  115952. /**
  115953. * Gets The camera contrast used on this material.
  115954. */
  115955. /**
  115956. * Sets The camera contrast used on this material.
  115957. */
  115958. cameraContrast: float;
  115959. /**
  115960. * Gets the Color Grading 2D Lookup Texture.
  115961. */
  115962. /**
  115963. * Sets the Color Grading 2D Lookup Texture.
  115964. */
  115965. cameraColorGradingTexture: Nullable<BaseTexture>;
  115966. /**
  115967. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115968. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115969. * 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;
  115970. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115971. */
  115972. /**
  115973. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115974. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115975. * 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;
  115976. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115977. */
  115978. cameraColorCurves: Nullable<ColorCurves>;
  115979. /**
  115980. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115981. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115982. */
  115983. switchToBGR: boolean;
  115984. private _renderTargets;
  115985. private _reflectionControls;
  115986. private _white;
  115987. private _primaryShadowColor;
  115988. private _primaryHighlightColor;
  115989. /**
  115990. * Instantiates a Background Material in the given scene
  115991. * @param name The friendly name of the material
  115992. * @param scene The scene to add the material to
  115993. */
  115994. constructor(name: string, scene: Scene);
  115995. /**
  115996. * Gets a boolean indicating that current material needs to register RTT
  115997. */
  115998. readonly hasRenderTargetTextures: boolean;
  115999. /**
  116000. * The entire material has been created in order to prevent overdraw.
  116001. * @returns false
  116002. */
  116003. needAlphaTesting(): boolean;
  116004. /**
  116005. * The entire material has been created in order to prevent overdraw.
  116006. * @returns true if blending is enable
  116007. */
  116008. needAlphaBlending(): boolean;
  116009. /**
  116010. * Checks wether the material is ready to be rendered for a given mesh.
  116011. * @param mesh The mesh to render
  116012. * @param subMesh The submesh to check against
  116013. * @param useInstances Specify wether or not the material is used with instances
  116014. * @returns true if all the dependencies are ready (Textures, Effects...)
  116015. */
  116016. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116017. /**
  116018. * Compute the primary color according to the chosen perceptual color.
  116019. */
  116020. private _computePrimaryColorFromPerceptualColor;
  116021. /**
  116022. * Compute the highlights and shadow colors according to their chosen levels.
  116023. */
  116024. private _computePrimaryColors;
  116025. /**
  116026. * Build the uniform buffer used in the material.
  116027. */
  116028. buildUniformLayout(): void;
  116029. /**
  116030. * Unbind the material.
  116031. */
  116032. unbind(): void;
  116033. /**
  116034. * Bind only the world matrix to the material.
  116035. * @param world The world matrix to bind.
  116036. */
  116037. bindOnlyWorldMatrix(world: Matrix): void;
  116038. /**
  116039. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116040. * @param world The world matrix to bind.
  116041. * @param subMesh The submesh to bind for.
  116042. */
  116043. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116044. /**
  116045. * Checks to see if a texture is used in the material.
  116046. * @param texture - Base texture to use.
  116047. * @returns - Boolean specifying if a texture is used in the material.
  116048. */
  116049. hasTexture(texture: BaseTexture): boolean;
  116050. /**
  116051. * Dispose the material.
  116052. * @param forceDisposeEffect Force disposal of the associated effect.
  116053. * @param forceDisposeTextures Force disposal of the associated textures.
  116054. */
  116055. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116056. /**
  116057. * Clones the material.
  116058. * @param name The cloned name.
  116059. * @returns The cloned material.
  116060. */
  116061. clone(name: string): BackgroundMaterial;
  116062. /**
  116063. * Serializes the current material to its JSON representation.
  116064. * @returns The JSON representation.
  116065. */
  116066. serialize(): any;
  116067. /**
  116068. * Gets the class name of the material
  116069. * @returns "BackgroundMaterial"
  116070. */
  116071. getClassName(): string;
  116072. /**
  116073. * Parse a JSON input to create back a background material.
  116074. * @param source The JSON data to parse
  116075. * @param scene The scene to create the parsed material in
  116076. * @param rootUrl The root url of the assets the material depends upon
  116077. * @returns the instantiated BackgroundMaterial.
  116078. */
  116079. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116080. }
  116081. }
  116082. declare module BABYLON {
  116083. /**
  116084. * Represents the different options available during the creation of
  116085. * a Environment helper.
  116086. *
  116087. * This can control the default ground, skybox and image processing setup of your scene.
  116088. */
  116089. export interface IEnvironmentHelperOptions {
  116090. /**
  116091. * Specifies wether or not to create a ground.
  116092. * True by default.
  116093. */
  116094. createGround: boolean;
  116095. /**
  116096. * Specifies the ground size.
  116097. * 15 by default.
  116098. */
  116099. groundSize: number;
  116100. /**
  116101. * The texture used on the ground for the main color.
  116102. * Comes from the BabylonJS CDN by default.
  116103. *
  116104. * Remarks: Can be either a texture or a url.
  116105. */
  116106. groundTexture: string | BaseTexture;
  116107. /**
  116108. * The color mixed in the ground texture by default.
  116109. * BabylonJS clearColor by default.
  116110. */
  116111. groundColor: Color3;
  116112. /**
  116113. * Specifies the ground opacity.
  116114. * 1 by default.
  116115. */
  116116. groundOpacity: number;
  116117. /**
  116118. * Enables the ground to receive shadows.
  116119. * True by default.
  116120. */
  116121. enableGroundShadow: boolean;
  116122. /**
  116123. * Helps preventing the shadow to be fully black on the ground.
  116124. * 0.5 by default.
  116125. */
  116126. groundShadowLevel: number;
  116127. /**
  116128. * Creates a mirror texture attach to the ground.
  116129. * false by default.
  116130. */
  116131. enableGroundMirror: boolean;
  116132. /**
  116133. * Specifies the ground mirror size ratio.
  116134. * 0.3 by default as the default kernel is 64.
  116135. */
  116136. groundMirrorSizeRatio: number;
  116137. /**
  116138. * Specifies the ground mirror blur kernel size.
  116139. * 64 by default.
  116140. */
  116141. groundMirrorBlurKernel: number;
  116142. /**
  116143. * Specifies the ground mirror visibility amount.
  116144. * 1 by default
  116145. */
  116146. groundMirrorAmount: number;
  116147. /**
  116148. * Specifies the ground mirror reflectance weight.
  116149. * This uses the standard weight of the background material to setup the fresnel effect
  116150. * of the mirror.
  116151. * 1 by default.
  116152. */
  116153. groundMirrorFresnelWeight: number;
  116154. /**
  116155. * Specifies the ground mirror Falloff distance.
  116156. * This can helps reducing the size of the reflection.
  116157. * 0 by Default.
  116158. */
  116159. groundMirrorFallOffDistance: number;
  116160. /**
  116161. * Specifies the ground mirror texture type.
  116162. * Unsigned Int by Default.
  116163. */
  116164. groundMirrorTextureType: number;
  116165. /**
  116166. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116167. * the shown objects.
  116168. */
  116169. groundYBias: number;
  116170. /**
  116171. * Specifies wether or not to create a skybox.
  116172. * True by default.
  116173. */
  116174. createSkybox: boolean;
  116175. /**
  116176. * Specifies the skybox size.
  116177. * 20 by default.
  116178. */
  116179. skyboxSize: number;
  116180. /**
  116181. * The texture used on the skybox for the main color.
  116182. * Comes from the BabylonJS CDN by default.
  116183. *
  116184. * Remarks: Can be either a texture or a url.
  116185. */
  116186. skyboxTexture: string | BaseTexture;
  116187. /**
  116188. * The color mixed in the skybox texture by default.
  116189. * BabylonJS clearColor by default.
  116190. */
  116191. skyboxColor: Color3;
  116192. /**
  116193. * The background rotation around the Y axis of the scene.
  116194. * This helps aligning the key lights of your scene with the background.
  116195. * 0 by default.
  116196. */
  116197. backgroundYRotation: number;
  116198. /**
  116199. * Compute automatically the size of the elements to best fit with the scene.
  116200. */
  116201. sizeAuto: boolean;
  116202. /**
  116203. * Default position of the rootMesh if autoSize is not true.
  116204. */
  116205. rootPosition: Vector3;
  116206. /**
  116207. * Sets up the image processing in the scene.
  116208. * true by default.
  116209. */
  116210. setupImageProcessing: boolean;
  116211. /**
  116212. * The texture used as your environment texture in the scene.
  116213. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116214. *
  116215. * Remarks: Can be either a texture or a url.
  116216. */
  116217. environmentTexture: string | BaseTexture;
  116218. /**
  116219. * The value of the exposure to apply to the scene.
  116220. * 0.6 by default if setupImageProcessing is true.
  116221. */
  116222. cameraExposure: number;
  116223. /**
  116224. * The value of the contrast to apply to the scene.
  116225. * 1.6 by default if setupImageProcessing is true.
  116226. */
  116227. cameraContrast: number;
  116228. /**
  116229. * Specifies wether or not tonemapping should be enabled in the scene.
  116230. * true by default if setupImageProcessing is true.
  116231. */
  116232. toneMappingEnabled: boolean;
  116233. }
  116234. /**
  116235. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116236. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116237. * It also helps with the default setup of your imageProcessing configuration.
  116238. */
  116239. export class EnvironmentHelper {
  116240. /**
  116241. * Default ground texture URL.
  116242. */
  116243. private static _groundTextureCDNUrl;
  116244. /**
  116245. * Default skybox texture URL.
  116246. */
  116247. private static _skyboxTextureCDNUrl;
  116248. /**
  116249. * Default environment texture URL.
  116250. */
  116251. private static _environmentTextureCDNUrl;
  116252. /**
  116253. * Creates the default options for the helper.
  116254. */
  116255. private static _getDefaultOptions;
  116256. private _rootMesh;
  116257. /**
  116258. * Gets the root mesh created by the helper.
  116259. */
  116260. readonly rootMesh: Mesh;
  116261. private _skybox;
  116262. /**
  116263. * Gets the skybox created by the helper.
  116264. */
  116265. readonly skybox: Nullable<Mesh>;
  116266. private _skyboxTexture;
  116267. /**
  116268. * Gets the skybox texture created by the helper.
  116269. */
  116270. readonly skyboxTexture: Nullable<BaseTexture>;
  116271. private _skyboxMaterial;
  116272. /**
  116273. * Gets the skybox material created by the helper.
  116274. */
  116275. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116276. private _ground;
  116277. /**
  116278. * Gets the ground mesh created by the helper.
  116279. */
  116280. readonly ground: Nullable<Mesh>;
  116281. private _groundTexture;
  116282. /**
  116283. * Gets the ground texture created by the helper.
  116284. */
  116285. readonly groundTexture: Nullable<BaseTexture>;
  116286. private _groundMirror;
  116287. /**
  116288. * Gets the ground mirror created by the helper.
  116289. */
  116290. readonly groundMirror: Nullable<MirrorTexture>;
  116291. /**
  116292. * Gets the ground mirror render list to helps pushing the meshes
  116293. * you wish in the ground reflection.
  116294. */
  116295. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116296. private _groundMaterial;
  116297. /**
  116298. * Gets the ground material created by the helper.
  116299. */
  116300. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116301. /**
  116302. * Stores the creation options.
  116303. */
  116304. private readonly _scene;
  116305. private _options;
  116306. /**
  116307. * This observable will be notified with any error during the creation of the environment,
  116308. * mainly texture creation errors.
  116309. */
  116310. onErrorObservable: Observable<{
  116311. message?: string;
  116312. exception?: any;
  116313. }>;
  116314. /**
  116315. * constructor
  116316. * @param options Defines the options we want to customize the helper
  116317. * @param scene The scene to add the material to
  116318. */
  116319. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116320. /**
  116321. * Updates the background according to the new options
  116322. * @param options
  116323. */
  116324. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116325. /**
  116326. * Sets the primary color of all the available elements.
  116327. * @param color the main color to affect to the ground and the background
  116328. */
  116329. setMainColor(color: Color3): void;
  116330. /**
  116331. * Setup the image processing according to the specified options.
  116332. */
  116333. private _setupImageProcessing;
  116334. /**
  116335. * Setup the environment texture according to the specified options.
  116336. */
  116337. private _setupEnvironmentTexture;
  116338. /**
  116339. * Setup the background according to the specified options.
  116340. */
  116341. private _setupBackground;
  116342. /**
  116343. * Get the scene sizes according to the setup.
  116344. */
  116345. private _getSceneSize;
  116346. /**
  116347. * Setup the ground according to the specified options.
  116348. */
  116349. private _setupGround;
  116350. /**
  116351. * Setup the ground material according to the specified options.
  116352. */
  116353. private _setupGroundMaterial;
  116354. /**
  116355. * Setup the ground diffuse texture according to the specified options.
  116356. */
  116357. private _setupGroundDiffuseTexture;
  116358. /**
  116359. * Setup the ground mirror texture according to the specified options.
  116360. */
  116361. private _setupGroundMirrorTexture;
  116362. /**
  116363. * Setup the ground to receive the mirror texture.
  116364. */
  116365. private _setupMirrorInGroundMaterial;
  116366. /**
  116367. * Setup the skybox according to the specified options.
  116368. */
  116369. private _setupSkybox;
  116370. /**
  116371. * Setup the skybox material according to the specified options.
  116372. */
  116373. private _setupSkyboxMaterial;
  116374. /**
  116375. * Setup the skybox reflection texture according to the specified options.
  116376. */
  116377. private _setupSkyboxReflectionTexture;
  116378. private _errorHandler;
  116379. /**
  116380. * Dispose all the elements created by the Helper.
  116381. */
  116382. dispose(): void;
  116383. }
  116384. }
  116385. declare module BABYLON {
  116386. /**
  116387. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  116388. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  116389. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  116390. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116391. */
  116392. export class PhotoDome extends TransformNode {
  116393. /**
  116394. * Define the image as a Monoscopic panoramic 360 image.
  116395. */
  116396. static readonly MODE_MONOSCOPIC: number;
  116397. /**
  116398. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116399. */
  116400. static readonly MODE_TOPBOTTOM: number;
  116401. /**
  116402. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116403. */
  116404. static readonly MODE_SIDEBYSIDE: number;
  116405. private _useDirectMapping;
  116406. /**
  116407. * The texture being displayed on the sphere
  116408. */
  116409. protected _photoTexture: Texture;
  116410. /**
  116411. * Gets or sets the texture being displayed on the sphere
  116412. */
  116413. photoTexture: Texture;
  116414. /**
  116415. * Observable raised when an error occured while loading the 360 image
  116416. */
  116417. onLoadErrorObservable: Observable<string>;
  116418. /**
  116419. * The skybox material
  116420. */
  116421. protected _material: BackgroundMaterial;
  116422. /**
  116423. * The surface used for the skybox
  116424. */
  116425. protected _mesh: Mesh;
  116426. /**
  116427. * Gets the mesh used for the skybox.
  116428. */
  116429. readonly mesh: Mesh;
  116430. /**
  116431. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116432. * Also see the options.resolution property.
  116433. */
  116434. fovMultiplier: number;
  116435. private _imageMode;
  116436. /**
  116437. * Gets or set the current video mode for the video. It can be:
  116438. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  116439. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116440. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116441. */
  116442. imageMode: number;
  116443. /**
  116444. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  116445. * @param name Element's name, child elements will append suffixes for their own names.
  116446. * @param urlsOfPhoto defines the url of the photo to display
  116447. * @param options defines an object containing optional or exposed sub element properties
  116448. * @param onError defines a callback called when an error occured while loading the texture
  116449. */
  116450. constructor(name: string, urlOfPhoto: string, options: {
  116451. resolution?: number;
  116452. size?: number;
  116453. useDirectMapping?: boolean;
  116454. faceForward?: boolean;
  116455. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  116456. private _onBeforeCameraRenderObserver;
  116457. private _changeImageMode;
  116458. /**
  116459. * Releases resources associated with this node.
  116460. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116461. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116462. */
  116463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116464. }
  116465. }
  116466. declare module BABYLON {
  116467. /**
  116468. * Class used to host RGBD texture specific utilities
  116469. */
  116470. export class RGBDTextureTools {
  116471. /**
  116472. * Expand the RGBD Texture from RGBD to Half Float if possible.
  116473. * @param texture the texture to expand.
  116474. */
  116475. static ExpandRGBDTexture(texture: Texture): void;
  116476. }
  116477. }
  116478. declare module BABYLON {
  116479. /**
  116480. * Class used to host texture specific utilities
  116481. */
  116482. export class BRDFTextureTools {
  116483. /**
  116484. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  116485. * @param scene defines the hosting scene
  116486. * @returns the environment BRDF texture
  116487. */
  116488. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  116489. private static _environmentBRDFBase64Texture;
  116490. }
  116491. }
  116492. declare module BABYLON {
  116493. /**
  116494. * @hidden
  116495. */
  116496. export interface IMaterialClearCoatDefines {
  116497. CLEARCOAT: boolean;
  116498. CLEARCOAT_DEFAULTIOR: boolean;
  116499. CLEARCOAT_TEXTURE: boolean;
  116500. CLEARCOAT_TEXTUREDIRECTUV: number;
  116501. CLEARCOAT_BUMP: boolean;
  116502. CLEARCOAT_BUMPDIRECTUV: number;
  116503. CLEARCOAT_TINT: boolean;
  116504. CLEARCOAT_TINT_TEXTURE: boolean;
  116505. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116506. /** @hidden */
  116507. _areTexturesDirty: boolean;
  116508. }
  116509. /**
  116510. * Define the code related to the clear coat parameters of the pbr material.
  116511. */
  116512. export class PBRClearCoatConfiguration {
  116513. /**
  116514. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116515. * The default fits with a polyurethane material.
  116516. */
  116517. private static readonly _DefaultIndexOfRefraction;
  116518. private _isEnabled;
  116519. /**
  116520. * Defines if the clear coat is enabled in the material.
  116521. */
  116522. isEnabled: boolean;
  116523. /**
  116524. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116525. */
  116526. intensity: number;
  116527. /**
  116528. * Defines the clear coat layer roughness.
  116529. */
  116530. roughness: number;
  116531. private _indexOfRefraction;
  116532. /**
  116533. * Defines the index of refraction of the clear coat.
  116534. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116535. * The default fits with a polyurethane material.
  116536. * Changing the default value is more performance intensive.
  116537. */
  116538. indexOfRefraction: number;
  116539. private _texture;
  116540. /**
  116541. * Stores the clear coat values in a texture.
  116542. */
  116543. texture: Nullable<BaseTexture>;
  116544. private _bumpTexture;
  116545. /**
  116546. * Define the clear coat specific bump texture.
  116547. */
  116548. bumpTexture: Nullable<BaseTexture>;
  116549. private _isTintEnabled;
  116550. /**
  116551. * Defines if the clear coat tint is enabled in the material.
  116552. */
  116553. isTintEnabled: boolean;
  116554. /**
  116555. * Defines the clear coat tint of the material.
  116556. * This is only use if tint is enabled
  116557. */
  116558. tintColor: Color3;
  116559. /**
  116560. * Defines the distance at which the tint color should be found in the
  116561. * clear coat media.
  116562. * This is only use if tint is enabled
  116563. */
  116564. tintColorAtDistance: number;
  116565. /**
  116566. * Defines the clear coat layer thickness.
  116567. * This is only use if tint is enabled
  116568. */
  116569. tintThickness: number;
  116570. private _tintTexture;
  116571. /**
  116572. * Stores the clear tint values in a texture.
  116573. * rgb is tint
  116574. * a is a thickness factor
  116575. */
  116576. tintTexture: Nullable<BaseTexture>;
  116577. /** @hidden */
  116578. private _internalMarkAllSubMeshesAsTexturesDirty;
  116579. /** @hidden */
  116580. _markAllSubMeshesAsTexturesDirty(): void;
  116581. /**
  116582. * Instantiate a new istance of clear coat configuration.
  116583. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116584. */
  116585. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116586. /**
  116587. * Gets wehter the submesh is ready to be used or not.
  116588. * @param defines the list of "defines" to update.
  116589. * @param scene defines the scene the material belongs to.
  116590. * @param engine defines the engine the material belongs to.
  116591. * @param disableBumpMap defines wether the material disables bump or not.
  116592. * @returns - boolean indicating that the submesh is ready or not.
  116593. */
  116594. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116595. /**
  116596. * Checks to see if a texture is used in the material.
  116597. * @param defines the list of "defines" to update.
  116598. * @param scene defines the scene to the material belongs to.
  116599. */
  116600. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116601. /**
  116602. * Binds the material data.
  116603. * @param uniformBuffer defines the Uniform buffer to fill in.
  116604. * @param scene defines the scene the material belongs to.
  116605. * @param engine defines the engine the material belongs to.
  116606. * @param disableBumpMap defines wether the material disables bump or not.
  116607. * @param isFrozen defines wether the material is frozen or not.
  116608. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116609. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116610. */
  116611. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116612. /**
  116613. * Checks to see if a texture is used in the material.
  116614. * @param texture - Base texture to use.
  116615. * @returns - Boolean specifying if a texture is used in the material.
  116616. */
  116617. hasTexture(texture: BaseTexture): boolean;
  116618. /**
  116619. * Returns an array of the actively used textures.
  116620. * @param activeTextures Array of BaseTextures
  116621. */
  116622. getActiveTextures(activeTextures: BaseTexture[]): void;
  116623. /**
  116624. * Returns the animatable textures.
  116625. * @param animatables Array of animatable textures.
  116626. */
  116627. getAnimatables(animatables: IAnimatable[]): void;
  116628. /**
  116629. * Disposes the resources of the material.
  116630. * @param forceDisposeTextures - Forces the disposal of all textures.
  116631. */
  116632. dispose(forceDisposeTextures?: boolean): void;
  116633. /**
  116634. * Get the current class name of the texture useful for serialization or dynamic coding.
  116635. * @returns "PBRClearCoatConfiguration"
  116636. */
  116637. getClassName(): string;
  116638. /**
  116639. * Add fallbacks to the effect fallbacks list.
  116640. * @param defines defines the Base texture to use.
  116641. * @param fallbacks defines the current fallback list.
  116642. * @param currentRank defines the current fallback rank.
  116643. * @returns the new fallback rank.
  116644. */
  116645. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116646. /**
  116647. * Add the required uniforms to the current list.
  116648. * @param uniforms defines the current uniform list.
  116649. */
  116650. static AddUniforms(uniforms: string[]): void;
  116651. /**
  116652. * Add the required samplers to the current list.
  116653. * @param samplers defines the current sampler list.
  116654. */
  116655. static AddSamplers(samplers: string[]): void;
  116656. /**
  116657. * Add the required uniforms to the current buffer.
  116658. * @param uniformBuffer defines the current uniform buffer.
  116659. */
  116660. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116661. /**
  116662. * Makes a duplicate of the current configuration into another one.
  116663. * @param clearCoatConfiguration define the config where to copy the info
  116664. */
  116665. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116666. /**
  116667. * Serializes this clear coat configuration.
  116668. * @returns - An object with the serialized config.
  116669. */
  116670. serialize(): any;
  116671. /**
  116672. * Parses a anisotropy Configuration from a serialized object.
  116673. * @param source - Serialized object.
  116674. * @param scene Defines the scene we are parsing for
  116675. * @param rootUrl Defines the rootUrl to load from
  116676. */
  116677. parse(source: any, scene: Scene, rootUrl: string): void;
  116678. }
  116679. }
  116680. declare module BABYLON {
  116681. /**
  116682. * @hidden
  116683. */
  116684. export interface IMaterialAnisotropicDefines {
  116685. ANISOTROPIC: boolean;
  116686. ANISOTROPIC_TEXTURE: boolean;
  116687. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116688. MAINUV1: boolean;
  116689. _areTexturesDirty: boolean;
  116690. _needUVs: boolean;
  116691. }
  116692. /**
  116693. * Define the code related to the anisotropic parameters of the pbr material.
  116694. */
  116695. export class PBRAnisotropicConfiguration {
  116696. private _isEnabled;
  116697. /**
  116698. * Defines if the anisotropy is enabled in the material.
  116699. */
  116700. isEnabled: boolean;
  116701. /**
  116702. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116703. */
  116704. intensity: number;
  116705. /**
  116706. * Defines if the effect is along the tangents, bitangents or in between.
  116707. * By default, the effect is "strectching" the highlights along the tangents.
  116708. */
  116709. direction: Vector2;
  116710. private _texture;
  116711. /**
  116712. * Stores the anisotropy values in a texture.
  116713. * rg is direction (like normal from -1 to 1)
  116714. * b is a intensity
  116715. */
  116716. texture: Nullable<BaseTexture>;
  116717. /** @hidden */
  116718. private _internalMarkAllSubMeshesAsTexturesDirty;
  116719. /** @hidden */
  116720. _markAllSubMeshesAsTexturesDirty(): void;
  116721. /**
  116722. * Instantiate a new istance of anisotropy configuration.
  116723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116724. */
  116725. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116726. /**
  116727. * Specifies that the submesh is ready to be used.
  116728. * @param defines the list of "defines" to update.
  116729. * @param scene defines the scene the material belongs to.
  116730. * @returns - boolean indicating that the submesh is ready or not.
  116731. */
  116732. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116733. /**
  116734. * Checks to see if a texture is used in the material.
  116735. * @param defines the list of "defines" to update.
  116736. * @param mesh the mesh we are preparing the defines for.
  116737. * @param scene defines the scene the material belongs to.
  116738. */
  116739. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116740. /**
  116741. * Binds the material data.
  116742. * @param uniformBuffer defines the Uniform buffer to fill in.
  116743. * @param scene defines the scene the material belongs to.
  116744. * @param isFrozen defines wether the material is frozen or not.
  116745. */
  116746. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116747. /**
  116748. * Checks to see if a texture is used in the material.
  116749. * @param texture - Base texture to use.
  116750. * @returns - Boolean specifying if a texture is used in the material.
  116751. */
  116752. hasTexture(texture: BaseTexture): boolean;
  116753. /**
  116754. * Returns an array of the actively used textures.
  116755. * @param activeTextures Array of BaseTextures
  116756. */
  116757. getActiveTextures(activeTextures: BaseTexture[]): void;
  116758. /**
  116759. * Returns the animatable textures.
  116760. * @param animatables Array of animatable textures.
  116761. */
  116762. getAnimatables(animatables: IAnimatable[]): void;
  116763. /**
  116764. * Disposes the resources of the material.
  116765. * @param forceDisposeTextures - Forces the disposal of all textures.
  116766. */
  116767. dispose(forceDisposeTextures?: boolean): void;
  116768. /**
  116769. * Get the current class name of the texture useful for serialization or dynamic coding.
  116770. * @returns "PBRAnisotropicConfiguration"
  116771. */
  116772. getClassName(): string;
  116773. /**
  116774. * Add fallbacks to the effect fallbacks list.
  116775. * @param defines defines the Base texture to use.
  116776. * @param fallbacks defines the current fallback list.
  116777. * @param currentRank defines the current fallback rank.
  116778. * @returns the new fallback rank.
  116779. */
  116780. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116781. /**
  116782. * Add the required uniforms to the current list.
  116783. * @param uniforms defines the current uniform list.
  116784. */
  116785. static AddUniforms(uniforms: string[]): void;
  116786. /**
  116787. * Add the required uniforms to the current buffer.
  116788. * @param uniformBuffer defines the current uniform buffer.
  116789. */
  116790. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116791. /**
  116792. * Add the required samplers to the current list.
  116793. * @param samplers defines the current sampler list.
  116794. */
  116795. static AddSamplers(samplers: string[]): void;
  116796. /**
  116797. * Makes a duplicate of the current configuration into another one.
  116798. * @param anisotropicConfiguration define the config where to copy the info
  116799. */
  116800. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116801. /**
  116802. * Serializes this anisotropy configuration.
  116803. * @returns - An object with the serialized config.
  116804. */
  116805. serialize(): any;
  116806. /**
  116807. * Parses a anisotropy Configuration from a serialized object.
  116808. * @param source - Serialized object.
  116809. * @param scene Defines the scene we are parsing for
  116810. * @param rootUrl Defines the rootUrl to load from
  116811. */
  116812. parse(source: any, scene: Scene, rootUrl: string): void;
  116813. }
  116814. }
  116815. declare module BABYLON {
  116816. /**
  116817. * @hidden
  116818. */
  116819. export interface IMaterialBRDFDefines {
  116820. BRDF_V_HEIGHT_CORRELATED: boolean;
  116821. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116822. SPHERICAL_HARMONICS: boolean;
  116823. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116824. /** @hidden */
  116825. _areMiscDirty: boolean;
  116826. }
  116827. /**
  116828. * Define the code related to the BRDF parameters of the pbr material.
  116829. */
  116830. export class PBRBRDFConfiguration {
  116831. /**
  116832. * Default value used for the energy conservation.
  116833. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116834. */
  116835. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116836. /**
  116837. * Default value used for the Smith Visibility Height Correlated mode.
  116838. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116839. */
  116840. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116841. /**
  116842. * Default value used for the IBL diffuse part.
  116843. * This can help switching back to the polynomials mode globally which is a tiny bit
  116844. * less GPU intensive at the drawback of a lower quality.
  116845. */
  116846. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116847. /**
  116848. * Default value used for activating energy conservation for the specular workflow.
  116849. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116850. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116851. */
  116852. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116853. private _useEnergyConservation;
  116854. /**
  116855. * Defines if the material uses energy conservation.
  116856. */
  116857. useEnergyConservation: boolean;
  116858. private _useSmithVisibilityHeightCorrelated;
  116859. /**
  116860. * LEGACY Mode set to false
  116861. * Defines if the material uses height smith correlated visibility term.
  116862. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116863. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116864. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116865. * Not relying on height correlated will also disable energy conservation.
  116866. */
  116867. useSmithVisibilityHeightCorrelated: boolean;
  116868. private _useSphericalHarmonics;
  116869. /**
  116870. * LEGACY Mode set to false
  116871. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116872. * diffuse part of the IBL.
  116873. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116874. * to the ground truth.
  116875. */
  116876. useSphericalHarmonics: boolean;
  116877. private _useSpecularGlossinessInputEnergyConservation;
  116878. /**
  116879. * Defines if the material uses energy conservation, when the specular workflow is active.
  116880. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116881. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116882. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116883. */
  116884. useSpecularGlossinessInputEnergyConservation: boolean;
  116885. /** @hidden */
  116886. private _internalMarkAllSubMeshesAsMiscDirty;
  116887. /** @hidden */
  116888. _markAllSubMeshesAsMiscDirty(): void;
  116889. /**
  116890. * Instantiate a new istance of clear coat configuration.
  116891. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116892. */
  116893. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116894. /**
  116895. * Checks to see if a texture is used in the material.
  116896. * @param defines the list of "defines" to update.
  116897. */
  116898. prepareDefines(defines: IMaterialBRDFDefines): void;
  116899. /**
  116900. * Get the current class name of the texture useful for serialization or dynamic coding.
  116901. * @returns "PBRClearCoatConfiguration"
  116902. */
  116903. getClassName(): string;
  116904. /**
  116905. * Makes a duplicate of the current configuration into another one.
  116906. * @param brdfConfiguration define the config where to copy the info
  116907. */
  116908. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116909. /**
  116910. * Serializes this BRDF configuration.
  116911. * @returns - An object with the serialized config.
  116912. */
  116913. serialize(): any;
  116914. /**
  116915. * Parses a anisotropy Configuration from a serialized object.
  116916. * @param source - Serialized object.
  116917. * @param scene Defines the scene we are parsing for
  116918. * @param rootUrl Defines the rootUrl to load from
  116919. */
  116920. parse(source: any, scene: Scene, rootUrl: string): void;
  116921. }
  116922. }
  116923. declare module BABYLON {
  116924. /**
  116925. * @hidden
  116926. */
  116927. export interface IMaterialSheenDefines {
  116928. SHEEN: boolean;
  116929. SHEEN_TEXTURE: boolean;
  116930. SHEEN_TEXTUREDIRECTUV: number;
  116931. SHEEN_LINKWITHALBEDO: boolean;
  116932. /** @hidden */
  116933. _areTexturesDirty: boolean;
  116934. }
  116935. /**
  116936. * Define the code related to the Sheen parameters of the pbr material.
  116937. */
  116938. export class PBRSheenConfiguration {
  116939. private _isEnabled;
  116940. /**
  116941. * Defines if the material uses sheen.
  116942. */
  116943. isEnabled: boolean;
  116944. private _linkSheenWithAlbedo;
  116945. /**
  116946. * Defines if the sheen is linked to the sheen color.
  116947. */
  116948. linkSheenWithAlbedo: boolean;
  116949. /**
  116950. * Defines the sheen intensity.
  116951. */
  116952. intensity: number;
  116953. /**
  116954. * Defines the sheen color.
  116955. */
  116956. color: Color3;
  116957. private _texture;
  116958. /**
  116959. * Stores the sheen tint values in a texture.
  116960. * rgb is tint
  116961. * a is a intensity
  116962. */
  116963. texture: Nullable<BaseTexture>;
  116964. /** @hidden */
  116965. private _internalMarkAllSubMeshesAsTexturesDirty;
  116966. /** @hidden */
  116967. _markAllSubMeshesAsTexturesDirty(): void;
  116968. /**
  116969. * Instantiate a new istance of clear coat configuration.
  116970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116971. */
  116972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116973. /**
  116974. * Specifies that the submesh is ready to be used.
  116975. * @param defines the list of "defines" to update.
  116976. * @param scene defines the scene the material belongs to.
  116977. * @returns - boolean indicating that the submesh is ready or not.
  116978. */
  116979. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  116980. /**
  116981. * Checks to see if a texture is used in the material.
  116982. * @param defines the list of "defines" to update.
  116983. * @param scene defines the scene the material belongs to.
  116984. */
  116985. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116986. /**
  116987. * Binds the material data.
  116988. * @param uniformBuffer defines the Uniform buffer to fill in.
  116989. * @param scene defines the scene the material belongs to.
  116990. * @param isFrozen defines wether the material is frozen or not.
  116991. */
  116992. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116993. /**
  116994. * Checks to see if a texture is used in the material.
  116995. * @param texture - Base texture to use.
  116996. * @returns - Boolean specifying if a texture is used in the material.
  116997. */
  116998. hasTexture(texture: BaseTexture): boolean;
  116999. /**
  117000. * Returns an array of the actively used textures.
  117001. * @param activeTextures Array of BaseTextures
  117002. */
  117003. getActiveTextures(activeTextures: BaseTexture[]): void;
  117004. /**
  117005. * Returns the animatable textures.
  117006. * @param animatables Array of animatable textures.
  117007. */
  117008. getAnimatables(animatables: IAnimatable[]): void;
  117009. /**
  117010. * Disposes the resources of the material.
  117011. * @param forceDisposeTextures - Forces the disposal of all textures.
  117012. */
  117013. dispose(forceDisposeTextures?: boolean): void;
  117014. /**
  117015. * Get the current class name of the texture useful for serialization or dynamic coding.
  117016. * @returns "PBRSheenConfiguration"
  117017. */
  117018. getClassName(): string;
  117019. /**
  117020. * Add fallbacks to the effect fallbacks list.
  117021. * @param defines defines the Base texture to use.
  117022. * @param fallbacks defines the current fallback list.
  117023. * @param currentRank defines the current fallback rank.
  117024. * @returns the new fallback rank.
  117025. */
  117026. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117027. /**
  117028. * Add the required uniforms to the current list.
  117029. * @param uniforms defines the current uniform list.
  117030. */
  117031. static AddUniforms(uniforms: string[]): void;
  117032. /**
  117033. * Add the required uniforms to the current buffer.
  117034. * @param uniformBuffer defines the current uniform buffer.
  117035. */
  117036. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117037. /**
  117038. * Add the required samplers to the current list.
  117039. * @param samplers defines the current sampler list.
  117040. */
  117041. static AddSamplers(samplers: string[]): void;
  117042. /**
  117043. * Makes a duplicate of the current configuration into another one.
  117044. * @param sheenConfiguration define the config where to copy the info
  117045. */
  117046. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117047. /**
  117048. * Serializes this BRDF configuration.
  117049. * @returns - An object with the serialized config.
  117050. */
  117051. serialize(): any;
  117052. /**
  117053. * Parses a anisotropy Configuration from a serialized object.
  117054. * @param source - Serialized object.
  117055. * @param scene Defines the scene we are parsing for
  117056. * @param rootUrl Defines the rootUrl to load from
  117057. */
  117058. parse(source: any, scene: Scene, rootUrl: string): void;
  117059. }
  117060. }
  117061. declare module BABYLON {
  117062. /**
  117063. * @hidden
  117064. */
  117065. export interface IMaterialSubSurfaceDefines {
  117066. SUBSURFACE: boolean;
  117067. SS_REFRACTION: boolean;
  117068. SS_TRANSLUCENCY: boolean;
  117069. SS_SCATERRING: boolean;
  117070. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117071. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117072. SS_REFRACTIONMAP_3D: boolean;
  117073. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117074. SS_LODINREFRACTIONALPHA: boolean;
  117075. SS_GAMMAREFRACTION: boolean;
  117076. SS_RGBDREFRACTION: boolean;
  117077. SS_LINEARSPECULARREFRACTION: boolean;
  117078. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117079. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117080. /** @hidden */
  117081. _areTexturesDirty: boolean;
  117082. }
  117083. /**
  117084. * Define the code related to the sub surface parameters of the pbr material.
  117085. */
  117086. export class PBRSubSurfaceConfiguration {
  117087. private _isRefractionEnabled;
  117088. /**
  117089. * Defines if the refraction is enabled in the material.
  117090. */
  117091. isRefractionEnabled: boolean;
  117092. private _isTranslucencyEnabled;
  117093. /**
  117094. * Defines if the translucency is enabled in the material.
  117095. */
  117096. isTranslucencyEnabled: boolean;
  117097. private _isScatteringEnabled;
  117098. /**
  117099. * Defines the refraction intensity of the material.
  117100. * The refraction when enabled replaces the Diffuse part of the material.
  117101. * The intensity helps transitionning between diffuse and refraction.
  117102. */
  117103. refractionIntensity: number;
  117104. /**
  117105. * Defines the translucency intensity of the material.
  117106. * When translucency has been enabled, this defines how much of the "translucency"
  117107. * is addded to the diffuse part of the material.
  117108. */
  117109. translucencyIntensity: number;
  117110. /**
  117111. * Defines the scattering intensity of the material.
  117112. * When scattering has been enabled, this defines how much of the "scattered light"
  117113. * is addded to the diffuse part of the material.
  117114. */
  117115. scatteringIntensity: number;
  117116. private _thicknessTexture;
  117117. /**
  117118. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117119. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117120. * 0 would mean minimumThickness
  117121. * 1 would mean maximumThickness
  117122. * The other channels might be use as a mask to vary the different effects intensity.
  117123. */
  117124. thicknessTexture: Nullable<BaseTexture>;
  117125. private _refractionTexture;
  117126. /**
  117127. * Defines the texture to use for refraction.
  117128. */
  117129. refractionTexture: Nullable<BaseTexture>;
  117130. private _indexOfRefraction;
  117131. /**
  117132. * Defines the index of refraction used in the material.
  117133. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117134. */
  117135. indexOfRefraction: number;
  117136. private _invertRefractionY;
  117137. /**
  117138. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117139. */
  117140. invertRefractionY: boolean;
  117141. private _linkRefractionWithTransparency;
  117142. /**
  117143. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117144. * Materials half opaque for instance using refraction could benefit from this control.
  117145. */
  117146. linkRefractionWithTransparency: boolean;
  117147. /**
  117148. * Defines the minimum thickness stored in the thickness map.
  117149. * If no thickness map is defined, this value will be used to simulate thickness.
  117150. */
  117151. minimumThickness: number;
  117152. /**
  117153. * Defines the maximum thickness stored in the thickness map.
  117154. */
  117155. maximumThickness: number;
  117156. /**
  117157. * Defines the volume tint of the material.
  117158. * This is used for both translucency and scattering.
  117159. */
  117160. tintColor: Color3;
  117161. /**
  117162. * Defines the distance at which the tint color should be found in the media.
  117163. * This is used for refraction only.
  117164. */
  117165. tintColorAtDistance: number;
  117166. /**
  117167. * Defines how far each channel transmit through the media.
  117168. * It is defined as a color to simplify it selection.
  117169. */
  117170. diffusionDistance: Color3;
  117171. private _useMaskFromThicknessTexture;
  117172. /**
  117173. * Stores the intensity of the different subsurface effects in the thickness texture.
  117174. * * the green channel is the translucency intensity.
  117175. * * the blue channel is the scattering intensity.
  117176. * * the alpha channel is the refraction intensity.
  117177. */
  117178. useMaskFromThicknessTexture: boolean;
  117179. /** @hidden */
  117180. private _internalMarkAllSubMeshesAsTexturesDirty;
  117181. /** @hidden */
  117182. _markAllSubMeshesAsTexturesDirty(): void;
  117183. /**
  117184. * Instantiate a new istance of sub surface configuration.
  117185. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117186. */
  117187. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117188. /**
  117189. * Gets wehter the submesh is ready to be used or not.
  117190. * @param defines the list of "defines" to update.
  117191. * @param scene defines the scene the material belongs to.
  117192. * @returns - boolean indicating that the submesh is ready or not.
  117193. */
  117194. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117195. /**
  117196. * Checks to see if a texture is used in the material.
  117197. * @param defines the list of "defines" to update.
  117198. * @param scene defines the scene to the material belongs to.
  117199. */
  117200. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117201. /**
  117202. * Binds the material data.
  117203. * @param uniformBuffer defines the Uniform buffer to fill in.
  117204. * @param scene defines the scene the material belongs to.
  117205. * @param engine defines the engine the material belongs to.
  117206. * @param isFrozen defines wether the material is frozen or not.
  117207. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117208. */
  117209. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117210. /**
  117211. * Unbinds the material from the mesh.
  117212. * @param activeEffect defines the effect that should be unbound from.
  117213. * @returns true if unbound, otherwise false
  117214. */
  117215. unbind(activeEffect: Effect): boolean;
  117216. /**
  117217. * Returns the texture used for refraction or null if none is used.
  117218. * @param scene defines the scene the material belongs to.
  117219. * @returns - Refraction texture if present. If no refraction texture and refraction
  117220. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117221. */
  117222. private _getRefractionTexture;
  117223. /**
  117224. * Returns true if alpha blending should be disabled.
  117225. */
  117226. readonly disableAlphaBlending: boolean;
  117227. /**
  117228. * Fills the list of render target textures.
  117229. * @param renderTargets the list of render targets to update
  117230. */
  117231. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117232. /**
  117233. * Checks to see if a texture is used in the material.
  117234. * @param texture - Base texture to use.
  117235. * @returns - Boolean specifying if a texture is used in the material.
  117236. */
  117237. hasTexture(texture: BaseTexture): boolean;
  117238. /**
  117239. * Gets a boolean indicating that current material needs to register RTT
  117240. * @returns true if this uses a render target otherwise false.
  117241. */
  117242. hasRenderTargetTextures(): boolean;
  117243. /**
  117244. * Returns an array of the actively used textures.
  117245. * @param activeTextures Array of BaseTextures
  117246. */
  117247. getActiveTextures(activeTextures: BaseTexture[]): void;
  117248. /**
  117249. * Returns the animatable textures.
  117250. * @param animatables Array of animatable textures.
  117251. */
  117252. getAnimatables(animatables: IAnimatable[]): void;
  117253. /**
  117254. * Disposes the resources of the material.
  117255. * @param forceDisposeTextures - Forces the disposal of all textures.
  117256. */
  117257. dispose(forceDisposeTextures?: boolean): void;
  117258. /**
  117259. * Get the current class name of the texture useful for serialization or dynamic coding.
  117260. * @returns "PBRSubSurfaceConfiguration"
  117261. */
  117262. getClassName(): string;
  117263. /**
  117264. * Add fallbacks to the effect fallbacks list.
  117265. * @param defines defines the Base texture to use.
  117266. * @param fallbacks defines the current fallback list.
  117267. * @param currentRank defines the current fallback rank.
  117268. * @returns the new fallback rank.
  117269. */
  117270. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117271. /**
  117272. * Add the required uniforms to the current list.
  117273. * @param uniforms defines the current uniform list.
  117274. */
  117275. static AddUniforms(uniforms: string[]): void;
  117276. /**
  117277. * Add the required samplers to the current list.
  117278. * @param samplers defines the current sampler list.
  117279. */
  117280. static AddSamplers(samplers: string[]): void;
  117281. /**
  117282. * Add the required uniforms to the current buffer.
  117283. * @param uniformBuffer defines the current uniform buffer.
  117284. */
  117285. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117286. /**
  117287. * Makes a duplicate of the current configuration into another one.
  117288. * @param configuration define the config where to copy the info
  117289. */
  117290. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117291. /**
  117292. * Serializes this Sub Surface configuration.
  117293. * @returns - An object with the serialized config.
  117294. */
  117295. serialize(): any;
  117296. /**
  117297. * Parses a anisotropy Configuration from a serialized object.
  117298. * @param source - Serialized object.
  117299. * @param scene Defines the scene we are parsing for
  117300. * @param rootUrl Defines the rootUrl to load from
  117301. */
  117302. parse(source: any, scene: Scene, rootUrl: string): void;
  117303. }
  117304. }
  117305. declare module BABYLON {
  117306. /** @hidden */
  117307. export var pbrFragmentDeclaration: {
  117308. name: string;
  117309. shader: string;
  117310. };
  117311. }
  117312. declare module BABYLON {
  117313. /** @hidden */
  117314. export var pbrUboDeclaration: {
  117315. name: string;
  117316. shader: string;
  117317. };
  117318. }
  117319. declare module BABYLON {
  117320. /** @hidden */
  117321. export var pbrFragmentExtraDeclaration: {
  117322. name: string;
  117323. shader: string;
  117324. };
  117325. }
  117326. declare module BABYLON {
  117327. /** @hidden */
  117328. export var pbrFragmentSamplersDeclaration: {
  117329. name: string;
  117330. shader: string;
  117331. };
  117332. }
  117333. declare module BABYLON {
  117334. /** @hidden */
  117335. export var pbrHelperFunctions: {
  117336. name: string;
  117337. shader: string;
  117338. };
  117339. }
  117340. declare module BABYLON {
  117341. /** @hidden */
  117342. export var harmonicsFunctions: {
  117343. name: string;
  117344. shader: string;
  117345. };
  117346. }
  117347. declare module BABYLON {
  117348. /** @hidden */
  117349. export var pbrDirectLightingSetupFunctions: {
  117350. name: string;
  117351. shader: string;
  117352. };
  117353. }
  117354. declare module BABYLON {
  117355. /** @hidden */
  117356. export var pbrDirectLightingFalloffFunctions: {
  117357. name: string;
  117358. shader: string;
  117359. };
  117360. }
  117361. declare module BABYLON {
  117362. /** @hidden */
  117363. export var pbrBRDFFunctions: {
  117364. name: string;
  117365. shader: string;
  117366. };
  117367. }
  117368. declare module BABYLON {
  117369. /** @hidden */
  117370. export var pbrDirectLightingFunctions: {
  117371. name: string;
  117372. shader: string;
  117373. };
  117374. }
  117375. declare module BABYLON {
  117376. /** @hidden */
  117377. export var pbrIBLFunctions: {
  117378. name: string;
  117379. shader: string;
  117380. };
  117381. }
  117382. declare module BABYLON {
  117383. /** @hidden */
  117384. export var pbrDebug: {
  117385. name: string;
  117386. shader: string;
  117387. };
  117388. }
  117389. declare module BABYLON {
  117390. /** @hidden */
  117391. export var pbrPixelShader: {
  117392. name: string;
  117393. shader: string;
  117394. };
  117395. }
  117396. declare module BABYLON {
  117397. /** @hidden */
  117398. export var pbrVertexDeclaration: {
  117399. name: string;
  117400. shader: string;
  117401. };
  117402. }
  117403. declare module BABYLON {
  117404. /** @hidden */
  117405. export var pbrVertexShader: {
  117406. name: string;
  117407. shader: string;
  117408. };
  117409. }
  117410. declare module BABYLON {
  117411. /**
  117412. * Manages the defines for the PBR Material.
  117413. * @hidden
  117414. */
  117415. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  117416. PBR: boolean;
  117417. MAINUV1: boolean;
  117418. MAINUV2: boolean;
  117419. UV1: boolean;
  117420. UV2: boolean;
  117421. ALBEDO: boolean;
  117422. ALBEDODIRECTUV: number;
  117423. VERTEXCOLOR: boolean;
  117424. AMBIENT: boolean;
  117425. AMBIENTDIRECTUV: number;
  117426. AMBIENTINGRAYSCALE: boolean;
  117427. OPACITY: boolean;
  117428. VERTEXALPHA: boolean;
  117429. OPACITYDIRECTUV: number;
  117430. OPACITYRGB: boolean;
  117431. ALPHATEST: boolean;
  117432. DEPTHPREPASS: boolean;
  117433. ALPHABLEND: boolean;
  117434. ALPHAFROMALBEDO: boolean;
  117435. ALPHATESTVALUE: string;
  117436. SPECULAROVERALPHA: boolean;
  117437. RADIANCEOVERALPHA: boolean;
  117438. ALPHAFRESNEL: boolean;
  117439. LINEARALPHAFRESNEL: boolean;
  117440. PREMULTIPLYALPHA: boolean;
  117441. EMISSIVE: boolean;
  117442. EMISSIVEDIRECTUV: number;
  117443. REFLECTIVITY: boolean;
  117444. REFLECTIVITYDIRECTUV: number;
  117445. SPECULARTERM: boolean;
  117446. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  117447. MICROSURFACEAUTOMATIC: boolean;
  117448. LODBASEDMICROSFURACE: boolean;
  117449. MICROSURFACEMAP: boolean;
  117450. MICROSURFACEMAPDIRECTUV: number;
  117451. METALLICWORKFLOW: boolean;
  117452. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  117453. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  117454. METALLNESSSTOREINMETALMAPBLUE: boolean;
  117455. AOSTOREINMETALMAPRED: boolean;
  117456. METALLICF0FACTORFROMMETALLICMAP: boolean;
  117457. ENVIRONMENTBRDF: boolean;
  117458. ENVIRONMENTBRDF_RGBD: boolean;
  117459. NORMAL: boolean;
  117460. TANGENT: boolean;
  117461. BUMP: boolean;
  117462. BUMPDIRECTUV: number;
  117463. OBJECTSPACE_NORMALMAP: boolean;
  117464. PARALLAX: boolean;
  117465. PARALLAXOCCLUSION: boolean;
  117466. NORMALXYSCALE: boolean;
  117467. LIGHTMAP: boolean;
  117468. LIGHTMAPDIRECTUV: number;
  117469. USELIGHTMAPASSHADOWMAP: boolean;
  117470. GAMMALIGHTMAP: boolean;
  117471. RGBDLIGHTMAP: boolean;
  117472. REFLECTION: boolean;
  117473. REFLECTIONMAP_3D: boolean;
  117474. REFLECTIONMAP_SPHERICAL: boolean;
  117475. REFLECTIONMAP_PLANAR: boolean;
  117476. REFLECTIONMAP_CUBIC: boolean;
  117477. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  117478. REFLECTIONMAP_PROJECTION: boolean;
  117479. REFLECTIONMAP_SKYBOX: boolean;
  117480. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  117481. REFLECTIONMAP_EXPLICIT: boolean;
  117482. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  117483. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  117484. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  117485. INVERTCUBICMAP: boolean;
  117486. USESPHERICALFROMREFLECTIONMAP: boolean;
  117487. USEIRRADIANCEMAP: boolean;
  117488. SPHERICAL_HARMONICS: boolean;
  117489. USESPHERICALINVERTEX: boolean;
  117490. REFLECTIONMAP_OPPOSITEZ: boolean;
  117491. LODINREFLECTIONALPHA: boolean;
  117492. GAMMAREFLECTION: boolean;
  117493. RGBDREFLECTION: boolean;
  117494. LINEARSPECULARREFLECTION: boolean;
  117495. RADIANCEOCCLUSION: boolean;
  117496. HORIZONOCCLUSION: boolean;
  117497. INSTANCES: boolean;
  117498. NUM_BONE_INFLUENCERS: number;
  117499. BonesPerMesh: number;
  117500. BONETEXTURE: boolean;
  117501. NONUNIFORMSCALING: boolean;
  117502. MORPHTARGETS: boolean;
  117503. MORPHTARGETS_NORMAL: boolean;
  117504. MORPHTARGETS_TANGENT: boolean;
  117505. MORPHTARGETS_UV: boolean;
  117506. NUM_MORPH_INFLUENCERS: number;
  117507. IMAGEPROCESSING: boolean;
  117508. VIGNETTE: boolean;
  117509. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117510. VIGNETTEBLENDMODEOPAQUE: boolean;
  117511. TONEMAPPING: boolean;
  117512. TONEMAPPING_ACES: boolean;
  117513. CONTRAST: boolean;
  117514. COLORCURVES: boolean;
  117515. COLORGRADING: boolean;
  117516. COLORGRADING3D: boolean;
  117517. SAMPLER3DGREENDEPTH: boolean;
  117518. SAMPLER3DBGRMAP: boolean;
  117519. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117520. EXPOSURE: boolean;
  117521. MULTIVIEW: boolean;
  117522. USEPHYSICALLIGHTFALLOFF: boolean;
  117523. USEGLTFLIGHTFALLOFF: boolean;
  117524. TWOSIDEDLIGHTING: boolean;
  117525. SHADOWFLOAT: boolean;
  117526. CLIPPLANE: boolean;
  117527. CLIPPLANE2: boolean;
  117528. CLIPPLANE3: boolean;
  117529. CLIPPLANE4: boolean;
  117530. POINTSIZE: boolean;
  117531. FOG: boolean;
  117532. LOGARITHMICDEPTH: boolean;
  117533. FORCENORMALFORWARD: boolean;
  117534. SPECULARAA: boolean;
  117535. CLEARCOAT: boolean;
  117536. CLEARCOAT_DEFAULTIOR: boolean;
  117537. CLEARCOAT_TEXTURE: boolean;
  117538. CLEARCOAT_TEXTUREDIRECTUV: number;
  117539. CLEARCOAT_BUMP: boolean;
  117540. CLEARCOAT_BUMPDIRECTUV: number;
  117541. CLEARCOAT_TINT: boolean;
  117542. CLEARCOAT_TINT_TEXTURE: boolean;
  117543. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117544. ANISOTROPIC: boolean;
  117545. ANISOTROPIC_TEXTURE: boolean;
  117546. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117547. BRDF_V_HEIGHT_CORRELATED: boolean;
  117548. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117549. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117550. SHEEN: boolean;
  117551. SHEEN_TEXTURE: boolean;
  117552. SHEEN_TEXTUREDIRECTUV: number;
  117553. SHEEN_LINKWITHALBEDO: boolean;
  117554. SUBSURFACE: boolean;
  117555. SS_REFRACTION: boolean;
  117556. SS_TRANSLUCENCY: boolean;
  117557. SS_SCATERRING: boolean;
  117558. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117559. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117560. SS_REFRACTIONMAP_3D: boolean;
  117561. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117562. SS_LODINREFRACTIONALPHA: boolean;
  117563. SS_GAMMAREFRACTION: boolean;
  117564. SS_RGBDREFRACTION: boolean;
  117565. SS_LINEARSPECULARREFRACTION: boolean;
  117566. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117567. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117568. UNLIT: boolean;
  117569. DEBUGMODE: number;
  117570. /**
  117571. * Initializes the PBR Material defines.
  117572. */
  117573. constructor();
  117574. /**
  117575. * Resets the PBR Material defines.
  117576. */
  117577. reset(): void;
  117578. }
  117579. /**
  117580. * The Physically based material base class of BJS.
  117581. *
  117582. * This offers the main features of a standard PBR material.
  117583. * For more information, please refer to the documentation :
  117584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117585. */
  117586. export abstract class PBRBaseMaterial extends PushMaterial {
  117587. /**
  117588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117589. */
  117590. static readonly PBRMATERIAL_OPAQUE: number;
  117591. /**
  117592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117593. */
  117594. static readonly PBRMATERIAL_ALPHATEST: number;
  117595. /**
  117596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117597. */
  117598. static readonly PBRMATERIAL_ALPHABLEND: number;
  117599. /**
  117600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117601. * They are also discarded below the alpha cutoff threshold to improve performances.
  117602. */
  117603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117604. /**
  117605. * Defines the default value of how much AO map is occluding the analytical lights
  117606. * (point spot...).
  117607. */
  117608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117609. /**
  117610. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117611. */
  117612. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117613. /**
  117614. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117615. * to enhance interoperability with other engines.
  117616. */
  117617. static readonly LIGHTFALLOFF_GLTF: number;
  117618. /**
  117619. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117620. * to enhance interoperability with other materials.
  117621. */
  117622. static readonly LIGHTFALLOFF_STANDARD: number;
  117623. /**
  117624. * Intensity of the direct lights e.g. the four lights available in your scene.
  117625. * This impacts both the direct diffuse and specular highlights.
  117626. */
  117627. protected _directIntensity: number;
  117628. /**
  117629. * Intensity of the emissive part of the material.
  117630. * This helps controlling the emissive effect without modifying the emissive color.
  117631. */
  117632. protected _emissiveIntensity: number;
  117633. /**
  117634. * Intensity of the environment e.g. how much the environment will light the object
  117635. * either through harmonics for rough material or through the refelction for shiny ones.
  117636. */
  117637. protected _environmentIntensity: number;
  117638. /**
  117639. * This is a special control allowing the reduction of the specular highlights coming from the
  117640. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117641. */
  117642. protected _specularIntensity: number;
  117643. /**
  117644. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  117645. */
  117646. private _lightingInfos;
  117647. /**
  117648. * Debug Control allowing disabling the bump map on this material.
  117649. */
  117650. protected _disableBumpMap: boolean;
  117651. /**
  117652. * AKA Diffuse Texture in standard nomenclature.
  117653. */
  117654. protected _albedoTexture: Nullable<BaseTexture>;
  117655. /**
  117656. * AKA Occlusion Texture in other nomenclature.
  117657. */
  117658. protected _ambientTexture: Nullable<BaseTexture>;
  117659. /**
  117660. * AKA Occlusion Texture Intensity in other nomenclature.
  117661. */
  117662. protected _ambientTextureStrength: number;
  117663. /**
  117664. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117665. * 1 means it completely occludes it
  117666. * 0 mean it has no impact
  117667. */
  117668. protected _ambientTextureImpactOnAnalyticalLights: number;
  117669. /**
  117670. * Stores the alpha values in a texture.
  117671. */
  117672. protected _opacityTexture: Nullable<BaseTexture>;
  117673. /**
  117674. * Stores the reflection values in a texture.
  117675. */
  117676. protected _reflectionTexture: Nullable<BaseTexture>;
  117677. /**
  117678. * Stores the emissive values in a texture.
  117679. */
  117680. protected _emissiveTexture: Nullable<BaseTexture>;
  117681. /**
  117682. * AKA Specular texture in other nomenclature.
  117683. */
  117684. protected _reflectivityTexture: Nullable<BaseTexture>;
  117685. /**
  117686. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117687. */
  117688. protected _metallicTexture: Nullable<BaseTexture>;
  117689. /**
  117690. * Specifies the metallic scalar of the metallic/roughness workflow.
  117691. * Can also be used to scale the metalness values of the metallic texture.
  117692. */
  117693. protected _metallic: Nullable<number>;
  117694. /**
  117695. * Specifies the roughness scalar of the metallic/roughness workflow.
  117696. * Can also be used to scale the roughness values of the metallic texture.
  117697. */
  117698. protected _roughness: Nullable<number>;
  117699. /**
  117700. * Specifies the an F0 factor to help configuring the material F0.
  117701. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117702. * to 0.5 the previously hard coded value stays the same.
  117703. * Can also be used to scale the F0 values of the metallic texture.
  117704. */
  117705. protected _metallicF0Factor: number;
  117706. /**
  117707. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117708. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117709. * your expectation as it multiplies with the texture data.
  117710. */
  117711. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117712. /**
  117713. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117714. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117715. */
  117716. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117717. /**
  117718. * Stores surface normal data used to displace a mesh in a texture.
  117719. */
  117720. protected _bumpTexture: Nullable<BaseTexture>;
  117721. /**
  117722. * Stores the pre-calculated light information of a mesh in a texture.
  117723. */
  117724. protected _lightmapTexture: Nullable<BaseTexture>;
  117725. /**
  117726. * The color of a material in ambient lighting.
  117727. */
  117728. protected _ambientColor: Color3;
  117729. /**
  117730. * AKA Diffuse Color in other nomenclature.
  117731. */
  117732. protected _albedoColor: Color3;
  117733. /**
  117734. * AKA Specular Color in other nomenclature.
  117735. */
  117736. protected _reflectivityColor: Color3;
  117737. /**
  117738. * The color applied when light is reflected from a material.
  117739. */
  117740. protected _reflectionColor: Color3;
  117741. /**
  117742. * The color applied when light is emitted from a material.
  117743. */
  117744. protected _emissiveColor: Color3;
  117745. /**
  117746. * AKA Glossiness in other nomenclature.
  117747. */
  117748. protected _microSurface: number;
  117749. /**
  117750. * Specifies that the material will use the light map as a show map.
  117751. */
  117752. protected _useLightmapAsShadowmap: boolean;
  117753. /**
  117754. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117755. * makes the reflect vector face the model (under horizon).
  117756. */
  117757. protected _useHorizonOcclusion: boolean;
  117758. /**
  117759. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117760. * too much the area relying on ambient texture to define their ambient occlusion.
  117761. */
  117762. protected _useRadianceOcclusion: boolean;
  117763. /**
  117764. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117765. */
  117766. protected _useAlphaFromAlbedoTexture: boolean;
  117767. /**
  117768. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117769. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117770. */
  117771. protected _useSpecularOverAlpha: boolean;
  117772. /**
  117773. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117774. */
  117775. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117776. /**
  117777. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117778. */
  117779. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117780. /**
  117781. * Specifies if the metallic texture contains the roughness information in its green channel.
  117782. */
  117783. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117784. /**
  117785. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117786. */
  117787. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117788. /**
  117789. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117790. */
  117791. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117792. /**
  117793. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117794. */
  117795. protected _useAmbientInGrayScale: boolean;
  117796. /**
  117797. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117798. * The material will try to infer what glossiness each pixel should be.
  117799. */
  117800. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117801. /**
  117802. * Defines the falloff type used in this material.
  117803. * It by default is Physical.
  117804. */
  117805. protected _lightFalloff: number;
  117806. /**
  117807. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117808. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117809. */
  117810. protected _useRadianceOverAlpha: boolean;
  117811. /**
  117812. * Allows using an object space normal map (instead of tangent space).
  117813. */
  117814. protected _useObjectSpaceNormalMap: boolean;
  117815. /**
  117816. * Allows using the bump map in parallax mode.
  117817. */
  117818. protected _useParallax: boolean;
  117819. /**
  117820. * Allows using the bump map in parallax occlusion mode.
  117821. */
  117822. protected _useParallaxOcclusion: boolean;
  117823. /**
  117824. * Controls the scale bias of the parallax mode.
  117825. */
  117826. protected _parallaxScaleBias: number;
  117827. /**
  117828. * If sets to true, disables all the lights affecting the material.
  117829. */
  117830. protected _disableLighting: boolean;
  117831. /**
  117832. * Number of Simultaneous lights allowed on the material.
  117833. */
  117834. protected _maxSimultaneousLights: number;
  117835. /**
  117836. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117837. */
  117838. protected _invertNormalMapX: boolean;
  117839. /**
  117840. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117841. */
  117842. protected _invertNormalMapY: boolean;
  117843. /**
  117844. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117845. */
  117846. protected _twoSidedLighting: boolean;
  117847. /**
  117848. * Defines the alpha limits in alpha test mode.
  117849. */
  117850. protected _alphaCutOff: number;
  117851. /**
  117852. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117853. */
  117854. protected _forceAlphaTest: boolean;
  117855. /**
  117856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117857. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117858. */
  117859. protected _useAlphaFresnel: boolean;
  117860. /**
  117861. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117862. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117863. */
  117864. protected _useLinearAlphaFresnel: boolean;
  117865. /**
  117866. * The transparency mode of the material.
  117867. */
  117868. protected _transparencyMode: Nullable<number>;
  117869. /**
  117870. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117871. * from cos thetav and roughness:
  117872. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117873. */
  117874. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117875. /**
  117876. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117877. */
  117878. protected _forceIrradianceInFragment: boolean;
  117879. /**
  117880. * Force normal to face away from face.
  117881. */
  117882. protected _forceNormalForward: boolean;
  117883. /**
  117884. * Enables specular anti aliasing in the PBR shader.
  117885. * It will both interacts on the Geometry for analytical and IBL lighting.
  117886. * It also prefilter the roughness map based on the bump values.
  117887. */
  117888. protected _enableSpecularAntiAliasing: boolean;
  117889. /**
  117890. * Default configuration related to image processing available in the PBR Material.
  117891. */
  117892. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117893. /**
  117894. * Keep track of the image processing observer to allow dispose and replace.
  117895. */
  117896. private _imageProcessingObserver;
  117897. /**
  117898. * Attaches a new image processing configuration to the PBR Material.
  117899. * @param configuration
  117900. */
  117901. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117902. /**
  117903. * Stores the available render targets.
  117904. */
  117905. private _renderTargets;
  117906. /**
  117907. * Sets the global ambient color for the material used in lighting calculations.
  117908. */
  117909. private _globalAmbientColor;
  117910. /**
  117911. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117912. */
  117913. private _useLogarithmicDepth;
  117914. /**
  117915. * If set to true, no lighting calculations will be applied.
  117916. */
  117917. private _unlit;
  117918. private _debugMode;
  117919. /**
  117920. * @hidden
  117921. * This is reserved for the inspector.
  117922. * Defines the material debug mode.
  117923. * It helps seeing only some components of the material while troubleshooting.
  117924. */
  117925. debugMode: number;
  117926. /**
  117927. * @hidden
  117928. * This is reserved for the inspector.
  117929. * Specify from where on screen the debug mode should start.
  117930. * The value goes from -1 (full screen) to 1 (not visible)
  117931. * It helps with side by side comparison against the final render
  117932. * This defaults to -1
  117933. */
  117934. private debugLimit;
  117935. /**
  117936. * @hidden
  117937. * This is reserved for the inspector.
  117938. * As the default viewing range might not be enough (if the ambient is really small for instance)
  117939. * You can use the factor to better multiply the final value.
  117940. */
  117941. private debugFactor;
  117942. /**
  117943. * Defines the clear coat layer parameters for the material.
  117944. */
  117945. readonly clearCoat: PBRClearCoatConfiguration;
  117946. /**
  117947. * Defines the anisotropic parameters for the material.
  117948. */
  117949. readonly anisotropy: PBRAnisotropicConfiguration;
  117950. /**
  117951. * Defines the BRDF parameters for the material.
  117952. */
  117953. readonly brdf: PBRBRDFConfiguration;
  117954. /**
  117955. * Defines the Sheen parameters for the material.
  117956. */
  117957. readonly sheen: PBRSheenConfiguration;
  117958. /**
  117959. * Defines the SubSurface parameters for the material.
  117960. */
  117961. readonly subSurface: PBRSubSurfaceConfiguration;
  117962. /**
  117963. * Custom callback helping to override the default shader used in the material.
  117964. */
  117965. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  117966. protected _rebuildInParallel: boolean;
  117967. /**
  117968. * Instantiates a new PBRMaterial instance.
  117969. *
  117970. * @param name The material name
  117971. * @param scene The scene the material will be use in.
  117972. */
  117973. constructor(name: string, scene: Scene);
  117974. /**
  117975. * Gets a boolean indicating that current material needs to register RTT
  117976. */
  117977. readonly hasRenderTargetTextures: boolean;
  117978. /**
  117979. * Gets the name of the material class.
  117980. */
  117981. getClassName(): string;
  117982. /**
  117983. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117984. */
  117985. /**
  117986. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117987. */
  117988. useLogarithmicDepth: boolean;
  117989. /**
  117990. * Gets the current transparency mode.
  117991. */
  117992. /**
  117993. * Sets the transparency mode of the material.
  117994. *
  117995. * | Value | Type | Description |
  117996. * | ----- | ----------------------------------- | ----------- |
  117997. * | 0 | OPAQUE | |
  117998. * | 1 | ALPHATEST | |
  117999. * | 2 | ALPHABLEND | |
  118000. * | 3 | ALPHATESTANDBLEND | |
  118001. *
  118002. */
  118003. transparencyMode: Nullable<number>;
  118004. /**
  118005. * Returns true if alpha blending should be disabled.
  118006. */
  118007. private readonly _disableAlphaBlending;
  118008. /**
  118009. * Specifies whether or not this material should be rendered in alpha blend mode.
  118010. */
  118011. needAlphaBlending(): boolean;
  118012. /**
  118013. * Specifies if the mesh will require alpha blending.
  118014. * @param mesh - BJS mesh.
  118015. */
  118016. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  118017. /**
  118018. * Specifies whether or not this material should be rendered in alpha test mode.
  118019. */
  118020. needAlphaTesting(): boolean;
  118021. /**
  118022. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  118023. */
  118024. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  118025. /**
  118026. * Gets the texture used for the alpha test.
  118027. */
  118028. getAlphaTestTexture(): Nullable<BaseTexture>;
  118029. /**
  118030. * Specifies that the submesh is ready to be used.
  118031. * @param mesh - BJS mesh.
  118032. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  118033. * @param useInstances - Specifies that instances should be used.
  118034. * @returns - boolean indicating that the submesh is ready or not.
  118035. */
  118036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118037. /**
  118038. * Specifies if the material uses metallic roughness workflow.
  118039. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118040. */
  118041. isMetallicWorkflow(): boolean;
  118042. private _prepareEffect;
  118043. private _prepareDefines;
  118044. /**
  118045. * Force shader compilation
  118046. */
  118047. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118048. /**
  118049. * Initializes the uniform buffer layout for the shader.
  118050. */
  118051. buildUniformLayout(): void;
  118052. /**
  118053. * Unbinds the material from the mesh
  118054. */
  118055. unbind(): void;
  118056. /**
  118057. * Binds the submesh data.
  118058. * @param world - The world matrix.
  118059. * @param mesh - The BJS mesh.
  118060. * @param subMesh - A submesh of the BJS mesh.
  118061. */
  118062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118063. /**
  118064. * Returns the animatable textures.
  118065. * @returns - Array of animatable textures.
  118066. */
  118067. getAnimatables(): IAnimatable[];
  118068. /**
  118069. * Returns the texture used for reflections.
  118070. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118071. */
  118072. private _getReflectionTexture;
  118073. /**
  118074. * Returns an array of the actively used textures.
  118075. * @returns - Array of BaseTextures
  118076. */
  118077. getActiveTextures(): BaseTexture[];
  118078. /**
  118079. * Checks to see if a texture is used in the material.
  118080. * @param texture - Base texture to use.
  118081. * @returns - Boolean specifying if a texture is used in the material.
  118082. */
  118083. hasTexture(texture: BaseTexture): boolean;
  118084. /**
  118085. * Disposes the resources of the material.
  118086. * @param forceDisposeEffect - Forces the disposal of effects.
  118087. * @param forceDisposeTextures - Forces the disposal of all textures.
  118088. */
  118089. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118090. }
  118091. }
  118092. declare module BABYLON {
  118093. /**
  118094. * The Physically based material of BJS.
  118095. *
  118096. * This offers the main features of a standard PBR material.
  118097. * For more information, please refer to the documentation :
  118098. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118099. */
  118100. export class PBRMaterial extends PBRBaseMaterial {
  118101. /**
  118102. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118103. */
  118104. static readonly PBRMATERIAL_OPAQUE: number;
  118105. /**
  118106. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118107. */
  118108. static readonly PBRMATERIAL_ALPHATEST: number;
  118109. /**
  118110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118111. */
  118112. static readonly PBRMATERIAL_ALPHABLEND: number;
  118113. /**
  118114. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118115. * They are also discarded below the alpha cutoff threshold to improve performances.
  118116. */
  118117. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118118. /**
  118119. * Defines the default value of how much AO map is occluding the analytical lights
  118120. * (point spot...).
  118121. */
  118122. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118123. /**
  118124. * Intensity of the direct lights e.g. the four lights available in your scene.
  118125. * This impacts both the direct diffuse and specular highlights.
  118126. */
  118127. directIntensity: number;
  118128. /**
  118129. * Intensity of the emissive part of the material.
  118130. * This helps controlling the emissive effect without modifying the emissive color.
  118131. */
  118132. emissiveIntensity: number;
  118133. /**
  118134. * Intensity of the environment e.g. how much the environment will light the object
  118135. * either through harmonics for rough material or through the refelction for shiny ones.
  118136. */
  118137. environmentIntensity: number;
  118138. /**
  118139. * This is a special control allowing the reduction of the specular highlights coming from the
  118140. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118141. */
  118142. specularIntensity: number;
  118143. /**
  118144. * Debug Control allowing disabling the bump map on this material.
  118145. */
  118146. disableBumpMap: boolean;
  118147. /**
  118148. * AKA Diffuse Texture in standard nomenclature.
  118149. */
  118150. albedoTexture: BaseTexture;
  118151. /**
  118152. * AKA Occlusion Texture in other nomenclature.
  118153. */
  118154. ambientTexture: BaseTexture;
  118155. /**
  118156. * AKA Occlusion Texture Intensity in other nomenclature.
  118157. */
  118158. ambientTextureStrength: number;
  118159. /**
  118160. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118161. * 1 means it completely occludes it
  118162. * 0 mean it has no impact
  118163. */
  118164. ambientTextureImpactOnAnalyticalLights: number;
  118165. /**
  118166. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118167. */
  118168. opacityTexture: BaseTexture;
  118169. /**
  118170. * Stores the reflection values in a texture.
  118171. */
  118172. reflectionTexture: Nullable<BaseTexture>;
  118173. /**
  118174. * Stores the emissive values in a texture.
  118175. */
  118176. emissiveTexture: BaseTexture;
  118177. /**
  118178. * AKA Specular texture in other nomenclature.
  118179. */
  118180. reflectivityTexture: BaseTexture;
  118181. /**
  118182. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118183. */
  118184. metallicTexture: BaseTexture;
  118185. /**
  118186. * Specifies the metallic scalar of the metallic/roughness workflow.
  118187. * Can also be used to scale the metalness values of the metallic texture.
  118188. */
  118189. metallic: Nullable<number>;
  118190. /**
  118191. * Specifies the roughness scalar of the metallic/roughness workflow.
  118192. * Can also be used to scale the roughness values of the metallic texture.
  118193. */
  118194. roughness: Nullable<number>;
  118195. /**
  118196. * Specifies the an F0 factor to help configuring the material F0.
  118197. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118198. * to 0.5 the previously hard coded value stays the same.
  118199. * Can also be used to scale the F0 values of the metallic texture.
  118200. */
  118201. metallicF0Factor: number;
  118202. /**
  118203. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118204. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118205. * your expectation as it multiplies with the texture data.
  118206. */
  118207. useMetallicF0FactorFromMetallicTexture: boolean;
  118208. /**
  118209. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118210. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118211. */
  118212. microSurfaceTexture: BaseTexture;
  118213. /**
  118214. * Stores surface normal data used to displace a mesh in a texture.
  118215. */
  118216. bumpTexture: BaseTexture;
  118217. /**
  118218. * Stores the pre-calculated light information of a mesh in a texture.
  118219. */
  118220. lightmapTexture: BaseTexture;
  118221. /**
  118222. * Stores the refracted light information in a texture.
  118223. */
  118224. refractionTexture: Nullable<BaseTexture>;
  118225. /**
  118226. * The color of a material in ambient lighting.
  118227. */
  118228. ambientColor: Color3;
  118229. /**
  118230. * AKA Diffuse Color in other nomenclature.
  118231. */
  118232. albedoColor: Color3;
  118233. /**
  118234. * AKA Specular Color in other nomenclature.
  118235. */
  118236. reflectivityColor: Color3;
  118237. /**
  118238. * The color reflected from the material.
  118239. */
  118240. reflectionColor: Color3;
  118241. /**
  118242. * The color emitted from the material.
  118243. */
  118244. emissiveColor: Color3;
  118245. /**
  118246. * AKA Glossiness in other nomenclature.
  118247. */
  118248. microSurface: number;
  118249. /**
  118250. * source material index of refraction (IOR)' / 'destination material IOR.
  118251. */
  118252. indexOfRefraction: number;
  118253. /**
  118254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118255. */
  118256. invertRefractionY: boolean;
  118257. /**
  118258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118259. * Materials half opaque for instance using refraction could benefit from this control.
  118260. */
  118261. linkRefractionWithTransparency: boolean;
  118262. /**
  118263. * If true, the light map contains occlusion information instead of lighting info.
  118264. */
  118265. useLightmapAsShadowmap: boolean;
  118266. /**
  118267. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118268. */
  118269. useAlphaFromAlbedoTexture: boolean;
  118270. /**
  118271. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118272. */
  118273. forceAlphaTest: boolean;
  118274. /**
  118275. * Defines the alpha limits in alpha test mode.
  118276. */
  118277. alphaCutOff: number;
  118278. /**
  118279. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118280. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118281. */
  118282. useSpecularOverAlpha: boolean;
  118283. /**
  118284. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118285. */
  118286. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118287. /**
  118288. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118289. */
  118290. useRoughnessFromMetallicTextureAlpha: boolean;
  118291. /**
  118292. * Specifies if the metallic texture contains the roughness information in its green channel.
  118293. */
  118294. useRoughnessFromMetallicTextureGreen: boolean;
  118295. /**
  118296. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118297. */
  118298. useMetallnessFromMetallicTextureBlue: boolean;
  118299. /**
  118300. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118301. */
  118302. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118303. /**
  118304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118305. */
  118306. useAmbientInGrayScale: boolean;
  118307. /**
  118308. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118309. * The material will try to infer what glossiness each pixel should be.
  118310. */
  118311. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118312. /**
  118313. * BJS is using an harcoded light falloff based on a manually sets up range.
  118314. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118315. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118316. */
  118317. /**
  118318. * BJS is using an harcoded light falloff based on a manually sets up range.
  118319. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118320. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118321. */
  118322. usePhysicalLightFalloff: boolean;
  118323. /**
  118324. * In order to support the falloff compatibility with gltf, a special mode has been added
  118325. * to reproduce the gltf light falloff.
  118326. */
  118327. /**
  118328. * In order to support the falloff compatibility with gltf, a special mode has been added
  118329. * to reproduce the gltf light falloff.
  118330. */
  118331. useGLTFLightFalloff: boolean;
  118332. /**
  118333. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118334. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118335. */
  118336. useRadianceOverAlpha: boolean;
  118337. /**
  118338. * Allows using an object space normal map (instead of tangent space).
  118339. */
  118340. useObjectSpaceNormalMap: boolean;
  118341. /**
  118342. * Allows using the bump map in parallax mode.
  118343. */
  118344. useParallax: boolean;
  118345. /**
  118346. * Allows using the bump map in parallax occlusion mode.
  118347. */
  118348. useParallaxOcclusion: boolean;
  118349. /**
  118350. * Controls the scale bias of the parallax mode.
  118351. */
  118352. parallaxScaleBias: number;
  118353. /**
  118354. * If sets to true, disables all the lights affecting the material.
  118355. */
  118356. disableLighting: boolean;
  118357. /**
  118358. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118359. */
  118360. forceIrradianceInFragment: boolean;
  118361. /**
  118362. * Number of Simultaneous lights allowed on the material.
  118363. */
  118364. maxSimultaneousLights: number;
  118365. /**
  118366. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118367. */
  118368. invertNormalMapX: boolean;
  118369. /**
  118370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118371. */
  118372. invertNormalMapY: boolean;
  118373. /**
  118374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118375. */
  118376. twoSidedLighting: boolean;
  118377. /**
  118378. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118379. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118380. */
  118381. useAlphaFresnel: boolean;
  118382. /**
  118383. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118384. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118385. */
  118386. useLinearAlphaFresnel: boolean;
  118387. /**
  118388. * Let user defines the brdf lookup texture used for IBL.
  118389. * A default 8bit version is embedded but you could point at :
  118390. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  118391. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118392. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  118393. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118394. */
  118395. environmentBRDFTexture: Nullable<BaseTexture>;
  118396. /**
  118397. * Force normal to face away from face.
  118398. */
  118399. forceNormalForward: boolean;
  118400. /**
  118401. * Enables specular anti aliasing in the PBR shader.
  118402. * It will both interacts on the Geometry for analytical and IBL lighting.
  118403. * It also prefilter the roughness map based on the bump values.
  118404. */
  118405. enableSpecularAntiAliasing: boolean;
  118406. /**
  118407. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118408. * makes the reflect vector face the model (under horizon).
  118409. */
  118410. useHorizonOcclusion: boolean;
  118411. /**
  118412. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118413. * too much the area relying on ambient texture to define their ambient occlusion.
  118414. */
  118415. useRadianceOcclusion: boolean;
  118416. /**
  118417. * If set to true, no lighting calculations will be applied.
  118418. */
  118419. unlit: boolean;
  118420. /**
  118421. * Gets the image processing configuration used either in this material.
  118422. */
  118423. /**
  118424. * Sets the Default image processing configuration used either in the this material.
  118425. *
  118426. * If sets to null, the scene one is in use.
  118427. */
  118428. imageProcessingConfiguration: ImageProcessingConfiguration;
  118429. /**
  118430. * Gets wether the color curves effect is enabled.
  118431. */
  118432. /**
  118433. * Sets wether the color curves effect is enabled.
  118434. */
  118435. cameraColorCurvesEnabled: boolean;
  118436. /**
  118437. * Gets wether the color grading effect is enabled.
  118438. */
  118439. /**
  118440. * Gets wether the color grading effect is enabled.
  118441. */
  118442. cameraColorGradingEnabled: boolean;
  118443. /**
  118444. * Gets wether tonemapping is enabled or not.
  118445. */
  118446. /**
  118447. * Sets wether tonemapping is enabled or not
  118448. */
  118449. cameraToneMappingEnabled: boolean;
  118450. /**
  118451. * The camera exposure used on this material.
  118452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118453. * This corresponds to a photographic exposure.
  118454. */
  118455. /**
  118456. * The camera exposure used on this material.
  118457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118458. * This corresponds to a photographic exposure.
  118459. */
  118460. cameraExposure: number;
  118461. /**
  118462. * Gets The camera contrast used on this material.
  118463. */
  118464. /**
  118465. * Sets The camera contrast used on this material.
  118466. */
  118467. cameraContrast: number;
  118468. /**
  118469. * Gets the Color Grading 2D Lookup Texture.
  118470. */
  118471. /**
  118472. * Sets the Color Grading 2D Lookup Texture.
  118473. */
  118474. cameraColorGradingTexture: Nullable<BaseTexture>;
  118475. /**
  118476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118478. * 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;
  118479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118480. */
  118481. /**
  118482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118484. * 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;
  118485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118486. */
  118487. cameraColorCurves: Nullable<ColorCurves>;
  118488. /**
  118489. * Instantiates a new PBRMaterial instance.
  118490. *
  118491. * @param name The material name
  118492. * @param scene The scene the material will be use in.
  118493. */
  118494. constructor(name: string, scene: Scene);
  118495. /**
  118496. * Returns the name of this material class.
  118497. */
  118498. getClassName(): string;
  118499. /**
  118500. * Makes a duplicate of the current material.
  118501. * @param name - name to use for the new material.
  118502. */
  118503. clone(name: string): PBRMaterial;
  118504. /**
  118505. * Serializes this PBR Material.
  118506. * @returns - An object with the serialized material.
  118507. */
  118508. serialize(): any;
  118509. /**
  118510. * Parses a PBR Material from a serialized object.
  118511. * @param source - Serialized object.
  118512. * @param scene - BJS scene instance.
  118513. * @param rootUrl - url for the scene object
  118514. * @returns - PBRMaterial
  118515. */
  118516. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118517. }
  118518. }
  118519. declare module BABYLON {
  118520. /**
  118521. * Direct draw surface info
  118522. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118523. */
  118524. export interface DDSInfo {
  118525. /**
  118526. * Width of the texture
  118527. */
  118528. width: number;
  118529. /**
  118530. * Width of the texture
  118531. */
  118532. height: number;
  118533. /**
  118534. * Number of Mipmaps for the texture
  118535. * @see https://en.wikipedia.org/wiki/Mipmap
  118536. */
  118537. mipmapCount: number;
  118538. /**
  118539. * If the textures format is a known fourCC format
  118540. * @see https://www.fourcc.org/
  118541. */
  118542. isFourCC: boolean;
  118543. /**
  118544. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118545. */
  118546. isRGB: boolean;
  118547. /**
  118548. * If the texture is a lumincance format
  118549. */
  118550. isLuminance: boolean;
  118551. /**
  118552. * If this is a cube texture
  118553. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118554. */
  118555. isCube: boolean;
  118556. /**
  118557. * If the texture is a compressed format eg. FOURCC_DXT1
  118558. */
  118559. isCompressed: boolean;
  118560. /**
  118561. * The dxgiFormat of the texture
  118562. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118563. */
  118564. dxgiFormat: number;
  118565. /**
  118566. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118567. */
  118568. textureType: number;
  118569. /**
  118570. * Sphericle polynomial created for the dds texture
  118571. */
  118572. sphericalPolynomial?: SphericalPolynomial;
  118573. }
  118574. /**
  118575. * Class used to provide DDS decompression tools
  118576. */
  118577. export class DDSTools {
  118578. /**
  118579. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118580. */
  118581. static StoreLODInAlphaChannel: boolean;
  118582. /**
  118583. * Gets DDS information from an array buffer
  118584. * @param arrayBuffer defines the array buffer to read data from
  118585. * @returns the DDS information
  118586. */
  118587. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118588. private static _FloatView;
  118589. private static _Int32View;
  118590. private static _ToHalfFloat;
  118591. private static _FromHalfFloat;
  118592. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118593. private static _GetHalfFloatRGBAArrayBuffer;
  118594. private static _GetFloatRGBAArrayBuffer;
  118595. private static _GetFloatAsUIntRGBAArrayBuffer;
  118596. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118597. private static _GetRGBAArrayBuffer;
  118598. private static _ExtractLongWordOrder;
  118599. private static _GetRGBArrayBuffer;
  118600. private static _GetLuminanceArrayBuffer;
  118601. /**
  118602. * Uploads DDS Levels to a Babylon Texture
  118603. * @hidden
  118604. */
  118605. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118606. }
  118607. interface ThinEngine {
  118608. /**
  118609. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118610. * @param rootUrl defines the url where the file to load is located
  118611. * @param scene defines the current scene
  118612. * @param lodScale defines scale to apply to the mip map selection
  118613. * @param lodOffset defines offset to apply to the mip map selection
  118614. * @param onLoad defines an optional callback raised when the texture is loaded
  118615. * @param onError defines an optional callback raised if there is an issue to load the texture
  118616. * @param format defines the format of the data
  118617. * @param forcedExtension defines the extension to use to pick the right loader
  118618. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118619. * @returns the cube texture as an InternalTexture
  118620. */
  118621. 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;
  118622. }
  118623. }
  118624. declare module BABYLON {
  118625. /**
  118626. * Implementation of the DDS Texture Loader.
  118627. * @hidden
  118628. */
  118629. export class _DDSTextureLoader implements IInternalTextureLoader {
  118630. /**
  118631. * Defines wether the loader supports cascade loading the different faces.
  118632. */
  118633. readonly supportCascades: boolean;
  118634. /**
  118635. * This returns if the loader support the current file information.
  118636. * @param extension defines the file extension of the file being loaded
  118637. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118638. * @param fallback defines the fallback internal texture if any
  118639. * @param isBase64 defines whether the texture is encoded as a base64
  118640. * @param isBuffer defines whether the texture data are stored as a buffer
  118641. * @returns true if the loader can load the specified file
  118642. */
  118643. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118644. /**
  118645. * Transform the url before loading if required.
  118646. * @param rootUrl the url of the texture
  118647. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118648. * @returns the transformed texture
  118649. */
  118650. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118651. /**
  118652. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118653. * @param rootUrl the url of the texture
  118654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118655. * @returns the fallback texture
  118656. */
  118657. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118658. /**
  118659. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118660. * @param data contains the texture data
  118661. * @param texture defines the BabylonJS internal texture
  118662. * @param createPolynomials will be true if polynomials have been requested
  118663. * @param onLoad defines the callback to trigger once the texture is ready
  118664. * @param onError defines the callback to trigger in case of error
  118665. */
  118666. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118667. /**
  118668. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118669. * @param data contains the texture data
  118670. * @param texture defines the BabylonJS internal texture
  118671. * @param callback defines the method to call once ready to upload
  118672. */
  118673. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118674. }
  118675. }
  118676. declare module BABYLON {
  118677. /**
  118678. * Implementation of the ENV Texture Loader.
  118679. * @hidden
  118680. */
  118681. export class _ENVTextureLoader implements IInternalTextureLoader {
  118682. /**
  118683. * Defines wether the loader supports cascade loading the different faces.
  118684. */
  118685. readonly supportCascades: boolean;
  118686. /**
  118687. * This returns if the loader support the current file information.
  118688. * @param extension defines the file extension of the file being loaded
  118689. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118690. * @param fallback defines the fallback internal texture if any
  118691. * @param isBase64 defines whether the texture is encoded as a base64
  118692. * @param isBuffer defines whether the texture data are stored as a buffer
  118693. * @returns true if the loader can load the specified file
  118694. */
  118695. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118696. /**
  118697. * Transform the url before loading if required.
  118698. * @param rootUrl the url of the texture
  118699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118700. * @returns the transformed texture
  118701. */
  118702. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118703. /**
  118704. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118705. * @param rootUrl the url of the texture
  118706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118707. * @returns the fallback texture
  118708. */
  118709. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118710. /**
  118711. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118712. * @param data contains the texture data
  118713. * @param texture defines the BabylonJS internal texture
  118714. * @param createPolynomials will be true if polynomials have been requested
  118715. * @param onLoad defines the callback to trigger once the texture is ready
  118716. * @param onError defines the callback to trigger in case of error
  118717. */
  118718. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118719. /**
  118720. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118721. * @param data contains the texture data
  118722. * @param texture defines the BabylonJS internal texture
  118723. * @param callback defines the method to call once ready to upload
  118724. */
  118725. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118726. }
  118727. }
  118728. declare module BABYLON {
  118729. /**
  118730. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118731. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118732. */
  118733. export class KhronosTextureContainer {
  118734. /** contents of the KTX container file */
  118735. arrayBuffer: any;
  118736. private static HEADER_LEN;
  118737. private static COMPRESSED_2D;
  118738. private static COMPRESSED_3D;
  118739. private static TEX_2D;
  118740. private static TEX_3D;
  118741. /**
  118742. * Gets the openGL type
  118743. */
  118744. glType: number;
  118745. /**
  118746. * Gets the openGL type size
  118747. */
  118748. glTypeSize: number;
  118749. /**
  118750. * Gets the openGL format
  118751. */
  118752. glFormat: number;
  118753. /**
  118754. * Gets the openGL internal format
  118755. */
  118756. glInternalFormat: number;
  118757. /**
  118758. * Gets the base internal format
  118759. */
  118760. glBaseInternalFormat: number;
  118761. /**
  118762. * Gets image width in pixel
  118763. */
  118764. pixelWidth: number;
  118765. /**
  118766. * Gets image height in pixel
  118767. */
  118768. pixelHeight: number;
  118769. /**
  118770. * Gets image depth in pixels
  118771. */
  118772. pixelDepth: number;
  118773. /**
  118774. * Gets the number of array elements
  118775. */
  118776. numberOfArrayElements: number;
  118777. /**
  118778. * Gets the number of faces
  118779. */
  118780. numberOfFaces: number;
  118781. /**
  118782. * Gets the number of mipmap levels
  118783. */
  118784. numberOfMipmapLevels: number;
  118785. /**
  118786. * Gets the bytes of key value data
  118787. */
  118788. bytesOfKeyValueData: number;
  118789. /**
  118790. * Gets the load type
  118791. */
  118792. loadType: number;
  118793. /**
  118794. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118795. */
  118796. isInvalid: boolean;
  118797. /**
  118798. * Creates a new KhronosTextureContainer
  118799. * @param arrayBuffer contents of the KTX container file
  118800. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118801. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118802. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118803. */
  118804. constructor(
  118805. /** contents of the KTX container file */
  118806. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118807. /**
  118808. * Uploads KTX content to a Babylon Texture.
  118809. * It is assumed that the texture has already been created & is currently bound
  118810. * @hidden
  118811. */
  118812. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118813. private _upload2DCompressedLevels;
  118814. }
  118815. }
  118816. declare module BABYLON {
  118817. /**
  118818. * Implementation of the KTX Texture Loader.
  118819. * @hidden
  118820. */
  118821. export class _KTXTextureLoader implements IInternalTextureLoader {
  118822. /**
  118823. * Defines wether the loader supports cascade loading the different faces.
  118824. */
  118825. readonly supportCascades: boolean;
  118826. /**
  118827. * This returns if the loader support the current file information.
  118828. * @param extension defines the file extension of the file being loaded
  118829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118830. * @param fallback defines the fallback internal texture if any
  118831. * @param isBase64 defines whether the texture is encoded as a base64
  118832. * @param isBuffer defines whether the texture data are stored as a buffer
  118833. * @returns true if the loader can load the specified file
  118834. */
  118835. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118836. /**
  118837. * Transform the url before loading if required.
  118838. * @param rootUrl the url of the texture
  118839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118840. * @returns the transformed texture
  118841. */
  118842. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118843. /**
  118844. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118845. * @param rootUrl the url of the texture
  118846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118847. * @returns the fallback texture
  118848. */
  118849. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118850. /**
  118851. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118852. * @param data contains the texture data
  118853. * @param texture defines the BabylonJS internal texture
  118854. * @param createPolynomials will be true if polynomials have been requested
  118855. * @param onLoad defines the callback to trigger once the texture is ready
  118856. * @param onError defines the callback to trigger in case of error
  118857. */
  118858. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118859. /**
  118860. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118861. * @param data contains the texture data
  118862. * @param texture defines the BabylonJS internal texture
  118863. * @param callback defines the method to call once ready to upload
  118864. */
  118865. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118866. }
  118867. }
  118868. declare module BABYLON {
  118869. /** @hidden */
  118870. export var _forceSceneHelpersToBundle: boolean;
  118871. interface Scene {
  118872. /**
  118873. * Creates a default light for the scene.
  118874. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118875. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118876. */
  118877. createDefaultLight(replace?: boolean): void;
  118878. /**
  118879. * Creates a default camera for the scene.
  118880. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118881. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118882. * @param replace has default false, when true replaces the active camera in the scene
  118883. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118884. */
  118885. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118886. /**
  118887. * Creates a default camera and a default light.
  118888. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118889. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118890. * @param replace has the default false, when true replaces the active camera/light in the scene
  118891. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118892. */
  118893. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118894. /**
  118895. * Creates a new sky box
  118896. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118897. * @param environmentTexture defines the texture to use as environment texture
  118898. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118899. * @param scale defines the overall scale of the skybox
  118900. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118901. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118902. * @returns a new mesh holding the sky box
  118903. */
  118904. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118905. /**
  118906. * Creates a new environment
  118907. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118908. * @param options defines the options you can use to configure the environment
  118909. * @returns the new EnvironmentHelper
  118910. */
  118911. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118912. /**
  118913. * Creates a new VREXperienceHelper
  118914. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118915. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118916. * @returns a new VREXperienceHelper
  118917. */
  118918. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118919. /**
  118920. * Creates a new WebXRDefaultExperience
  118921. * @see http://doc.babylonjs.com/how_to/webxr
  118922. * @param options experience options
  118923. * @returns a promise for a new WebXRDefaultExperience
  118924. */
  118925. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118926. }
  118927. }
  118928. declare module BABYLON {
  118929. /**
  118930. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118931. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118932. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118933. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118934. */
  118935. export class VideoDome extends TransformNode {
  118936. /**
  118937. * Define the video source as a Monoscopic panoramic 360 video.
  118938. */
  118939. static readonly MODE_MONOSCOPIC: number;
  118940. /**
  118941. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118942. */
  118943. static readonly MODE_TOPBOTTOM: number;
  118944. /**
  118945. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118946. */
  118947. static readonly MODE_SIDEBYSIDE: number;
  118948. private _halfDome;
  118949. private _useDirectMapping;
  118950. /**
  118951. * The video texture being displayed on the sphere
  118952. */
  118953. protected _videoTexture: VideoTexture;
  118954. /**
  118955. * Gets the video texture being displayed on the sphere
  118956. */
  118957. readonly videoTexture: VideoTexture;
  118958. /**
  118959. * The skybox material
  118960. */
  118961. protected _material: BackgroundMaterial;
  118962. /**
  118963. * The surface used for the skybox
  118964. */
  118965. protected _mesh: Mesh;
  118966. /**
  118967. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  118968. */
  118969. private _halfDomeMask;
  118970. /**
  118971. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118972. * Also see the options.resolution property.
  118973. */
  118974. fovMultiplier: number;
  118975. private _videoMode;
  118976. /**
  118977. * Gets or set the current video mode for the video. It can be:
  118978. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  118979. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118980. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118981. */
  118982. videoMode: number;
  118983. /**
  118984. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118985. *
  118986. */
  118987. /**
  118988. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118989. */
  118990. halfDome: boolean;
  118991. /**
  118992. * Oberserver used in Stereoscopic VR Mode.
  118993. */
  118994. private _onBeforeCameraRenderObserver;
  118995. /**
  118996. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118997. * @param name Element's name, child elements will append suffixes for their own names.
  118998. * @param urlsOrVideo defines the url(s) or the video element to use
  118999. * @param options An object containing optional or exposed sub element properties
  119000. */
  119001. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  119002. resolution?: number;
  119003. clickToPlay?: boolean;
  119004. autoPlay?: boolean;
  119005. loop?: boolean;
  119006. size?: number;
  119007. poster?: string;
  119008. faceForward?: boolean;
  119009. useDirectMapping?: boolean;
  119010. halfDomeMode?: boolean;
  119011. }, scene: Scene);
  119012. private _changeVideoMode;
  119013. /**
  119014. * Releases resources associated with this node.
  119015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119017. */
  119018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119019. }
  119020. }
  119021. declare module BABYLON {
  119022. /**
  119023. * This class can be used to get instrumentation data from a Babylon engine
  119024. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119025. */
  119026. export class EngineInstrumentation implements IDisposable {
  119027. /**
  119028. * Define the instrumented engine.
  119029. */
  119030. engine: Engine;
  119031. private _captureGPUFrameTime;
  119032. private _gpuFrameTimeToken;
  119033. private _gpuFrameTime;
  119034. private _captureShaderCompilationTime;
  119035. private _shaderCompilationTime;
  119036. private _onBeginFrameObserver;
  119037. private _onEndFrameObserver;
  119038. private _onBeforeShaderCompilationObserver;
  119039. private _onAfterShaderCompilationObserver;
  119040. /**
  119041. * Gets the perf counter used for GPU frame time
  119042. */
  119043. readonly gpuFrameTimeCounter: PerfCounter;
  119044. /**
  119045. * Gets the GPU frame time capture status
  119046. */
  119047. /**
  119048. * Enable or disable the GPU frame time capture
  119049. */
  119050. captureGPUFrameTime: boolean;
  119051. /**
  119052. * Gets the perf counter used for shader compilation time
  119053. */
  119054. readonly shaderCompilationTimeCounter: PerfCounter;
  119055. /**
  119056. * Gets the shader compilation time capture status
  119057. */
  119058. /**
  119059. * Enable or disable the shader compilation time capture
  119060. */
  119061. captureShaderCompilationTime: boolean;
  119062. /**
  119063. * Instantiates a new engine instrumentation.
  119064. * This class can be used to get instrumentation data from a Babylon engine
  119065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119066. * @param engine Defines the engine to instrument
  119067. */
  119068. constructor(
  119069. /**
  119070. * Define the instrumented engine.
  119071. */
  119072. engine: Engine);
  119073. /**
  119074. * Dispose and release associated resources.
  119075. */
  119076. dispose(): void;
  119077. }
  119078. }
  119079. declare module BABYLON {
  119080. /**
  119081. * This class can be used to get instrumentation data from a Babylon engine
  119082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119083. */
  119084. export class SceneInstrumentation implements IDisposable {
  119085. /**
  119086. * Defines the scene to instrument
  119087. */
  119088. scene: Scene;
  119089. private _captureActiveMeshesEvaluationTime;
  119090. private _activeMeshesEvaluationTime;
  119091. private _captureRenderTargetsRenderTime;
  119092. private _renderTargetsRenderTime;
  119093. private _captureFrameTime;
  119094. private _frameTime;
  119095. private _captureRenderTime;
  119096. private _renderTime;
  119097. private _captureInterFrameTime;
  119098. private _interFrameTime;
  119099. private _captureParticlesRenderTime;
  119100. private _particlesRenderTime;
  119101. private _captureSpritesRenderTime;
  119102. private _spritesRenderTime;
  119103. private _capturePhysicsTime;
  119104. private _physicsTime;
  119105. private _captureAnimationsTime;
  119106. private _animationsTime;
  119107. private _captureCameraRenderTime;
  119108. private _cameraRenderTime;
  119109. private _onBeforeActiveMeshesEvaluationObserver;
  119110. private _onAfterActiveMeshesEvaluationObserver;
  119111. private _onBeforeRenderTargetsRenderObserver;
  119112. private _onAfterRenderTargetsRenderObserver;
  119113. private _onAfterRenderObserver;
  119114. private _onBeforeDrawPhaseObserver;
  119115. private _onAfterDrawPhaseObserver;
  119116. private _onBeforeAnimationsObserver;
  119117. private _onBeforeParticlesRenderingObserver;
  119118. private _onAfterParticlesRenderingObserver;
  119119. private _onBeforeSpritesRenderingObserver;
  119120. private _onAfterSpritesRenderingObserver;
  119121. private _onBeforePhysicsObserver;
  119122. private _onAfterPhysicsObserver;
  119123. private _onAfterAnimationsObserver;
  119124. private _onBeforeCameraRenderObserver;
  119125. private _onAfterCameraRenderObserver;
  119126. /**
  119127. * Gets the perf counter used for active meshes evaluation time
  119128. */
  119129. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119130. /**
  119131. * Gets the active meshes evaluation time capture status
  119132. */
  119133. /**
  119134. * Enable or disable the active meshes evaluation time capture
  119135. */
  119136. captureActiveMeshesEvaluationTime: boolean;
  119137. /**
  119138. * Gets the perf counter used for render targets render time
  119139. */
  119140. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119141. /**
  119142. * Gets the render targets render time capture status
  119143. */
  119144. /**
  119145. * Enable or disable the render targets render time capture
  119146. */
  119147. captureRenderTargetsRenderTime: boolean;
  119148. /**
  119149. * Gets the perf counter used for particles render time
  119150. */
  119151. readonly particlesRenderTimeCounter: PerfCounter;
  119152. /**
  119153. * Gets the particles render time capture status
  119154. */
  119155. /**
  119156. * Enable or disable the particles render time capture
  119157. */
  119158. captureParticlesRenderTime: boolean;
  119159. /**
  119160. * Gets the perf counter used for sprites render time
  119161. */
  119162. readonly spritesRenderTimeCounter: PerfCounter;
  119163. /**
  119164. * Gets the sprites render time capture status
  119165. */
  119166. /**
  119167. * Enable or disable the sprites render time capture
  119168. */
  119169. captureSpritesRenderTime: boolean;
  119170. /**
  119171. * Gets the perf counter used for physics time
  119172. */
  119173. readonly physicsTimeCounter: PerfCounter;
  119174. /**
  119175. * Gets the physics time capture status
  119176. */
  119177. /**
  119178. * Enable or disable the physics time capture
  119179. */
  119180. capturePhysicsTime: boolean;
  119181. /**
  119182. * Gets the perf counter used for animations time
  119183. */
  119184. readonly animationsTimeCounter: PerfCounter;
  119185. /**
  119186. * Gets the animations time capture status
  119187. */
  119188. /**
  119189. * Enable or disable the animations time capture
  119190. */
  119191. captureAnimationsTime: boolean;
  119192. /**
  119193. * Gets the perf counter used for frame time capture
  119194. */
  119195. readonly frameTimeCounter: PerfCounter;
  119196. /**
  119197. * Gets the frame time capture status
  119198. */
  119199. /**
  119200. * Enable or disable the frame time capture
  119201. */
  119202. captureFrameTime: boolean;
  119203. /**
  119204. * Gets the perf counter used for inter-frames time capture
  119205. */
  119206. readonly interFrameTimeCounter: PerfCounter;
  119207. /**
  119208. * Gets the inter-frames time capture status
  119209. */
  119210. /**
  119211. * Enable or disable the inter-frames time capture
  119212. */
  119213. captureInterFrameTime: boolean;
  119214. /**
  119215. * Gets the perf counter used for render time capture
  119216. */
  119217. readonly renderTimeCounter: PerfCounter;
  119218. /**
  119219. * Gets the render time capture status
  119220. */
  119221. /**
  119222. * Enable or disable the render time capture
  119223. */
  119224. captureRenderTime: boolean;
  119225. /**
  119226. * Gets the perf counter used for camera render time capture
  119227. */
  119228. readonly cameraRenderTimeCounter: PerfCounter;
  119229. /**
  119230. * Gets the camera render time capture status
  119231. */
  119232. /**
  119233. * Enable or disable the camera render time capture
  119234. */
  119235. captureCameraRenderTime: boolean;
  119236. /**
  119237. * Gets the perf counter used for draw calls
  119238. */
  119239. readonly drawCallsCounter: PerfCounter;
  119240. /**
  119241. * Instantiates a new scene instrumentation.
  119242. * This class can be used to get instrumentation data from a Babylon engine
  119243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119244. * @param scene Defines the scene to instrument
  119245. */
  119246. constructor(
  119247. /**
  119248. * Defines the scene to instrument
  119249. */
  119250. scene: Scene);
  119251. /**
  119252. * Dispose and release associated resources.
  119253. */
  119254. dispose(): void;
  119255. }
  119256. }
  119257. declare module BABYLON {
  119258. /** @hidden */
  119259. export var glowMapGenerationPixelShader: {
  119260. name: string;
  119261. shader: string;
  119262. };
  119263. }
  119264. declare module BABYLON {
  119265. /** @hidden */
  119266. export var glowMapGenerationVertexShader: {
  119267. name: string;
  119268. shader: string;
  119269. };
  119270. }
  119271. declare module BABYLON {
  119272. /**
  119273. * Effect layer options. This helps customizing the behaviour
  119274. * of the effect layer.
  119275. */
  119276. export interface IEffectLayerOptions {
  119277. /**
  119278. * Multiplication factor apply to the canvas size to compute the render target size
  119279. * used to generated the objects (the smaller the faster).
  119280. */
  119281. mainTextureRatio: number;
  119282. /**
  119283. * Enforces a fixed size texture to ensure effect stability across devices.
  119284. */
  119285. mainTextureFixedSize?: number;
  119286. /**
  119287. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119288. */
  119289. alphaBlendingMode: number;
  119290. /**
  119291. * The camera attached to the layer.
  119292. */
  119293. camera: Nullable<Camera>;
  119294. /**
  119295. * The rendering group to draw the layer in.
  119296. */
  119297. renderingGroupId: number;
  119298. }
  119299. /**
  119300. * The effect layer Helps adding post process effect blended with the main pass.
  119301. *
  119302. * This can be for instance use to generate glow or higlight effects on the scene.
  119303. *
  119304. * The effect layer class can not be used directly and is intented to inherited from to be
  119305. * customized per effects.
  119306. */
  119307. export abstract class EffectLayer {
  119308. private _vertexBuffers;
  119309. private _indexBuffer;
  119310. private _cachedDefines;
  119311. private _effectLayerMapGenerationEffect;
  119312. private _effectLayerOptions;
  119313. private _mergeEffect;
  119314. protected _scene: Scene;
  119315. protected _engine: Engine;
  119316. protected _maxSize: number;
  119317. protected _mainTextureDesiredSize: ISize;
  119318. protected _mainTexture: RenderTargetTexture;
  119319. protected _shouldRender: boolean;
  119320. protected _postProcesses: PostProcess[];
  119321. protected _textures: BaseTexture[];
  119322. protected _emissiveTextureAndColor: {
  119323. texture: Nullable<BaseTexture>;
  119324. color: Color4;
  119325. };
  119326. /**
  119327. * The name of the layer
  119328. */
  119329. name: string;
  119330. /**
  119331. * The clear color of the texture used to generate the glow map.
  119332. */
  119333. neutralColor: Color4;
  119334. /**
  119335. * Specifies wether the highlight layer is enabled or not.
  119336. */
  119337. isEnabled: boolean;
  119338. /**
  119339. * Gets the camera attached to the layer.
  119340. */
  119341. readonly camera: Nullable<Camera>;
  119342. /**
  119343. * Gets the rendering group id the layer should render in.
  119344. */
  119345. renderingGroupId: number;
  119346. /**
  119347. * An event triggered when the effect layer has been disposed.
  119348. */
  119349. onDisposeObservable: Observable<EffectLayer>;
  119350. /**
  119351. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119352. */
  119353. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119354. /**
  119355. * An event triggered when the generated texture is being merged in the scene.
  119356. */
  119357. onBeforeComposeObservable: Observable<EffectLayer>;
  119358. /**
  119359. * An event triggered when the mesh is rendered into the effect render target.
  119360. */
  119361. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119362. /**
  119363. * An event triggered after the mesh has been rendered into the effect render target.
  119364. */
  119365. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119366. /**
  119367. * An event triggered when the generated texture has been merged in the scene.
  119368. */
  119369. onAfterComposeObservable: Observable<EffectLayer>;
  119370. /**
  119371. * An event triggered when the efffect layer changes its size.
  119372. */
  119373. onSizeChangedObservable: Observable<EffectLayer>;
  119374. /** @hidden */
  119375. static _SceneComponentInitialization: (scene: Scene) => void;
  119376. /**
  119377. * Instantiates a new effect Layer and references it in the scene.
  119378. * @param name The name of the layer
  119379. * @param scene The scene to use the layer in
  119380. */
  119381. constructor(
  119382. /** The Friendly of the effect in the scene */
  119383. name: string, scene: Scene);
  119384. /**
  119385. * Get the effect name of the layer.
  119386. * @return The effect name
  119387. */
  119388. abstract getEffectName(): string;
  119389. /**
  119390. * Checks for the readiness of the element composing the layer.
  119391. * @param subMesh the mesh to check for
  119392. * @param useInstances specify wether or not to use instances to render the mesh
  119393. * @return true if ready otherwise, false
  119394. */
  119395. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119396. /**
  119397. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119398. * @returns true if the effect requires stencil during the main canvas render pass.
  119399. */
  119400. abstract needStencil(): boolean;
  119401. /**
  119402. * Create the merge effect. This is the shader use to blit the information back
  119403. * to the main canvas at the end of the scene rendering.
  119404. * @returns The effect containing the shader used to merge the effect on the main canvas
  119405. */
  119406. protected abstract _createMergeEffect(): Effect;
  119407. /**
  119408. * Creates the render target textures and post processes used in the effect layer.
  119409. */
  119410. protected abstract _createTextureAndPostProcesses(): void;
  119411. /**
  119412. * Implementation specific of rendering the generating effect on the main canvas.
  119413. * @param effect The effect used to render through
  119414. */
  119415. protected abstract _internalRender(effect: Effect): void;
  119416. /**
  119417. * Sets the required values for both the emissive texture and and the main color.
  119418. */
  119419. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119420. /**
  119421. * Free any resources and references associated to a mesh.
  119422. * Internal use
  119423. * @param mesh The mesh to free.
  119424. */
  119425. abstract _disposeMesh(mesh: Mesh): void;
  119426. /**
  119427. * Serializes this layer (Glow or Highlight for example)
  119428. * @returns a serialized layer object
  119429. */
  119430. abstract serialize?(): any;
  119431. /**
  119432. * Initializes the effect layer with the required options.
  119433. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  119434. */
  119435. protected _init(options: Partial<IEffectLayerOptions>): void;
  119436. /**
  119437. * Generates the index buffer of the full screen quad blending to the main canvas.
  119438. */
  119439. private _generateIndexBuffer;
  119440. /**
  119441. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  119442. */
  119443. private _generateVertexBuffer;
  119444. /**
  119445. * Sets the main texture desired size which is the closest power of two
  119446. * of the engine canvas size.
  119447. */
  119448. private _setMainTextureSize;
  119449. /**
  119450. * Creates the main texture for the effect layer.
  119451. */
  119452. protected _createMainTexture(): void;
  119453. /**
  119454. * Adds specific effects defines.
  119455. * @param defines The defines to add specifics to.
  119456. */
  119457. protected _addCustomEffectDefines(defines: string[]): void;
  119458. /**
  119459. * Checks for the readiness of the element composing the layer.
  119460. * @param subMesh the mesh to check for
  119461. * @param useInstances specify wether or not to use instances to render the mesh
  119462. * @param emissiveTexture the associated emissive texture used to generate the glow
  119463. * @return true if ready otherwise, false
  119464. */
  119465. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  119466. /**
  119467. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  119468. */
  119469. render(): void;
  119470. /**
  119471. * Determine if a given mesh will be used in the current effect.
  119472. * @param mesh mesh to test
  119473. * @returns true if the mesh will be used
  119474. */
  119475. hasMesh(mesh: AbstractMesh): boolean;
  119476. /**
  119477. * Returns true if the layer contains information to display, otherwise false.
  119478. * @returns true if the glow layer should be rendered
  119479. */
  119480. shouldRender(): boolean;
  119481. /**
  119482. * Returns true if the mesh should render, otherwise false.
  119483. * @param mesh The mesh to render
  119484. * @returns true if it should render otherwise false
  119485. */
  119486. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  119487. /**
  119488. * Returns true if the mesh can be rendered, otherwise false.
  119489. * @param mesh The mesh to render
  119490. * @param material The material used on the mesh
  119491. * @returns true if it can be rendered otherwise false
  119492. */
  119493. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119494. /**
  119495. * Returns true if the mesh should render, otherwise false.
  119496. * @param mesh The mesh to render
  119497. * @returns true if it should render otherwise false
  119498. */
  119499. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119500. /**
  119501. * Renders the submesh passed in parameter to the generation map.
  119502. */
  119503. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119504. /**
  119505. * Defines wether the current material of the mesh should be use to render the effect.
  119506. * @param mesh defines the current mesh to render
  119507. */
  119508. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119509. /**
  119510. * Rebuild the required buffers.
  119511. * @hidden Internal use only.
  119512. */
  119513. _rebuild(): void;
  119514. /**
  119515. * Dispose only the render target textures and post process.
  119516. */
  119517. private _disposeTextureAndPostProcesses;
  119518. /**
  119519. * Dispose the highlight layer and free resources.
  119520. */
  119521. dispose(): void;
  119522. /**
  119523. * Gets the class name of the effect layer
  119524. * @returns the string with the class name of the effect layer
  119525. */
  119526. getClassName(): string;
  119527. /**
  119528. * Creates an effect layer from parsed effect layer data
  119529. * @param parsedEffectLayer defines effect layer data
  119530. * @param scene defines the current scene
  119531. * @param rootUrl defines the root URL containing the effect layer information
  119532. * @returns a parsed effect Layer
  119533. */
  119534. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119535. }
  119536. }
  119537. declare module BABYLON {
  119538. interface AbstractScene {
  119539. /**
  119540. * The list of effect layers (highlights/glow) added to the scene
  119541. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119542. * @see http://doc.babylonjs.com/how_to/glow_layer
  119543. */
  119544. effectLayers: Array<EffectLayer>;
  119545. /**
  119546. * Removes the given effect layer from this scene.
  119547. * @param toRemove defines the effect layer to remove
  119548. * @returns the index of the removed effect layer
  119549. */
  119550. removeEffectLayer(toRemove: EffectLayer): number;
  119551. /**
  119552. * Adds the given effect layer to this scene
  119553. * @param newEffectLayer defines the effect layer to add
  119554. */
  119555. addEffectLayer(newEffectLayer: EffectLayer): void;
  119556. }
  119557. /**
  119558. * Defines the layer scene component responsible to manage any effect layers
  119559. * in a given scene.
  119560. */
  119561. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119562. /**
  119563. * The component name helpfull to identify the component in the list of scene components.
  119564. */
  119565. readonly name: string;
  119566. /**
  119567. * The scene the component belongs to.
  119568. */
  119569. scene: Scene;
  119570. private _engine;
  119571. private _renderEffects;
  119572. private _needStencil;
  119573. private _previousStencilState;
  119574. /**
  119575. * Creates a new instance of the component for the given scene
  119576. * @param scene Defines the scene to register the component in
  119577. */
  119578. constructor(scene: Scene);
  119579. /**
  119580. * Registers the component in a given scene
  119581. */
  119582. register(): void;
  119583. /**
  119584. * Rebuilds the elements related to this component in case of
  119585. * context lost for instance.
  119586. */
  119587. rebuild(): void;
  119588. /**
  119589. * Serializes the component data to the specified json object
  119590. * @param serializationObject The object to serialize to
  119591. */
  119592. serialize(serializationObject: any): void;
  119593. /**
  119594. * Adds all the elements from the container to the scene
  119595. * @param container the container holding the elements
  119596. */
  119597. addFromContainer(container: AbstractScene): void;
  119598. /**
  119599. * Removes all the elements in the container from the scene
  119600. * @param container contains the elements to remove
  119601. * @param dispose if the removed element should be disposed (default: false)
  119602. */
  119603. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119604. /**
  119605. * Disposes the component and the associated ressources.
  119606. */
  119607. dispose(): void;
  119608. private _isReadyForMesh;
  119609. private _renderMainTexture;
  119610. private _setStencil;
  119611. private _setStencilBack;
  119612. private _draw;
  119613. private _drawCamera;
  119614. private _drawRenderingGroup;
  119615. }
  119616. }
  119617. declare module BABYLON {
  119618. /** @hidden */
  119619. export var glowMapMergePixelShader: {
  119620. name: string;
  119621. shader: string;
  119622. };
  119623. }
  119624. declare module BABYLON {
  119625. /** @hidden */
  119626. export var glowMapMergeVertexShader: {
  119627. name: string;
  119628. shader: string;
  119629. };
  119630. }
  119631. declare module BABYLON {
  119632. interface AbstractScene {
  119633. /**
  119634. * Return a the first highlight layer of the scene with a given name.
  119635. * @param name The name of the highlight layer to look for.
  119636. * @return The highlight layer if found otherwise null.
  119637. */
  119638. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  119639. }
  119640. /**
  119641. * Glow layer options. This helps customizing the behaviour
  119642. * of the glow layer.
  119643. */
  119644. export interface IGlowLayerOptions {
  119645. /**
  119646. * Multiplication factor apply to the canvas size to compute the render target size
  119647. * used to generated the glowing objects (the smaller the faster).
  119648. */
  119649. mainTextureRatio: number;
  119650. /**
  119651. * Enforces a fixed size texture to ensure resize independant blur.
  119652. */
  119653. mainTextureFixedSize?: number;
  119654. /**
  119655. * How big is the kernel of the blur texture.
  119656. */
  119657. blurKernelSize: number;
  119658. /**
  119659. * The camera attached to the layer.
  119660. */
  119661. camera: Nullable<Camera>;
  119662. /**
  119663. * Enable MSAA by chosing the number of samples.
  119664. */
  119665. mainTextureSamples?: number;
  119666. /**
  119667. * The rendering group to draw the layer in.
  119668. */
  119669. renderingGroupId: number;
  119670. }
  119671. /**
  119672. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119673. *
  119674. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119675. *
  119676. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119677. */
  119678. export class GlowLayer extends EffectLayer {
  119679. /**
  119680. * Effect Name of the layer.
  119681. */
  119682. static readonly EffectName: string;
  119683. /**
  119684. * The default blur kernel size used for the glow.
  119685. */
  119686. static DefaultBlurKernelSize: number;
  119687. /**
  119688. * The default texture size ratio used for the glow.
  119689. */
  119690. static DefaultTextureRatio: number;
  119691. /**
  119692. * Sets the kernel size of the blur.
  119693. */
  119694. /**
  119695. * Gets the kernel size of the blur.
  119696. */
  119697. blurKernelSize: number;
  119698. /**
  119699. * Sets the glow intensity.
  119700. */
  119701. /**
  119702. * Gets the glow intensity.
  119703. */
  119704. intensity: number;
  119705. private _options;
  119706. private _intensity;
  119707. private _horizontalBlurPostprocess1;
  119708. private _verticalBlurPostprocess1;
  119709. private _horizontalBlurPostprocess2;
  119710. private _verticalBlurPostprocess2;
  119711. private _blurTexture1;
  119712. private _blurTexture2;
  119713. private _postProcesses1;
  119714. private _postProcesses2;
  119715. private _includedOnlyMeshes;
  119716. private _excludedMeshes;
  119717. private _meshesUsingTheirOwnMaterials;
  119718. /**
  119719. * Callback used to let the user override the color selection on a per mesh basis
  119720. */
  119721. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119722. /**
  119723. * Callback used to let the user override the texture selection on a per mesh basis
  119724. */
  119725. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119726. /**
  119727. * Instantiates a new glow Layer and references it to the scene.
  119728. * @param name The name of the layer
  119729. * @param scene The scene to use the layer in
  119730. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119731. */
  119732. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119733. /**
  119734. * Get the effect name of the layer.
  119735. * @return The effect name
  119736. */
  119737. getEffectName(): string;
  119738. /**
  119739. * Create the merge effect. This is the shader use to blit the information back
  119740. * to the main canvas at the end of the scene rendering.
  119741. */
  119742. protected _createMergeEffect(): Effect;
  119743. /**
  119744. * Creates the render target textures and post processes used in the glow layer.
  119745. */
  119746. protected _createTextureAndPostProcesses(): void;
  119747. /**
  119748. * Checks for the readiness of the element composing the layer.
  119749. * @param subMesh the mesh to check for
  119750. * @param useInstances specify wether or not to use instances to render the mesh
  119751. * @param emissiveTexture the associated emissive texture used to generate the glow
  119752. * @return true if ready otherwise, false
  119753. */
  119754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119755. /**
  119756. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119757. */
  119758. needStencil(): boolean;
  119759. /**
  119760. * Returns true if the mesh can be rendered, otherwise false.
  119761. * @param mesh The mesh to render
  119762. * @param material The material used on the mesh
  119763. * @returns true if it can be rendered otherwise false
  119764. */
  119765. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119766. /**
  119767. * Implementation specific of rendering the generating effect on the main canvas.
  119768. * @param effect The effect used to render through
  119769. */
  119770. protected _internalRender(effect: Effect): void;
  119771. /**
  119772. * Sets the required values for both the emissive texture and and the main color.
  119773. */
  119774. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119775. /**
  119776. * Returns true if the mesh should render, otherwise false.
  119777. * @param mesh The mesh to render
  119778. * @returns true if it should render otherwise false
  119779. */
  119780. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119781. /**
  119782. * Adds specific effects defines.
  119783. * @param defines The defines to add specifics to.
  119784. */
  119785. protected _addCustomEffectDefines(defines: string[]): void;
  119786. /**
  119787. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119788. * @param mesh The mesh to exclude from the glow layer
  119789. */
  119790. addExcludedMesh(mesh: Mesh): void;
  119791. /**
  119792. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119793. * @param mesh The mesh to remove
  119794. */
  119795. removeExcludedMesh(mesh: Mesh): void;
  119796. /**
  119797. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119798. * @param mesh The mesh to include in the glow layer
  119799. */
  119800. addIncludedOnlyMesh(mesh: Mesh): void;
  119801. /**
  119802. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119803. * @param mesh The mesh to remove
  119804. */
  119805. removeIncludedOnlyMesh(mesh: Mesh): void;
  119806. /**
  119807. * Determine if a given mesh will be used in the glow layer
  119808. * @param mesh The mesh to test
  119809. * @returns true if the mesh will be highlighted by the current glow layer
  119810. */
  119811. hasMesh(mesh: AbstractMesh): boolean;
  119812. /**
  119813. * Defines wether the current material of the mesh should be use to render the effect.
  119814. * @param mesh defines the current mesh to render
  119815. */
  119816. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119817. /**
  119818. * Add a mesh to be rendered through its own material and not with emissive only.
  119819. * @param mesh The mesh for which we need to use its material
  119820. */
  119821. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119822. /**
  119823. * Remove a mesh from being rendered through its own material and not with emissive only.
  119824. * @param mesh The mesh for which we need to not use its material
  119825. */
  119826. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119827. /**
  119828. * Free any resources and references associated to a mesh.
  119829. * Internal use
  119830. * @param mesh The mesh to free.
  119831. * @hidden
  119832. */
  119833. _disposeMesh(mesh: Mesh): void;
  119834. /**
  119835. * Gets the class name of the effect layer
  119836. * @returns the string with the class name of the effect layer
  119837. */
  119838. getClassName(): string;
  119839. /**
  119840. * Serializes this glow layer
  119841. * @returns a serialized glow layer object
  119842. */
  119843. serialize(): any;
  119844. /**
  119845. * Creates a Glow Layer from parsed glow layer data
  119846. * @param parsedGlowLayer defines glow layer data
  119847. * @param scene defines the current scene
  119848. * @param rootUrl defines the root URL containing the glow layer information
  119849. * @returns a parsed Glow Layer
  119850. */
  119851. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119852. }
  119853. }
  119854. declare module BABYLON {
  119855. /** @hidden */
  119856. export var glowBlurPostProcessPixelShader: {
  119857. name: string;
  119858. shader: string;
  119859. };
  119860. }
  119861. declare module BABYLON {
  119862. interface AbstractScene {
  119863. /**
  119864. * Return a the first highlight layer of the scene with a given name.
  119865. * @param name The name of the highlight layer to look for.
  119866. * @return The highlight layer if found otherwise null.
  119867. */
  119868. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119869. }
  119870. /**
  119871. * Highlight layer options. This helps customizing the behaviour
  119872. * of the highlight layer.
  119873. */
  119874. export interface IHighlightLayerOptions {
  119875. /**
  119876. * Multiplication factor apply to the canvas size to compute the render target size
  119877. * used to generated the glowing objects (the smaller the faster).
  119878. */
  119879. mainTextureRatio: number;
  119880. /**
  119881. * Enforces a fixed size texture to ensure resize independant blur.
  119882. */
  119883. mainTextureFixedSize?: number;
  119884. /**
  119885. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119886. * of the picture to blur (the smaller the faster).
  119887. */
  119888. blurTextureSizeRatio: number;
  119889. /**
  119890. * How big in texel of the blur texture is the vertical blur.
  119891. */
  119892. blurVerticalSize: number;
  119893. /**
  119894. * How big in texel of the blur texture is the horizontal blur.
  119895. */
  119896. blurHorizontalSize: number;
  119897. /**
  119898. * Alpha blending mode used to apply the blur. Default is combine.
  119899. */
  119900. alphaBlendingMode: number;
  119901. /**
  119902. * The camera attached to the layer.
  119903. */
  119904. camera: Nullable<Camera>;
  119905. /**
  119906. * Should we display highlight as a solid stroke?
  119907. */
  119908. isStroke?: boolean;
  119909. /**
  119910. * The rendering group to draw the layer in.
  119911. */
  119912. renderingGroupId: number;
  119913. }
  119914. /**
  119915. * The highlight layer Helps adding a glow effect around a mesh.
  119916. *
  119917. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119918. * glowy meshes to your scene.
  119919. *
  119920. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119921. */
  119922. export class HighlightLayer extends EffectLayer {
  119923. name: string;
  119924. /**
  119925. * Effect Name of the highlight layer.
  119926. */
  119927. static readonly EffectName: string;
  119928. /**
  119929. * The neutral color used during the preparation of the glow effect.
  119930. * This is black by default as the blend operation is a blend operation.
  119931. */
  119932. static NeutralColor: Color4;
  119933. /**
  119934. * Stencil value used for glowing meshes.
  119935. */
  119936. static GlowingMeshStencilReference: number;
  119937. /**
  119938. * Stencil value used for the other meshes in the scene.
  119939. */
  119940. static NormalMeshStencilReference: number;
  119941. /**
  119942. * Specifies whether or not the inner glow is ACTIVE in the layer.
  119943. */
  119944. innerGlow: boolean;
  119945. /**
  119946. * Specifies whether or not the outer glow is ACTIVE in the layer.
  119947. */
  119948. outerGlow: boolean;
  119949. /**
  119950. * Specifies the horizontal size of the blur.
  119951. */
  119952. /**
  119953. * Gets the horizontal size of the blur.
  119954. */
  119955. blurHorizontalSize: number;
  119956. /**
  119957. * Specifies the vertical size of the blur.
  119958. */
  119959. /**
  119960. * Gets the vertical size of the blur.
  119961. */
  119962. blurVerticalSize: number;
  119963. /**
  119964. * An event triggered when the highlight layer is being blurred.
  119965. */
  119966. onBeforeBlurObservable: Observable<HighlightLayer>;
  119967. /**
  119968. * An event triggered when the highlight layer has been blurred.
  119969. */
  119970. onAfterBlurObservable: Observable<HighlightLayer>;
  119971. private _instanceGlowingMeshStencilReference;
  119972. private _options;
  119973. private _downSamplePostprocess;
  119974. private _horizontalBlurPostprocess;
  119975. private _verticalBlurPostprocess;
  119976. private _blurTexture;
  119977. private _meshes;
  119978. private _excludedMeshes;
  119979. /**
  119980. * Instantiates a new highlight Layer and references it to the scene..
  119981. * @param name The name of the layer
  119982. * @param scene The scene to use the layer in
  119983. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119984. */
  119985. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119986. /**
  119987. * Get the effect name of the layer.
  119988. * @return The effect name
  119989. */
  119990. getEffectName(): string;
  119991. /**
  119992. * Create the merge effect. This is the shader use to blit the information back
  119993. * to the main canvas at the end of the scene rendering.
  119994. */
  119995. protected _createMergeEffect(): Effect;
  119996. /**
  119997. * Creates the render target textures and post processes used in the highlight layer.
  119998. */
  119999. protected _createTextureAndPostProcesses(): void;
  120000. /**
  120001. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120002. */
  120003. needStencil(): boolean;
  120004. /**
  120005. * Checks for the readiness of the element composing the layer.
  120006. * @param subMesh the mesh to check for
  120007. * @param useInstances specify wether or not to use instances to render the mesh
  120008. * @param emissiveTexture the associated emissive texture used to generate the glow
  120009. * @return true if ready otherwise, false
  120010. */
  120011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120012. /**
  120013. * Implementation specific of rendering the generating effect on the main canvas.
  120014. * @param effect The effect used to render through
  120015. */
  120016. protected _internalRender(effect: Effect): void;
  120017. /**
  120018. * Returns true if the layer contains information to display, otherwise false.
  120019. */
  120020. shouldRender(): boolean;
  120021. /**
  120022. * Returns true if the mesh should render, otherwise false.
  120023. * @param mesh The mesh to render
  120024. * @returns true if it should render otherwise false
  120025. */
  120026. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120027. /**
  120028. * Sets the required values for both the emissive texture and and the main color.
  120029. */
  120030. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120031. /**
  120032. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  120033. * @param mesh The mesh to exclude from the highlight layer
  120034. */
  120035. addExcludedMesh(mesh: Mesh): void;
  120036. /**
  120037. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  120038. * @param mesh The mesh to highlight
  120039. */
  120040. removeExcludedMesh(mesh: Mesh): void;
  120041. /**
  120042. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120043. * @param mesh mesh to test
  120044. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120045. */
  120046. hasMesh(mesh: AbstractMesh): boolean;
  120047. /**
  120048. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120049. * @param mesh The mesh to highlight
  120050. * @param color The color of the highlight
  120051. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120052. */
  120053. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120054. /**
  120055. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120056. * @param mesh The mesh to highlight
  120057. */
  120058. removeMesh(mesh: Mesh): void;
  120059. /**
  120060. * Force the stencil to the normal expected value for none glowing parts
  120061. */
  120062. private _defaultStencilReference;
  120063. /**
  120064. * Free any resources and references associated to a mesh.
  120065. * Internal use
  120066. * @param mesh The mesh to free.
  120067. * @hidden
  120068. */
  120069. _disposeMesh(mesh: Mesh): void;
  120070. /**
  120071. * Dispose the highlight layer and free resources.
  120072. */
  120073. dispose(): void;
  120074. /**
  120075. * Gets the class name of the effect layer
  120076. * @returns the string with the class name of the effect layer
  120077. */
  120078. getClassName(): string;
  120079. /**
  120080. * Serializes this Highlight layer
  120081. * @returns a serialized Highlight layer object
  120082. */
  120083. serialize(): any;
  120084. /**
  120085. * Creates a Highlight layer from parsed Highlight layer data
  120086. * @param parsedHightlightLayer defines the Highlight layer data
  120087. * @param scene defines the current scene
  120088. * @param rootUrl defines the root URL containing the Highlight layer information
  120089. * @returns a parsed Highlight layer
  120090. */
  120091. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120092. }
  120093. }
  120094. declare module BABYLON {
  120095. interface AbstractScene {
  120096. /**
  120097. * The list of layers (background and foreground) of the scene
  120098. */
  120099. layers: Array<Layer>;
  120100. }
  120101. /**
  120102. * Defines the layer scene component responsible to manage any layers
  120103. * in a given scene.
  120104. */
  120105. export class LayerSceneComponent implements ISceneComponent {
  120106. /**
  120107. * The component name helpfull to identify the component in the list of scene components.
  120108. */
  120109. readonly name: string;
  120110. /**
  120111. * The scene the component belongs to.
  120112. */
  120113. scene: Scene;
  120114. private _engine;
  120115. /**
  120116. * Creates a new instance of the component for the given scene
  120117. * @param scene Defines the scene to register the component in
  120118. */
  120119. constructor(scene: Scene);
  120120. /**
  120121. * Registers the component in a given scene
  120122. */
  120123. register(): void;
  120124. /**
  120125. * Rebuilds the elements related to this component in case of
  120126. * context lost for instance.
  120127. */
  120128. rebuild(): void;
  120129. /**
  120130. * Disposes the component and the associated ressources.
  120131. */
  120132. dispose(): void;
  120133. private _draw;
  120134. private _drawCameraPredicate;
  120135. private _drawCameraBackground;
  120136. private _drawCameraForeground;
  120137. private _drawRenderTargetPredicate;
  120138. private _drawRenderTargetBackground;
  120139. private _drawRenderTargetForeground;
  120140. /**
  120141. * Adds all the elements from the container to the scene
  120142. * @param container the container holding the elements
  120143. */
  120144. addFromContainer(container: AbstractScene): void;
  120145. /**
  120146. * Removes all the elements in the container from the scene
  120147. * @param container contains the elements to remove
  120148. * @param dispose if the removed element should be disposed (default: false)
  120149. */
  120150. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120151. }
  120152. }
  120153. declare module BABYLON {
  120154. /** @hidden */
  120155. export var layerPixelShader: {
  120156. name: string;
  120157. shader: string;
  120158. };
  120159. }
  120160. declare module BABYLON {
  120161. /** @hidden */
  120162. export var layerVertexShader: {
  120163. name: string;
  120164. shader: string;
  120165. };
  120166. }
  120167. declare module BABYLON {
  120168. /**
  120169. * This represents a full screen 2d layer.
  120170. * This can be useful to display a picture in the background of your scene for instance.
  120171. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120172. */
  120173. export class Layer {
  120174. /**
  120175. * Define the name of the layer.
  120176. */
  120177. name: string;
  120178. /**
  120179. * Define the texture the layer should display.
  120180. */
  120181. texture: Nullable<Texture>;
  120182. /**
  120183. * Is the layer in background or foreground.
  120184. */
  120185. isBackground: boolean;
  120186. /**
  120187. * Define the color of the layer (instead of texture).
  120188. */
  120189. color: Color4;
  120190. /**
  120191. * Define the scale of the layer in order to zoom in out of the texture.
  120192. */
  120193. scale: Vector2;
  120194. /**
  120195. * Define an offset for the layer in order to shift the texture.
  120196. */
  120197. offset: Vector2;
  120198. /**
  120199. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120200. */
  120201. alphaBlendingMode: number;
  120202. /**
  120203. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120204. * Alpha test will not mix with the background color in case of transparency.
  120205. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120206. */
  120207. alphaTest: boolean;
  120208. /**
  120209. * Define a mask to restrict the layer to only some of the scene cameras.
  120210. */
  120211. layerMask: number;
  120212. /**
  120213. * Define the list of render target the layer is visible into.
  120214. */
  120215. renderTargetTextures: RenderTargetTexture[];
  120216. /**
  120217. * Define if the layer is only used in renderTarget or if it also
  120218. * renders in the main frame buffer of the canvas.
  120219. */
  120220. renderOnlyInRenderTargetTextures: boolean;
  120221. private _scene;
  120222. private _vertexBuffers;
  120223. private _indexBuffer;
  120224. private _effect;
  120225. private _alphaTestEffect;
  120226. /**
  120227. * An event triggered when the layer is disposed.
  120228. */
  120229. onDisposeObservable: Observable<Layer>;
  120230. private _onDisposeObserver;
  120231. /**
  120232. * Back compatibility with callback before the onDisposeObservable existed.
  120233. * The set callback will be triggered when the layer has been disposed.
  120234. */
  120235. onDispose: () => void;
  120236. /**
  120237. * An event triggered before rendering the scene
  120238. */
  120239. onBeforeRenderObservable: Observable<Layer>;
  120240. private _onBeforeRenderObserver;
  120241. /**
  120242. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120243. * The set callback will be triggered just before rendering the layer.
  120244. */
  120245. onBeforeRender: () => void;
  120246. /**
  120247. * An event triggered after rendering the scene
  120248. */
  120249. onAfterRenderObservable: Observable<Layer>;
  120250. private _onAfterRenderObserver;
  120251. /**
  120252. * Back compatibility with callback before the onAfterRenderObservable existed.
  120253. * The set callback will be triggered just after rendering the layer.
  120254. */
  120255. onAfterRender: () => void;
  120256. /**
  120257. * Instantiates a new layer.
  120258. * This represents a full screen 2d layer.
  120259. * This can be useful to display a picture in the background of your scene for instance.
  120260. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120261. * @param name Define the name of the layer in the scene
  120262. * @param imgUrl Define the url of the texture to display in the layer
  120263. * @param scene Define the scene the layer belongs to
  120264. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120265. * @param color Defines a color for the layer
  120266. */
  120267. constructor(
  120268. /**
  120269. * Define the name of the layer.
  120270. */
  120271. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120272. private _createIndexBuffer;
  120273. /** @hidden */
  120274. _rebuild(): void;
  120275. /**
  120276. * Renders the layer in the scene.
  120277. */
  120278. render(): void;
  120279. /**
  120280. * Disposes and releases the associated ressources.
  120281. */
  120282. dispose(): void;
  120283. }
  120284. }
  120285. declare module BABYLON {
  120286. /** @hidden */
  120287. export var lensFlarePixelShader: {
  120288. name: string;
  120289. shader: string;
  120290. };
  120291. }
  120292. declare module BABYLON {
  120293. /** @hidden */
  120294. export var lensFlareVertexShader: {
  120295. name: string;
  120296. shader: string;
  120297. };
  120298. }
  120299. declare module BABYLON {
  120300. /**
  120301. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120302. * It is usually composed of several `lensFlare`.
  120303. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120304. */
  120305. export class LensFlareSystem {
  120306. /**
  120307. * Define the name of the lens flare system
  120308. */
  120309. name: string;
  120310. /**
  120311. * List of lens flares used in this system.
  120312. */
  120313. lensFlares: LensFlare[];
  120314. /**
  120315. * Define a limit from the border the lens flare can be visible.
  120316. */
  120317. borderLimit: number;
  120318. /**
  120319. * Define a viewport border we do not want to see the lens flare in.
  120320. */
  120321. viewportBorder: number;
  120322. /**
  120323. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120324. */
  120325. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120326. /**
  120327. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120328. */
  120329. layerMask: number;
  120330. /**
  120331. * Define the id of the lens flare system in the scene.
  120332. * (equal to name by default)
  120333. */
  120334. id: string;
  120335. private _scene;
  120336. private _emitter;
  120337. private _vertexBuffers;
  120338. private _indexBuffer;
  120339. private _effect;
  120340. private _positionX;
  120341. private _positionY;
  120342. private _isEnabled;
  120343. /** @hidden */
  120344. static _SceneComponentInitialization: (scene: Scene) => void;
  120345. /**
  120346. * Instantiates a lens flare system.
  120347. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120348. * It is usually composed of several `lensFlare`.
  120349. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120350. * @param name Define the name of the lens flare system in the scene
  120351. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120352. * @param scene Define the scene the lens flare system belongs to
  120353. */
  120354. constructor(
  120355. /**
  120356. * Define the name of the lens flare system
  120357. */
  120358. name: string, emitter: any, scene: Scene);
  120359. /**
  120360. * Define if the lens flare system is enabled.
  120361. */
  120362. isEnabled: boolean;
  120363. /**
  120364. * Get the scene the effects belongs to.
  120365. * @returns the scene holding the lens flare system
  120366. */
  120367. getScene(): Scene;
  120368. /**
  120369. * Get the emitter of the lens flare system.
  120370. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120371. * @returns the emitter of the lens flare system
  120372. */
  120373. getEmitter(): any;
  120374. /**
  120375. * Set the emitter of the lens flare system.
  120376. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120377. * @param newEmitter Define the new emitter of the system
  120378. */
  120379. setEmitter(newEmitter: any): void;
  120380. /**
  120381. * Get the lens flare system emitter position.
  120382. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120383. * @returns the position
  120384. */
  120385. getEmitterPosition(): Vector3;
  120386. /**
  120387. * @hidden
  120388. */
  120389. computeEffectivePosition(globalViewport: Viewport): boolean;
  120390. /** @hidden */
  120391. _isVisible(): boolean;
  120392. /**
  120393. * @hidden
  120394. */
  120395. render(): boolean;
  120396. /**
  120397. * Dispose and release the lens flare with its associated resources.
  120398. */
  120399. dispose(): void;
  120400. /**
  120401. * Parse a lens flare system from a JSON repressentation
  120402. * @param parsedLensFlareSystem Define the JSON to parse
  120403. * @param scene Define the scene the parsed system should be instantiated in
  120404. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  120405. * @returns the parsed system
  120406. */
  120407. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  120408. /**
  120409. * Serialize the current Lens Flare System into a JSON representation.
  120410. * @returns the serialized JSON
  120411. */
  120412. serialize(): any;
  120413. }
  120414. }
  120415. declare module BABYLON {
  120416. /**
  120417. * This represents one of the lens effect in a `lensFlareSystem`.
  120418. * It controls one of the indiviual texture used in the effect.
  120419. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120420. */
  120421. export class LensFlare {
  120422. /**
  120423. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120424. */
  120425. size: number;
  120426. /**
  120427. * 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.
  120428. */
  120429. position: number;
  120430. /**
  120431. * Define the lens color.
  120432. */
  120433. color: Color3;
  120434. /**
  120435. * Define the lens texture.
  120436. */
  120437. texture: Nullable<Texture>;
  120438. /**
  120439. * Define the alpha mode to render this particular lens.
  120440. */
  120441. alphaMode: number;
  120442. private _system;
  120443. /**
  120444. * Creates a new Lens Flare.
  120445. * This represents one of the lens effect in a `lensFlareSystem`.
  120446. * It controls one of the indiviual texture used in the effect.
  120447. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120448. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  120449. * @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.
  120450. * @param color Define the lens color
  120451. * @param imgUrl Define the lens texture url
  120452. * @param system Define the `lensFlareSystem` this flare is part of
  120453. * @returns The newly created Lens Flare
  120454. */
  120455. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  120456. /**
  120457. * Instantiates a new Lens Flare.
  120458. * This represents one of the lens effect in a `lensFlareSystem`.
  120459. * It controls one of the indiviual texture used in the effect.
  120460. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120461. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  120462. * @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.
  120463. * @param color Define the lens color
  120464. * @param imgUrl Define the lens texture url
  120465. * @param system Define the `lensFlareSystem` this flare is part of
  120466. */
  120467. constructor(
  120468. /**
  120469. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120470. */
  120471. size: number,
  120472. /**
  120473. * 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.
  120474. */
  120475. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  120476. /**
  120477. * Dispose and release the lens flare with its associated resources.
  120478. */
  120479. dispose(): void;
  120480. }
  120481. }
  120482. declare module BABYLON {
  120483. interface AbstractScene {
  120484. /**
  120485. * The list of lens flare system added to the scene
  120486. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120487. */
  120488. lensFlareSystems: Array<LensFlareSystem>;
  120489. /**
  120490. * Removes the given lens flare system from this scene.
  120491. * @param toRemove The lens flare system to remove
  120492. * @returns The index of the removed lens flare system
  120493. */
  120494. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120495. /**
  120496. * Adds the given lens flare system to this scene
  120497. * @param newLensFlareSystem The lens flare system to add
  120498. */
  120499. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120500. /**
  120501. * Gets a lens flare system using its name
  120502. * @param name defines the name to look for
  120503. * @returns the lens flare system or null if not found
  120504. */
  120505. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120506. /**
  120507. * Gets a lens flare system using its id
  120508. * @param id defines the id to look for
  120509. * @returns the lens flare system or null if not found
  120510. */
  120511. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120512. }
  120513. /**
  120514. * Defines the lens flare scene component responsible to manage any lens flares
  120515. * in a given scene.
  120516. */
  120517. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120518. /**
  120519. * The component name helpfull to identify the component in the list of scene components.
  120520. */
  120521. readonly name: string;
  120522. /**
  120523. * The scene the component belongs to.
  120524. */
  120525. scene: Scene;
  120526. /**
  120527. * Creates a new instance of the component for the given scene
  120528. * @param scene Defines the scene to register the component in
  120529. */
  120530. constructor(scene: Scene);
  120531. /**
  120532. * Registers the component in a given scene
  120533. */
  120534. register(): void;
  120535. /**
  120536. * Rebuilds the elements related to this component in case of
  120537. * context lost for instance.
  120538. */
  120539. rebuild(): void;
  120540. /**
  120541. * Adds all the elements from the container to the scene
  120542. * @param container the container holding the elements
  120543. */
  120544. addFromContainer(container: AbstractScene): void;
  120545. /**
  120546. * Removes all the elements in the container from the scene
  120547. * @param container contains the elements to remove
  120548. * @param dispose if the removed element should be disposed (default: false)
  120549. */
  120550. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120551. /**
  120552. * Serializes the component data to the specified json object
  120553. * @param serializationObject The object to serialize to
  120554. */
  120555. serialize(serializationObject: any): void;
  120556. /**
  120557. * Disposes the component and the associated ressources.
  120558. */
  120559. dispose(): void;
  120560. private _draw;
  120561. }
  120562. }
  120563. declare module BABYLON {
  120564. /**
  120565. * Defines the shadow generator component responsible to manage any shadow generators
  120566. * in a given scene.
  120567. */
  120568. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120569. /**
  120570. * The component name helpfull to identify the component in the list of scene components.
  120571. */
  120572. readonly name: string;
  120573. /**
  120574. * The scene the component belongs to.
  120575. */
  120576. scene: Scene;
  120577. /**
  120578. * Creates a new instance of the component for the given scene
  120579. * @param scene Defines the scene to register the component in
  120580. */
  120581. constructor(scene: Scene);
  120582. /**
  120583. * Registers the component in a given scene
  120584. */
  120585. register(): void;
  120586. /**
  120587. * Rebuilds the elements related to this component in case of
  120588. * context lost for instance.
  120589. */
  120590. rebuild(): void;
  120591. /**
  120592. * Serializes the component data to the specified json object
  120593. * @param serializationObject The object to serialize to
  120594. */
  120595. serialize(serializationObject: any): void;
  120596. /**
  120597. * Adds all the elements from the container to the scene
  120598. * @param container the container holding the elements
  120599. */
  120600. addFromContainer(container: AbstractScene): void;
  120601. /**
  120602. * Removes all the elements in the container from the scene
  120603. * @param container contains the elements to remove
  120604. * @param dispose if the removed element should be disposed (default: false)
  120605. */
  120606. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120607. /**
  120608. * Rebuilds the elements related to this component in case of
  120609. * context lost for instance.
  120610. */
  120611. dispose(): void;
  120612. private _gatherRenderTargets;
  120613. }
  120614. }
  120615. declare module BABYLON {
  120616. /**
  120617. * A point light is a light defined by an unique point in world space.
  120618. * The light is emitted in every direction from this point.
  120619. * A good example of a point light is a standard light bulb.
  120620. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120621. */
  120622. export class PointLight extends ShadowLight {
  120623. private _shadowAngle;
  120624. /**
  120625. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120626. * This specifies what angle the shadow will use to be created.
  120627. *
  120628. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120629. */
  120630. /**
  120631. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120632. * This specifies what angle the shadow will use to be created.
  120633. *
  120634. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120635. */
  120636. shadowAngle: number;
  120637. /**
  120638. * Gets the direction if it has been set.
  120639. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120640. */
  120641. /**
  120642. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120643. */
  120644. direction: Vector3;
  120645. /**
  120646. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  120647. * A PointLight emits the light in every direction.
  120648. * It can cast shadows.
  120649. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  120650. * ```javascript
  120651. * var pointLight = new PointLight("pl", camera.position, scene);
  120652. * ```
  120653. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120654. * @param name The light friendly name
  120655. * @param position The position of the point light in the scene
  120656. * @param scene The scene the lights belongs to
  120657. */
  120658. constructor(name: string, position: Vector3, scene: Scene);
  120659. /**
  120660. * Returns the string "PointLight"
  120661. * @returns the class name
  120662. */
  120663. getClassName(): string;
  120664. /**
  120665. * Returns the integer 0.
  120666. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120667. */
  120668. getTypeID(): number;
  120669. /**
  120670. * Specifies wether or not the shadowmap should be a cube texture.
  120671. * @returns true if the shadowmap needs to be a cube texture.
  120672. */
  120673. needCube(): boolean;
  120674. /**
  120675. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120676. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120677. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120678. */
  120679. getShadowDirection(faceIndex?: number): Vector3;
  120680. /**
  120681. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120682. * - fov = PI / 2
  120683. * - aspect ratio : 1.0
  120684. * - z-near and far equal to the active camera minZ and maxZ.
  120685. * Returns the PointLight.
  120686. */
  120687. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120688. protected _buildUniformLayout(): void;
  120689. /**
  120690. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120691. * @param effect The effect to update
  120692. * @param lightIndex The index of the light in the effect to update
  120693. * @returns The point light
  120694. */
  120695. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120696. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120697. /**
  120698. * Prepares the list of defines specific to the light type.
  120699. * @param defines the list of defines
  120700. * @param lightIndex defines the index of the light for the effect
  120701. */
  120702. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120703. }
  120704. }
  120705. declare module BABYLON {
  120706. /**
  120707. * Header information of HDR texture files.
  120708. */
  120709. export interface HDRInfo {
  120710. /**
  120711. * The height of the texture in pixels.
  120712. */
  120713. height: number;
  120714. /**
  120715. * The width of the texture in pixels.
  120716. */
  120717. width: number;
  120718. /**
  120719. * The index of the beginning of the data in the binary file.
  120720. */
  120721. dataPosition: number;
  120722. }
  120723. /**
  120724. * This groups tools to convert HDR texture to native colors array.
  120725. */
  120726. export class HDRTools {
  120727. private static Ldexp;
  120728. private static Rgbe2float;
  120729. private static readStringLine;
  120730. /**
  120731. * Reads header information from an RGBE texture stored in a native array.
  120732. * More information on this format are available here:
  120733. * https://en.wikipedia.org/wiki/RGBE_image_format
  120734. *
  120735. * @param uint8array The binary file stored in native array.
  120736. * @return The header information.
  120737. */
  120738. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120739. /**
  120740. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120741. * This RGBE texture needs to store the information as a panorama.
  120742. *
  120743. * More information on this format are available here:
  120744. * https://en.wikipedia.org/wiki/RGBE_image_format
  120745. *
  120746. * @param buffer The binary file stored in an array buffer.
  120747. * @param size The expected size of the extracted cubemap.
  120748. * @return The Cube Map information.
  120749. */
  120750. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120751. /**
  120752. * Returns the pixels data extracted from an RGBE texture.
  120753. * This pixels will be stored left to right up to down in the R G B order in one array.
  120754. *
  120755. * More information on this format are available here:
  120756. * https://en.wikipedia.org/wiki/RGBE_image_format
  120757. *
  120758. * @param uint8array The binary file stored in an array buffer.
  120759. * @param hdrInfo The header information of the file.
  120760. * @return The pixels data in RGB right to left up to down order.
  120761. */
  120762. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120763. private static RGBE_ReadPixels_RLE;
  120764. }
  120765. }
  120766. declare module BABYLON {
  120767. /**
  120768. * This represents a texture coming from an HDR input.
  120769. *
  120770. * The only supported format is currently panorama picture stored in RGBE format.
  120771. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120772. */
  120773. export class HDRCubeTexture extends BaseTexture {
  120774. private static _facesMapping;
  120775. private _generateHarmonics;
  120776. private _noMipmap;
  120777. private _textureMatrix;
  120778. private _size;
  120779. private _onLoad;
  120780. private _onError;
  120781. /**
  120782. * The texture URL.
  120783. */
  120784. url: string;
  120785. /**
  120786. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120787. */
  120788. coordinatesMode: number;
  120789. protected _isBlocking: boolean;
  120790. /**
  120791. * Sets wether or not the texture is blocking during loading.
  120792. */
  120793. /**
  120794. * Gets wether or not the texture is blocking during loading.
  120795. */
  120796. isBlocking: boolean;
  120797. protected _rotationY: number;
  120798. /**
  120799. * Sets texture matrix rotation angle around Y axis in radians.
  120800. */
  120801. /**
  120802. * Gets texture matrix rotation angle around Y axis radians.
  120803. */
  120804. rotationY: number;
  120805. /**
  120806. * Gets or sets the center of the bounding box associated with the cube texture
  120807. * It must define where the camera used to render the texture was set
  120808. */
  120809. boundingBoxPosition: Vector3;
  120810. private _boundingBoxSize;
  120811. /**
  120812. * Gets or sets the size of the bounding box associated with the cube texture
  120813. * When defined, the cubemap will switch to local mode
  120814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120815. * @example https://www.babylonjs-playground.com/#RNASML
  120816. */
  120817. boundingBoxSize: Vector3;
  120818. /**
  120819. * Instantiates an HDRTexture from the following parameters.
  120820. *
  120821. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120822. * @param scene The scene the texture will be used in
  120823. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120824. * @param noMipmap Forces to not generate the mipmap if true
  120825. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120826. * @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)
  120827. * @param reserved Reserved flag for internal use.
  120828. */
  120829. 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>);
  120830. /**
  120831. * Get the current class name of the texture useful for serialization or dynamic coding.
  120832. * @returns "HDRCubeTexture"
  120833. */
  120834. getClassName(): string;
  120835. /**
  120836. * Occurs when the file is raw .hdr file.
  120837. */
  120838. private loadTexture;
  120839. clone(): HDRCubeTexture;
  120840. delayLoad(): void;
  120841. /**
  120842. * Get the texture reflection matrix used to rotate/transform the reflection.
  120843. * @returns the reflection matrix
  120844. */
  120845. getReflectionTextureMatrix(): Matrix;
  120846. /**
  120847. * Set the texture reflection matrix used to rotate/transform the reflection.
  120848. * @param value Define the reflection matrix to set
  120849. */
  120850. setReflectionTextureMatrix(value: Matrix): void;
  120851. /**
  120852. * Parses a JSON representation of an HDR Texture in order to create the texture
  120853. * @param parsedTexture Define the JSON representation
  120854. * @param scene Define the scene the texture should be created in
  120855. * @param rootUrl Define the root url in case we need to load relative dependencies
  120856. * @returns the newly created texture after parsing
  120857. */
  120858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120859. serialize(): any;
  120860. }
  120861. }
  120862. declare module BABYLON {
  120863. /**
  120864. * Class used to control physics engine
  120865. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120866. */
  120867. export class PhysicsEngine implements IPhysicsEngine {
  120868. private _physicsPlugin;
  120869. /**
  120870. * Global value used to control the smallest number supported by the simulation
  120871. */
  120872. static Epsilon: number;
  120873. private _impostors;
  120874. private _joints;
  120875. private _subTimeStep;
  120876. /**
  120877. * Gets the gravity vector used by the simulation
  120878. */
  120879. gravity: Vector3;
  120880. /**
  120881. * Factory used to create the default physics plugin.
  120882. * @returns The default physics plugin
  120883. */
  120884. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120885. /**
  120886. * Creates a new Physics Engine
  120887. * @param gravity defines the gravity vector used by the simulation
  120888. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120889. */
  120890. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120891. /**
  120892. * Sets the gravity vector used by the simulation
  120893. * @param gravity defines the gravity vector to use
  120894. */
  120895. setGravity(gravity: Vector3): void;
  120896. /**
  120897. * Set the time step of the physics engine.
  120898. * Default is 1/60.
  120899. * To slow it down, enter 1/600 for example.
  120900. * To speed it up, 1/30
  120901. * @param newTimeStep defines the new timestep to apply to this world.
  120902. */
  120903. setTimeStep(newTimeStep?: number): void;
  120904. /**
  120905. * Get the time step of the physics engine.
  120906. * @returns the current time step
  120907. */
  120908. getTimeStep(): number;
  120909. /**
  120910. * Set the sub time step of the physics engine.
  120911. * Default is 0 meaning there is no sub steps
  120912. * To increase physics resolution precision, set a small value (like 1 ms)
  120913. * @param subTimeStep defines the new sub timestep used for physics resolution.
  120914. */
  120915. setSubTimeStep(subTimeStep?: number): void;
  120916. /**
  120917. * Get the sub time step of the physics engine.
  120918. * @returns the current sub time step
  120919. */
  120920. getSubTimeStep(): number;
  120921. /**
  120922. * Release all resources
  120923. */
  120924. dispose(): void;
  120925. /**
  120926. * Gets the name of the current physics plugin
  120927. * @returns the name of the plugin
  120928. */
  120929. getPhysicsPluginName(): string;
  120930. /**
  120931. * Adding a new impostor for the impostor tracking.
  120932. * This will be done by the impostor itself.
  120933. * @param impostor the impostor to add
  120934. */
  120935. addImpostor(impostor: PhysicsImpostor): void;
  120936. /**
  120937. * Remove an impostor from the engine.
  120938. * This impostor and its mesh will not longer be updated by the physics engine.
  120939. * @param impostor the impostor to remove
  120940. */
  120941. removeImpostor(impostor: PhysicsImpostor): void;
  120942. /**
  120943. * Add a joint to the physics engine
  120944. * @param mainImpostor defines the main impostor to which the joint is added.
  120945. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  120946. * @param joint defines the joint that will connect both impostors.
  120947. */
  120948. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120949. /**
  120950. * Removes a joint from the simulation
  120951. * @param mainImpostor defines the impostor used with the joint
  120952. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  120953. * @param joint defines the joint to remove
  120954. */
  120955. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120956. /**
  120957. * Called by the scene. No need to call it.
  120958. * @param delta defines the timespam between frames
  120959. */
  120960. _step(delta: number): void;
  120961. /**
  120962. * Gets the current plugin used to run the simulation
  120963. * @returns current plugin
  120964. */
  120965. getPhysicsPlugin(): IPhysicsEnginePlugin;
  120966. /**
  120967. * Gets the list of physic impostors
  120968. * @returns an array of PhysicsImpostor
  120969. */
  120970. getImpostors(): Array<PhysicsImpostor>;
  120971. /**
  120972. * Gets the impostor for a physics enabled object
  120973. * @param object defines the object impersonated by the impostor
  120974. * @returns the PhysicsImpostor or null if not found
  120975. */
  120976. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  120977. /**
  120978. * Gets the impostor for a physics body object
  120979. * @param body defines physics body used by the impostor
  120980. * @returns the PhysicsImpostor or null if not found
  120981. */
  120982. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  120983. /**
  120984. * Does a raycast in the physics world
  120985. * @param from when should the ray start?
  120986. * @param to when should the ray end?
  120987. * @returns PhysicsRaycastResult
  120988. */
  120989. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120990. }
  120991. }
  120992. declare module BABYLON {
  120993. /** @hidden */
  120994. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120995. private _useDeltaForWorldStep;
  120996. world: any;
  120997. name: string;
  120998. private _physicsMaterials;
  120999. private _fixedTimeStep;
  121000. private _cannonRaycastResult;
  121001. private _raycastResult;
  121002. private _physicsBodysToRemoveAfterStep;
  121003. BJSCANNON: any;
  121004. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  121005. setGravity(gravity: Vector3): void;
  121006. setTimeStep(timeStep: number): void;
  121007. getTimeStep(): number;
  121008. executeStep(delta: number): void;
  121009. private _removeMarkedPhysicsBodiesFromWorld;
  121010. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121011. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121012. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121013. private _processChildMeshes;
  121014. removePhysicsBody(impostor: PhysicsImpostor): void;
  121015. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121016. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121017. private _addMaterial;
  121018. private _checkWithEpsilon;
  121019. private _createShape;
  121020. private _createHeightmap;
  121021. private _minus90X;
  121022. private _plus90X;
  121023. private _tmpPosition;
  121024. private _tmpDeltaPosition;
  121025. private _tmpUnityRotation;
  121026. private _updatePhysicsBodyTransformation;
  121027. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121028. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121029. isSupported(): boolean;
  121030. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121031. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121032. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121033. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121034. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121035. getBodyMass(impostor: PhysicsImpostor): number;
  121036. getBodyFriction(impostor: PhysicsImpostor): number;
  121037. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121038. getBodyRestitution(impostor: PhysicsImpostor): number;
  121039. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121040. sleepBody(impostor: PhysicsImpostor): void;
  121041. wakeUpBody(impostor: PhysicsImpostor): void;
  121042. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121043. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121044. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121045. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121046. getRadius(impostor: PhysicsImpostor): number;
  121047. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121048. dispose(): void;
  121049. private _extendNamespace;
  121050. /**
  121051. * Does a raycast in the physics world
  121052. * @param from when should the ray start?
  121053. * @param to when should the ray end?
  121054. * @returns PhysicsRaycastResult
  121055. */
  121056. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121057. }
  121058. }
  121059. declare module BABYLON {
  121060. /** @hidden */
  121061. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121062. world: any;
  121063. name: string;
  121064. BJSOIMO: any;
  121065. private _raycastResult;
  121066. constructor(iterations?: number, oimoInjection?: any);
  121067. setGravity(gravity: Vector3): void;
  121068. setTimeStep(timeStep: number): void;
  121069. getTimeStep(): number;
  121070. private _tmpImpostorsArray;
  121071. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121072. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121073. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121074. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121075. private _tmpPositionVector;
  121076. removePhysicsBody(impostor: PhysicsImpostor): void;
  121077. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121078. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121079. isSupported(): boolean;
  121080. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121081. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121082. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121083. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121084. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121085. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121086. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121087. getBodyMass(impostor: PhysicsImpostor): number;
  121088. getBodyFriction(impostor: PhysicsImpostor): number;
  121089. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121090. getBodyRestitution(impostor: PhysicsImpostor): number;
  121091. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121092. sleepBody(impostor: PhysicsImpostor): void;
  121093. wakeUpBody(impostor: PhysicsImpostor): void;
  121094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121095. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121096. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121098. getRadius(impostor: PhysicsImpostor): number;
  121099. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121100. dispose(): void;
  121101. /**
  121102. * Does a raycast in the physics world
  121103. * @param from when should the ray start?
  121104. * @param to when should the ray end?
  121105. * @returns PhysicsRaycastResult
  121106. */
  121107. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121108. }
  121109. }
  121110. declare module BABYLON {
  121111. /**
  121112. * Class containing static functions to help procedurally build meshes
  121113. */
  121114. export class RibbonBuilder {
  121115. /**
  121116. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121117. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121118. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121119. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121120. * * 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
  121121. * * 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
  121122. * * 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
  121123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121126. * * 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
  121127. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121128. * * 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
  121129. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121131. * @param name defines the name of the mesh
  121132. * @param options defines the options used to create the mesh
  121133. * @param scene defines the hosting scene
  121134. * @returns the ribbon mesh
  121135. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121137. */
  121138. static CreateRibbon(name: string, options: {
  121139. pathArray: Vector3[][];
  121140. closeArray?: boolean;
  121141. closePath?: boolean;
  121142. offset?: number;
  121143. updatable?: boolean;
  121144. sideOrientation?: number;
  121145. frontUVs?: Vector4;
  121146. backUVs?: Vector4;
  121147. instance?: Mesh;
  121148. invertUV?: boolean;
  121149. uvs?: Vector2[];
  121150. colors?: Color4[];
  121151. }, scene?: Nullable<Scene>): Mesh;
  121152. }
  121153. }
  121154. declare module BABYLON {
  121155. /**
  121156. * Class containing static functions to help procedurally build meshes
  121157. */
  121158. export class ShapeBuilder {
  121159. /**
  121160. * 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.
  121161. * * 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.
  121162. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121163. * * 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.
  121164. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121165. * * 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
  121166. * * 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
  121167. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121172. * @param name defines the name of the mesh
  121173. * @param options defines the options used to create the mesh
  121174. * @param scene defines the hosting scene
  121175. * @returns the extruded shape mesh
  121176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121178. */
  121179. static ExtrudeShape(name: string, options: {
  121180. shape: Vector3[];
  121181. path: Vector3[];
  121182. scale?: number;
  121183. rotation?: number;
  121184. cap?: number;
  121185. updatable?: boolean;
  121186. sideOrientation?: number;
  121187. frontUVs?: Vector4;
  121188. backUVs?: Vector4;
  121189. instance?: Mesh;
  121190. invertUV?: boolean;
  121191. }, scene?: Nullable<Scene>): Mesh;
  121192. /**
  121193. * Creates an custom extruded shape mesh.
  121194. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121195. * * 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.
  121196. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121197. * * 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
  121198. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121199. * * 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
  121200. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121201. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121202. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121203. * * 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
  121204. * * 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
  121205. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121207. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121208. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121210. * @param name defines the name of the mesh
  121211. * @param options defines the options used to create the mesh
  121212. * @param scene defines the hosting scene
  121213. * @returns the custom extruded shape mesh
  121214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121217. */
  121218. static ExtrudeShapeCustom(name: string, options: {
  121219. shape: Vector3[];
  121220. path: Vector3[];
  121221. scaleFunction?: any;
  121222. rotationFunction?: any;
  121223. ribbonCloseArray?: boolean;
  121224. ribbonClosePath?: boolean;
  121225. cap?: number;
  121226. updatable?: boolean;
  121227. sideOrientation?: number;
  121228. frontUVs?: Vector4;
  121229. backUVs?: Vector4;
  121230. instance?: Mesh;
  121231. invertUV?: boolean;
  121232. }, scene?: Nullable<Scene>): Mesh;
  121233. private static _ExtrudeShapeGeneric;
  121234. }
  121235. }
  121236. declare module BABYLON {
  121237. /**
  121238. * AmmoJS Physics plugin
  121239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121240. * @see https://github.com/kripken/ammo.js/
  121241. */
  121242. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121243. private _useDeltaForWorldStep;
  121244. /**
  121245. * Reference to the Ammo library
  121246. */
  121247. bjsAMMO: any;
  121248. /**
  121249. * Created ammoJS world which physics bodies are added to
  121250. */
  121251. world: any;
  121252. /**
  121253. * Name of the plugin
  121254. */
  121255. name: string;
  121256. private _timeStep;
  121257. private _fixedTimeStep;
  121258. private _maxSteps;
  121259. private _tmpQuaternion;
  121260. private _tmpAmmoTransform;
  121261. private _tmpAmmoQuaternion;
  121262. private _tmpAmmoConcreteContactResultCallback;
  121263. private _collisionConfiguration;
  121264. private _dispatcher;
  121265. private _overlappingPairCache;
  121266. private _solver;
  121267. private _softBodySolver;
  121268. private _tmpAmmoVectorA;
  121269. private _tmpAmmoVectorB;
  121270. private _tmpAmmoVectorC;
  121271. private _tmpAmmoVectorD;
  121272. private _tmpContactCallbackResult;
  121273. private _tmpAmmoVectorRCA;
  121274. private _tmpAmmoVectorRCB;
  121275. private _raycastResult;
  121276. private static readonly DISABLE_COLLISION_FLAG;
  121277. private static readonly KINEMATIC_FLAG;
  121278. private static readonly DISABLE_DEACTIVATION_FLAG;
  121279. /**
  121280. * Initializes the ammoJS plugin
  121281. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121282. * @param ammoInjection can be used to inject your own ammo reference
  121283. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121284. */
  121285. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121286. /**
  121287. * Sets the gravity of the physics world (m/(s^2))
  121288. * @param gravity Gravity to set
  121289. */
  121290. setGravity(gravity: Vector3): void;
  121291. /**
  121292. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121293. * @param timeStep timestep to use in seconds
  121294. */
  121295. setTimeStep(timeStep: number): void;
  121296. /**
  121297. * 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)
  121298. * @param fixedTimeStep fixedTimeStep to use in seconds
  121299. */
  121300. setFixedTimeStep(fixedTimeStep: number): void;
  121301. /**
  121302. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121303. * @param maxSteps the maximum number of steps by the physics engine per frame
  121304. */
  121305. setMaxSteps(maxSteps: number): void;
  121306. /**
  121307. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121308. * @returns the current timestep in seconds
  121309. */
  121310. getTimeStep(): number;
  121311. /**
  121312. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121313. */
  121314. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121315. private _isImpostorInContact;
  121316. private _isImpostorPairInContact;
  121317. private _stepSimulation;
  121318. /**
  121319. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121320. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121321. * After the step the babylon meshes are set to the position of the physics imposters
  121322. * @param delta amount of time to step forward
  121323. * @param impostors array of imposters to update before/after the step
  121324. */
  121325. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121326. /**
  121327. * Update babylon mesh to match physics world object
  121328. * @param impostor imposter to match
  121329. */
  121330. private _afterSoftStep;
  121331. /**
  121332. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121333. * @param impostor imposter to match
  121334. */
  121335. private _ropeStep;
  121336. /**
  121337. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121338. * @param impostor imposter to match
  121339. */
  121340. private _softbodyOrClothStep;
  121341. private _tmpVector;
  121342. private _tmpMatrix;
  121343. /**
  121344. * Applies an impulse on the imposter
  121345. * @param impostor imposter to apply impulse to
  121346. * @param force amount of force to be applied to the imposter
  121347. * @param contactPoint the location to apply the impulse on the imposter
  121348. */
  121349. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121350. /**
  121351. * Applies a force on the imposter
  121352. * @param impostor imposter to apply force
  121353. * @param force amount of force to be applied to the imposter
  121354. * @param contactPoint the location to apply the force on the imposter
  121355. */
  121356. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121357. /**
  121358. * Creates a physics body using the plugin
  121359. * @param impostor the imposter to create the physics body on
  121360. */
  121361. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121362. /**
  121363. * Removes the physics body from the imposter and disposes of the body's memory
  121364. * @param impostor imposter to remove the physics body from
  121365. */
  121366. removePhysicsBody(impostor: PhysicsImpostor): void;
  121367. /**
  121368. * Generates a joint
  121369. * @param impostorJoint the imposter joint to create the joint with
  121370. */
  121371. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121372. /**
  121373. * Removes a joint
  121374. * @param impostorJoint the imposter joint to remove the joint from
  121375. */
  121376. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121377. private _addMeshVerts;
  121378. /**
  121379. * Initialise the soft body vertices to match its object's (mesh) vertices
  121380. * Softbody vertices (nodes) are in world space and to match this
  121381. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121382. * @param impostor to create the softbody for
  121383. */
  121384. private _softVertexData;
  121385. /**
  121386. * Create an impostor's soft body
  121387. * @param impostor to create the softbody for
  121388. */
  121389. private _createSoftbody;
  121390. /**
  121391. * Create cloth for an impostor
  121392. * @param impostor to create the softbody for
  121393. */
  121394. private _createCloth;
  121395. /**
  121396. * Create rope for an impostor
  121397. * @param impostor to create the softbody for
  121398. */
  121399. private _createRope;
  121400. /**
  121401. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  121402. * @param impostor to create the custom physics shape for
  121403. */
  121404. private _createCustom;
  121405. private _addHullVerts;
  121406. private _createShape;
  121407. /**
  121408. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  121409. * @param impostor imposter containing the physics body and babylon object
  121410. */
  121411. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121412. /**
  121413. * Sets the babylon object's position/rotation from the physics body's position/rotation
  121414. * @param impostor imposter containing the physics body and babylon object
  121415. * @param newPosition new position
  121416. * @param newRotation new rotation
  121417. */
  121418. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121419. /**
  121420. * If this plugin is supported
  121421. * @returns true if its supported
  121422. */
  121423. isSupported(): boolean;
  121424. /**
  121425. * Sets the linear velocity of the physics body
  121426. * @param impostor imposter to set the velocity on
  121427. * @param velocity velocity to set
  121428. */
  121429. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121430. /**
  121431. * Sets the angular velocity of the physics body
  121432. * @param impostor imposter to set the velocity on
  121433. * @param velocity velocity to set
  121434. */
  121435. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121436. /**
  121437. * gets the linear velocity
  121438. * @param impostor imposter to get linear velocity from
  121439. * @returns linear velocity
  121440. */
  121441. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121442. /**
  121443. * gets the angular velocity
  121444. * @param impostor imposter to get angular velocity from
  121445. * @returns angular velocity
  121446. */
  121447. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121448. /**
  121449. * Sets the mass of physics body
  121450. * @param impostor imposter to set the mass on
  121451. * @param mass mass to set
  121452. */
  121453. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121454. /**
  121455. * Gets the mass of the physics body
  121456. * @param impostor imposter to get the mass from
  121457. * @returns mass
  121458. */
  121459. getBodyMass(impostor: PhysicsImpostor): number;
  121460. /**
  121461. * Gets friction of the impostor
  121462. * @param impostor impostor to get friction from
  121463. * @returns friction value
  121464. */
  121465. getBodyFriction(impostor: PhysicsImpostor): number;
  121466. /**
  121467. * Sets friction of the impostor
  121468. * @param impostor impostor to set friction on
  121469. * @param friction friction value
  121470. */
  121471. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121472. /**
  121473. * Gets restitution of the impostor
  121474. * @param impostor impostor to get restitution from
  121475. * @returns restitution value
  121476. */
  121477. getBodyRestitution(impostor: PhysicsImpostor): number;
  121478. /**
  121479. * Sets resitution of the impostor
  121480. * @param impostor impostor to set resitution on
  121481. * @param restitution resitution value
  121482. */
  121483. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121484. /**
  121485. * Gets pressure inside the impostor
  121486. * @param impostor impostor to get pressure from
  121487. * @returns pressure value
  121488. */
  121489. getBodyPressure(impostor: PhysicsImpostor): number;
  121490. /**
  121491. * Sets pressure inside a soft body impostor
  121492. * Cloth and rope must remain 0 pressure
  121493. * @param impostor impostor to set pressure on
  121494. * @param pressure pressure value
  121495. */
  121496. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  121497. /**
  121498. * Gets stiffness of the impostor
  121499. * @param impostor impostor to get stiffness from
  121500. * @returns pressure value
  121501. */
  121502. getBodyStiffness(impostor: PhysicsImpostor): number;
  121503. /**
  121504. * Sets stiffness of the impostor
  121505. * @param impostor impostor to set stiffness on
  121506. * @param stiffness stiffness value from 0 to 1
  121507. */
  121508. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  121509. /**
  121510. * Gets velocityIterations of the impostor
  121511. * @param impostor impostor to get velocity iterations from
  121512. * @returns velocityIterations value
  121513. */
  121514. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121515. /**
  121516. * Sets velocityIterations of the impostor
  121517. * @param impostor impostor to set velocity iterations on
  121518. * @param velocityIterations velocityIterations value
  121519. */
  121520. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121521. /**
  121522. * Gets positionIterations of the impostor
  121523. * @param impostor impostor to get position iterations from
  121524. * @returns positionIterations value
  121525. */
  121526. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121527. /**
  121528. * Sets positionIterations of the impostor
  121529. * @param impostor impostor to set position on
  121530. * @param positionIterations positionIterations value
  121531. */
  121532. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121533. /**
  121534. * Append an anchor to a cloth object
  121535. * @param impostor is the cloth impostor to add anchor to
  121536. * @param otherImpostor is the rigid impostor to anchor to
  121537. * @param width ratio across width from 0 to 1
  121538. * @param height ratio up height from 0 to 1
  121539. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121540. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121541. */
  121542. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121543. /**
  121544. * Append an hook to a rope object
  121545. * @param impostor is the rope impostor to add hook to
  121546. * @param otherImpostor is the rigid impostor to hook to
  121547. * @param length ratio along the rope from 0 to 1
  121548. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121549. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121550. */
  121551. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121552. /**
  121553. * Sleeps the physics body and stops it from being active
  121554. * @param impostor impostor to sleep
  121555. */
  121556. sleepBody(impostor: PhysicsImpostor): void;
  121557. /**
  121558. * Activates the physics body
  121559. * @param impostor impostor to activate
  121560. */
  121561. wakeUpBody(impostor: PhysicsImpostor): void;
  121562. /**
  121563. * Updates the distance parameters of the joint
  121564. * @param joint joint to update
  121565. * @param maxDistance maximum distance of the joint
  121566. * @param minDistance minimum distance of the joint
  121567. */
  121568. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121569. /**
  121570. * Sets a motor on the joint
  121571. * @param joint joint to set motor on
  121572. * @param speed speed of the motor
  121573. * @param maxForce maximum force of the motor
  121574. * @param motorIndex index of the motor
  121575. */
  121576. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121577. /**
  121578. * Sets the motors limit
  121579. * @param joint joint to set limit on
  121580. * @param upperLimit upper limit
  121581. * @param lowerLimit lower limit
  121582. */
  121583. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121584. /**
  121585. * Syncs the position and rotation of a mesh with the impostor
  121586. * @param mesh mesh to sync
  121587. * @param impostor impostor to update the mesh with
  121588. */
  121589. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121590. /**
  121591. * Gets the radius of the impostor
  121592. * @param impostor impostor to get radius from
  121593. * @returns the radius
  121594. */
  121595. getRadius(impostor: PhysicsImpostor): number;
  121596. /**
  121597. * Gets the box size of the impostor
  121598. * @param impostor impostor to get box size from
  121599. * @param result the resulting box size
  121600. */
  121601. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121602. /**
  121603. * Disposes of the impostor
  121604. */
  121605. dispose(): void;
  121606. /**
  121607. * Does a raycast in the physics world
  121608. * @param from when should the ray start?
  121609. * @param to when should the ray end?
  121610. * @returns PhysicsRaycastResult
  121611. */
  121612. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121613. }
  121614. }
  121615. declare module BABYLON {
  121616. interface AbstractScene {
  121617. /**
  121618. * The list of reflection probes added to the scene
  121619. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121620. */
  121621. reflectionProbes: Array<ReflectionProbe>;
  121622. /**
  121623. * Removes the given reflection probe from this scene.
  121624. * @param toRemove The reflection probe to remove
  121625. * @returns The index of the removed reflection probe
  121626. */
  121627. removeReflectionProbe(toRemove: ReflectionProbe): number;
  121628. /**
  121629. * Adds the given reflection probe to this scene.
  121630. * @param newReflectionProbe The reflection probe to add
  121631. */
  121632. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  121633. }
  121634. /**
  121635. * Class used to generate realtime reflection / refraction cube textures
  121636. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121637. */
  121638. export class ReflectionProbe {
  121639. /** defines the name of the probe */
  121640. name: string;
  121641. private _scene;
  121642. private _renderTargetTexture;
  121643. private _projectionMatrix;
  121644. private _viewMatrix;
  121645. private _target;
  121646. private _add;
  121647. private _attachedMesh;
  121648. private _invertYAxis;
  121649. /** Gets or sets probe position (center of the cube map) */
  121650. position: Vector3;
  121651. /**
  121652. * Creates a new reflection probe
  121653. * @param name defines the name of the probe
  121654. * @param size defines the texture resolution (for each face)
  121655. * @param scene defines the hosting scene
  121656. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121657. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121658. */
  121659. constructor(
  121660. /** defines the name of the probe */
  121661. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  121662. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121663. samples: number;
  121664. /** Gets or sets the refresh rate to use (on every frame by default) */
  121665. refreshRate: number;
  121666. /**
  121667. * Gets the hosting scene
  121668. * @returns a Scene
  121669. */
  121670. getScene(): Scene;
  121671. /** Gets the internal CubeTexture used to render to */
  121672. readonly cubeTexture: RenderTargetTexture;
  121673. /** Gets the list of meshes to render */
  121674. readonly renderList: Nullable<AbstractMesh[]>;
  121675. /**
  121676. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121677. * @param mesh defines the mesh to attach to
  121678. */
  121679. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121680. /**
  121681. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121682. * @param renderingGroupId The rendering group id corresponding to its index
  121683. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121684. */
  121685. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  121686. /**
  121687. * Clean all associated resources
  121688. */
  121689. dispose(): void;
  121690. /**
  121691. * Converts the reflection probe information to a readable string for debug purpose.
  121692. * @param fullDetails Supports for multiple levels of logging within scene loading
  121693. * @returns the human readable reflection probe info
  121694. */
  121695. toString(fullDetails?: boolean): string;
  121696. /**
  121697. * Get the class name of the relfection probe.
  121698. * @returns "ReflectionProbe"
  121699. */
  121700. getClassName(): string;
  121701. /**
  121702. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121703. * @returns The JSON representation of the texture
  121704. */
  121705. serialize(): any;
  121706. /**
  121707. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121708. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121709. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121710. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121711. * @returns The parsed reflection probe if successful
  121712. */
  121713. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /** @hidden */
  121718. export var _BabylonLoaderRegistered: boolean;
  121719. /**
  121720. * Helps setting up some configuration for the babylon file loader.
  121721. */
  121722. export class BabylonFileLoaderConfiguration {
  121723. /**
  121724. * The loader does not allow injecting custom physix engine into the plugins.
  121725. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121726. * So you could set this variable to your engine import to make it work.
  121727. */
  121728. static LoaderInjectedPhysicsEngine: any;
  121729. }
  121730. }
  121731. declare module BABYLON {
  121732. /**
  121733. * The Physically based simple base material of BJS.
  121734. *
  121735. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121736. * It is used as the base class for both the specGloss and metalRough conventions.
  121737. */
  121738. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121739. /**
  121740. * Number of Simultaneous lights allowed on the material.
  121741. */
  121742. maxSimultaneousLights: number;
  121743. /**
  121744. * If sets to true, disables all the lights affecting the material.
  121745. */
  121746. disableLighting: boolean;
  121747. /**
  121748. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121749. */
  121750. environmentTexture: BaseTexture;
  121751. /**
  121752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121753. */
  121754. invertNormalMapX: boolean;
  121755. /**
  121756. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121757. */
  121758. invertNormalMapY: boolean;
  121759. /**
  121760. * Normal map used in the model.
  121761. */
  121762. normalTexture: BaseTexture;
  121763. /**
  121764. * Emissivie color used to self-illuminate the model.
  121765. */
  121766. emissiveColor: Color3;
  121767. /**
  121768. * Emissivie texture used to self-illuminate the model.
  121769. */
  121770. emissiveTexture: BaseTexture;
  121771. /**
  121772. * Occlusion Channel Strenght.
  121773. */
  121774. occlusionStrength: number;
  121775. /**
  121776. * Occlusion Texture of the material (adding extra occlusion effects).
  121777. */
  121778. occlusionTexture: BaseTexture;
  121779. /**
  121780. * Defines the alpha limits in alpha test mode.
  121781. */
  121782. alphaCutOff: number;
  121783. /**
  121784. * Gets the current double sided mode.
  121785. */
  121786. /**
  121787. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121788. */
  121789. doubleSided: boolean;
  121790. /**
  121791. * Stores the pre-calculated light information of a mesh in a texture.
  121792. */
  121793. lightmapTexture: BaseTexture;
  121794. /**
  121795. * If true, the light map contains occlusion information instead of lighting info.
  121796. */
  121797. useLightmapAsShadowmap: boolean;
  121798. /**
  121799. * Instantiates a new PBRMaterial instance.
  121800. *
  121801. * @param name The material name
  121802. * @param scene The scene the material will be use in.
  121803. */
  121804. constructor(name: string, scene: Scene);
  121805. getClassName(): string;
  121806. }
  121807. }
  121808. declare module BABYLON {
  121809. /**
  121810. * The PBR material of BJS following the metal roughness convention.
  121811. *
  121812. * This fits to the PBR convention in the GLTF definition:
  121813. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121814. */
  121815. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121816. /**
  121817. * The base color has two different interpretations depending on the value of metalness.
  121818. * When the material is a metal, the base color is the specific measured reflectance value
  121819. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121820. * of the material.
  121821. */
  121822. baseColor: Color3;
  121823. /**
  121824. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121825. * well as opacity information in the alpha channel.
  121826. */
  121827. baseTexture: BaseTexture;
  121828. /**
  121829. * Specifies the metallic scalar value of the material.
  121830. * Can also be used to scale the metalness values of the metallic texture.
  121831. */
  121832. metallic: number;
  121833. /**
  121834. * Specifies the roughness scalar value of the material.
  121835. * Can also be used to scale the roughness values of the metallic texture.
  121836. */
  121837. roughness: number;
  121838. /**
  121839. * Texture containing both the metallic value in the B channel and the
  121840. * roughness value in the G channel to keep better precision.
  121841. */
  121842. metallicRoughnessTexture: BaseTexture;
  121843. /**
  121844. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121845. *
  121846. * @param name The material name
  121847. * @param scene The scene the material will be use in.
  121848. */
  121849. constructor(name: string, scene: Scene);
  121850. /**
  121851. * Return the currrent class name of the material.
  121852. */
  121853. getClassName(): string;
  121854. /**
  121855. * Makes a duplicate of the current material.
  121856. * @param name - name to use for the new material.
  121857. */
  121858. clone(name: string): PBRMetallicRoughnessMaterial;
  121859. /**
  121860. * Serialize the material to a parsable JSON object.
  121861. */
  121862. serialize(): any;
  121863. /**
  121864. * Parses a JSON object correponding to the serialize function.
  121865. */
  121866. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121867. }
  121868. }
  121869. declare module BABYLON {
  121870. /**
  121871. * The PBR material of BJS following the specular glossiness convention.
  121872. *
  121873. * This fits to the PBR convention in the GLTF definition:
  121874. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121875. */
  121876. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121877. /**
  121878. * Specifies the diffuse color of the material.
  121879. */
  121880. diffuseColor: Color3;
  121881. /**
  121882. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121883. * channel.
  121884. */
  121885. diffuseTexture: BaseTexture;
  121886. /**
  121887. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121888. */
  121889. specularColor: Color3;
  121890. /**
  121891. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121892. */
  121893. glossiness: number;
  121894. /**
  121895. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121896. */
  121897. specularGlossinessTexture: BaseTexture;
  121898. /**
  121899. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121900. *
  121901. * @param name The material name
  121902. * @param scene The scene the material will be use in.
  121903. */
  121904. constructor(name: string, scene: Scene);
  121905. /**
  121906. * Return the currrent class name of the material.
  121907. */
  121908. getClassName(): string;
  121909. /**
  121910. * Makes a duplicate of the current material.
  121911. * @param name - name to use for the new material.
  121912. */
  121913. clone(name: string): PBRSpecularGlossinessMaterial;
  121914. /**
  121915. * Serialize the material to a parsable JSON object.
  121916. */
  121917. serialize(): any;
  121918. /**
  121919. * Parses a JSON object correponding to the serialize function.
  121920. */
  121921. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121922. }
  121923. }
  121924. declare module BABYLON {
  121925. /**
  121926. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121927. * It can help converting any input color in a desired output one. This can then be used to create effects
  121928. * from sepia, black and white to sixties or futuristic rendering...
  121929. *
  121930. * The only supported format is currently 3dl.
  121931. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121932. */
  121933. export class ColorGradingTexture extends BaseTexture {
  121934. /**
  121935. * The current texture matrix. (will always be identity in color grading texture)
  121936. */
  121937. private _textureMatrix;
  121938. /**
  121939. * The texture URL.
  121940. */
  121941. url: string;
  121942. /**
  121943. * Empty line regex stored for GC.
  121944. */
  121945. private static _noneEmptyLineRegex;
  121946. private _engine;
  121947. /**
  121948. * Instantiates a ColorGradingTexture from the following parameters.
  121949. *
  121950. * @param url The location of the color gradind data (currently only supporting 3dl)
  121951. * @param scene The scene the texture will be used in
  121952. */
  121953. constructor(url: string, scene: Scene);
  121954. /**
  121955. * Returns the texture matrix used in most of the material.
  121956. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  121957. */
  121958. getTextureMatrix(): Matrix;
  121959. /**
  121960. * Occurs when the file being loaded is a .3dl LUT file.
  121961. */
  121962. private load3dlTexture;
  121963. /**
  121964. * Starts the loading process of the texture.
  121965. */
  121966. private loadTexture;
  121967. /**
  121968. * Clones the color gradind texture.
  121969. */
  121970. clone(): ColorGradingTexture;
  121971. /**
  121972. * Called during delayed load for textures.
  121973. */
  121974. delayLoad(): void;
  121975. /**
  121976. * Parses a color grading texture serialized by Babylon.
  121977. * @param parsedTexture The texture information being parsedTexture
  121978. * @param scene The scene to load the texture in
  121979. * @param rootUrl The root url of the data assets to load
  121980. * @return A color gradind texture
  121981. */
  121982. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  121983. /**
  121984. * Serializes the LUT texture to json format.
  121985. */
  121986. serialize(): any;
  121987. }
  121988. }
  121989. declare module BABYLON {
  121990. /**
  121991. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  121992. */
  121993. export class EquiRectangularCubeTexture extends BaseTexture {
  121994. /** The six faces of the cube. */
  121995. private static _FacesMapping;
  121996. private _noMipmap;
  121997. private _onLoad;
  121998. private _onError;
  121999. /** The size of the cubemap. */
  122000. private _size;
  122001. /** The buffer of the image. */
  122002. private _buffer;
  122003. /** The width of the input image. */
  122004. private _width;
  122005. /** The height of the input image. */
  122006. private _height;
  122007. /** The URL to the image. */
  122008. url: string;
  122009. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  122010. coordinatesMode: number;
  122011. /**
  122012. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  122013. * @param url The location of the image
  122014. * @param scene The scene the texture will be used in
  122015. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122016. * @param noMipmap Forces to not generate the mipmap if true
  122017. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122018. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122019. * @param onLoad — defines a callback called when texture is loaded
  122020. * @param onError — defines a callback called if there is an error
  122021. */
  122022. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  122023. /**
  122024. * Load the image data, by putting the image on a canvas and extracting its buffer.
  122025. */
  122026. private loadImage;
  122027. /**
  122028. * Convert the image buffer into a cubemap and create a CubeTexture.
  122029. */
  122030. private loadTexture;
  122031. /**
  122032. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  122033. * @param buffer The ArrayBuffer that should be converted.
  122034. * @returns The buffer as Float32Array.
  122035. */
  122036. private getFloat32ArrayFromArrayBuffer;
  122037. /**
  122038. * Get the current class name of the texture useful for serialization or dynamic coding.
  122039. * @returns "EquiRectangularCubeTexture"
  122040. */
  122041. getClassName(): string;
  122042. /**
  122043. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122044. * @returns A clone of the current EquiRectangularCubeTexture.
  122045. */
  122046. clone(): EquiRectangularCubeTexture;
  122047. }
  122048. }
  122049. declare module BABYLON {
  122050. /**
  122051. * Based on jsTGALoader - Javascript loader for TGA file
  122052. * By Vincent Thibault
  122053. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122054. */
  122055. export class TGATools {
  122056. private static _TYPE_INDEXED;
  122057. private static _TYPE_RGB;
  122058. private static _TYPE_GREY;
  122059. private static _TYPE_RLE_INDEXED;
  122060. private static _TYPE_RLE_RGB;
  122061. private static _TYPE_RLE_GREY;
  122062. private static _ORIGIN_MASK;
  122063. private static _ORIGIN_SHIFT;
  122064. private static _ORIGIN_BL;
  122065. private static _ORIGIN_BR;
  122066. private static _ORIGIN_UL;
  122067. private static _ORIGIN_UR;
  122068. /**
  122069. * Gets the header of a TGA file
  122070. * @param data defines the TGA data
  122071. * @returns the header
  122072. */
  122073. static GetTGAHeader(data: Uint8Array): any;
  122074. /**
  122075. * Uploads TGA content to a Babylon Texture
  122076. * @hidden
  122077. */
  122078. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122079. /** @hidden */
  122080. 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;
  122081. /** @hidden */
  122082. 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;
  122083. /** @hidden */
  122084. 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;
  122085. /** @hidden */
  122086. 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;
  122087. /** @hidden */
  122088. 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;
  122089. /** @hidden */
  122090. 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;
  122091. }
  122092. }
  122093. declare module BABYLON {
  122094. /**
  122095. * Implementation of the TGA Texture Loader.
  122096. * @hidden
  122097. */
  122098. export class _TGATextureLoader implements IInternalTextureLoader {
  122099. /**
  122100. * Defines wether the loader supports cascade loading the different faces.
  122101. */
  122102. readonly supportCascades: boolean;
  122103. /**
  122104. * This returns if the loader support the current file information.
  122105. * @param extension defines the file extension of the file being loaded
  122106. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122107. * @param fallback defines the fallback internal texture if any
  122108. * @param isBase64 defines whether the texture is encoded as a base64
  122109. * @param isBuffer defines whether the texture data are stored as a buffer
  122110. * @returns true if the loader can load the specified file
  122111. */
  122112. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122113. /**
  122114. * Transform the url before loading if required.
  122115. * @param rootUrl the url of the texture
  122116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122117. * @returns the transformed texture
  122118. */
  122119. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122120. /**
  122121. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122122. * @param rootUrl the url of the texture
  122123. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122124. * @returns the fallback texture
  122125. */
  122126. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122127. /**
  122128. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122129. * @param data contains the texture data
  122130. * @param texture defines the BabylonJS internal texture
  122131. * @param createPolynomials will be true if polynomials have been requested
  122132. * @param onLoad defines the callback to trigger once the texture is ready
  122133. * @param onError defines the callback to trigger in case of error
  122134. */
  122135. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122136. /**
  122137. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122138. * @param data contains the texture data
  122139. * @param texture defines the BabylonJS internal texture
  122140. * @param callback defines the method to call once ready to upload
  122141. */
  122142. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122143. }
  122144. }
  122145. declare module BABYLON {
  122146. /**
  122147. * Info about the .basis files
  122148. */
  122149. class BasisFileInfo {
  122150. /**
  122151. * If the file has alpha
  122152. */
  122153. hasAlpha: boolean;
  122154. /**
  122155. * Info about each image of the basis file
  122156. */
  122157. images: Array<{
  122158. levels: Array<{
  122159. width: number;
  122160. height: number;
  122161. transcodedPixels: ArrayBufferView;
  122162. }>;
  122163. }>;
  122164. }
  122165. /**
  122166. * Result of transcoding a basis file
  122167. */
  122168. class TranscodeResult {
  122169. /**
  122170. * Info about the .basis file
  122171. */
  122172. fileInfo: BasisFileInfo;
  122173. /**
  122174. * Format to use when loading the file
  122175. */
  122176. format: number;
  122177. }
  122178. /**
  122179. * Configuration options for the Basis transcoder
  122180. */
  122181. export class BasisTranscodeConfiguration {
  122182. /**
  122183. * Supported compression formats used to determine the supported output format of the transcoder
  122184. */
  122185. supportedCompressionFormats?: {
  122186. /**
  122187. * etc1 compression format
  122188. */
  122189. etc1?: boolean;
  122190. /**
  122191. * s3tc compression format
  122192. */
  122193. s3tc?: boolean;
  122194. /**
  122195. * pvrtc compression format
  122196. */
  122197. pvrtc?: boolean;
  122198. /**
  122199. * etc2 compression format
  122200. */
  122201. etc2?: boolean;
  122202. };
  122203. /**
  122204. * If mipmap levels should be loaded for transcoded images (Default: true)
  122205. */
  122206. loadMipmapLevels?: boolean;
  122207. /**
  122208. * Index of a single image to load (Default: all images)
  122209. */
  122210. loadSingleImage?: number;
  122211. }
  122212. /**
  122213. * Used to load .Basis files
  122214. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122215. */
  122216. export class BasisTools {
  122217. private static _IgnoreSupportedFormats;
  122218. /**
  122219. * URL to use when loading the basis transcoder
  122220. */
  122221. static JSModuleURL: string;
  122222. /**
  122223. * URL to use when loading the wasm module for the transcoder
  122224. */
  122225. static WasmModuleURL: string;
  122226. /**
  122227. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122228. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122229. * @returns internal format corresponding to the Basis format
  122230. */
  122231. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122232. private static _WorkerPromise;
  122233. private static _Worker;
  122234. private static _actionId;
  122235. private static _CreateWorkerAsync;
  122236. /**
  122237. * Transcodes a loaded image file to compressed pixel data
  122238. * @param imageData image data to transcode
  122239. * @param config configuration options for the transcoding
  122240. * @returns a promise resulting in the transcoded image
  122241. */
  122242. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122243. /**
  122244. * Loads a texture from the transcode result
  122245. * @param texture texture load to
  122246. * @param transcodeResult the result of transcoding the basis file to load from
  122247. */
  122248. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122249. }
  122250. }
  122251. declare module BABYLON {
  122252. /**
  122253. * Loader for .basis file format
  122254. */
  122255. export class _BasisTextureLoader implements IInternalTextureLoader {
  122256. /**
  122257. * Defines whether the loader supports cascade loading the different faces.
  122258. */
  122259. readonly supportCascades: boolean;
  122260. /**
  122261. * This returns if the loader support the current file information.
  122262. * @param extension defines the file extension of the file being loaded
  122263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122264. * @param fallback defines the fallback internal texture if any
  122265. * @param isBase64 defines whether the texture is encoded as a base64
  122266. * @param isBuffer defines whether the texture data are stored as a buffer
  122267. * @returns true if the loader can load the specified file
  122268. */
  122269. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122270. /**
  122271. * Transform the url before loading if required.
  122272. * @param rootUrl the url of the texture
  122273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122274. * @returns the transformed texture
  122275. */
  122276. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122277. /**
  122278. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122279. * @param rootUrl the url of the texture
  122280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122281. * @returns the fallback texture
  122282. */
  122283. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122284. /**
  122285. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122286. * @param data contains the texture data
  122287. * @param texture defines the BabylonJS internal texture
  122288. * @param createPolynomials will be true if polynomials have been requested
  122289. * @param onLoad defines the callback to trigger once the texture is ready
  122290. * @param onError defines the callback to trigger in case of error
  122291. */
  122292. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122293. /**
  122294. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122295. * @param data contains the texture data
  122296. * @param texture defines the BabylonJS internal texture
  122297. * @param callback defines the method to call once ready to upload
  122298. */
  122299. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122300. }
  122301. }
  122302. declare module BABYLON {
  122303. /**
  122304. * 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.
  122305. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122306. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122307. */
  122308. export class CustomProceduralTexture extends ProceduralTexture {
  122309. private _animate;
  122310. private _time;
  122311. private _config;
  122312. private _texturePath;
  122313. /**
  122314. * Instantiates a new Custom Procedural Texture.
  122315. * 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.
  122316. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122317. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122318. * @param name Define the name of the texture
  122319. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122320. * @param size Define the size of the texture to create
  122321. * @param scene Define the scene the texture belongs to
  122322. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122323. * @param generateMipMaps Define if the texture should creates mip maps or not
  122324. */
  122325. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122326. private _loadJson;
  122327. /**
  122328. * Is the texture ready to be used ? (rendered at least once)
  122329. * @returns true if ready, otherwise, false.
  122330. */
  122331. isReady(): boolean;
  122332. /**
  122333. * Render the texture to its associated render target.
  122334. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122335. */
  122336. render(useCameraPostProcess?: boolean): void;
  122337. /**
  122338. * Update the list of dependant textures samplers in the shader.
  122339. */
  122340. updateTextures(): void;
  122341. /**
  122342. * Update the uniform values of the procedural texture in the shader.
  122343. */
  122344. updateShaderUniforms(): void;
  122345. /**
  122346. * Define if the texture animates or not.
  122347. */
  122348. animate: boolean;
  122349. }
  122350. }
  122351. declare module BABYLON {
  122352. /** @hidden */
  122353. export var noisePixelShader: {
  122354. name: string;
  122355. shader: string;
  122356. };
  122357. }
  122358. declare module BABYLON {
  122359. /**
  122360. * Class used to generate noise procedural textures
  122361. */
  122362. export class NoiseProceduralTexture extends ProceduralTexture {
  122363. private _time;
  122364. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122365. brightness: number;
  122366. /** Defines the number of octaves to process */
  122367. octaves: number;
  122368. /** Defines the level of persistence (0.8 by default) */
  122369. persistence: number;
  122370. /** Gets or sets animation speed factor (default is 1) */
  122371. animationSpeedFactor: number;
  122372. /**
  122373. * Creates a new NoiseProceduralTexture
  122374. * @param name defines the name fo the texture
  122375. * @param size defines the size of the texture (default is 256)
  122376. * @param scene defines the hosting scene
  122377. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122378. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122379. */
  122380. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122381. private _updateShaderUniforms;
  122382. protected _getDefines(): string;
  122383. /** Generate the current state of the procedural texture */
  122384. render(useCameraPostProcess?: boolean): void;
  122385. /**
  122386. * Serializes this noise procedural texture
  122387. * @returns a serialized noise procedural texture object
  122388. */
  122389. serialize(): any;
  122390. /**
  122391. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  122392. * @param parsedTexture defines parsed texture data
  122393. * @param scene defines the current scene
  122394. * @param rootUrl defines the root URL containing noise procedural texture information
  122395. * @returns a parsed NoiseProceduralTexture
  122396. */
  122397. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  122398. }
  122399. }
  122400. declare module BABYLON {
  122401. /**
  122402. * Raw cube texture where the raw buffers are passed in
  122403. */
  122404. export class RawCubeTexture extends CubeTexture {
  122405. /**
  122406. * Creates a cube texture where the raw buffers are passed in.
  122407. * @param scene defines the scene the texture is attached to
  122408. * @param data defines the array of data to use to create each face
  122409. * @param size defines the size of the textures
  122410. * @param format defines the format of the data
  122411. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  122412. * @param generateMipMaps defines if the engine should generate the mip levels
  122413. * @param invertY defines if data must be stored with Y axis inverted
  122414. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  122415. * @param compression defines the compression used (null by default)
  122416. */
  122417. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  122418. /**
  122419. * Updates the raw cube texture.
  122420. * @param data defines the data to store
  122421. * @param format defines the data format
  122422. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122423. * @param invertY defines if data must be stored with Y axis inverted
  122424. * @param compression defines the compression used (null by default)
  122425. * @param level defines which level of the texture to update
  122426. */
  122427. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  122428. /**
  122429. * Updates a raw cube texture with RGBD encoded data.
  122430. * @param data defines the array of data [mipmap][face] to use to create each face
  122431. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  122432. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122433. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122434. * @returns a promsie that resolves when the operation is complete
  122435. */
  122436. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  122437. /**
  122438. * Clones the raw cube texture.
  122439. * @return a new cube texture
  122440. */
  122441. clone(): CubeTexture;
  122442. /** @hidden */
  122443. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122444. }
  122445. }
  122446. declare module BABYLON {
  122447. /**
  122448. * Class used to store 3D textures containing user data
  122449. */
  122450. export class RawTexture3D extends Texture {
  122451. /** Gets or sets the texture format to use */
  122452. format: number;
  122453. private _engine;
  122454. /**
  122455. * Create a new RawTexture3D
  122456. * @param data defines the data of the texture
  122457. * @param width defines the width of the texture
  122458. * @param height defines the height of the texture
  122459. * @param depth defines the depth of the texture
  122460. * @param format defines the texture format to use
  122461. * @param scene defines the hosting scene
  122462. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122463. * @param invertY defines if texture must be stored with Y axis inverted
  122464. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122465. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122466. */
  122467. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122468. /** Gets or sets the texture format to use */
  122469. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122470. /**
  122471. * Update the texture with new data
  122472. * @param data defines the data to store in the texture
  122473. */
  122474. update(data: ArrayBufferView): void;
  122475. }
  122476. }
  122477. declare module BABYLON {
  122478. /**
  122479. * Class used to store 2D array textures containing user data
  122480. */
  122481. export class RawTexture2DArray extends Texture {
  122482. /** Gets or sets the texture format to use */
  122483. format: number;
  122484. private _engine;
  122485. /**
  122486. * Create a new RawTexture2DArray
  122487. * @param data defines the data of the texture
  122488. * @param width defines the width of the texture
  122489. * @param height defines the height of the texture
  122490. * @param depth defines the number of layers of the texture
  122491. * @param format defines the texture format to use
  122492. * @param scene defines the hosting scene
  122493. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122494. * @param invertY defines if texture must be stored with Y axis inverted
  122495. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122496. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122497. */
  122498. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122499. /** Gets or sets the texture format to use */
  122500. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122501. /**
  122502. * Update the texture with new data
  122503. * @param data defines the data to store in the texture
  122504. */
  122505. update(data: ArrayBufferView): void;
  122506. }
  122507. }
  122508. declare module BABYLON {
  122509. /**
  122510. * Creates a refraction texture used by refraction channel of the standard material.
  122511. * It is like a mirror but to see through a material.
  122512. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122513. */
  122514. export class RefractionTexture extends RenderTargetTexture {
  122515. /**
  122516. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122517. * 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.
  122518. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122519. */
  122520. refractionPlane: Plane;
  122521. /**
  122522. * Define how deep under the surface we should see.
  122523. */
  122524. depth: number;
  122525. /**
  122526. * Creates a refraction texture used by refraction channel of the standard material.
  122527. * It is like a mirror but to see through a material.
  122528. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122529. * @param name Define the texture name
  122530. * @param size Define the size of the underlying texture
  122531. * @param scene Define the scene the refraction belongs to
  122532. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122533. */
  122534. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122535. /**
  122536. * Clone the refraction texture.
  122537. * @returns the cloned texture
  122538. */
  122539. clone(): RefractionTexture;
  122540. /**
  122541. * Serialize the texture to a JSON representation you could use in Parse later on
  122542. * @returns the serialized JSON representation
  122543. */
  122544. serialize(): any;
  122545. }
  122546. }
  122547. declare module BABYLON {
  122548. /**
  122549. * Defines the options related to the creation of an HtmlElementTexture
  122550. */
  122551. export interface IHtmlElementTextureOptions {
  122552. /**
  122553. * Defines wether mip maps should be created or not.
  122554. */
  122555. generateMipMaps?: boolean;
  122556. /**
  122557. * Defines the sampling mode of the texture.
  122558. */
  122559. samplingMode?: number;
  122560. /**
  122561. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122562. */
  122563. engine: Nullable<ThinEngine>;
  122564. /**
  122565. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122566. */
  122567. scene: Nullable<Scene>;
  122568. }
  122569. /**
  122570. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122571. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122572. * is automatically managed.
  122573. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122574. * in your application.
  122575. *
  122576. * As the update is not automatic, you need to call them manually.
  122577. */
  122578. export class HtmlElementTexture extends BaseTexture {
  122579. /**
  122580. * The texture URL.
  122581. */
  122582. element: HTMLVideoElement | HTMLCanvasElement;
  122583. private static readonly DefaultOptions;
  122584. private _textureMatrix;
  122585. private _engine;
  122586. private _isVideo;
  122587. private _generateMipMaps;
  122588. private _samplingMode;
  122589. /**
  122590. * Instantiates a HtmlElementTexture from the following parameters.
  122591. *
  122592. * @param name Defines the name of the texture
  122593. * @param element Defines the video or canvas the texture is filled with
  122594. * @param options Defines the other none mandatory texture creation options
  122595. */
  122596. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122597. private _createInternalTexture;
  122598. /**
  122599. * Returns the texture matrix used in most of the material.
  122600. */
  122601. getTextureMatrix(): Matrix;
  122602. /**
  122603. * Updates the content of the texture.
  122604. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122605. */
  122606. update(invertY?: Nullable<boolean>): void;
  122607. }
  122608. }
  122609. declare module BABYLON {
  122610. /**
  122611. * Enum used to define the target of a block
  122612. */
  122613. export enum NodeMaterialBlockTargets {
  122614. /** Vertex shader */
  122615. Vertex = 1,
  122616. /** Fragment shader */
  122617. Fragment = 2,
  122618. /** Neutral */
  122619. Neutral = 4,
  122620. /** Vertex and Fragment */
  122621. VertexAndFragment = 3
  122622. }
  122623. }
  122624. declare module BABYLON {
  122625. /**
  122626. * Defines the kind of connection point for node based material
  122627. */
  122628. export enum NodeMaterialBlockConnectionPointTypes {
  122629. /** Float */
  122630. Float = 1,
  122631. /** Int */
  122632. Int = 2,
  122633. /** Vector2 */
  122634. Vector2 = 4,
  122635. /** Vector3 */
  122636. Vector3 = 8,
  122637. /** Vector4 */
  122638. Vector4 = 16,
  122639. /** Color3 */
  122640. Color3 = 32,
  122641. /** Color4 */
  122642. Color4 = 64,
  122643. /** Matrix */
  122644. Matrix = 128,
  122645. /** Detect type based on connection */
  122646. AutoDetect = 1024,
  122647. /** Output type that will be defined by input type */
  122648. BasedOnInput = 2048
  122649. }
  122650. }
  122651. declare module BABYLON {
  122652. /**
  122653. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  122654. */
  122655. export enum NodeMaterialBlockConnectionPointMode {
  122656. /** Value is an uniform */
  122657. Uniform = 0,
  122658. /** Value is a mesh attribute */
  122659. Attribute = 1,
  122660. /** Value is a varying between vertex and fragment shaders */
  122661. Varying = 2,
  122662. /** Mode is undefined */
  122663. Undefined = 3
  122664. }
  122665. }
  122666. declare module BABYLON {
  122667. /**
  122668. * Enum used to define system values e.g. values automatically provided by the system
  122669. */
  122670. export enum NodeMaterialSystemValues {
  122671. /** World */
  122672. World = 1,
  122673. /** View */
  122674. View = 2,
  122675. /** Projection */
  122676. Projection = 3,
  122677. /** ViewProjection */
  122678. ViewProjection = 4,
  122679. /** WorldView */
  122680. WorldView = 5,
  122681. /** WorldViewProjection */
  122682. WorldViewProjection = 6,
  122683. /** CameraPosition */
  122684. CameraPosition = 7,
  122685. /** Fog Color */
  122686. FogColor = 8,
  122687. /** Delta time */
  122688. DeltaTime = 9
  122689. }
  122690. }
  122691. declare module BABYLON {
  122692. /**
  122693. * Root class for all node material optimizers
  122694. */
  122695. export class NodeMaterialOptimizer {
  122696. /**
  122697. * Function used to optimize a NodeMaterial graph
  122698. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122699. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122700. */
  122701. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122702. }
  122703. }
  122704. declare module BABYLON {
  122705. /**
  122706. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122707. */
  122708. export class TransformBlock extends NodeMaterialBlock {
  122709. /**
  122710. * Defines the value to use to complement W value to transform it to a Vector4
  122711. */
  122712. complementW: number;
  122713. /**
  122714. * Defines the value to use to complement z value to transform it to a Vector4
  122715. */
  122716. complementZ: number;
  122717. /**
  122718. * Creates a new TransformBlock
  122719. * @param name defines the block name
  122720. */
  122721. constructor(name: string);
  122722. /**
  122723. * Gets the current class name
  122724. * @returns the class name
  122725. */
  122726. getClassName(): string;
  122727. /**
  122728. * Gets the vector input
  122729. */
  122730. readonly vector: NodeMaterialConnectionPoint;
  122731. /**
  122732. * Gets the output component
  122733. */
  122734. readonly output: NodeMaterialConnectionPoint;
  122735. /**
  122736. * Gets the matrix transform input
  122737. */
  122738. readonly transform: NodeMaterialConnectionPoint;
  122739. protected _buildBlock(state: NodeMaterialBuildState): this;
  122740. serialize(): any;
  122741. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122742. protected _dumpPropertiesCode(): string;
  122743. }
  122744. }
  122745. declare module BABYLON {
  122746. /**
  122747. * Block used to output the vertex position
  122748. */
  122749. export class VertexOutputBlock extends NodeMaterialBlock {
  122750. /**
  122751. * Creates a new VertexOutputBlock
  122752. * @param name defines the block name
  122753. */
  122754. constructor(name: string);
  122755. /**
  122756. * Gets the current class name
  122757. * @returns the class name
  122758. */
  122759. getClassName(): string;
  122760. /**
  122761. * Gets the vector input component
  122762. */
  122763. readonly vector: NodeMaterialConnectionPoint;
  122764. protected _buildBlock(state: NodeMaterialBuildState): this;
  122765. }
  122766. }
  122767. declare module BABYLON {
  122768. /**
  122769. * Block used to output the final color
  122770. */
  122771. export class FragmentOutputBlock extends NodeMaterialBlock {
  122772. /**
  122773. * Create a new FragmentOutputBlock
  122774. * @param name defines the block name
  122775. */
  122776. constructor(name: string);
  122777. /**
  122778. * Gets the current class name
  122779. * @returns the class name
  122780. */
  122781. getClassName(): string;
  122782. /**
  122783. * Gets the rgba input component
  122784. */
  122785. readonly rgba: NodeMaterialConnectionPoint;
  122786. /**
  122787. * Gets the rgb input component
  122788. */
  122789. readonly rgb: NodeMaterialConnectionPoint;
  122790. /**
  122791. * Gets the a input component
  122792. */
  122793. readonly a: NodeMaterialConnectionPoint;
  122794. protected _buildBlock(state: NodeMaterialBuildState): this;
  122795. }
  122796. }
  122797. declare module BABYLON {
  122798. /**
  122799. * Block used to read a reflection texture from a sampler
  122800. */
  122801. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122802. private _define3DName;
  122803. private _defineCubicName;
  122804. private _defineExplicitName;
  122805. private _defineProjectionName;
  122806. private _defineLocalCubicName;
  122807. private _defineSphericalName;
  122808. private _definePlanarName;
  122809. private _defineEquirectangularName;
  122810. private _defineMirroredEquirectangularFixedName;
  122811. private _defineEquirectangularFixedName;
  122812. private _defineSkyboxName;
  122813. private _cubeSamplerName;
  122814. private _2DSamplerName;
  122815. private _positionUVWName;
  122816. private _directionWName;
  122817. private _reflectionCoordsName;
  122818. private _reflection2DCoordsName;
  122819. private _reflectionColorName;
  122820. private _reflectionMatrixName;
  122821. /**
  122822. * Gets or sets the texture associated with the node
  122823. */
  122824. texture: Nullable<BaseTexture>;
  122825. /**
  122826. * Create a new TextureBlock
  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 world position input component
  122837. */
  122838. readonly position: NodeMaterialConnectionPoint;
  122839. /**
  122840. * Gets the world position input component
  122841. */
  122842. readonly worldPosition: NodeMaterialConnectionPoint;
  122843. /**
  122844. * Gets the world normal input component
  122845. */
  122846. readonly worldNormal: NodeMaterialConnectionPoint;
  122847. /**
  122848. * Gets the world input component
  122849. */
  122850. readonly world: NodeMaterialConnectionPoint;
  122851. /**
  122852. * Gets the camera (or eye) position component
  122853. */
  122854. readonly cameraPosition: NodeMaterialConnectionPoint;
  122855. /**
  122856. * Gets the view input component
  122857. */
  122858. readonly view: NodeMaterialConnectionPoint;
  122859. /**
  122860. * Gets the rgb output component
  122861. */
  122862. readonly rgb: NodeMaterialConnectionPoint;
  122863. /**
  122864. * Gets the r output component
  122865. */
  122866. readonly r: NodeMaterialConnectionPoint;
  122867. /**
  122868. * Gets the g output component
  122869. */
  122870. readonly g: NodeMaterialConnectionPoint;
  122871. /**
  122872. * Gets the b output component
  122873. */
  122874. readonly b: NodeMaterialConnectionPoint;
  122875. autoConfigure(material: NodeMaterial): void;
  122876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122877. isReady(): boolean;
  122878. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122879. private _injectVertexCode;
  122880. private _writeOutput;
  122881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122882. protected _dumpPropertiesCode(): string;
  122883. serialize(): any;
  122884. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122885. }
  122886. }
  122887. declare module BABYLON {
  122888. /**
  122889. * Interface used to configure the node material editor
  122890. */
  122891. export interface INodeMaterialEditorOptions {
  122892. /** Define the URl to load node editor script */
  122893. editorURL?: string;
  122894. }
  122895. /** @hidden */
  122896. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122897. /** BONES */
  122898. NUM_BONE_INFLUENCERS: number;
  122899. BonesPerMesh: number;
  122900. BONETEXTURE: boolean;
  122901. /** MORPH TARGETS */
  122902. MORPHTARGETS: boolean;
  122903. MORPHTARGETS_NORMAL: boolean;
  122904. MORPHTARGETS_TANGENT: boolean;
  122905. MORPHTARGETS_UV: boolean;
  122906. NUM_MORPH_INFLUENCERS: number;
  122907. /** IMAGE PROCESSING */
  122908. IMAGEPROCESSING: boolean;
  122909. VIGNETTE: boolean;
  122910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122911. VIGNETTEBLENDMODEOPAQUE: boolean;
  122912. TONEMAPPING: boolean;
  122913. TONEMAPPING_ACES: boolean;
  122914. CONTRAST: boolean;
  122915. EXPOSURE: boolean;
  122916. COLORCURVES: boolean;
  122917. COLORGRADING: boolean;
  122918. COLORGRADING3D: boolean;
  122919. SAMPLER3DGREENDEPTH: boolean;
  122920. SAMPLER3DBGRMAP: boolean;
  122921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122922. /** MISC. */
  122923. BUMPDIRECTUV: number;
  122924. constructor();
  122925. setValue(name: string, value: boolean): void;
  122926. }
  122927. /**
  122928. * Class used to configure NodeMaterial
  122929. */
  122930. export interface INodeMaterialOptions {
  122931. /**
  122932. * Defines if blocks should emit comments
  122933. */
  122934. emitComments: boolean;
  122935. }
  122936. /**
  122937. * Class used to create a node based material built by assembling shader blocks
  122938. */
  122939. export class NodeMaterial extends PushMaterial {
  122940. private static _BuildIdGenerator;
  122941. private _options;
  122942. private _vertexCompilationState;
  122943. private _fragmentCompilationState;
  122944. private _sharedData;
  122945. private _buildId;
  122946. private _buildWasSuccessful;
  122947. private _cachedWorldViewMatrix;
  122948. private _cachedWorldViewProjectionMatrix;
  122949. private _optimizers;
  122950. private _animationFrame;
  122951. /** Define the URl to load node editor script */
  122952. static EditorURL: string;
  122953. private BJSNODEMATERIALEDITOR;
  122954. /** Get the inspector from bundle or global */
  122955. private _getGlobalNodeMaterialEditor;
  122956. /**
  122957. * Gets or sets data used by visual editor
  122958. * @see https://nme.babylonjs.com
  122959. */
  122960. editorData: any;
  122961. /**
  122962. * 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)
  122963. */
  122964. ignoreAlpha: boolean;
  122965. /**
  122966. * Defines the maximum number of lights that can be used in the material
  122967. */
  122968. maxSimultaneousLights: number;
  122969. /**
  122970. * Observable raised when the material is built
  122971. */
  122972. onBuildObservable: Observable<NodeMaterial>;
  122973. /**
  122974. * Gets or sets the root nodes of the material vertex shader
  122975. */
  122976. _vertexOutputNodes: NodeMaterialBlock[];
  122977. /**
  122978. * Gets or sets the root nodes of the material fragment (pixel) shader
  122979. */
  122980. _fragmentOutputNodes: NodeMaterialBlock[];
  122981. /** Gets or sets options to control the node material overall behavior */
  122982. options: INodeMaterialOptions;
  122983. /**
  122984. * Default configuration related to image processing available in the standard Material.
  122985. */
  122986. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122987. /**
  122988. * Gets the image processing configuration used either in this material.
  122989. */
  122990. /**
  122991. * Sets the Default image processing configuration used either in the this material.
  122992. *
  122993. * If sets to null, the scene one is in use.
  122994. */
  122995. imageProcessingConfiguration: ImageProcessingConfiguration;
  122996. /**
  122997. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  122998. */
  122999. attachedBlocks: NodeMaterialBlock[];
  123000. /**
  123001. * Create a new node based material
  123002. * @param name defines the material name
  123003. * @param scene defines the hosting scene
  123004. * @param options defines creation option
  123005. */
  123006. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  123007. /**
  123008. * Gets the current class name of the material e.g. "NodeMaterial"
  123009. * @returns the class name
  123010. */
  123011. getClassName(): string;
  123012. /**
  123013. * Keep track of the image processing observer to allow dispose and replace.
  123014. */
  123015. private _imageProcessingObserver;
  123016. /**
  123017. * Attaches a new image processing configuration to the Standard Material.
  123018. * @param configuration
  123019. */
  123020. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123021. /**
  123022. * Get a block by its name
  123023. * @param name defines the name of the block to retrieve
  123024. * @returns the required block or null if not found
  123025. */
  123026. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  123027. /**
  123028. * Get a block by its name
  123029. * @param predicate defines the predicate used to find the good candidate
  123030. * @returns the required block or null if not found
  123031. */
  123032. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  123033. /**
  123034. * Get an input block by its name
  123035. * @param predicate defines the predicate used to find the good candidate
  123036. * @returns the required input block or null if not found
  123037. */
  123038. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  123039. /**
  123040. * Gets the list of input blocks attached to this material
  123041. * @returns an array of InputBlocks
  123042. */
  123043. getInputBlocks(): InputBlock[];
  123044. /**
  123045. * Adds a new optimizer to the list of optimizers
  123046. * @param optimizer defines the optimizers to add
  123047. * @returns the current material
  123048. */
  123049. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123050. /**
  123051. * Remove an optimizer from the list of optimizers
  123052. * @param optimizer defines the optimizers to remove
  123053. * @returns the current material
  123054. */
  123055. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123056. /**
  123057. * Add a new block to the list of output nodes
  123058. * @param node defines the node to add
  123059. * @returns the current material
  123060. */
  123061. addOutputNode(node: NodeMaterialBlock): this;
  123062. /**
  123063. * Remove a block from the list of root nodes
  123064. * @param node defines the node to remove
  123065. * @returns the current material
  123066. */
  123067. removeOutputNode(node: NodeMaterialBlock): this;
  123068. private _addVertexOutputNode;
  123069. private _removeVertexOutputNode;
  123070. private _addFragmentOutputNode;
  123071. private _removeFragmentOutputNode;
  123072. /**
  123073. * Specifies if the material will require alpha blending
  123074. * @returns a boolean specifying if alpha blending is needed
  123075. */
  123076. needAlphaBlending(): boolean;
  123077. /**
  123078. * Specifies if this material should be rendered in alpha test mode
  123079. * @returns a boolean specifying if an alpha test is needed.
  123080. */
  123081. needAlphaTesting(): boolean;
  123082. private _initializeBlock;
  123083. private _resetDualBlocks;
  123084. /**
  123085. * Remove a block from the current node material
  123086. * @param block defines the block to remove
  123087. */
  123088. removeBlock(block: NodeMaterialBlock): void;
  123089. /**
  123090. * Build the material and generates the inner effect
  123091. * @param verbose defines if the build should log activity
  123092. */
  123093. build(verbose?: boolean): void;
  123094. /**
  123095. * Runs an otpimization phase to try to improve the shader code
  123096. */
  123097. optimize(): void;
  123098. private _prepareDefinesForAttributes;
  123099. /**
  123100. * Get if the submesh is ready to be used and all its information available.
  123101. * Child classes can use it to update shaders
  123102. * @param mesh defines the mesh to check
  123103. * @param subMesh defines which submesh to check
  123104. * @param useInstances specifies that instances should be used
  123105. * @returns a boolean indicating that the submesh is ready or not
  123106. */
  123107. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123108. /**
  123109. * Get a string representing the shaders built by the current node graph
  123110. */
  123111. readonly compiledShaders: string;
  123112. /**
  123113. * Binds the world matrix to the material
  123114. * @param world defines the world transformation matrix
  123115. */
  123116. bindOnlyWorldMatrix(world: Matrix): void;
  123117. /**
  123118. * Binds the submesh to this material by preparing the effect and shader to draw
  123119. * @param world defines the world transformation matrix
  123120. * @param mesh defines the mesh containing the submesh
  123121. * @param subMesh defines the submesh to bind the material to
  123122. */
  123123. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123124. /**
  123125. * Gets the active textures from the material
  123126. * @returns an array of textures
  123127. */
  123128. getActiveTextures(): BaseTexture[];
  123129. /**
  123130. * Gets the list of texture blocks
  123131. * @returns an array of texture blocks
  123132. */
  123133. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123134. /**
  123135. * Specifies if the material uses a texture
  123136. * @param texture defines the texture to check against the material
  123137. * @returns a boolean specifying if the material uses the texture
  123138. */
  123139. hasTexture(texture: BaseTexture): boolean;
  123140. /**
  123141. * Disposes the material
  123142. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123143. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123144. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123145. */
  123146. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123147. /** Creates the node editor window. */
  123148. private _createNodeEditor;
  123149. /**
  123150. * Launch the node material editor
  123151. * @param config Define the configuration of the editor
  123152. * @return a promise fulfilled when the node editor is visible
  123153. */
  123154. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123155. /**
  123156. * Clear the current material
  123157. */
  123158. clear(): void;
  123159. /**
  123160. * Clear the current material and set it to a default state
  123161. */
  123162. setToDefault(): void;
  123163. /**
  123164. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123165. * @param url defines the url to load from
  123166. * @returns a promise that will fullfil when the material is fully loaded
  123167. */
  123168. loadAsync(url: string): Promise<void>;
  123169. private _gatherBlocks;
  123170. /**
  123171. * Generate a string containing the code declaration required to create an equivalent of this material
  123172. * @returns a string
  123173. */
  123174. generateCode(): string;
  123175. /**
  123176. * Serializes this material in a JSON representation
  123177. * @returns the serialized material object
  123178. */
  123179. serialize(): any;
  123180. private _restoreConnections;
  123181. /**
  123182. * Clear the current graph and load a new one from a serialization object
  123183. * @param source defines the JSON representation of the material
  123184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123185. */
  123186. loadFromSerialization(source: any, rootUrl?: string): void;
  123187. /**
  123188. * Creates a node material from parsed material data
  123189. * @param source defines the JSON representation of the material
  123190. * @param scene defines the hosting scene
  123191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123192. * @returns a new node material
  123193. */
  123194. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123195. /**
  123196. * Creates a new node material set to default basic configuration
  123197. * @param name defines the name of the material
  123198. * @param scene defines the hosting scene
  123199. * @returns a new NodeMaterial
  123200. */
  123201. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123202. }
  123203. }
  123204. declare module BABYLON {
  123205. /**
  123206. * Block used to read a texture from a sampler
  123207. */
  123208. export class TextureBlock extends NodeMaterialBlock {
  123209. private _defineName;
  123210. private _linearDefineName;
  123211. private _tempTextureRead;
  123212. private _samplerName;
  123213. private _transformedUVName;
  123214. private _textureTransformName;
  123215. private _textureInfoName;
  123216. private _mainUVName;
  123217. private _mainUVDefineName;
  123218. /**
  123219. * Gets or sets the texture associated with the node
  123220. */
  123221. texture: Nullable<Texture>;
  123222. /**
  123223. * Create a new TextureBlock
  123224. * @param name defines the block name
  123225. */
  123226. constructor(name: string);
  123227. /**
  123228. * Gets the current class name
  123229. * @returns the class name
  123230. */
  123231. getClassName(): string;
  123232. /**
  123233. * Gets the uv input component
  123234. */
  123235. readonly uv: NodeMaterialConnectionPoint;
  123236. /**
  123237. * Gets the rgba output component
  123238. */
  123239. readonly rgba: NodeMaterialConnectionPoint;
  123240. /**
  123241. * Gets the rgb output component
  123242. */
  123243. readonly rgb: NodeMaterialConnectionPoint;
  123244. /**
  123245. * Gets the r output component
  123246. */
  123247. readonly r: NodeMaterialConnectionPoint;
  123248. /**
  123249. * Gets the g output component
  123250. */
  123251. readonly g: NodeMaterialConnectionPoint;
  123252. /**
  123253. * Gets the b output component
  123254. */
  123255. readonly b: NodeMaterialConnectionPoint;
  123256. /**
  123257. * Gets the a output component
  123258. */
  123259. readonly a: NodeMaterialConnectionPoint;
  123260. readonly target: NodeMaterialBlockTargets;
  123261. autoConfigure(material: NodeMaterial): void;
  123262. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123264. private _getTextureBase;
  123265. isReady(): boolean;
  123266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123267. private readonly _isMixed;
  123268. private _injectVertexCode;
  123269. private _writeTextureRead;
  123270. private _writeOutput;
  123271. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123272. protected _dumpPropertiesCode(): string;
  123273. serialize(): any;
  123274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123275. }
  123276. }
  123277. declare module BABYLON {
  123278. /**
  123279. * Class used to store shared data between 2 NodeMaterialBuildState
  123280. */
  123281. export class NodeMaterialBuildStateSharedData {
  123282. /**
  123283. * Gets the list of emitted varyings
  123284. */
  123285. temps: string[];
  123286. /**
  123287. * Gets the list of emitted varyings
  123288. */
  123289. varyings: string[];
  123290. /**
  123291. * Gets the varying declaration string
  123292. */
  123293. varyingDeclaration: string;
  123294. /**
  123295. * Input blocks
  123296. */
  123297. inputBlocks: InputBlock[];
  123298. /**
  123299. * Input blocks
  123300. */
  123301. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123302. /**
  123303. * Bindable blocks (Blocks that need to set data to the effect)
  123304. */
  123305. bindableBlocks: NodeMaterialBlock[];
  123306. /**
  123307. * List of blocks that can provide a compilation fallback
  123308. */
  123309. blocksWithFallbacks: NodeMaterialBlock[];
  123310. /**
  123311. * List of blocks that can provide a define update
  123312. */
  123313. blocksWithDefines: NodeMaterialBlock[];
  123314. /**
  123315. * List of blocks that can provide a repeatable content
  123316. */
  123317. repeatableContentBlocks: NodeMaterialBlock[];
  123318. /**
  123319. * List of blocks that can provide a dynamic list of uniforms
  123320. */
  123321. dynamicUniformBlocks: NodeMaterialBlock[];
  123322. /**
  123323. * List of blocks that can block the isReady function for the material
  123324. */
  123325. blockingBlocks: NodeMaterialBlock[];
  123326. /**
  123327. * Gets the list of animated inputs
  123328. */
  123329. animatedInputs: InputBlock[];
  123330. /**
  123331. * Build Id used to avoid multiple recompilations
  123332. */
  123333. buildId: number;
  123334. /** List of emitted variables */
  123335. variableNames: {
  123336. [key: string]: number;
  123337. };
  123338. /** List of emitted defines */
  123339. defineNames: {
  123340. [key: string]: number;
  123341. };
  123342. /** Should emit comments? */
  123343. emitComments: boolean;
  123344. /** Emit build activity */
  123345. verbose: boolean;
  123346. /** Gets or sets the hosting scene */
  123347. scene: Scene;
  123348. /**
  123349. * Gets the compilation hints emitted at compilation time
  123350. */
  123351. hints: {
  123352. needWorldViewMatrix: boolean;
  123353. needWorldViewProjectionMatrix: boolean;
  123354. needAlphaBlending: boolean;
  123355. needAlphaTesting: boolean;
  123356. };
  123357. /**
  123358. * List of compilation checks
  123359. */
  123360. checks: {
  123361. emitVertex: boolean;
  123362. emitFragment: boolean;
  123363. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123364. };
  123365. /** Creates a new shared data */
  123366. constructor();
  123367. /**
  123368. * Emits console errors and exceptions if there is a failing check
  123369. */
  123370. emitErrors(): void;
  123371. }
  123372. }
  123373. declare module BABYLON {
  123374. /**
  123375. * Class used to store node based material build state
  123376. */
  123377. export class NodeMaterialBuildState {
  123378. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123379. supportUniformBuffers: boolean;
  123380. /**
  123381. * Gets the list of emitted attributes
  123382. */
  123383. attributes: string[];
  123384. /**
  123385. * Gets the list of emitted uniforms
  123386. */
  123387. uniforms: string[];
  123388. /**
  123389. * Gets the list of emitted constants
  123390. */
  123391. constants: string[];
  123392. /**
  123393. * Gets the list of emitted samplers
  123394. */
  123395. samplers: string[];
  123396. /**
  123397. * Gets the list of emitted functions
  123398. */
  123399. functions: {
  123400. [key: string]: string;
  123401. };
  123402. /**
  123403. * Gets the list of emitted extensions
  123404. */
  123405. extensions: {
  123406. [key: string]: string;
  123407. };
  123408. /**
  123409. * Gets the target of the compilation state
  123410. */
  123411. target: NodeMaterialBlockTargets;
  123412. /**
  123413. * Gets the list of emitted counters
  123414. */
  123415. counters: {
  123416. [key: string]: number;
  123417. };
  123418. /**
  123419. * Shared data between multiple NodeMaterialBuildState instances
  123420. */
  123421. sharedData: NodeMaterialBuildStateSharedData;
  123422. /** @hidden */
  123423. _vertexState: NodeMaterialBuildState;
  123424. /** @hidden */
  123425. _attributeDeclaration: string;
  123426. /** @hidden */
  123427. _uniformDeclaration: string;
  123428. /** @hidden */
  123429. _constantDeclaration: string;
  123430. /** @hidden */
  123431. _samplerDeclaration: string;
  123432. /** @hidden */
  123433. _varyingTransfer: string;
  123434. private _repeatableContentAnchorIndex;
  123435. /** @hidden */
  123436. _builtCompilationString: string;
  123437. /**
  123438. * Gets the emitted compilation strings
  123439. */
  123440. compilationString: string;
  123441. /**
  123442. * Finalize the compilation strings
  123443. * @param state defines the current compilation state
  123444. */
  123445. finalize(state: NodeMaterialBuildState): void;
  123446. /** @hidden */
  123447. readonly _repeatableContentAnchor: string;
  123448. /** @hidden */
  123449. _getFreeVariableName(prefix: string): string;
  123450. /** @hidden */
  123451. _getFreeDefineName(prefix: string): string;
  123452. /** @hidden */
  123453. _excludeVariableName(name: string): void;
  123454. /** @hidden */
  123455. _emit2DSampler(name: string): void;
  123456. /** @hidden */
  123457. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  123458. /** @hidden */
  123459. _emitExtension(name: string, extension: string): void;
  123460. /** @hidden */
  123461. _emitFunction(name: string, code: string, comments: string): void;
  123462. /** @hidden */
  123463. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  123464. replaceStrings?: {
  123465. search: RegExp;
  123466. replace: string;
  123467. }[];
  123468. repeatKey?: string;
  123469. }): string;
  123470. /** @hidden */
  123471. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  123472. repeatKey?: string;
  123473. removeAttributes?: boolean;
  123474. removeUniforms?: boolean;
  123475. removeVaryings?: boolean;
  123476. removeIfDef?: boolean;
  123477. replaceStrings?: {
  123478. search: RegExp;
  123479. replace: string;
  123480. }[];
  123481. }, storeKey?: string): void;
  123482. /** @hidden */
  123483. _registerTempVariable(name: string): boolean;
  123484. /** @hidden */
  123485. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  123486. /** @hidden */
  123487. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  123488. /** @hidden */
  123489. _emitFloat(value: number): string;
  123490. }
  123491. }
  123492. declare module BABYLON {
  123493. /**
  123494. * Defines a block that can be used inside a node based material
  123495. */
  123496. export class NodeMaterialBlock {
  123497. private _buildId;
  123498. private _buildTarget;
  123499. private _target;
  123500. private _isFinalMerger;
  123501. private _isInput;
  123502. protected _isUnique: boolean;
  123503. /** @hidden */
  123504. _codeVariableName: string;
  123505. /** @hidden */
  123506. _inputs: NodeMaterialConnectionPoint[];
  123507. /** @hidden */
  123508. _outputs: NodeMaterialConnectionPoint[];
  123509. /** @hidden */
  123510. _preparationId: number;
  123511. /**
  123512. * Gets or sets the name of the block
  123513. */
  123514. name: string;
  123515. /**
  123516. * Gets or sets the unique id of the node
  123517. */
  123518. uniqueId: number;
  123519. /**
  123520. * Gets or sets the comments associated with this block
  123521. */
  123522. comments: string;
  123523. /**
  123524. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123525. */
  123526. readonly isUnique: boolean;
  123527. /**
  123528. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123529. */
  123530. readonly isFinalMerger: boolean;
  123531. /**
  123532. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123533. */
  123534. readonly isInput: boolean;
  123535. /**
  123536. * Gets or sets the build Id
  123537. */
  123538. buildId: number;
  123539. /**
  123540. * Gets or sets the target of the block
  123541. */
  123542. target: NodeMaterialBlockTargets;
  123543. /**
  123544. * Gets the list of input points
  123545. */
  123546. readonly inputs: NodeMaterialConnectionPoint[];
  123547. /** Gets the list of output points */
  123548. readonly outputs: NodeMaterialConnectionPoint[];
  123549. /**
  123550. * Find an input by its name
  123551. * @param name defines the name of the input to look for
  123552. * @returns the input or null if not found
  123553. */
  123554. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123555. /**
  123556. * Find an output by its name
  123557. * @param name defines the name of the outputto look for
  123558. * @returns the output or null if not found
  123559. */
  123560. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123561. /**
  123562. * Creates a new NodeMaterialBlock
  123563. * @param name defines the block name
  123564. * @param target defines the target of that block (Vertex by default)
  123565. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123566. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123567. */
  123568. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123569. /**
  123570. * Initialize the block and prepare the context for build
  123571. * @param state defines the state that will be used for the build
  123572. */
  123573. initialize(state: NodeMaterialBuildState): void;
  123574. /**
  123575. * Bind data to effect. Will only be called for blocks with isBindable === true
  123576. * @param effect defines the effect to bind data to
  123577. * @param nodeMaterial defines the hosting NodeMaterial
  123578. * @param mesh defines the mesh that will be rendered
  123579. */
  123580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123581. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123582. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123583. protected _writeFloat(value: number): string;
  123584. /**
  123585. * Gets the current class name e.g. "NodeMaterialBlock"
  123586. * @returns the class name
  123587. */
  123588. getClassName(): string;
  123589. /**
  123590. * Register a new input. Must be called inside a block constructor
  123591. * @param name defines the connection point name
  123592. * @param type defines the connection point type
  123593. * @param isOptional defines a boolean indicating that this input can be omitted
  123594. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123595. * @returns the current block
  123596. */
  123597. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123598. /**
  123599. * Register a new output. Must be called inside a block constructor
  123600. * @param name defines the connection point name
  123601. * @param type defines the connection point type
  123602. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123603. * @returns the current block
  123604. */
  123605. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123606. /**
  123607. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123608. * @param forOutput defines an optional connection point to check compatibility with
  123609. * @returns the first available input or null
  123610. */
  123611. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123612. /**
  123613. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123614. * @param forBlock defines an optional block to check compatibility with
  123615. * @returns the first available input or null
  123616. */
  123617. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123618. /**
  123619. * Gets the sibling of the given output
  123620. * @param current defines the current output
  123621. * @returns the next output in the list or null
  123622. */
  123623. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123624. /**
  123625. * Connect current block with another block
  123626. * @param other defines the block to connect with
  123627. * @param options define the various options to help pick the right connections
  123628. * @returns the current block
  123629. */
  123630. connectTo(other: NodeMaterialBlock, options?: {
  123631. input?: string;
  123632. output?: string;
  123633. outputSwizzle?: string;
  123634. }): this | undefined;
  123635. protected _buildBlock(state: NodeMaterialBuildState): void;
  123636. /**
  123637. * Add uniforms, samplers and uniform buffers at compilation time
  123638. * @param state defines the state to update
  123639. * @param nodeMaterial defines the node material requesting the update
  123640. * @param defines defines the material defines to update
  123641. * @param uniformBuffers defines the list of uniform buffer names
  123642. */
  123643. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123644. /**
  123645. * Add potential fallbacks if shader compilation fails
  123646. * @param mesh defines the mesh to be rendered
  123647. * @param fallbacks defines the current prioritized list of fallbacks
  123648. */
  123649. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123650. /**
  123651. * Initialize defines for shader compilation
  123652. * @param mesh defines the mesh to be rendered
  123653. * @param nodeMaterial defines the node material requesting the update
  123654. * @param defines defines the material defines to update
  123655. * @param useInstances specifies that instances should be used
  123656. */
  123657. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123658. /**
  123659. * Update defines for shader compilation
  123660. * @param mesh defines the mesh to be rendered
  123661. * @param nodeMaterial defines the node material requesting the update
  123662. * @param defines defines the material defines to update
  123663. * @param useInstances specifies that instances should be used
  123664. */
  123665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123666. /**
  123667. * Lets the block try to connect some inputs automatically
  123668. * @param material defines the hosting NodeMaterial
  123669. */
  123670. autoConfigure(material: NodeMaterial): void;
  123671. /**
  123672. * Function called when a block is declared as repeatable content generator
  123673. * @param vertexShaderState defines the current compilation state for the vertex shader
  123674. * @param fragmentShaderState defines the current compilation state for the fragment shader
  123675. * @param mesh defines the mesh to be rendered
  123676. * @param defines defines the material defines to update
  123677. */
  123678. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123679. /**
  123680. * Checks if the block is ready
  123681. * @param mesh defines the mesh to be rendered
  123682. * @param nodeMaterial defines the node material requesting the update
  123683. * @param defines defines the material defines to update
  123684. * @param useInstances specifies that instances should be used
  123685. * @returns true if the block is ready
  123686. */
  123687. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  123688. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  123689. private _processBuild;
  123690. /**
  123691. * Compile the current node and generate the shader code
  123692. * @param state defines the current compilation state (uniforms, samplers, current string)
  123693. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  123694. * @returns true if already built
  123695. */
  123696. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123697. protected _inputRename(name: string): string;
  123698. protected _outputRename(name: string): string;
  123699. protected _dumpPropertiesCode(): string;
  123700. /** @hidden */
  123701. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123702. /** @hidden */
  123703. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123704. /**
  123705. * Clone the current block to a new identical block
  123706. * @param scene defines the hosting scene
  123707. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123708. * @returns a copy of the current block
  123709. */
  123710. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123711. /**
  123712. * Serializes this block in a JSON representation
  123713. * @returns the serialized block object
  123714. */
  123715. serialize(): any;
  123716. /** @hidden */
  123717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123718. /**
  123719. * Release resources
  123720. */
  123721. dispose(): void;
  123722. }
  123723. }
  123724. declare module BABYLON {
  123725. /**
  123726. * Enum defining the type of animations supported by InputBlock
  123727. */
  123728. export enum AnimatedInputBlockTypes {
  123729. /** No animation */
  123730. None = 0,
  123731. /** Time based animation. Will only work for floats */
  123732. Time = 1
  123733. }
  123734. }
  123735. declare module BABYLON {
  123736. /**
  123737. * Block used to expose an input value
  123738. */
  123739. export class InputBlock extends NodeMaterialBlock {
  123740. private _mode;
  123741. private _associatedVariableName;
  123742. private _storedValue;
  123743. private _valueCallback;
  123744. private _type;
  123745. private _animationType;
  123746. /** Gets or set a value used to limit the range of float values */
  123747. min: number;
  123748. /** Gets or set a value used to limit the range of float values */
  123749. max: number;
  123750. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123751. matrixMode: number;
  123752. /** @hidden */
  123753. _systemValue: Nullable<NodeMaterialSystemValues>;
  123754. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123755. visibleInInspector: boolean;
  123756. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123757. isConstant: boolean;
  123758. /**
  123759. * Gets or sets the connection point type (default is float)
  123760. */
  123761. readonly type: NodeMaterialBlockConnectionPointTypes;
  123762. /**
  123763. * Creates a new InputBlock
  123764. * @param name defines the block name
  123765. * @param target defines the target of that block (Vertex by default)
  123766. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123767. */
  123768. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123769. /**
  123770. * Gets the output component
  123771. */
  123772. readonly output: NodeMaterialConnectionPoint;
  123773. /**
  123774. * Set the source of this connection point to a vertex attribute
  123775. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123776. * @returns the current connection point
  123777. */
  123778. setAsAttribute(attributeName?: string): InputBlock;
  123779. /**
  123780. * Set the source of this connection point to a system value
  123781. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123782. * @returns the current connection point
  123783. */
  123784. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123785. /**
  123786. * Gets or sets the value of that point.
  123787. * Please note that this value will be ignored if valueCallback is defined
  123788. */
  123789. value: any;
  123790. /**
  123791. * Gets or sets a callback used to get the value of that point.
  123792. * Please note that setting this value will force the connection point to ignore the value property
  123793. */
  123794. valueCallback: () => any;
  123795. /**
  123796. * Gets or sets the associated variable name in the shader
  123797. */
  123798. associatedVariableName: string;
  123799. /** Gets or sets the type of animation applied to the input */
  123800. animationType: AnimatedInputBlockTypes;
  123801. /**
  123802. * Gets a boolean indicating that this connection point not defined yet
  123803. */
  123804. readonly isUndefined: boolean;
  123805. /**
  123806. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123807. * In this case the connection point name must be the name of the uniform to use.
  123808. * Can only be set on inputs
  123809. */
  123810. isUniform: boolean;
  123811. /**
  123812. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123813. * In this case the connection point name must be the name of the attribute to use
  123814. * Can only be set on inputs
  123815. */
  123816. isAttribute: boolean;
  123817. /**
  123818. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123819. * Can only be set on exit points
  123820. */
  123821. isVarying: boolean;
  123822. /**
  123823. * Gets a boolean indicating that the current connection point is a system value
  123824. */
  123825. readonly isSystemValue: boolean;
  123826. /**
  123827. * Gets or sets the current well known value or null if not defined as a system value
  123828. */
  123829. systemValue: Nullable<NodeMaterialSystemValues>;
  123830. /**
  123831. * Gets the current class name
  123832. * @returns the class name
  123833. */
  123834. getClassName(): string;
  123835. /**
  123836. * Animate the input if animationType !== None
  123837. * @param scene defines the rendering scene
  123838. */
  123839. animate(scene: Scene): void;
  123840. private _emitDefine;
  123841. initialize(state: NodeMaterialBuildState): void;
  123842. /**
  123843. * Set the input block to its default value (based on its type)
  123844. */
  123845. setDefaultValue(): void;
  123846. private _emitConstant;
  123847. private _emit;
  123848. /** @hidden */
  123849. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123850. /** @hidden */
  123851. _transmit(effect: Effect, scene: Scene): void;
  123852. protected _buildBlock(state: NodeMaterialBuildState): void;
  123853. protected _dumpPropertiesCode(): string;
  123854. serialize(): any;
  123855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123856. }
  123857. }
  123858. declare module BABYLON {
  123859. /**
  123860. * Enum used to define the compatibility state between two connection points
  123861. */
  123862. export enum NodeMaterialConnectionPointCompatibilityStates {
  123863. /** Points are compatibles */
  123864. Compatible = 0,
  123865. /** Points are incompatible because of their types */
  123866. TypeIncompatible = 1,
  123867. /** Points are incompatible because of their targets (vertex vs fragment) */
  123868. TargetIncompatible = 2
  123869. }
  123870. /**
  123871. * Defines the direction of a connection point
  123872. */
  123873. export enum NodeMaterialConnectionPointDirection {
  123874. /** Input */
  123875. Input = 0,
  123876. /** Output */
  123877. Output = 1
  123878. }
  123879. /**
  123880. * Defines a connection point for a block
  123881. */
  123882. export class NodeMaterialConnectionPoint {
  123883. /** @hidden */
  123884. _ownerBlock: NodeMaterialBlock;
  123885. /** @hidden */
  123886. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123887. private _endpoints;
  123888. private _associatedVariableName;
  123889. private _direction;
  123890. /** @hidden */
  123891. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123892. /** @hidden */
  123893. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123894. private _type;
  123895. /** @hidden */
  123896. _enforceAssociatedVariableName: boolean;
  123897. /** Gets the direction of the point */
  123898. readonly direction: NodeMaterialConnectionPointDirection;
  123899. /**
  123900. * Gets or sets the additional types supported by this connection point
  123901. */
  123902. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123903. /**
  123904. * Gets or sets the additional types excluded by this connection point
  123905. */
  123906. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123907. /**
  123908. * Observable triggered when this point is connected
  123909. */
  123910. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123911. /**
  123912. * Gets or sets the associated variable name in the shader
  123913. */
  123914. associatedVariableName: string;
  123915. /**
  123916. * Gets or sets the connection point type (default is float)
  123917. */
  123918. type: NodeMaterialBlockConnectionPointTypes;
  123919. /**
  123920. * Gets or sets the connection point name
  123921. */
  123922. name: string;
  123923. /**
  123924. * Gets or sets a boolean indicating that this connection point can be omitted
  123925. */
  123926. isOptional: boolean;
  123927. /**
  123928. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123929. */
  123930. define: string;
  123931. /** @hidden */
  123932. _prioritizeVertex: boolean;
  123933. private _target;
  123934. /** Gets or sets the target of that connection point */
  123935. target: NodeMaterialBlockTargets;
  123936. /**
  123937. * Gets a boolean indicating that the current point is connected
  123938. */
  123939. readonly isConnected: boolean;
  123940. /**
  123941. * Gets a boolean indicating that the current point is connected to an input block
  123942. */
  123943. readonly isConnectedToInputBlock: boolean;
  123944. /**
  123945. * Gets a the connected input block (if any)
  123946. */
  123947. readonly connectInputBlock: Nullable<InputBlock>;
  123948. /** Get the other side of the connection (if any) */
  123949. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123950. /** Get the block that owns this connection point */
  123951. readonly ownerBlock: NodeMaterialBlock;
  123952. /** Get the block connected on the other side of this connection (if any) */
  123953. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  123954. /** Get the block connected on the endpoints of this connection (if any) */
  123955. readonly connectedBlocks: Array<NodeMaterialBlock>;
  123956. /** Gets the list of connected endpoints */
  123957. readonly endpoints: NodeMaterialConnectionPoint[];
  123958. /** Gets a boolean indicating if that output point is connected to at least one input */
  123959. readonly hasEndpoints: boolean;
  123960. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  123961. readonly isConnectedInVertexShader: boolean;
  123962. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  123963. readonly isConnectedInFragmentShader: boolean;
  123964. /**
  123965. * Creates a new connection point
  123966. * @param name defines the connection point name
  123967. * @param ownerBlock defines the block hosting this connection point
  123968. * @param direction defines the direction of the connection point
  123969. */
  123970. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  123971. /**
  123972. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  123973. * @returns the class name
  123974. */
  123975. getClassName(): string;
  123976. /**
  123977. * Gets a boolean indicating if the current point can be connected to another point
  123978. * @param connectionPoint defines the other connection point
  123979. * @returns a boolean
  123980. */
  123981. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  123982. /**
  123983. * Gets a number indicating if the current point can be connected to another point
  123984. * @param connectionPoint defines the other connection point
  123985. * @returns a number defining the compatibility state
  123986. */
  123987. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  123988. /**
  123989. * Connect this point to another connection point
  123990. * @param connectionPoint defines the other connection point
  123991. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  123992. * @returns the current connection point
  123993. */
  123994. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  123995. /**
  123996. * Disconnect this point from one of his endpoint
  123997. * @param endpoint defines the other connection point
  123998. * @returns the current connection point
  123999. */
  124000. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  124001. /**
  124002. * Serializes this point in a JSON representation
  124003. * @returns the serialized point object
  124004. */
  124005. serialize(): any;
  124006. /**
  124007. * Release resources
  124008. */
  124009. dispose(): void;
  124010. }
  124011. }
  124012. declare module BABYLON {
  124013. /**
  124014. * Block used to add support for vertex skinning (bones)
  124015. */
  124016. export class BonesBlock extends NodeMaterialBlock {
  124017. /**
  124018. * Creates a new BonesBlock
  124019. * @param name defines the block name
  124020. */
  124021. constructor(name: string);
  124022. /**
  124023. * Initialize the block and prepare the context for build
  124024. * @param state defines the state that will be used for the build
  124025. */
  124026. initialize(state: NodeMaterialBuildState): void;
  124027. /**
  124028. * Gets the current class name
  124029. * @returns the class name
  124030. */
  124031. getClassName(): string;
  124032. /**
  124033. * Gets the matrix indices input component
  124034. */
  124035. readonly matricesIndices: NodeMaterialConnectionPoint;
  124036. /**
  124037. * Gets the matrix weights input component
  124038. */
  124039. readonly matricesWeights: NodeMaterialConnectionPoint;
  124040. /**
  124041. * Gets the extra matrix indices input component
  124042. */
  124043. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124044. /**
  124045. * Gets the extra matrix weights input component
  124046. */
  124047. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124048. /**
  124049. * Gets the world input component
  124050. */
  124051. readonly world: NodeMaterialConnectionPoint;
  124052. /**
  124053. * Gets the output component
  124054. */
  124055. readonly output: NodeMaterialConnectionPoint;
  124056. autoConfigure(material: NodeMaterial): void;
  124057. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124058. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124060. protected _buildBlock(state: NodeMaterialBuildState): this;
  124061. }
  124062. }
  124063. declare module BABYLON {
  124064. /**
  124065. * Block used to add support for instances
  124066. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124067. */
  124068. export class InstancesBlock extends NodeMaterialBlock {
  124069. /**
  124070. * Creates a new InstancesBlock
  124071. * @param name defines the block name
  124072. */
  124073. constructor(name: string);
  124074. /**
  124075. * Gets the current class name
  124076. * @returns the class name
  124077. */
  124078. getClassName(): string;
  124079. /**
  124080. * Gets the first world row input component
  124081. */
  124082. readonly world0: NodeMaterialConnectionPoint;
  124083. /**
  124084. * Gets the second world row input component
  124085. */
  124086. readonly world1: NodeMaterialConnectionPoint;
  124087. /**
  124088. * Gets the third world row input component
  124089. */
  124090. readonly world2: NodeMaterialConnectionPoint;
  124091. /**
  124092. * Gets the forth world row input component
  124093. */
  124094. readonly world3: NodeMaterialConnectionPoint;
  124095. /**
  124096. * Gets the world input component
  124097. */
  124098. readonly world: NodeMaterialConnectionPoint;
  124099. /**
  124100. * Gets the output component
  124101. */
  124102. readonly output: NodeMaterialConnectionPoint;
  124103. autoConfigure(material: NodeMaterial): void;
  124104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124105. protected _buildBlock(state: NodeMaterialBuildState): this;
  124106. }
  124107. }
  124108. declare module BABYLON {
  124109. /**
  124110. * Block used to add morph targets support to vertex shader
  124111. */
  124112. export class MorphTargetsBlock extends NodeMaterialBlock {
  124113. private _repeatableContentAnchor;
  124114. private _repeatebleContentGenerated;
  124115. /**
  124116. * Create a new MorphTargetsBlock
  124117. * @param name defines the block name
  124118. */
  124119. constructor(name: string);
  124120. /**
  124121. * Gets the current class name
  124122. * @returns the class name
  124123. */
  124124. getClassName(): string;
  124125. /**
  124126. * Gets the position input component
  124127. */
  124128. readonly position: NodeMaterialConnectionPoint;
  124129. /**
  124130. * Gets the normal input component
  124131. */
  124132. readonly normal: NodeMaterialConnectionPoint;
  124133. /**
  124134. * Gets the tangent input component
  124135. */
  124136. readonly tangent: NodeMaterialConnectionPoint;
  124137. /**
  124138. * Gets the tangent input component
  124139. */
  124140. readonly uv: NodeMaterialConnectionPoint;
  124141. /**
  124142. * Gets the position output component
  124143. */
  124144. readonly positionOutput: NodeMaterialConnectionPoint;
  124145. /**
  124146. * Gets the normal output component
  124147. */
  124148. readonly normalOutput: NodeMaterialConnectionPoint;
  124149. /**
  124150. * Gets the tangent output component
  124151. */
  124152. readonly tangentOutput: NodeMaterialConnectionPoint;
  124153. /**
  124154. * Gets the tangent output component
  124155. */
  124156. readonly uvOutput: NodeMaterialConnectionPoint;
  124157. initialize(state: NodeMaterialBuildState): void;
  124158. autoConfigure(material: NodeMaterial): void;
  124159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124161. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124162. protected _buildBlock(state: NodeMaterialBuildState): this;
  124163. }
  124164. }
  124165. declare module BABYLON {
  124166. /**
  124167. * Block used to get data information from a light
  124168. */
  124169. export class LightInformationBlock extends NodeMaterialBlock {
  124170. private _lightDataUniformName;
  124171. private _lightColorUniformName;
  124172. private _lightTypeDefineName;
  124173. /**
  124174. * Gets or sets the light associated with this block
  124175. */
  124176. light: Nullable<Light>;
  124177. /**
  124178. * Creates a new LightInformationBlock
  124179. * @param name defines the block name
  124180. */
  124181. constructor(name: string);
  124182. /**
  124183. * Gets the current class name
  124184. * @returns the class name
  124185. */
  124186. getClassName(): string;
  124187. /**
  124188. * Gets the world position input component
  124189. */
  124190. readonly worldPosition: NodeMaterialConnectionPoint;
  124191. /**
  124192. * Gets the direction output component
  124193. */
  124194. readonly direction: NodeMaterialConnectionPoint;
  124195. /**
  124196. * Gets the direction output component
  124197. */
  124198. readonly color: NodeMaterialConnectionPoint;
  124199. /**
  124200. * Gets the direction output component
  124201. */
  124202. readonly intensity: NodeMaterialConnectionPoint;
  124203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124204. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124205. protected _buildBlock(state: NodeMaterialBuildState): this;
  124206. serialize(): any;
  124207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124208. }
  124209. }
  124210. declare module BABYLON {
  124211. /**
  124212. * Block used to add image processing support to fragment shader
  124213. */
  124214. export class ImageProcessingBlock extends NodeMaterialBlock {
  124215. /**
  124216. * Create a new ImageProcessingBlock
  124217. * @param name defines the block name
  124218. */
  124219. constructor(name: string);
  124220. /**
  124221. * Gets the current class name
  124222. * @returns the class name
  124223. */
  124224. getClassName(): string;
  124225. /**
  124226. * Gets the color input component
  124227. */
  124228. readonly color: NodeMaterialConnectionPoint;
  124229. /**
  124230. * Gets the output component
  124231. */
  124232. readonly output: NodeMaterialConnectionPoint;
  124233. /**
  124234. * Initialize the block and prepare the context for build
  124235. * @param state defines the state that will be used for the build
  124236. */
  124237. initialize(state: NodeMaterialBuildState): void;
  124238. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124241. protected _buildBlock(state: NodeMaterialBuildState): this;
  124242. }
  124243. }
  124244. declare module BABYLON {
  124245. /**
  124246. * Block used to pertub normals based on a normal map
  124247. */
  124248. export class PerturbNormalBlock extends NodeMaterialBlock {
  124249. private _tangentSpaceParameterName;
  124250. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124251. invertX: boolean;
  124252. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124253. invertY: boolean;
  124254. /**
  124255. * Create a new PerturbNormalBlock
  124256. * @param name defines the block name
  124257. */
  124258. constructor(name: string);
  124259. /**
  124260. * Gets the current class name
  124261. * @returns the class name
  124262. */
  124263. getClassName(): string;
  124264. /**
  124265. * Gets the world position input component
  124266. */
  124267. readonly worldPosition: NodeMaterialConnectionPoint;
  124268. /**
  124269. * Gets the world normal input component
  124270. */
  124271. readonly worldNormal: NodeMaterialConnectionPoint;
  124272. /**
  124273. * Gets the uv input component
  124274. */
  124275. readonly uv: NodeMaterialConnectionPoint;
  124276. /**
  124277. * Gets the normal map color input component
  124278. */
  124279. readonly normalMapColor: NodeMaterialConnectionPoint;
  124280. /**
  124281. * Gets the strength input component
  124282. */
  124283. readonly strength: NodeMaterialConnectionPoint;
  124284. /**
  124285. * Gets the output component
  124286. */
  124287. readonly output: NodeMaterialConnectionPoint;
  124288. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124289. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124290. autoConfigure(material: NodeMaterial): void;
  124291. protected _buildBlock(state: NodeMaterialBuildState): this;
  124292. protected _dumpPropertiesCode(): string;
  124293. serialize(): any;
  124294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124295. }
  124296. }
  124297. declare module BABYLON {
  124298. /**
  124299. * Block used to discard a pixel if a value is smaller than a cutoff
  124300. */
  124301. export class DiscardBlock extends NodeMaterialBlock {
  124302. /**
  124303. * Create a new DiscardBlock
  124304. * @param name defines the block name
  124305. */
  124306. constructor(name: string);
  124307. /**
  124308. * Gets the current class name
  124309. * @returns the class name
  124310. */
  124311. getClassName(): string;
  124312. /**
  124313. * Gets the color input component
  124314. */
  124315. readonly value: NodeMaterialConnectionPoint;
  124316. /**
  124317. * Gets the cutoff input component
  124318. */
  124319. readonly cutoff: NodeMaterialConnectionPoint;
  124320. protected _buildBlock(state: NodeMaterialBuildState): this;
  124321. }
  124322. }
  124323. declare module BABYLON {
  124324. /**
  124325. * Block used to test if the fragment shader is front facing
  124326. */
  124327. export class FrontFacingBlock extends NodeMaterialBlock {
  124328. /**
  124329. * Creates a new FrontFacingBlock
  124330. * @param name defines the block name
  124331. */
  124332. constructor(name: string);
  124333. /**
  124334. * Gets the current class name
  124335. * @returns the class name
  124336. */
  124337. getClassName(): string;
  124338. /**
  124339. * Gets the output component
  124340. */
  124341. readonly output: NodeMaterialConnectionPoint;
  124342. protected _buildBlock(state: NodeMaterialBuildState): this;
  124343. }
  124344. }
  124345. declare module BABYLON {
  124346. /**
  124347. * Block used to get the derivative value on x and y of a given input
  124348. */
  124349. export class DerivativeBlock extends NodeMaterialBlock {
  124350. /**
  124351. * Create a new DerivativeBlock
  124352. * @param name defines the block name
  124353. */
  124354. constructor(name: string);
  124355. /**
  124356. * Gets the current class name
  124357. * @returns the class name
  124358. */
  124359. getClassName(): string;
  124360. /**
  124361. * Gets the input component
  124362. */
  124363. readonly input: NodeMaterialConnectionPoint;
  124364. /**
  124365. * Gets the derivative output on x
  124366. */
  124367. readonly dx: NodeMaterialConnectionPoint;
  124368. /**
  124369. * Gets the derivative output on y
  124370. */
  124371. readonly dy: NodeMaterialConnectionPoint;
  124372. protected _buildBlock(state: NodeMaterialBuildState): this;
  124373. }
  124374. }
  124375. declare module BABYLON {
  124376. /**
  124377. * Block used to add support for scene fog
  124378. */
  124379. export class FogBlock extends NodeMaterialBlock {
  124380. private _fogDistanceName;
  124381. private _fogParameters;
  124382. /**
  124383. * Create a new FogBlock
  124384. * @param name defines the block name
  124385. */
  124386. constructor(name: string);
  124387. /**
  124388. * Gets the current class name
  124389. * @returns the class name
  124390. */
  124391. getClassName(): string;
  124392. /**
  124393. * Gets the world position input component
  124394. */
  124395. readonly worldPosition: NodeMaterialConnectionPoint;
  124396. /**
  124397. * Gets the view input component
  124398. */
  124399. readonly view: NodeMaterialConnectionPoint;
  124400. /**
  124401. * Gets the color input component
  124402. */
  124403. readonly input: NodeMaterialConnectionPoint;
  124404. /**
  124405. * Gets the fog color input component
  124406. */
  124407. readonly fogColor: NodeMaterialConnectionPoint;
  124408. /**
  124409. * Gets the output component
  124410. */
  124411. readonly output: NodeMaterialConnectionPoint;
  124412. autoConfigure(material: NodeMaterial): void;
  124413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124415. protected _buildBlock(state: NodeMaterialBuildState): this;
  124416. }
  124417. }
  124418. declare module BABYLON {
  124419. /**
  124420. * Block used to add light in the fragment shader
  124421. */
  124422. export class LightBlock extends NodeMaterialBlock {
  124423. private _lightId;
  124424. /**
  124425. * Gets or sets the light associated with this block
  124426. */
  124427. light: Nullable<Light>;
  124428. /**
  124429. * Create a new LightBlock
  124430. * @param name defines the block name
  124431. */
  124432. constructor(name: string);
  124433. /**
  124434. * Gets the current class name
  124435. * @returns the class name
  124436. */
  124437. getClassName(): string;
  124438. /**
  124439. * Gets the world position input component
  124440. */
  124441. readonly worldPosition: NodeMaterialConnectionPoint;
  124442. /**
  124443. * Gets the world normal input component
  124444. */
  124445. readonly worldNormal: NodeMaterialConnectionPoint;
  124446. /**
  124447. * Gets the camera (or eye) position component
  124448. */
  124449. readonly cameraPosition: NodeMaterialConnectionPoint;
  124450. /**
  124451. * Gets the glossiness component
  124452. */
  124453. readonly glossiness: NodeMaterialConnectionPoint;
  124454. /**
  124455. * Gets the glossinness power component
  124456. */
  124457. readonly glossPower: NodeMaterialConnectionPoint;
  124458. /**
  124459. * Gets the diffuse color component
  124460. */
  124461. readonly diffuseColor: NodeMaterialConnectionPoint;
  124462. /**
  124463. * Gets the specular color component
  124464. */
  124465. readonly specularColor: NodeMaterialConnectionPoint;
  124466. /**
  124467. * Gets the diffuse output component
  124468. */
  124469. readonly diffuseOutput: NodeMaterialConnectionPoint;
  124470. /**
  124471. * Gets the specular output component
  124472. */
  124473. readonly specularOutput: NodeMaterialConnectionPoint;
  124474. autoConfigure(material: NodeMaterial): void;
  124475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124476. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124478. private _injectVertexCode;
  124479. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124480. serialize(): any;
  124481. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124482. }
  124483. }
  124484. declare module BABYLON {
  124485. /**
  124486. * Block used to multiply 2 values
  124487. */
  124488. export class MultiplyBlock extends NodeMaterialBlock {
  124489. /**
  124490. * Creates a new MultiplyBlock
  124491. * @param name defines the block name
  124492. */
  124493. constructor(name: string);
  124494. /**
  124495. * Gets the current class name
  124496. * @returns the class name
  124497. */
  124498. getClassName(): string;
  124499. /**
  124500. * Gets the left operand input component
  124501. */
  124502. readonly left: NodeMaterialConnectionPoint;
  124503. /**
  124504. * Gets the right operand input component
  124505. */
  124506. readonly right: NodeMaterialConnectionPoint;
  124507. /**
  124508. * Gets the output component
  124509. */
  124510. readonly output: NodeMaterialConnectionPoint;
  124511. protected _buildBlock(state: NodeMaterialBuildState): this;
  124512. }
  124513. }
  124514. declare module BABYLON {
  124515. /**
  124516. * Block used to add 2 vectors
  124517. */
  124518. export class AddBlock extends NodeMaterialBlock {
  124519. /**
  124520. * Creates a new AddBlock
  124521. * @param name defines the block name
  124522. */
  124523. constructor(name: string);
  124524. /**
  124525. * Gets the current class name
  124526. * @returns the class name
  124527. */
  124528. getClassName(): string;
  124529. /**
  124530. * Gets the left operand input component
  124531. */
  124532. readonly left: NodeMaterialConnectionPoint;
  124533. /**
  124534. * Gets the right operand input component
  124535. */
  124536. readonly right: NodeMaterialConnectionPoint;
  124537. /**
  124538. * Gets the output component
  124539. */
  124540. readonly output: NodeMaterialConnectionPoint;
  124541. protected _buildBlock(state: NodeMaterialBuildState): this;
  124542. }
  124543. }
  124544. declare module BABYLON {
  124545. /**
  124546. * Block used to scale a vector by a float
  124547. */
  124548. export class ScaleBlock extends NodeMaterialBlock {
  124549. /**
  124550. * Creates a new ScaleBlock
  124551. * @param name defines the block name
  124552. */
  124553. constructor(name: string);
  124554. /**
  124555. * Gets the current class name
  124556. * @returns the class name
  124557. */
  124558. getClassName(): string;
  124559. /**
  124560. * Gets the input component
  124561. */
  124562. readonly input: NodeMaterialConnectionPoint;
  124563. /**
  124564. * Gets the factor input component
  124565. */
  124566. readonly factor: NodeMaterialConnectionPoint;
  124567. /**
  124568. * Gets the output component
  124569. */
  124570. readonly output: NodeMaterialConnectionPoint;
  124571. protected _buildBlock(state: NodeMaterialBuildState): this;
  124572. }
  124573. }
  124574. declare module BABYLON {
  124575. /**
  124576. * Block used to clamp a float
  124577. */
  124578. export class ClampBlock extends NodeMaterialBlock {
  124579. /** Gets or sets the minimum range */
  124580. minimum: number;
  124581. /** Gets or sets the maximum range */
  124582. maximum: number;
  124583. /**
  124584. * Creates a new ClampBlock
  124585. * @param name defines the block name
  124586. */
  124587. constructor(name: string);
  124588. /**
  124589. * Gets the current class name
  124590. * @returns the class name
  124591. */
  124592. getClassName(): string;
  124593. /**
  124594. * Gets the value input component
  124595. */
  124596. readonly value: NodeMaterialConnectionPoint;
  124597. /**
  124598. * Gets the output component
  124599. */
  124600. readonly output: NodeMaterialConnectionPoint;
  124601. protected _buildBlock(state: NodeMaterialBuildState): this;
  124602. protected _dumpPropertiesCode(): string;
  124603. serialize(): any;
  124604. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124605. }
  124606. }
  124607. declare module BABYLON {
  124608. /**
  124609. * Block used to apply a cross product between 2 vectors
  124610. */
  124611. export class CrossBlock extends NodeMaterialBlock {
  124612. /**
  124613. * Creates a new CrossBlock
  124614. * @param name defines the block name
  124615. */
  124616. constructor(name: string);
  124617. /**
  124618. * Gets the current class name
  124619. * @returns the class name
  124620. */
  124621. getClassName(): string;
  124622. /**
  124623. * Gets the left operand input component
  124624. */
  124625. readonly left: NodeMaterialConnectionPoint;
  124626. /**
  124627. * Gets the right operand input component
  124628. */
  124629. readonly right: NodeMaterialConnectionPoint;
  124630. /**
  124631. * Gets the output component
  124632. */
  124633. readonly output: NodeMaterialConnectionPoint;
  124634. protected _buildBlock(state: NodeMaterialBuildState): this;
  124635. }
  124636. }
  124637. declare module BABYLON {
  124638. /**
  124639. * Block used to apply a dot product between 2 vectors
  124640. */
  124641. export class DotBlock extends NodeMaterialBlock {
  124642. /**
  124643. * Creates a new DotBlock
  124644. * @param name defines the block name
  124645. */
  124646. constructor(name: string);
  124647. /**
  124648. * Gets the current class name
  124649. * @returns the class name
  124650. */
  124651. getClassName(): string;
  124652. /**
  124653. * Gets the left operand input component
  124654. */
  124655. readonly left: NodeMaterialConnectionPoint;
  124656. /**
  124657. * Gets the right operand input component
  124658. */
  124659. readonly right: NodeMaterialConnectionPoint;
  124660. /**
  124661. * Gets the output component
  124662. */
  124663. readonly output: NodeMaterialConnectionPoint;
  124664. protected _buildBlock(state: NodeMaterialBuildState): this;
  124665. }
  124666. }
  124667. declare module BABYLON {
  124668. /**
  124669. * Block used to remap a float from a range to a new one
  124670. */
  124671. export class RemapBlock extends NodeMaterialBlock {
  124672. /**
  124673. * Gets or sets the source range
  124674. */
  124675. sourceRange: Vector2;
  124676. /**
  124677. * Gets or sets the target range
  124678. */
  124679. targetRange: Vector2;
  124680. /**
  124681. * Creates a new RemapBlock
  124682. * @param name defines the block name
  124683. */
  124684. constructor(name: string);
  124685. /**
  124686. * Gets the current class name
  124687. * @returns the class name
  124688. */
  124689. getClassName(): string;
  124690. /**
  124691. * Gets the input component
  124692. */
  124693. readonly input: NodeMaterialConnectionPoint;
  124694. /**
  124695. * Gets the source min input component
  124696. */
  124697. readonly sourceMin: NodeMaterialConnectionPoint;
  124698. /**
  124699. * Gets the source max input component
  124700. */
  124701. readonly sourceMax: NodeMaterialConnectionPoint;
  124702. /**
  124703. * Gets the target min input component
  124704. */
  124705. readonly targetMin: NodeMaterialConnectionPoint;
  124706. /**
  124707. * Gets the target max input component
  124708. */
  124709. readonly targetMax: NodeMaterialConnectionPoint;
  124710. /**
  124711. * Gets the output component
  124712. */
  124713. readonly output: NodeMaterialConnectionPoint;
  124714. protected _buildBlock(state: NodeMaterialBuildState): this;
  124715. protected _dumpPropertiesCode(): string;
  124716. serialize(): any;
  124717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124718. }
  124719. }
  124720. declare module BABYLON {
  124721. /**
  124722. * Block used to normalize a vector
  124723. */
  124724. export class NormalizeBlock extends NodeMaterialBlock {
  124725. /**
  124726. * Creates a new NormalizeBlock
  124727. * @param name defines the block name
  124728. */
  124729. constructor(name: string);
  124730. /**
  124731. * Gets the current class name
  124732. * @returns the class name
  124733. */
  124734. getClassName(): string;
  124735. /**
  124736. * Gets the input component
  124737. */
  124738. readonly input: NodeMaterialConnectionPoint;
  124739. /**
  124740. * Gets the output component
  124741. */
  124742. readonly output: NodeMaterialConnectionPoint;
  124743. protected _buildBlock(state: NodeMaterialBuildState): this;
  124744. }
  124745. }
  124746. declare module BABYLON {
  124747. /**
  124748. * Operations supported by the Trigonometry block
  124749. */
  124750. export enum TrigonometryBlockOperations {
  124751. /** Cos */
  124752. Cos = 0,
  124753. /** Sin */
  124754. Sin = 1,
  124755. /** Abs */
  124756. Abs = 2,
  124757. /** Exp */
  124758. Exp = 3,
  124759. /** Exp2 */
  124760. Exp2 = 4,
  124761. /** Round */
  124762. Round = 5,
  124763. /** Floor */
  124764. Floor = 6,
  124765. /** Ceiling */
  124766. Ceiling = 7,
  124767. /** Square root */
  124768. Sqrt = 8,
  124769. /** Log */
  124770. Log = 9,
  124771. /** Tangent */
  124772. Tan = 10,
  124773. /** Arc tangent */
  124774. ArcTan = 11,
  124775. /** Arc cosinus */
  124776. ArcCos = 12,
  124777. /** Arc sinus */
  124778. ArcSin = 13,
  124779. /** Fraction */
  124780. Fract = 14,
  124781. /** Sign */
  124782. Sign = 15,
  124783. /** To radians (from degrees) */
  124784. Radians = 16,
  124785. /** To degrees (from radians) */
  124786. Degrees = 17
  124787. }
  124788. /**
  124789. * Block used to apply trigonometry operation to floats
  124790. */
  124791. export class TrigonometryBlock extends NodeMaterialBlock {
  124792. /**
  124793. * Gets or sets the operation applied by the block
  124794. */
  124795. operation: TrigonometryBlockOperations;
  124796. /**
  124797. * Creates a new TrigonometryBlock
  124798. * @param name defines the block name
  124799. */
  124800. constructor(name: string);
  124801. /**
  124802. * Gets the current class name
  124803. * @returns the class name
  124804. */
  124805. getClassName(): string;
  124806. /**
  124807. * Gets the input component
  124808. */
  124809. readonly input: NodeMaterialConnectionPoint;
  124810. /**
  124811. * Gets the output component
  124812. */
  124813. readonly output: NodeMaterialConnectionPoint;
  124814. protected _buildBlock(state: NodeMaterialBuildState): this;
  124815. serialize(): any;
  124816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124817. protected _dumpPropertiesCode(): string;
  124818. }
  124819. }
  124820. declare module BABYLON {
  124821. /**
  124822. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124823. */
  124824. export class ColorMergerBlock extends NodeMaterialBlock {
  124825. /**
  124826. * Create a new ColorMergerBlock
  124827. * @param name defines the block name
  124828. */
  124829. constructor(name: string);
  124830. /**
  124831. * Gets the current class name
  124832. * @returns the class name
  124833. */
  124834. getClassName(): string;
  124835. /**
  124836. * Gets the rgb component (input)
  124837. */
  124838. readonly rgbIn: NodeMaterialConnectionPoint;
  124839. /**
  124840. * Gets the r component (input)
  124841. */
  124842. readonly r: NodeMaterialConnectionPoint;
  124843. /**
  124844. * Gets the g component (input)
  124845. */
  124846. readonly g: NodeMaterialConnectionPoint;
  124847. /**
  124848. * Gets the b component (input)
  124849. */
  124850. readonly b: NodeMaterialConnectionPoint;
  124851. /**
  124852. * Gets the a component (input)
  124853. */
  124854. readonly a: NodeMaterialConnectionPoint;
  124855. /**
  124856. * Gets the rgba component (output)
  124857. */
  124858. readonly rgba: NodeMaterialConnectionPoint;
  124859. /**
  124860. * Gets the rgb component (output)
  124861. */
  124862. readonly rgbOut: NodeMaterialConnectionPoint;
  124863. /**
  124864. * Gets the rgb component (output)
  124865. * @deprecated Please use rgbOut instead.
  124866. */
  124867. readonly rgb: NodeMaterialConnectionPoint;
  124868. protected _buildBlock(state: NodeMaterialBuildState): this;
  124869. }
  124870. }
  124871. declare module BABYLON {
  124872. /**
  124873. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124874. */
  124875. export class VectorMergerBlock extends NodeMaterialBlock {
  124876. /**
  124877. * Create a new VectorMergerBlock
  124878. * @param name defines the block name
  124879. */
  124880. constructor(name: string);
  124881. /**
  124882. * Gets the current class name
  124883. * @returns the class name
  124884. */
  124885. getClassName(): string;
  124886. /**
  124887. * Gets the xyz component (input)
  124888. */
  124889. readonly xyzIn: NodeMaterialConnectionPoint;
  124890. /**
  124891. * Gets the xy component (input)
  124892. */
  124893. readonly xyIn: NodeMaterialConnectionPoint;
  124894. /**
  124895. * Gets the x component (input)
  124896. */
  124897. readonly x: NodeMaterialConnectionPoint;
  124898. /**
  124899. * Gets the y component (input)
  124900. */
  124901. readonly y: NodeMaterialConnectionPoint;
  124902. /**
  124903. * Gets the z component (input)
  124904. */
  124905. readonly z: NodeMaterialConnectionPoint;
  124906. /**
  124907. * Gets the w component (input)
  124908. */
  124909. readonly w: NodeMaterialConnectionPoint;
  124910. /**
  124911. * Gets the xyzw component (output)
  124912. */
  124913. readonly xyzw: NodeMaterialConnectionPoint;
  124914. /**
  124915. * Gets the xyz component (output)
  124916. */
  124917. readonly xyzOut: NodeMaterialConnectionPoint;
  124918. /**
  124919. * Gets the xy component (output)
  124920. */
  124921. readonly xyOut: NodeMaterialConnectionPoint;
  124922. /**
  124923. * Gets the xy component (output)
  124924. * @deprecated Please use xyOut instead.
  124925. */
  124926. readonly xy: NodeMaterialConnectionPoint;
  124927. /**
  124928. * Gets the xyz component (output)
  124929. * @deprecated Please use xyzOut instead.
  124930. */
  124931. readonly xyz: NodeMaterialConnectionPoint;
  124932. protected _buildBlock(state: NodeMaterialBuildState): this;
  124933. }
  124934. }
  124935. declare module BABYLON {
  124936. /**
  124937. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  124938. */
  124939. export class ColorSplitterBlock extends NodeMaterialBlock {
  124940. /**
  124941. * Create a new ColorSplitterBlock
  124942. * @param name defines the block name
  124943. */
  124944. constructor(name: string);
  124945. /**
  124946. * Gets the current class name
  124947. * @returns the class name
  124948. */
  124949. getClassName(): string;
  124950. /**
  124951. * Gets the rgba component (input)
  124952. */
  124953. readonly rgba: NodeMaterialConnectionPoint;
  124954. /**
  124955. * Gets the rgb component (input)
  124956. */
  124957. readonly rgbIn: NodeMaterialConnectionPoint;
  124958. /**
  124959. * Gets the rgb component (output)
  124960. */
  124961. readonly rgbOut: NodeMaterialConnectionPoint;
  124962. /**
  124963. * Gets the r component (output)
  124964. */
  124965. readonly r: NodeMaterialConnectionPoint;
  124966. /**
  124967. * Gets the g component (output)
  124968. */
  124969. readonly g: NodeMaterialConnectionPoint;
  124970. /**
  124971. * Gets the b component (output)
  124972. */
  124973. readonly b: NodeMaterialConnectionPoint;
  124974. /**
  124975. * Gets the a component (output)
  124976. */
  124977. readonly a: NodeMaterialConnectionPoint;
  124978. protected _inputRename(name: string): string;
  124979. protected _outputRename(name: string): string;
  124980. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124981. }
  124982. }
  124983. declare module BABYLON {
  124984. /**
  124985. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  124986. */
  124987. export class VectorSplitterBlock extends NodeMaterialBlock {
  124988. /**
  124989. * Create a new VectorSplitterBlock
  124990. * @param name defines the block name
  124991. */
  124992. constructor(name: string);
  124993. /**
  124994. * Gets the current class name
  124995. * @returns the class name
  124996. */
  124997. getClassName(): string;
  124998. /**
  124999. * Gets the xyzw component (input)
  125000. */
  125001. readonly xyzw: NodeMaterialConnectionPoint;
  125002. /**
  125003. * Gets the xyz component (input)
  125004. */
  125005. readonly xyzIn: NodeMaterialConnectionPoint;
  125006. /**
  125007. * Gets the xy component (input)
  125008. */
  125009. readonly xyIn: NodeMaterialConnectionPoint;
  125010. /**
  125011. * Gets the xyz component (output)
  125012. */
  125013. readonly xyzOut: NodeMaterialConnectionPoint;
  125014. /**
  125015. * Gets the xy component (output)
  125016. */
  125017. readonly xyOut: NodeMaterialConnectionPoint;
  125018. /**
  125019. * Gets the x component (output)
  125020. */
  125021. readonly x: NodeMaterialConnectionPoint;
  125022. /**
  125023. * Gets the y component (output)
  125024. */
  125025. readonly y: NodeMaterialConnectionPoint;
  125026. /**
  125027. * Gets the z component (output)
  125028. */
  125029. readonly z: NodeMaterialConnectionPoint;
  125030. /**
  125031. * Gets the w component (output)
  125032. */
  125033. readonly w: NodeMaterialConnectionPoint;
  125034. protected _inputRename(name: string): string;
  125035. protected _outputRename(name: string): string;
  125036. protected _buildBlock(state: NodeMaterialBuildState): this;
  125037. }
  125038. }
  125039. declare module BABYLON {
  125040. /**
  125041. * Block used to lerp between 2 values
  125042. */
  125043. export class LerpBlock extends NodeMaterialBlock {
  125044. /**
  125045. * Creates a new LerpBlock
  125046. * @param name defines the block name
  125047. */
  125048. constructor(name: string);
  125049. /**
  125050. * Gets the current class name
  125051. * @returns the class name
  125052. */
  125053. getClassName(): string;
  125054. /**
  125055. * Gets the left operand input component
  125056. */
  125057. readonly left: NodeMaterialConnectionPoint;
  125058. /**
  125059. * Gets the right operand input component
  125060. */
  125061. readonly right: NodeMaterialConnectionPoint;
  125062. /**
  125063. * Gets the gradient operand input component
  125064. */
  125065. readonly gradient: NodeMaterialConnectionPoint;
  125066. /**
  125067. * Gets the output component
  125068. */
  125069. readonly output: NodeMaterialConnectionPoint;
  125070. protected _buildBlock(state: NodeMaterialBuildState): this;
  125071. }
  125072. }
  125073. declare module BABYLON {
  125074. /**
  125075. * Block used to divide 2 vectors
  125076. */
  125077. export class DivideBlock extends NodeMaterialBlock {
  125078. /**
  125079. * Creates a new DivideBlock
  125080. * @param name defines the block name
  125081. */
  125082. constructor(name: string);
  125083. /**
  125084. * Gets the current class name
  125085. * @returns the class name
  125086. */
  125087. getClassName(): string;
  125088. /**
  125089. * Gets the left operand input component
  125090. */
  125091. readonly left: NodeMaterialConnectionPoint;
  125092. /**
  125093. * Gets the right operand input component
  125094. */
  125095. readonly right: NodeMaterialConnectionPoint;
  125096. /**
  125097. * Gets the output component
  125098. */
  125099. readonly output: NodeMaterialConnectionPoint;
  125100. protected _buildBlock(state: NodeMaterialBuildState): this;
  125101. }
  125102. }
  125103. declare module BABYLON {
  125104. /**
  125105. * Block used to subtract 2 vectors
  125106. */
  125107. export class SubtractBlock extends NodeMaterialBlock {
  125108. /**
  125109. * Creates a new SubtractBlock
  125110. * @param name defines the block name
  125111. */
  125112. constructor(name: string);
  125113. /**
  125114. * Gets the current class name
  125115. * @returns the class name
  125116. */
  125117. getClassName(): string;
  125118. /**
  125119. * Gets the left operand input component
  125120. */
  125121. readonly left: NodeMaterialConnectionPoint;
  125122. /**
  125123. * Gets the right operand input component
  125124. */
  125125. readonly right: NodeMaterialConnectionPoint;
  125126. /**
  125127. * Gets the output component
  125128. */
  125129. readonly output: NodeMaterialConnectionPoint;
  125130. protected _buildBlock(state: NodeMaterialBuildState): this;
  125131. }
  125132. }
  125133. declare module BABYLON {
  125134. /**
  125135. * Block used to step a value
  125136. */
  125137. export class StepBlock extends NodeMaterialBlock {
  125138. /**
  125139. * Creates a new StepBlock
  125140. * @param name defines the block name
  125141. */
  125142. constructor(name: string);
  125143. /**
  125144. * Gets the current class name
  125145. * @returns the class name
  125146. */
  125147. getClassName(): string;
  125148. /**
  125149. * Gets the value operand input component
  125150. */
  125151. readonly value: NodeMaterialConnectionPoint;
  125152. /**
  125153. * Gets the edge operand input component
  125154. */
  125155. readonly edge: NodeMaterialConnectionPoint;
  125156. /**
  125157. * Gets the output component
  125158. */
  125159. readonly output: NodeMaterialConnectionPoint;
  125160. protected _buildBlock(state: NodeMaterialBuildState): this;
  125161. }
  125162. }
  125163. declare module BABYLON {
  125164. /**
  125165. * Block used to get the opposite (1 - x) of a value
  125166. */
  125167. export class OneMinusBlock extends NodeMaterialBlock {
  125168. /**
  125169. * Creates a new OneMinusBlock
  125170. * @param name defines the block name
  125171. */
  125172. constructor(name: string);
  125173. /**
  125174. * Gets the current class name
  125175. * @returns the class name
  125176. */
  125177. getClassName(): string;
  125178. /**
  125179. * Gets the input component
  125180. */
  125181. readonly input: NodeMaterialConnectionPoint;
  125182. /**
  125183. * Gets the output component
  125184. */
  125185. readonly output: NodeMaterialConnectionPoint;
  125186. protected _buildBlock(state: NodeMaterialBuildState): this;
  125187. }
  125188. }
  125189. declare module BABYLON {
  125190. /**
  125191. * Block used to get the view direction
  125192. */
  125193. export class ViewDirectionBlock extends NodeMaterialBlock {
  125194. /**
  125195. * Creates a new ViewDirectionBlock
  125196. * @param name defines the block name
  125197. */
  125198. constructor(name: string);
  125199. /**
  125200. * Gets the current class name
  125201. * @returns the class name
  125202. */
  125203. getClassName(): string;
  125204. /**
  125205. * Gets the world position component
  125206. */
  125207. readonly worldPosition: NodeMaterialConnectionPoint;
  125208. /**
  125209. * Gets the camera position component
  125210. */
  125211. readonly cameraPosition: NodeMaterialConnectionPoint;
  125212. /**
  125213. * Gets the output component
  125214. */
  125215. readonly output: NodeMaterialConnectionPoint;
  125216. autoConfigure(material: NodeMaterial): void;
  125217. protected _buildBlock(state: NodeMaterialBuildState): this;
  125218. }
  125219. }
  125220. declare module BABYLON {
  125221. /**
  125222. * Block used to compute fresnel value
  125223. */
  125224. export class FresnelBlock extends NodeMaterialBlock {
  125225. /**
  125226. * Create a new FresnelBlock
  125227. * @param name defines the block name
  125228. */
  125229. constructor(name: string);
  125230. /**
  125231. * Gets the current class name
  125232. * @returns the class name
  125233. */
  125234. getClassName(): string;
  125235. /**
  125236. * Gets the world normal input component
  125237. */
  125238. readonly worldNormal: NodeMaterialConnectionPoint;
  125239. /**
  125240. * Gets the view direction input component
  125241. */
  125242. readonly viewDirection: NodeMaterialConnectionPoint;
  125243. /**
  125244. * Gets the bias input component
  125245. */
  125246. readonly bias: NodeMaterialConnectionPoint;
  125247. /**
  125248. * Gets the camera (or eye) position component
  125249. */
  125250. readonly power: NodeMaterialConnectionPoint;
  125251. /**
  125252. * Gets the fresnel output component
  125253. */
  125254. readonly fresnel: NodeMaterialConnectionPoint;
  125255. autoConfigure(material: NodeMaterial): void;
  125256. protected _buildBlock(state: NodeMaterialBuildState): this;
  125257. }
  125258. }
  125259. declare module BABYLON {
  125260. /**
  125261. * Block used to get the max of 2 values
  125262. */
  125263. export class MaxBlock extends NodeMaterialBlock {
  125264. /**
  125265. * Creates a new MaxBlock
  125266. * @param name defines the block name
  125267. */
  125268. constructor(name: string);
  125269. /**
  125270. * Gets the current class name
  125271. * @returns the class name
  125272. */
  125273. getClassName(): string;
  125274. /**
  125275. * Gets the left operand input component
  125276. */
  125277. readonly left: NodeMaterialConnectionPoint;
  125278. /**
  125279. * Gets the right operand input component
  125280. */
  125281. readonly right: NodeMaterialConnectionPoint;
  125282. /**
  125283. * Gets the output component
  125284. */
  125285. readonly output: NodeMaterialConnectionPoint;
  125286. protected _buildBlock(state: NodeMaterialBuildState): this;
  125287. }
  125288. }
  125289. declare module BABYLON {
  125290. /**
  125291. * Block used to get the min of 2 values
  125292. */
  125293. export class MinBlock extends NodeMaterialBlock {
  125294. /**
  125295. * Creates a new MinBlock
  125296. * @param name defines the block name
  125297. */
  125298. constructor(name: string);
  125299. /**
  125300. * Gets the current class name
  125301. * @returns the class name
  125302. */
  125303. getClassName(): string;
  125304. /**
  125305. * Gets the left operand input component
  125306. */
  125307. readonly left: NodeMaterialConnectionPoint;
  125308. /**
  125309. * Gets the right operand input component
  125310. */
  125311. readonly right: NodeMaterialConnectionPoint;
  125312. /**
  125313. * Gets the output component
  125314. */
  125315. readonly output: NodeMaterialConnectionPoint;
  125316. protected _buildBlock(state: NodeMaterialBuildState): this;
  125317. }
  125318. }
  125319. declare module BABYLON {
  125320. /**
  125321. * Block used to get the distance between 2 values
  125322. */
  125323. export class DistanceBlock extends NodeMaterialBlock {
  125324. /**
  125325. * Creates a new DistanceBlock
  125326. * @param name defines the block name
  125327. */
  125328. constructor(name: string);
  125329. /**
  125330. * Gets the current class name
  125331. * @returns the class name
  125332. */
  125333. getClassName(): string;
  125334. /**
  125335. * Gets the left operand input component
  125336. */
  125337. readonly left: NodeMaterialConnectionPoint;
  125338. /**
  125339. * Gets the right operand input component
  125340. */
  125341. readonly right: NodeMaterialConnectionPoint;
  125342. /**
  125343. * Gets the output component
  125344. */
  125345. readonly output: NodeMaterialConnectionPoint;
  125346. protected _buildBlock(state: NodeMaterialBuildState): this;
  125347. }
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * Block used to get the length of a vector
  125352. */
  125353. export class LengthBlock extends NodeMaterialBlock {
  125354. /**
  125355. * Creates a new LengthBlock
  125356. * @param name defines the block name
  125357. */
  125358. constructor(name: string);
  125359. /**
  125360. * Gets the current class name
  125361. * @returns the class name
  125362. */
  125363. getClassName(): string;
  125364. /**
  125365. * Gets the value input component
  125366. */
  125367. readonly value: NodeMaterialConnectionPoint;
  125368. /**
  125369. * Gets the output component
  125370. */
  125371. readonly output: NodeMaterialConnectionPoint;
  125372. protected _buildBlock(state: NodeMaterialBuildState): this;
  125373. }
  125374. }
  125375. declare module BABYLON {
  125376. /**
  125377. * Block used to get negative version of a value (i.e. x * -1)
  125378. */
  125379. export class NegateBlock extends NodeMaterialBlock {
  125380. /**
  125381. * Creates a new NegateBlock
  125382. * @param name defines the block name
  125383. */
  125384. constructor(name: string);
  125385. /**
  125386. * Gets the current class name
  125387. * @returns the class name
  125388. */
  125389. getClassName(): string;
  125390. /**
  125391. * Gets the value input component
  125392. */
  125393. readonly value: NodeMaterialConnectionPoint;
  125394. /**
  125395. * Gets the output component
  125396. */
  125397. readonly output: NodeMaterialConnectionPoint;
  125398. protected _buildBlock(state: NodeMaterialBuildState): this;
  125399. }
  125400. }
  125401. declare module BABYLON {
  125402. /**
  125403. * Block used to get the value of the first parameter raised to the power of the second
  125404. */
  125405. export class PowBlock extends NodeMaterialBlock {
  125406. /**
  125407. * Creates a new PowBlock
  125408. * @param name defines the block name
  125409. */
  125410. constructor(name: string);
  125411. /**
  125412. * Gets the current class name
  125413. * @returns the class name
  125414. */
  125415. getClassName(): string;
  125416. /**
  125417. * Gets the value operand input component
  125418. */
  125419. readonly value: NodeMaterialConnectionPoint;
  125420. /**
  125421. * Gets the power operand input component
  125422. */
  125423. readonly power: NodeMaterialConnectionPoint;
  125424. /**
  125425. * Gets the output component
  125426. */
  125427. readonly output: NodeMaterialConnectionPoint;
  125428. protected _buildBlock(state: NodeMaterialBuildState): this;
  125429. }
  125430. }
  125431. declare module BABYLON {
  125432. /**
  125433. * Block used to get a random number
  125434. */
  125435. export class RandomNumberBlock extends NodeMaterialBlock {
  125436. /**
  125437. * Creates a new RandomNumberBlock
  125438. * @param name defines the block name
  125439. */
  125440. constructor(name: string);
  125441. /**
  125442. * Gets the current class name
  125443. * @returns the class name
  125444. */
  125445. getClassName(): string;
  125446. /**
  125447. * Gets the seed input component
  125448. */
  125449. readonly seed: NodeMaterialConnectionPoint;
  125450. /**
  125451. * Gets the output component
  125452. */
  125453. readonly output: NodeMaterialConnectionPoint;
  125454. protected _buildBlock(state: NodeMaterialBuildState): this;
  125455. }
  125456. }
  125457. declare module BABYLON {
  125458. /**
  125459. * Block used to compute arc tangent of 2 values
  125460. */
  125461. export class ArcTan2Block extends NodeMaterialBlock {
  125462. /**
  125463. * Creates a new ArcTan2Block
  125464. * @param name defines the block name
  125465. */
  125466. constructor(name: string);
  125467. /**
  125468. * Gets the current class name
  125469. * @returns the class name
  125470. */
  125471. getClassName(): string;
  125472. /**
  125473. * Gets the x operand input component
  125474. */
  125475. readonly x: NodeMaterialConnectionPoint;
  125476. /**
  125477. * Gets the y operand input component
  125478. */
  125479. readonly y: NodeMaterialConnectionPoint;
  125480. /**
  125481. * Gets the output component
  125482. */
  125483. readonly output: NodeMaterialConnectionPoint;
  125484. protected _buildBlock(state: NodeMaterialBuildState): this;
  125485. }
  125486. }
  125487. declare module BABYLON {
  125488. /**
  125489. * Block used to smooth step a value
  125490. */
  125491. export class SmoothStepBlock extends NodeMaterialBlock {
  125492. /**
  125493. * Creates a new SmoothStepBlock
  125494. * @param name defines the block name
  125495. */
  125496. constructor(name: string);
  125497. /**
  125498. * Gets the current class name
  125499. * @returns the class name
  125500. */
  125501. getClassName(): string;
  125502. /**
  125503. * Gets the value operand input component
  125504. */
  125505. readonly value: NodeMaterialConnectionPoint;
  125506. /**
  125507. * Gets the first edge operand input component
  125508. */
  125509. readonly edge0: NodeMaterialConnectionPoint;
  125510. /**
  125511. * Gets the second edge operand input component
  125512. */
  125513. readonly edge1: NodeMaterialConnectionPoint;
  125514. /**
  125515. * Gets the output component
  125516. */
  125517. readonly output: NodeMaterialConnectionPoint;
  125518. protected _buildBlock(state: NodeMaterialBuildState): this;
  125519. }
  125520. }
  125521. declare module BABYLON {
  125522. /**
  125523. * Block used to get the reciprocal (1 / x) of a value
  125524. */
  125525. export class ReciprocalBlock extends NodeMaterialBlock {
  125526. /**
  125527. * Creates a new ReciprocalBlock
  125528. * @param name defines the block name
  125529. */
  125530. constructor(name: string);
  125531. /**
  125532. * Gets the current class name
  125533. * @returns the class name
  125534. */
  125535. getClassName(): string;
  125536. /**
  125537. * Gets the input component
  125538. */
  125539. readonly input: NodeMaterialConnectionPoint;
  125540. /**
  125541. * Gets the output component
  125542. */
  125543. readonly output: NodeMaterialConnectionPoint;
  125544. protected _buildBlock(state: NodeMaterialBuildState): this;
  125545. }
  125546. }
  125547. declare module BABYLON {
  125548. /**
  125549. * Block used to replace a color by another one
  125550. */
  125551. export class ReplaceColorBlock extends NodeMaterialBlock {
  125552. /**
  125553. * Creates a new ReplaceColorBlock
  125554. * @param name defines the block name
  125555. */
  125556. constructor(name: string);
  125557. /**
  125558. * Gets the current class name
  125559. * @returns the class name
  125560. */
  125561. getClassName(): string;
  125562. /**
  125563. * Gets the value input component
  125564. */
  125565. readonly value: NodeMaterialConnectionPoint;
  125566. /**
  125567. * Gets the reference input component
  125568. */
  125569. readonly reference: NodeMaterialConnectionPoint;
  125570. /**
  125571. * Gets the distance input component
  125572. */
  125573. readonly distance: NodeMaterialConnectionPoint;
  125574. /**
  125575. * Gets the replacement input component
  125576. */
  125577. readonly replacement: NodeMaterialConnectionPoint;
  125578. /**
  125579. * Gets the output component
  125580. */
  125581. readonly output: NodeMaterialConnectionPoint;
  125582. protected _buildBlock(state: NodeMaterialBuildState): this;
  125583. }
  125584. }
  125585. declare module BABYLON {
  125586. /**
  125587. * Block used to posterize a value
  125588. * @see https://en.wikipedia.org/wiki/Posterization
  125589. */
  125590. export class PosterizeBlock extends NodeMaterialBlock {
  125591. /**
  125592. * Creates a new PosterizeBlock
  125593. * @param name defines the block name
  125594. */
  125595. constructor(name: string);
  125596. /**
  125597. * Gets the current class name
  125598. * @returns the class name
  125599. */
  125600. getClassName(): string;
  125601. /**
  125602. * Gets the value input component
  125603. */
  125604. readonly value: NodeMaterialConnectionPoint;
  125605. /**
  125606. * Gets the steps input component
  125607. */
  125608. readonly steps: NodeMaterialConnectionPoint;
  125609. /**
  125610. * Gets the output component
  125611. */
  125612. readonly output: NodeMaterialConnectionPoint;
  125613. protected _buildBlock(state: NodeMaterialBuildState): this;
  125614. }
  125615. }
  125616. declare module BABYLON {
  125617. /**
  125618. * Operations supported by the Wave block
  125619. */
  125620. export enum WaveBlockKind {
  125621. /** SawTooth */
  125622. SawTooth = 0,
  125623. /** Square */
  125624. Square = 1,
  125625. /** Triangle */
  125626. Triangle = 2
  125627. }
  125628. /**
  125629. * Block used to apply wave operation to floats
  125630. */
  125631. export class WaveBlock extends NodeMaterialBlock {
  125632. /**
  125633. * Gets or sets the kibnd of wave to be applied by the block
  125634. */
  125635. kind: WaveBlockKind;
  125636. /**
  125637. * Creates a new WaveBlock
  125638. * @param name defines the block name
  125639. */
  125640. constructor(name: string);
  125641. /**
  125642. * Gets the current class name
  125643. * @returns the class name
  125644. */
  125645. getClassName(): string;
  125646. /**
  125647. * Gets the input component
  125648. */
  125649. readonly input: NodeMaterialConnectionPoint;
  125650. /**
  125651. * Gets the output component
  125652. */
  125653. readonly output: NodeMaterialConnectionPoint;
  125654. protected _buildBlock(state: NodeMaterialBuildState): this;
  125655. serialize(): any;
  125656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125657. }
  125658. }
  125659. declare module BABYLON {
  125660. /**
  125661. * Class used to store a color step for the GradientBlock
  125662. */
  125663. export class GradientBlockColorStep {
  125664. /**
  125665. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125666. */
  125667. step: number;
  125668. /**
  125669. * Gets or sets the color associated with this step
  125670. */
  125671. color: Color3;
  125672. /**
  125673. * Creates a new GradientBlockColorStep
  125674. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  125675. * @param color defines the color associated with this step
  125676. */
  125677. constructor(
  125678. /**
  125679. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125680. */
  125681. step: number,
  125682. /**
  125683. * Gets or sets the color associated with this step
  125684. */
  125685. color: Color3);
  125686. }
  125687. /**
  125688. * Block used to return a color from a gradient based on an input value between 0 and 1
  125689. */
  125690. export class GradientBlock extends NodeMaterialBlock {
  125691. /**
  125692. * Gets or sets the list of color steps
  125693. */
  125694. colorSteps: GradientBlockColorStep[];
  125695. /**
  125696. * Creates a new GradientBlock
  125697. * @param name defines the block name
  125698. */
  125699. constructor(name: string);
  125700. /**
  125701. * Gets the current class name
  125702. * @returns the class name
  125703. */
  125704. getClassName(): string;
  125705. /**
  125706. * Gets the gradient input component
  125707. */
  125708. readonly gradient: NodeMaterialConnectionPoint;
  125709. /**
  125710. * Gets the output component
  125711. */
  125712. readonly output: NodeMaterialConnectionPoint;
  125713. private _writeColorConstant;
  125714. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125715. serialize(): any;
  125716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125717. protected _dumpPropertiesCode(): string;
  125718. }
  125719. }
  125720. declare module BABYLON {
  125721. /**
  125722. * Block used to normalize lerp between 2 values
  125723. */
  125724. export class NLerpBlock extends NodeMaterialBlock {
  125725. /**
  125726. * Creates a new NLerpBlock
  125727. * @param name defines the block name
  125728. */
  125729. constructor(name: string);
  125730. /**
  125731. * Gets the current class name
  125732. * @returns the class name
  125733. */
  125734. getClassName(): string;
  125735. /**
  125736. * Gets the left operand input component
  125737. */
  125738. readonly left: NodeMaterialConnectionPoint;
  125739. /**
  125740. * Gets the right operand input component
  125741. */
  125742. readonly right: NodeMaterialConnectionPoint;
  125743. /**
  125744. * Gets the gradient operand input component
  125745. */
  125746. readonly gradient: NodeMaterialConnectionPoint;
  125747. /**
  125748. * Gets the output component
  125749. */
  125750. readonly output: NodeMaterialConnectionPoint;
  125751. protected _buildBlock(state: NodeMaterialBuildState): this;
  125752. }
  125753. }
  125754. declare module BABYLON {
  125755. /**
  125756. * block used to Generate a Worley Noise 3D Noise Pattern
  125757. */
  125758. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125759. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125760. manhattanDistance: boolean;
  125761. /**
  125762. * Creates a new WorleyNoise3DBlock
  125763. * @param name defines the block name
  125764. */
  125765. constructor(name: string);
  125766. /**
  125767. * Gets the current class name
  125768. * @returns the class name
  125769. */
  125770. getClassName(): string;
  125771. /**
  125772. * Gets the seed input component
  125773. */
  125774. readonly seed: NodeMaterialConnectionPoint;
  125775. /**
  125776. * Gets the jitter input component
  125777. */
  125778. readonly jitter: NodeMaterialConnectionPoint;
  125779. /**
  125780. * Gets the output component
  125781. */
  125782. readonly output: NodeMaterialConnectionPoint;
  125783. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125784. /**
  125785. * Exposes the properties to the UI?
  125786. */
  125787. protected _dumpPropertiesCode(): string;
  125788. /**
  125789. * Exposes the properties to the Seralize?
  125790. */
  125791. serialize(): any;
  125792. /**
  125793. * Exposes the properties to the deseralize?
  125794. */
  125795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125796. }
  125797. }
  125798. declare module BABYLON {
  125799. /**
  125800. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125801. */
  125802. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125803. /**
  125804. * Creates a new SimplexPerlin3DBlock
  125805. * @param name defines the block name
  125806. */
  125807. constructor(name: string);
  125808. /**
  125809. * Gets the current class name
  125810. * @returns the class name
  125811. */
  125812. getClassName(): string;
  125813. /**
  125814. * Gets the seed operand input component
  125815. */
  125816. readonly seed: NodeMaterialConnectionPoint;
  125817. /**
  125818. * Gets the output component
  125819. */
  125820. readonly output: NodeMaterialConnectionPoint;
  125821. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125822. }
  125823. }
  125824. declare module BABYLON {
  125825. /**
  125826. * Block used to blend normals
  125827. */
  125828. export class NormalBlendBlock extends NodeMaterialBlock {
  125829. /**
  125830. * Creates a new NormalBlendBlock
  125831. * @param name defines the block name
  125832. */
  125833. constructor(name: string);
  125834. /**
  125835. * Gets the current class name
  125836. * @returns the class name
  125837. */
  125838. getClassName(): string;
  125839. /**
  125840. * Gets the first input component
  125841. */
  125842. readonly normalMap0: NodeMaterialConnectionPoint;
  125843. /**
  125844. * Gets the second input component
  125845. */
  125846. readonly normalMap1: NodeMaterialConnectionPoint;
  125847. /**
  125848. * Gets the output component
  125849. */
  125850. readonly output: NodeMaterialConnectionPoint;
  125851. protected _buildBlock(state: NodeMaterialBuildState): this;
  125852. }
  125853. }
  125854. declare module BABYLON {
  125855. /**
  125856. * Block used to rotate a 2d vector by a given angle
  125857. */
  125858. export class Rotate2dBlock extends NodeMaterialBlock {
  125859. /**
  125860. * Creates a new Rotate2dBlock
  125861. * @param name defines the block name
  125862. */
  125863. constructor(name: string);
  125864. /**
  125865. * Gets the current class name
  125866. * @returns the class name
  125867. */
  125868. getClassName(): string;
  125869. /**
  125870. * Gets the input vector
  125871. */
  125872. readonly input: NodeMaterialConnectionPoint;
  125873. /**
  125874. * Gets the input angle
  125875. */
  125876. readonly angle: NodeMaterialConnectionPoint;
  125877. /**
  125878. * Gets the output component
  125879. */
  125880. readonly output: NodeMaterialConnectionPoint;
  125881. autoConfigure(material: NodeMaterial): void;
  125882. protected _buildBlock(state: NodeMaterialBuildState): this;
  125883. }
  125884. }
  125885. declare module BABYLON {
  125886. /**
  125887. * Block used to get the reflected vector from a direction and a normal
  125888. */
  125889. export class ReflectBlock extends NodeMaterialBlock {
  125890. /**
  125891. * Creates a new ReflectBlock
  125892. * @param name defines the block name
  125893. */
  125894. constructor(name: string);
  125895. /**
  125896. * Gets the current class name
  125897. * @returns the class name
  125898. */
  125899. getClassName(): string;
  125900. /**
  125901. * Gets the incident component
  125902. */
  125903. readonly incident: NodeMaterialConnectionPoint;
  125904. /**
  125905. * Gets the normal component
  125906. */
  125907. readonly normal: NodeMaterialConnectionPoint;
  125908. /**
  125909. * Gets the output component
  125910. */
  125911. readonly output: NodeMaterialConnectionPoint;
  125912. protected _buildBlock(state: NodeMaterialBuildState): this;
  125913. }
  125914. }
  125915. declare module BABYLON {
  125916. /**
  125917. * Block used to get the refracted vector from a direction and a normal
  125918. */
  125919. export class RefractBlock extends NodeMaterialBlock {
  125920. /**
  125921. * Creates a new RefractBlock
  125922. * @param name defines the block name
  125923. */
  125924. constructor(name: string);
  125925. /**
  125926. * Gets the current class name
  125927. * @returns the class name
  125928. */
  125929. getClassName(): string;
  125930. /**
  125931. * Gets the incident component
  125932. */
  125933. readonly incident: NodeMaterialConnectionPoint;
  125934. /**
  125935. * Gets the normal component
  125936. */
  125937. readonly normal: NodeMaterialConnectionPoint;
  125938. /**
  125939. * Gets the index of refraction component
  125940. */
  125941. readonly ior: NodeMaterialConnectionPoint;
  125942. /**
  125943. * Gets the output component
  125944. */
  125945. readonly output: NodeMaterialConnectionPoint;
  125946. protected _buildBlock(state: NodeMaterialBuildState): this;
  125947. }
  125948. }
  125949. declare module BABYLON {
  125950. /**
  125951. * Block used to desaturate a color
  125952. */
  125953. export class DesaturateBlock extends NodeMaterialBlock {
  125954. /**
  125955. * Creates a new DesaturateBlock
  125956. * @param name defines the block name
  125957. */
  125958. constructor(name: string);
  125959. /**
  125960. * Gets the current class name
  125961. * @returns the class name
  125962. */
  125963. getClassName(): string;
  125964. /**
  125965. * Gets the color operand input component
  125966. */
  125967. readonly color: NodeMaterialConnectionPoint;
  125968. /**
  125969. * Gets the level operand input component
  125970. */
  125971. readonly level: NodeMaterialConnectionPoint;
  125972. /**
  125973. * Gets the output component
  125974. */
  125975. readonly output: NodeMaterialConnectionPoint;
  125976. protected _buildBlock(state: NodeMaterialBuildState): this;
  125977. }
  125978. }
  125979. declare module BABYLON {
  125980. /**
  125981. * Effect Render Options
  125982. */
  125983. export interface IEffectRendererOptions {
  125984. /**
  125985. * Defines the vertices positions.
  125986. */
  125987. positions?: number[];
  125988. /**
  125989. * Defines the indices.
  125990. */
  125991. indices?: number[];
  125992. }
  125993. /**
  125994. * Helper class to render one or more effects
  125995. */
  125996. export class EffectRenderer {
  125997. private engine;
  125998. private static _DefaultOptions;
  125999. private _vertexBuffers;
  126000. private _indexBuffer;
  126001. private _ringBufferIndex;
  126002. private _ringScreenBuffer;
  126003. private _fullscreenViewport;
  126004. private _getNextFrameBuffer;
  126005. /**
  126006. * Creates an effect renderer
  126007. * @param engine the engine to use for rendering
  126008. * @param options defines the options of the effect renderer
  126009. */
  126010. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  126011. /**
  126012. * Sets the current viewport in normalized coordinates 0-1
  126013. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  126014. */
  126015. setViewport(viewport?: Viewport): void;
  126016. /**
  126017. * Binds the embedded attributes buffer to the effect.
  126018. * @param effect Defines the effect to bind the attributes for
  126019. */
  126020. bindBuffers(effect: Effect): void;
  126021. /**
  126022. * Sets the current effect wrapper to use during draw.
  126023. * The effect needs to be ready before calling this api.
  126024. * This also sets the default full screen position attribute.
  126025. * @param effectWrapper Defines the effect to draw with
  126026. */
  126027. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  126028. /**
  126029. * Draws a full screen quad.
  126030. */
  126031. draw(): void;
  126032. /**
  126033. * renders one or more effects to a specified texture
  126034. * @param effectWrappers list of effects to renderer
  126035. * @param outputTexture texture to draw to, if null it will render to the screen
  126036. */
  126037. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  126038. /**
  126039. * Disposes of the effect renderer
  126040. */
  126041. dispose(): void;
  126042. }
  126043. /**
  126044. * Options to create an EffectWrapper
  126045. */
  126046. interface EffectWrapperCreationOptions {
  126047. /**
  126048. * Engine to use to create the effect
  126049. */
  126050. engine: ThinEngine;
  126051. /**
  126052. * Fragment shader for the effect
  126053. */
  126054. fragmentShader: string;
  126055. /**
  126056. * Vertex shader for the effect
  126057. */
  126058. vertexShader?: string;
  126059. /**
  126060. * Attributes to use in the shader
  126061. */
  126062. attributeNames?: Array<string>;
  126063. /**
  126064. * Uniforms to use in the shader
  126065. */
  126066. uniformNames?: Array<string>;
  126067. /**
  126068. * Texture sampler names to use in the shader
  126069. */
  126070. samplerNames?: Array<string>;
  126071. /**
  126072. * The friendly name of the effect displayed in Spector.
  126073. */
  126074. name?: string;
  126075. }
  126076. /**
  126077. * Wraps an effect to be used for rendering
  126078. */
  126079. export class EffectWrapper {
  126080. /**
  126081. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126082. */
  126083. onApplyObservable: Observable<{}>;
  126084. /**
  126085. * The underlying effect
  126086. */
  126087. effect: Effect;
  126088. /**
  126089. * Creates an effect to be renderer
  126090. * @param creationOptions options to create the effect
  126091. */
  126092. constructor(creationOptions: EffectWrapperCreationOptions);
  126093. /**
  126094. * Disposes of the effect wrapper
  126095. */
  126096. dispose(): void;
  126097. }
  126098. }
  126099. declare module BABYLON {
  126100. /**
  126101. * Helper class to push actions to a pool of workers.
  126102. */
  126103. export class WorkerPool implements IDisposable {
  126104. private _workerInfos;
  126105. private _pendingActions;
  126106. /**
  126107. * Constructor
  126108. * @param workers Array of workers to use for actions
  126109. */
  126110. constructor(workers: Array<Worker>);
  126111. /**
  126112. * Terminates all workers and clears any pending actions.
  126113. */
  126114. dispose(): void;
  126115. /**
  126116. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126117. * pended until a worker has completed its action.
  126118. * @param action The action to perform. Call onComplete when the action is complete.
  126119. */
  126120. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126121. private _execute;
  126122. }
  126123. }
  126124. declare module BABYLON {
  126125. /**
  126126. * Configuration for Draco compression
  126127. */
  126128. export interface IDracoCompressionConfiguration {
  126129. /**
  126130. * Configuration for the decoder.
  126131. */
  126132. decoder: {
  126133. /**
  126134. * The url to the WebAssembly module.
  126135. */
  126136. wasmUrl?: string;
  126137. /**
  126138. * The url to the WebAssembly binary.
  126139. */
  126140. wasmBinaryUrl?: string;
  126141. /**
  126142. * The url to the fallback JavaScript module.
  126143. */
  126144. fallbackUrl?: string;
  126145. };
  126146. }
  126147. /**
  126148. * Draco compression (https://google.github.io/draco/)
  126149. *
  126150. * This class wraps the Draco module.
  126151. *
  126152. * **Encoder**
  126153. *
  126154. * The encoder is not currently implemented.
  126155. *
  126156. * **Decoder**
  126157. *
  126158. * 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.
  126159. *
  126160. * To update the configuration, use the following code:
  126161. * ```javascript
  126162. * DracoCompression.Configuration = {
  126163. * decoder: {
  126164. * wasmUrl: "<url to the WebAssembly library>",
  126165. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126166. * fallbackUrl: "<url to the fallback JavaScript library>",
  126167. * }
  126168. * };
  126169. * ```
  126170. *
  126171. * 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.
  126172. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126173. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126174. *
  126175. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126176. * ```javascript
  126177. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126178. * ```
  126179. *
  126180. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126181. */
  126182. export class DracoCompression implements IDisposable {
  126183. private _workerPoolPromise?;
  126184. private _decoderModulePromise?;
  126185. /**
  126186. * The configuration. Defaults to the following urls:
  126187. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126188. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126189. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126190. */
  126191. static Configuration: IDracoCompressionConfiguration;
  126192. /**
  126193. * Returns true if the decoder configuration is available.
  126194. */
  126195. static readonly DecoderAvailable: boolean;
  126196. /**
  126197. * Default number of workers to create when creating the draco compression object.
  126198. */
  126199. static DefaultNumWorkers: number;
  126200. private static GetDefaultNumWorkers;
  126201. private static _Default;
  126202. /**
  126203. * Default instance for the draco compression object.
  126204. */
  126205. static readonly Default: DracoCompression;
  126206. /**
  126207. * Constructor
  126208. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126209. */
  126210. constructor(numWorkers?: number);
  126211. /**
  126212. * Stop all async operations and release resources.
  126213. */
  126214. dispose(): void;
  126215. /**
  126216. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126217. * @returns a promise that resolves when ready
  126218. */
  126219. whenReadyAsync(): Promise<void>;
  126220. /**
  126221. * Decode Draco compressed mesh data to vertex data.
  126222. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126223. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126224. * @returns A promise that resolves with the decoded vertex data
  126225. */
  126226. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126227. [kind: string]: number;
  126228. }): Promise<VertexData>;
  126229. }
  126230. }
  126231. declare module BABYLON {
  126232. /**
  126233. * Class for building Constructive Solid Geometry
  126234. */
  126235. export class CSG {
  126236. private polygons;
  126237. /**
  126238. * The world matrix
  126239. */
  126240. matrix: Matrix;
  126241. /**
  126242. * Stores the position
  126243. */
  126244. position: Vector3;
  126245. /**
  126246. * Stores the rotation
  126247. */
  126248. rotation: Vector3;
  126249. /**
  126250. * Stores the rotation quaternion
  126251. */
  126252. rotationQuaternion: Nullable<Quaternion>;
  126253. /**
  126254. * Stores the scaling vector
  126255. */
  126256. scaling: Vector3;
  126257. /**
  126258. * Convert the Mesh to CSG
  126259. * @param mesh The Mesh to convert to CSG
  126260. * @returns A new CSG from the Mesh
  126261. */
  126262. static FromMesh(mesh: Mesh): CSG;
  126263. /**
  126264. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126265. * @param polygons Polygons used to construct a CSG solid
  126266. */
  126267. private static FromPolygons;
  126268. /**
  126269. * Clones, or makes a deep copy, of the CSG
  126270. * @returns A new CSG
  126271. */
  126272. clone(): CSG;
  126273. /**
  126274. * Unions this CSG with another CSG
  126275. * @param csg The CSG to union against this CSG
  126276. * @returns The unioned CSG
  126277. */
  126278. union(csg: CSG): CSG;
  126279. /**
  126280. * Unions this CSG with another CSG in place
  126281. * @param csg The CSG to union against this CSG
  126282. */
  126283. unionInPlace(csg: CSG): void;
  126284. /**
  126285. * Subtracts this CSG with another CSG
  126286. * @param csg The CSG to subtract against this CSG
  126287. * @returns A new CSG
  126288. */
  126289. subtract(csg: CSG): CSG;
  126290. /**
  126291. * Subtracts this CSG with another CSG in place
  126292. * @param csg The CSG to subtact against this CSG
  126293. */
  126294. subtractInPlace(csg: CSG): void;
  126295. /**
  126296. * Intersect this CSG with another CSG
  126297. * @param csg The CSG to intersect against this CSG
  126298. * @returns A new CSG
  126299. */
  126300. intersect(csg: CSG): CSG;
  126301. /**
  126302. * Intersects this CSG with another CSG in place
  126303. * @param csg The CSG to intersect against this CSG
  126304. */
  126305. intersectInPlace(csg: CSG): void;
  126306. /**
  126307. * Return a new CSG solid with solid and empty space switched. This solid is
  126308. * not modified.
  126309. * @returns A new CSG solid with solid and empty space switched
  126310. */
  126311. inverse(): CSG;
  126312. /**
  126313. * Inverses the CSG in place
  126314. */
  126315. inverseInPlace(): void;
  126316. /**
  126317. * This is used to keep meshes transformations so they can be restored
  126318. * when we build back a Babylon Mesh
  126319. * NB : All CSG operations are performed in world coordinates
  126320. * @param csg The CSG to copy the transform attributes from
  126321. * @returns This CSG
  126322. */
  126323. copyTransformAttributes(csg: CSG): CSG;
  126324. /**
  126325. * Build Raw mesh from CSG
  126326. * Coordinates here are in world space
  126327. * @param name The name of the mesh geometry
  126328. * @param scene The Scene
  126329. * @param keepSubMeshes Specifies if the submeshes should be kept
  126330. * @returns A new Mesh
  126331. */
  126332. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126333. /**
  126334. * Build Mesh from CSG taking material and transforms into account
  126335. * @param name The name of the Mesh
  126336. * @param material The material of the Mesh
  126337. * @param scene The Scene
  126338. * @param keepSubMeshes Specifies if submeshes should be kept
  126339. * @returns The new Mesh
  126340. */
  126341. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126342. }
  126343. }
  126344. declare module BABYLON {
  126345. /**
  126346. * Class used to create a trail following a mesh
  126347. */
  126348. export class TrailMesh extends Mesh {
  126349. private _generator;
  126350. private _autoStart;
  126351. private _running;
  126352. private _diameter;
  126353. private _length;
  126354. private _sectionPolygonPointsCount;
  126355. private _sectionVectors;
  126356. private _sectionNormalVectors;
  126357. private _beforeRenderObserver;
  126358. /**
  126359. * @constructor
  126360. * @param name The value used by scene.getMeshByName() to do a lookup.
  126361. * @param generator The mesh to generate a trail.
  126362. * @param scene The scene to add this mesh to.
  126363. * @param diameter Diameter of trailing mesh. Default is 1.
  126364. * @param length Length of trailing mesh. Default is 60.
  126365. * @param autoStart Automatically start trailing mesh. Default true.
  126366. */
  126367. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126368. /**
  126369. * "TrailMesh"
  126370. * @returns "TrailMesh"
  126371. */
  126372. getClassName(): string;
  126373. private _createMesh;
  126374. /**
  126375. * Start trailing mesh.
  126376. */
  126377. start(): void;
  126378. /**
  126379. * Stop trailing mesh.
  126380. */
  126381. stop(): void;
  126382. /**
  126383. * Update trailing mesh geometry.
  126384. */
  126385. update(): void;
  126386. /**
  126387. * Returns a new TrailMesh object.
  126388. * @param name is a string, the name given to the new mesh
  126389. * @param newGenerator use new generator object for cloned trail mesh
  126390. * @returns a new mesh
  126391. */
  126392. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  126393. /**
  126394. * Serializes this trail mesh
  126395. * @param serializationObject object to write serialization to
  126396. */
  126397. serialize(serializationObject: any): void;
  126398. /**
  126399. * Parses a serialized trail mesh
  126400. * @param parsedMesh the serialized mesh
  126401. * @param scene the scene to create the trail mesh in
  126402. * @returns the created trail mesh
  126403. */
  126404. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  126405. }
  126406. }
  126407. declare module BABYLON {
  126408. /**
  126409. * Class containing static functions to help procedurally build meshes
  126410. */
  126411. export class TiledBoxBuilder {
  126412. /**
  126413. * Creates a box mesh
  126414. * 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)
  126415. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126419. * @param name defines the name of the mesh
  126420. * @param options defines the options used to create the mesh
  126421. * @param scene defines the hosting scene
  126422. * @returns the box mesh
  126423. */
  126424. static CreateTiledBox(name: string, options: {
  126425. pattern?: number;
  126426. width?: number;
  126427. height?: number;
  126428. depth?: number;
  126429. tileSize?: number;
  126430. tileWidth?: number;
  126431. tileHeight?: number;
  126432. alignHorizontal?: number;
  126433. alignVertical?: number;
  126434. faceUV?: Vector4[];
  126435. faceColors?: Color4[];
  126436. sideOrientation?: number;
  126437. updatable?: boolean;
  126438. }, scene?: Nullable<Scene>): Mesh;
  126439. }
  126440. }
  126441. declare module BABYLON {
  126442. /**
  126443. * Class containing static functions to help procedurally build meshes
  126444. */
  126445. export class TorusKnotBuilder {
  126446. /**
  126447. * Creates a torus knot mesh
  126448. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126449. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126450. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126451. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126455. * @param name defines the name of the mesh
  126456. * @param options defines the options used to create the mesh
  126457. * @param scene defines the hosting scene
  126458. * @returns the torus knot mesh
  126459. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126460. */
  126461. static CreateTorusKnot(name: string, options: {
  126462. radius?: number;
  126463. tube?: number;
  126464. radialSegments?: number;
  126465. tubularSegments?: number;
  126466. p?: number;
  126467. q?: number;
  126468. updatable?: boolean;
  126469. sideOrientation?: number;
  126470. frontUVs?: Vector4;
  126471. backUVs?: Vector4;
  126472. }, scene: any): Mesh;
  126473. }
  126474. }
  126475. declare module BABYLON {
  126476. /**
  126477. * Polygon
  126478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  126479. */
  126480. export class Polygon {
  126481. /**
  126482. * Creates a rectangle
  126483. * @param xmin bottom X coord
  126484. * @param ymin bottom Y coord
  126485. * @param xmax top X coord
  126486. * @param ymax top Y coord
  126487. * @returns points that make the resulting rectation
  126488. */
  126489. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  126490. /**
  126491. * Creates a circle
  126492. * @param radius radius of circle
  126493. * @param cx scale in x
  126494. * @param cy scale in y
  126495. * @param numberOfSides number of sides that make up the circle
  126496. * @returns points that make the resulting circle
  126497. */
  126498. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  126499. /**
  126500. * Creates a polygon from input string
  126501. * @param input Input polygon data
  126502. * @returns the parsed points
  126503. */
  126504. static Parse(input: string): Vector2[];
  126505. /**
  126506. * Starts building a polygon from x and y coordinates
  126507. * @param x x coordinate
  126508. * @param y y coordinate
  126509. * @returns the started path2
  126510. */
  126511. static StartingAt(x: number, y: number): Path2;
  126512. }
  126513. /**
  126514. * Builds a polygon
  126515. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  126516. */
  126517. export class PolygonMeshBuilder {
  126518. private _points;
  126519. private _outlinepoints;
  126520. private _holes;
  126521. private _name;
  126522. private _scene;
  126523. private _epoints;
  126524. private _eholes;
  126525. private _addToepoint;
  126526. /**
  126527. * Babylon reference to the earcut plugin.
  126528. */
  126529. bjsEarcut: any;
  126530. /**
  126531. * Creates a PolygonMeshBuilder
  126532. * @param name name of the builder
  126533. * @param contours Path of the polygon
  126534. * @param scene scene to add to when creating the mesh
  126535. * @param earcutInjection can be used to inject your own earcut reference
  126536. */
  126537. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126538. /**
  126539. * Adds a whole within the polygon
  126540. * @param hole Array of points defining the hole
  126541. * @returns this
  126542. */
  126543. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126544. /**
  126545. * Creates the polygon
  126546. * @param updatable If the mesh should be updatable
  126547. * @param depth The depth of the mesh created
  126548. * @returns the created mesh
  126549. */
  126550. build(updatable?: boolean, depth?: number): Mesh;
  126551. /**
  126552. * Creates the polygon
  126553. * @param depth The depth of the mesh created
  126554. * @returns the created VertexData
  126555. */
  126556. buildVertexData(depth?: number): VertexData;
  126557. /**
  126558. * Adds a side to the polygon
  126559. * @param positions points that make the polygon
  126560. * @param normals normals of the polygon
  126561. * @param uvs uvs of the polygon
  126562. * @param indices indices of the polygon
  126563. * @param bounds bounds of the polygon
  126564. * @param points points of the polygon
  126565. * @param depth depth of the polygon
  126566. * @param flip flip of the polygon
  126567. */
  126568. private addSide;
  126569. }
  126570. }
  126571. declare module BABYLON {
  126572. /**
  126573. * Class containing static functions to help procedurally build meshes
  126574. */
  126575. export class PolygonBuilder {
  126576. /**
  126577. * Creates a polygon mesh
  126578. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126579. * * 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
  126580. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126583. * * Remember you can only change the shape positions, not their number when updating a polygon
  126584. * @param name defines the name of the mesh
  126585. * @param options defines the options used to create the mesh
  126586. * @param scene defines the hosting scene
  126587. * @param earcutInjection can be used to inject your own earcut reference
  126588. * @returns the polygon mesh
  126589. */
  126590. static CreatePolygon(name: string, options: {
  126591. shape: Vector3[];
  126592. holes?: Vector3[][];
  126593. depth?: number;
  126594. faceUV?: Vector4[];
  126595. faceColors?: Color4[];
  126596. updatable?: boolean;
  126597. sideOrientation?: number;
  126598. frontUVs?: Vector4;
  126599. backUVs?: Vector4;
  126600. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126601. /**
  126602. * Creates an extruded polygon mesh, with depth in the Y direction.
  126603. * * 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)
  126604. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126605. * @param name defines the name of the mesh
  126606. * @param options defines the options used to create the mesh
  126607. * @param scene defines the hosting scene
  126608. * @param earcutInjection can be used to inject your own earcut reference
  126609. * @returns the polygon mesh
  126610. */
  126611. static ExtrudePolygon(name: string, options: {
  126612. shape: Vector3[];
  126613. holes?: Vector3[][];
  126614. depth?: number;
  126615. faceUV?: Vector4[];
  126616. faceColors?: Color4[];
  126617. updatable?: boolean;
  126618. sideOrientation?: number;
  126619. frontUVs?: Vector4;
  126620. backUVs?: Vector4;
  126621. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126622. }
  126623. }
  126624. declare module BABYLON {
  126625. /**
  126626. * Class containing static functions to help procedurally build meshes
  126627. */
  126628. export class LatheBuilder {
  126629. /**
  126630. * Creates lathe mesh.
  126631. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126632. * * 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
  126633. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126634. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126635. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126636. * * 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
  126637. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126638. * * 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
  126639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126643. * @param name defines the name of the mesh
  126644. * @param options defines the options used to create the mesh
  126645. * @param scene defines the hosting scene
  126646. * @returns the lathe mesh
  126647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126648. */
  126649. static CreateLathe(name: string, options: {
  126650. shape: Vector3[];
  126651. radius?: number;
  126652. tessellation?: number;
  126653. clip?: number;
  126654. arc?: number;
  126655. closed?: boolean;
  126656. updatable?: boolean;
  126657. sideOrientation?: number;
  126658. frontUVs?: Vector4;
  126659. backUVs?: Vector4;
  126660. cap?: number;
  126661. invertUV?: boolean;
  126662. }, scene?: Nullable<Scene>): Mesh;
  126663. }
  126664. }
  126665. declare module BABYLON {
  126666. /**
  126667. * Class containing static functions to help procedurally build meshes
  126668. */
  126669. export class TiledPlaneBuilder {
  126670. /**
  126671. * Creates a tiled plane mesh
  126672. * * The parameter `pattern` will, depending on value, do nothing or
  126673. * * * flip (reflect about central vertical) alternate tiles across and up
  126674. * * * flip every tile on alternate rows
  126675. * * * rotate (180 degs) alternate tiles across and up
  126676. * * * rotate every tile on alternate rows
  126677. * * * flip and rotate alternate tiles across and up
  126678. * * * flip and rotate every tile on alternate rows
  126679. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  126680. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  126681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126683. * * 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)
  126684. * * 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)
  126685. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126686. * @param name defines the name of the mesh
  126687. * @param options defines the options used to create the mesh
  126688. * @param scene defines the hosting scene
  126689. * @returns the box mesh
  126690. */
  126691. static CreateTiledPlane(name: string, options: {
  126692. pattern?: number;
  126693. tileSize?: number;
  126694. tileWidth?: number;
  126695. tileHeight?: number;
  126696. size?: number;
  126697. width?: number;
  126698. height?: number;
  126699. alignHorizontal?: number;
  126700. alignVertical?: number;
  126701. sideOrientation?: number;
  126702. frontUVs?: Vector4;
  126703. backUVs?: Vector4;
  126704. updatable?: boolean;
  126705. }, scene?: Nullable<Scene>): Mesh;
  126706. }
  126707. }
  126708. declare module BABYLON {
  126709. /**
  126710. * Class containing static functions to help procedurally build meshes
  126711. */
  126712. export class TubeBuilder {
  126713. /**
  126714. * Creates a tube mesh.
  126715. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126716. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126717. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126718. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126719. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126720. * * 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)
  126721. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126722. * * 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
  126723. * * 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
  126724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126728. * @param name defines the name of the mesh
  126729. * @param options defines the options used to create the mesh
  126730. * @param scene defines the hosting scene
  126731. * @returns the tube mesh
  126732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126733. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126734. */
  126735. static CreateTube(name: string, options: {
  126736. path: Vector3[];
  126737. radius?: number;
  126738. tessellation?: number;
  126739. radiusFunction?: {
  126740. (i: number, distance: number): number;
  126741. };
  126742. cap?: number;
  126743. arc?: number;
  126744. updatable?: boolean;
  126745. sideOrientation?: number;
  126746. frontUVs?: Vector4;
  126747. backUVs?: Vector4;
  126748. instance?: Mesh;
  126749. invertUV?: boolean;
  126750. }, scene?: Nullable<Scene>): Mesh;
  126751. }
  126752. }
  126753. declare module BABYLON {
  126754. /**
  126755. * Class containing static functions to help procedurally build meshes
  126756. */
  126757. export class IcoSphereBuilder {
  126758. /**
  126759. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126760. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126761. * * 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`)
  126762. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126763. * * 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
  126764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126767. * @param name defines the name of the mesh
  126768. * @param options defines the options used to create the mesh
  126769. * @param scene defines the hosting scene
  126770. * @returns the icosahedron mesh
  126771. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126772. */
  126773. static CreateIcoSphere(name: string, options: {
  126774. radius?: number;
  126775. radiusX?: number;
  126776. radiusY?: number;
  126777. radiusZ?: number;
  126778. flat?: boolean;
  126779. subdivisions?: number;
  126780. sideOrientation?: number;
  126781. frontUVs?: Vector4;
  126782. backUVs?: Vector4;
  126783. updatable?: boolean;
  126784. }, scene?: Nullable<Scene>): Mesh;
  126785. }
  126786. }
  126787. declare module BABYLON {
  126788. /**
  126789. * Class containing static functions to help procedurally build meshes
  126790. */
  126791. export class DecalBuilder {
  126792. /**
  126793. * Creates a decal mesh.
  126794. * 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
  126795. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126796. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126797. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126798. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126799. * @param name defines the name of the mesh
  126800. * @param sourceMesh defines the mesh where the decal must be applied
  126801. * @param options defines the options used to create the mesh
  126802. * @param scene defines the hosting scene
  126803. * @returns the decal mesh
  126804. * @see https://doc.babylonjs.com/how_to/decals
  126805. */
  126806. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126807. position?: Vector3;
  126808. normal?: Vector3;
  126809. size?: Vector3;
  126810. angle?: number;
  126811. }): Mesh;
  126812. }
  126813. }
  126814. declare module BABYLON {
  126815. /**
  126816. * Class containing static functions to help procedurally build meshes
  126817. */
  126818. export class MeshBuilder {
  126819. /**
  126820. * Creates a box mesh
  126821. * * The parameter `size` sets the size (float) of each box side (default 1)
  126822. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126823. * * 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)
  126824. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126828. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126829. * @param name defines the name of the mesh
  126830. * @param options defines the options used to create the mesh
  126831. * @param scene defines the hosting scene
  126832. * @returns the box mesh
  126833. */
  126834. static CreateBox(name: string, options: {
  126835. size?: number;
  126836. width?: number;
  126837. height?: number;
  126838. depth?: number;
  126839. faceUV?: Vector4[];
  126840. faceColors?: Color4[];
  126841. sideOrientation?: number;
  126842. frontUVs?: Vector4;
  126843. backUVs?: Vector4;
  126844. updatable?: boolean;
  126845. }, scene?: Nullable<Scene>): Mesh;
  126846. /**
  126847. * Creates a tiled box mesh
  126848. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126850. * @param name defines the name of the mesh
  126851. * @param options defines the options used to create the mesh
  126852. * @param scene defines the hosting scene
  126853. * @returns the tiled box mesh
  126854. */
  126855. static CreateTiledBox(name: string, options: {
  126856. pattern?: number;
  126857. size?: number;
  126858. width?: number;
  126859. height?: number;
  126860. depth: number;
  126861. tileSize?: number;
  126862. tileWidth?: number;
  126863. tileHeight?: number;
  126864. faceUV?: Vector4[];
  126865. faceColors?: Color4[];
  126866. alignHorizontal?: number;
  126867. alignVertical?: number;
  126868. sideOrientation?: number;
  126869. updatable?: boolean;
  126870. }, scene?: Nullable<Scene>): Mesh;
  126871. /**
  126872. * Creates a sphere mesh
  126873. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126874. * * 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`)
  126875. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126876. * * 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
  126877. * * 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)
  126878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126879. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126881. * @param name defines the name of the mesh
  126882. * @param options defines the options used to create the mesh
  126883. * @param scene defines the hosting scene
  126884. * @returns the sphere mesh
  126885. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126886. */
  126887. static CreateSphere(name: string, options: {
  126888. segments?: number;
  126889. diameter?: number;
  126890. diameterX?: number;
  126891. diameterY?: number;
  126892. diameterZ?: number;
  126893. arc?: number;
  126894. slice?: number;
  126895. sideOrientation?: number;
  126896. frontUVs?: Vector4;
  126897. backUVs?: Vector4;
  126898. updatable?: boolean;
  126899. }, scene?: Nullable<Scene>): Mesh;
  126900. /**
  126901. * Creates a plane polygonal mesh. By default, this is a disc
  126902. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126903. * * 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
  126904. * * 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
  126905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126908. * @param name defines the name of the mesh
  126909. * @param options defines the options used to create the mesh
  126910. * @param scene defines the hosting scene
  126911. * @returns the plane polygonal mesh
  126912. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126913. */
  126914. static CreateDisc(name: string, options: {
  126915. radius?: number;
  126916. tessellation?: number;
  126917. arc?: number;
  126918. updatable?: boolean;
  126919. sideOrientation?: number;
  126920. frontUVs?: Vector4;
  126921. backUVs?: Vector4;
  126922. }, scene?: Nullable<Scene>): Mesh;
  126923. /**
  126924. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126925. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126926. * * 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`)
  126927. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126928. * * 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
  126929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126932. * @param name defines the name of the mesh
  126933. * @param options defines the options used to create the mesh
  126934. * @param scene defines the hosting scene
  126935. * @returns the icosahedron mesh
  126936. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126937. */
  126938. static CreateIcoSphere(name: string, options: {
  126939. radius?: number;
  126940. radiusX?: number;
  126941. radiusY?: number;
  126942. radiusZ?: number;
  126943. flat?: boolean;
  126944. subdivisions?: number;
  126945. sideOrientation?: number;
  126946. frontUVs?: Vector4;
  126947. backUVs?: Vector4;
  126948. updatable?: boolean;
  126949. }, scene?: Nullable<Scene>): Mesh;
  126950. /**
  126951. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126952. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  126953. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  126954. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  126955. * * 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
  126956. * * 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
  126957. * * 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
  126958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126960. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126961. * * 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
  126962. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  126963. * * 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
  126964. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  126965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126966. * @param name defines the name of the mesh
  126967. * @param options defines the options used to create the mesh
  126968. * @param scene defines the hosting scene
  126969. * @returns the ribbon mesh
  126970. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  126971. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126972. */
  126973. static CreateRibbon(name: string, options: {
  126974. pathArray: Vector3[][];
  126975. closeArray?: boolean;
  126976. closePath?: boolean;
  126977. offset?: number;
  126978. updatable?: boolean;
  126979. sideOrientation?: number;
  126980. frontUVs?: Vector4;
  126981. backUVs?: Vector4;
  126982. instance?: Mesh;
  126983. invertUV?: boolean;
  126984. uvs?: Vector2[];
  126985. colors?: Color4[];
  126986. }, scene?: Nullable<Scene>): Mesh;
  126987. /**
  126988. * Creates a cylinder or a cone mesh
  126989. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126990. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126991. * * 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.
  126992. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126993. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126994. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126995. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126996. * * 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).
  126997. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126998. * * 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).
  126999. * * 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
  127000. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127001. * * 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
  127002. * * 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.
  127003. * * If `enclose` is false, a ring surface is one element.
  127004. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127005. * * 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
  127006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127009. * @param name defines the name of the mesh
  127010. * @param options defines the options used to create the mesh
  127011. * @param scene defines the hosting scene
  127012. * @returns the cylinder mesh
  127013. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127014. */
  127015. static CreateCylinder(name: string, options: {
  127016. height?: number;
  127017. diameterTop?: number;
  127018. diameterBottom?: number;
  127019. diameter?: number;
  127020. tessellation?: number;
  127021. subdivisions?: number;
  127022. arc?: number;
  127023. faceColors?: Color4[];
  127024. faceUV?: Vector4[];
  127025. updatable?: boolean;
  127026. hasRings?: boolean;
  127027. enclose?: boolean;
  127028. cap?: number;
  127029. sideOrientation?: number;
  127030. frontUVs?: Vector4;
  127031. backUVs?: Vector4;
  127032. }, scene?: Nullable<Scene>): Mesh;
  127033. /**
  127034. * Creates a torus mesh
  127035. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127036. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127037. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127041. * @param name defines the name of the mesh
  127042. * @param options defines the options used to create the mesh
  127043. * @param scene defines the hosting scene
  127044. * @returns the torus mesh
  127045. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127046. */
  127047. static CreateTorus(name: string, options: {
  127048. diameter?: number;
  127049. thickness?: number;
  127050. tessellation?: number;
  127051. updatable?: boolean;
  127052. sideOrientation?: number;
  127053. frontUVs?: Vector4;
  127054. backUVs?: Vector4;
  127055. }, scene?: Nullable<Scene>): Mesh;
  127056. /**
  127057. * Creates a torus knot mesh
  127058. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127059. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127060. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127061. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127065. * @param name defines the name of the mesh
  127066. * @param options defines the options used to create the mesh
  127067. * @param scene defines the hosting scene
  127068. * @returns the torus knot mesh
  127069. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127070. */
  127071. static CreateTorusKnot(name: string, options: {
  127072. radius?: number;
  127073. tube?: number;
  127074. radialSegments?: number;
  127075. tubularSegments?: number;
  127076. p?: number;
  127077. q?: number;
  127078. updatable?: boolean;
  127079. sideOrientation?: number;
  127080. frontUVs?: Vector4;
  127081. backUVs?: Vector4;
  127082. }, scene?: Nullable<Scene>): Mesh;
  127083. /**
  127084. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127085. * * 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
  127086. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127087. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127088. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127089. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127090. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127091. * * 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
  127092. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127095. * @param name defines the name of the new line system
  127096. * @param options defines the options used to create the line system
  127097. * @param scene defines the hosting scene
  127098. * @returns a new line system mesh
  127099. */
  127100. static CreateLineSystem(name: string, options: {
  127101. lines: Vector3[][];
  127102. updatable?: boolean;
  127103. instance?: Nullable<LinesMesh>;
  127104. colors?: Nullable<Color4[][]>;
  127105. useVertexAlpha?: boolean;
  127106. }, scene: Nullable<Scene>): LinesMesh;
  127107. /**
  127108. * Creates a line mesh
  127109. * 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
  127110. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127111. * * The parameter `points` is an array successive Vector3
  127112. * * 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
  127113. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127114. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127115. * * When updating an instance, remember that only point positions can change, not the number of points
  127116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127118. * @param name defines the name of the new line system
  127119. * @param options defines the options used to create the line system
  127120. * @param scene defines the hosting scene
  127121. * @returns a new line mesh
  127122. */
  127123. static CreateLines(name: string, options: {
  127124. points: Vector3[];
  127125. updatable?: boolean;
  127126. instance?: Nullable<LinesMesh>;
  127127. colors?: Color4[];
  127128. useVertexAlpha?: boolean;
  127129. }, scene?: Nullable<Scene>): LinesMesh;
  127130. /**
  127131. * Creates a dashed line mesh
  127132. * * 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
  127133. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127134. * * The parameter `points` is an array successive Vector3
  127135. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127136. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127137. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127138. * * 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
  127139. * * When updating an instance, remember that only point positions can change, not the number of points
  127140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127141. * @param name defines the name of the mesh
  127142. * @param options defines the options used to create the mesh
  127143. * @param scene defines the hosting scene
  127144. * @returns the dashed line mesh
  127145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127146. */
  127147. static CreateDashedLines(name: string, options: {
  127148. points: Vector3[];
  127149. dashSize?: number;
  127150. gapSize?: number;
  127151. dashNb?: number;
  127152. updatable?: boolean;
  127153. instance?: LinesMesh;
  127154. }, scene?: Nullable<Scene>): LinesMesh;
  127155. /**
  127156. * 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.
  127157. * * 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.
  127158. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127159. * * 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.
  127160. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127161. * * 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
  127162. * * 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
  127163. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127168. * @param name defines the name of the mesh
  127169. * @param options defines the options used to create the mesh
  127170. * @param scene defines the hosting scene
  127171. * @returns the extruded shape mesh
  127172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127174. */
  127175. static ExtrudeShape(name: string, options: {
  127176. shape: Vector3[];
  127177. path: Vector3[];
  127178. scale?: number;
  127179. rotation?: number;
  127180. cap?: number;
  127181. updatable?: boolean;
  127182. sideOrientation?: number;
  127183. frontUVs?: Vector4;
  127184. backUVs?: Vector4;
  127185. instance?: Mesh;
  127186. invertUV?: boolean;
  127187. }, scene?: Nullable<Scene>): Mesh;
  127188. /**
  127189. * Creates an custom extruded shape mesh.
  127190. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127191. * * 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.
  127192. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127193. * * 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
  127194. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127195. * * 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
  127196. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127197. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127198. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127199. * * 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
  127200. * * 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
  127201. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127206. * @param name defines the name of the mesh
  127207. * @param options defines the options used to create the mesh
  127208. * @param scene defines the hosting scene
  127209. * @returns the custom extruded shape mesh
  127210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127213. */
  127214. static ExtrudeShapeCustom(name: string, options: {
  127215. shape: Vector3[];
  127216. path: Vector3[];
  127217. scaleFunction?: any;
  127218. rotationFunction?: any;
  127219. ribbonCloseArray?: boolean;
  127220. ribbonClosePath?: boolean;
  127221. cap?: number;
  127222. updatable?: boolean;
  127223. sideOrientation?: number;
  127224. frontUVs?: Vector4;
  127225. backUVs?: Vector4;
  127226. instance?: Mesh;
  127227. invertUV?: boolean;
  127228. }, scene?: Nullable<Scene>): Mesh;
  127229. /**
  127230. * Creates lathe mesh.
  127231. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127232. * * 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
  127233. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127234. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127235. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127236. * * 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
  127237. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127238. * * 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
  127239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127241. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127243. * @param name defines the name of the mesh
  127244. * @param options defines the options used to create the mesh
  127245. * @param scene defines the hosting scene
  127246. * @returns the lathe mesh
  127247. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127248. */
  127249. static CreateLathe(name: string, options: {
  127250. shape: Vector3[];
  127251. radius?: number;
  127252. tessellation?: number;
  127253. clip?: number;
  127254. arc?: number;
  127255. closed?: boolean;
  127256. updatable?: boolean;
  127257. sideOrientation?: number;
  127258. frontUVs?: Vector4;
  127259. backUVs?: Vector4;
  127260. cap?: number;
  127261. invertUV?: boolean;
  127262. }, scene?: Nullable<Scene>): Mesh;
  127263. /**
  127264. * Creates a tiled plane mesh
  127265. * * You can set a limited pattern arrangement with the tiles
  127266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127269. * @param name defines the name of the mesh
  127270. * @param options defines the options used to create the mesh
  127271. * @param scene defines the hosting scene
  127272. * @returns the plane mesh
  127273. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127274. */
  127275. static CreateTiledPlane(name: string, options: {
  127276. pattern?: number;
  127277. tileSize?: number;
  127278. tileWidth?: number;
  127279. tileHeight?: number;
  127280. size?: number;
  127281. width?: number;
  127282. height?: number;
  127283. alignHorizontal?: number;
  127284. alignVertical?: number;
  127285. sideOrientation?: number;
  127286. frontUVs?: Vector4;
  127287. backUVs?: Vector4;
  127288. updatable?: boolean;
  127289. }, scene?: Nullable<Scene>): Mesh;
  127290. /**
  127291. * Creates a plane mesh
  127292. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127293. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127294. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127298. * @param name defines the name of the mesh
  127299. * @param options defines the options used to create the mesh
  127300. * @param scene defines the hosting scene
  127301. * @returns the plane mesh
  127302. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127303. */
  127304. static CreatePlane(name: string, options: {
  127305. size?: number;
  127306. width?: number;
  127307. height?: number;
  127308. sideOrientation?: number;
  127309. frontUVs?: Vector4;
  127310. backUVs?: Vector4;
  127311. updatable?: boolean;
  127312. sourcePlane?: Plane;
  127313. }, scene?: Nullable<Scene>): Mesh;
  127314. /**
  127315. * Creates a ground mesh
  127316. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127317. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127319. * @param name defines the name of the mesh
  127320. * @param options defines the options used to create the mesh
  127321. * @param scene defines the hosting scene
  127322. * @returns the ground mesh
  127323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127324. */
  127325. static CreateGround(name: string, options: {
  127326. width?: number;
  127327. height?: number;
  127328. subdivisions?: number;
  127329. subdivisionsX?: number;
  127330. subdivisionsY?: number;
  127331. updatable?: boolean;
  127332. }, scene?: Nullable<Scene>): Mesh;
  127333. /**
  127334. * Creates a tiled ground mesh
  127335. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127336. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127337. * * 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
  127338. * * 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
  127339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127340. * @param name defines the name of the mesh
  127341. * @param options defines the options used to create the mesh
  127342. * @param scene defines the hosting scene
  127343. * @returns the tiled ground mesh
  127344. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127345. */
  127346. static CreateTiledGround(name: string, options: {
  127347. xmin: number;
  127348. zmin: number;
  127349. xmax: number;
  127350. zmax: number;
  127351. subdivisions?: {
  127352. w: number;
  127353. h: number;
  127354. };
  127355. precision?: {
  127356. w: number;
  127357. h: number;
  127358. };
  127359. updatable?: boolean;
  127360. }, scene?: Nullable<Scene>): Mesh;
  127361. /**
  127362. * Creates a ground mesh from a height map
  127363. * * The parameter `url` sets the URL of the height map image resource.
  127364. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127365. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127366. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127367. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127368. * * 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.
  127369. * * 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).
  127370. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127372. * @param name defines the name of the mesh
  127373. * @param url defines the url to the height map
  127374. * @param options defines the options used to create the mesh
  127375. * @param scene defines the hosting scene
  127376. * @returns the ground mesh
  127377. * @see https://doc.babylonjs.com/babylon101/height_map
  127378. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127379. */
  127380. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127381. width?: number;
  127382. height?: number;
  127383. subdivisions?: number;
  127384. minHeight?: number;
  127385. maxHeight?: number;
  127386. colorFilter?: Color3;
  127387. alphaFilter?: number;
  127388. updatable?: boolean;
  127389. onReady?: (mesh: GroundMesh) => void;
  127390. }, scene?: Nullable<Scene>): GroundMesh;
  127391. /**
  127392. * Creates a polygon mesh
  127393. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127394. * * 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
  127395. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127398. * * Remember you can only change the shape positions, not their number when updating a polygon
  127399. * @param name defines the name of the mesh
  127400. * @param options defines the options used to create the mesh
  127401. * @param scene defines the hosting scene
  127402. * @param earcutInjection can be used to inject your own earcut reference
  127403. * @returns the polygon mesh
  127404. */
  127405. static CreatePolygon(name: string, options: {
  127406. shape: Vector3[];
  127407. holes?: Vector3[][];
  127408. depth?: number;
  127409. faceUV?: Vector4[];
  127410. faceColors?: Color4[];
  127411. updatable?: boolean;
  127412. sideOrientation?: number;
  127413. frontUVs?: Vector4;
  127414. backUVs?: Vector4;
  127415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127416. /**
  127417. * Creates an extruded polygon mesh, with depth in the Y direction.
  127418. * * 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)
  127419. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127420. * @param name defines the name of the mesh
  127421. * @param options defines the options used to create the mesh
  127422. * @param scene defines the hosting scene
  127423. * @param earcutInjection can be used to inject your own earcut reference
  127424. * @returns the polygon mesh
  127425. */
  127426. static ExtrudePolygon(name: string, options: {
  127427. shape: Vector3[];
  127428. holes?: Vector3[][];
  127429. depth?: number;
  127430. faceUV?: Vector4[];
  127431. faceColors?: Color4[];
  127432. updatable?: boolean;
  127433. sideOrientation?: number;
  127434. frontUVs?: Vector4;
  127435. backUVs?: Vector4;
  127436. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127437. /**
  127438. * Creates a tube mesh.
  127439. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127440. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127441. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127442. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127443. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127444. * * 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)
  127445. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127446. * * 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
  127447. * * 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
  127448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127450. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127452. * @param name defines the name of the mesh
  127453. * @param options defines the options used to create the mesh
  127454. * @param scene defines the hosting scene
  127455. * @returns the tube mesh
  127456. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127457. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127458. */
  127459. static CreateTube(name: string, options: {
  127460. path: Vector3[];
  127461. radius?: number;
  127462. tessellation?: number;
  127463. radiusFunction?: {
  127464. (i: number, distance: number): number;
  127465. };
  127466. cap?: number;
  127467. arc?: number;
  127468. updatable?: boolean;
  127469. sideOrientation?: number;
  127470. frontUVs?: Vector4;
  127471. backUVs?: Vector4;
  127472. instance?: Mesh;
  127473. invertUV?: boolean;
  127474. }, scene?: Nullable<Scene>): Mesh;
  127475. /**
  127476. * Creates a polyhedron mesh
  127477. * * 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
  127478. * * The parameter `size` (positive float, default 1) sets the polygon size
  127479. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  127480. * * 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`
  127481. * * 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
  127482. * * 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)`)
  127483. * * 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
  127484. * * 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
  127485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127488. * @param name defines the name of the mesh
  127489. * @param options defines the options used to create the mesh
  127490. * @param scene defines the hosting scene
  127491. * @returns the polyhedron mesh
  127492. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  127493. */
  127494. static CreatePolyhedron(name: string, options: {
  127495. type?: number;
  127496. size?: number;
  127497. sizeX?: number;
  127498. sizeY?: number;
  127499. sizeZ?: number;
  127500. custom?: any;
  127501. faceUV?: Vector4[];
  127502. faceColors?: Color4[];
  127503. flat?: boolean;
  127504. updatable?: boolean;
  127505. sideOrientation?: number;
  127506. frontUVs?: Vector4;
  127507. backUVs?: Vector4;
  127508. }, scene?: Nullable<Scene>): Mesh;
  127509. /**
  127510. * Creates a decal mesh.
  127511. * 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
  127512. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127513. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127514. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127515. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127516. * @param name defines the name of the mesh
  127517. * @param sourceMesh defines the mesh where the decal must be applied
  127518. * @param options defines the options used to create the mesh
  127519. * @param scene defines the hosting scene
  127520. * @returns the decal mesh
  127521. * @see https://doc.babylonjs.com/how_to/decals
  127522. */
  127523. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127524. position?: Vector3;
  127525. normal?: Vector3;
  127526. size?: Vector3;
  127527. angle?: number;
  127528. }): Mesh;
  127529. }
  127530. }
  127531. declare module BABYLON {
  127532. /**
  127533. * A simplifier interface for future simplification implementations
  127534. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127535. */
  127536. export interface ISimplifier {
  127537. /**
  127538. * Simplification of a given mesh according to the given settings.
  127539. * Since this requires computation, it is assumed that the function runs async.
  127540. * @param settings The settings of the simplification, including quality and distance
  127541. * @param successCallback A callback that will be called after the mesh was simplified.
  127542. * @param errorCallback in case of an error, this callback will be called. optional.
  127543. */
  127544. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127545. }
  127546. /**
  127547. * Expected simplification settings.
  127548. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127549. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127550. */
  127551. export interface ISimplificationSettings {
  127552. /**
  127553. * Gets or sets the expected quality
  127554. */
  127555. quality: number;
  127556. /**
  127557. * Gets or sets the distance when this optimized version should be used
  127558. */
  127559. distance: number;
  127560. /**
  127561. * Gets an already optimized mesh
  127562. */
  127563. optimizeMesh?: boolean;
  127564. }
  127565. /**
  127566. * Class used to specify simplification options
  127567. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127568. */
  127569. export class SimplificationSettings implements ISimplificationSettings {
  127570. /** expected quality */
  127571. quality: number;
  127572. /** distance when this optimized version should be used */
  127573. distance: number;
  127574. /** already optimized mesh */
  127575. optimizeMesh?: boolean | undefined;
  127576. /**
  127577. * Creates a SimplificationSettings
  127578. * @param quality expected quality
  127579. * @param distance distance when this optimized version should be used
  127580. * @param optimizeMesh already optimized mesh
  127581. */
  127582. constructor(
  127583. /** expected quality */
  127584. quality: number,
  127585. /** distance when this optimized version should be used */
  127586. distance: number,
  127587. /** already optimized mesh */
  127588. optimizeMesh?: boolean | undefined);
  127589. }
  127590. /**
  127591. * Interface used to define a simplification task
  127592. */
  127593. export interface ISimplificationTask {
  127594. /**
  127595. * Array of settings
  127596. */
  127597. settings: Array<ISimplificationSettings>;
  127598. /**
  127599. * Simplification type
  127600. */
  127601. simplificationType: SimplificationType;
  127602. /**
  127603. * Mesh to simplify
  127604. */
  127605. mesh: Mesh;
  127606. /**
  127607. * Callback called on success
  127608. */
  127609. successCallback?: () => void;
  127610. /**
  127611. * Defines if parallel processing can be used
  127612. */
  127613. parallelProcessing: boolean;
  127614. }
  127615. /**
  127616. * Queue used to order the simplification tasks
  127617. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127618. */
  127619. export class SimplificationQueue {
  127620. private _simplificationArray;
  127621. /**
  127622. * Gets a boolean indicating that the process is still running
  127623. */
  127624. running: boolean;
  127625. /**
  127626. * Creates a new queue
  127627. */
  127628. constructor();
  127629. /**
  127630. * Adds a new simplification task
  127631. * @param task defines a task to add
  127632. */
  127633. addTask(task: ISimplificationTask): void;
  127634. /**
  127635. * Execute next task
  127636. */
  127637. executeNext(): void;
  127638. /**
  127639. * Execute a simplification task
  127640. * @param task defines the task to run
  127641. */
  127642. runSimplification(task: ISimplificationTask): void;
  127643. private getSimplifier;
  127644. }
  127645. /**
  127646. * The implemented types of simplification
  127647. * At the moment only Quadratic Error Decimation is implemented
  127648. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127649. */
  127650. export enum SimplificationType {
  127651. /** Quadratic error decimation */
  127652. QUADRATIC = 0
  127653. }
  127654. }
  127655. declare module BABYLON {
  127656. interface Scene {
  127657. /** @hidden (Backing field) */
  127658. _simplificationQueue: SimplificationQueue;
  127659. /**
  127660. * Gets or sets the simplification queue attached to the scene
  127661. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127662. */
  127663. simplificationQueue: SimplificationQueue;
  127664. }
  127665. interface Mesh {
  127666. /**
  127667. * Simplify the mesh according to the given array of settings.
  127668. * Function will return immediately and will simplify async
  127669. * @param settings a collection of simplification settings
  127670. * @param parallelProcessing should all levels calculate parallel or one after the other
  127671. * @param simplificationType the type of simplification to run
  127672. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  127673. * @returns the current mesh
  127674. */
  127675. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  127676. }
  127677. /**
  127678. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  127679. * created in a scene
  127680. */
  127681. export class SimplicationQueueSceneComponent implements ISceneComponent {
  127682. /**
  127683. * The component name helpfull to identify the component in the list of scene components.
  127684. */
  127685. readonly name: string;
  127686. /**
  127687. * The scene the component belongs to.
  127688. */
  127689. scene: Scene;
  127690. /**
  127691. * Creates a new instance of the component for the given scene
  127692. * @param scene Defines the scene to register the component in
  127693. */
  127694. constructor(scene: Scene);
  127695. /**
  127696. * Registers the component in a given scene
  127697. */
  127698. register(): void;
  127699. /**
  127700. * Rebuilds the elements related to this component in case of
  127701. * context lost for instance.
  127702. */
  127703. rebuild(): void;
  127704. /**
  127705. * Disposes the component and the associated ressources
  127706. */
  127707. dispose(): void;
  127708. private _beforeCameraUpdate;
  127709. }
  127710. }
  127711. declare module BABYLON {
  127712. /**
  127713. * Navigation plugin interface to add navigation constrained by a navigation mesh
  127714. */
  127715. export interface INavigationEnginePlugin {
  127716. /**
  127717. * plugin name
  127718. */
  127719. name: string;
  127720. /**
  127721. * Creates a navigation mesh
  127722. * @param meshes array of all the geometry used to compute the navigatio mesh
  127723. * @param parameters bunch of parameters used to filter geometry
  127724. */
  127725. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127726. /**
  127727. * Create a navigation mesh debug mesh
  127728. * @param scene is where the mesh will be added
  127729. * @returns debug display mesh
  127730. */
  127731. createDebugNavMesh(scene: Scene): Mesh;
  127732. /**
  127733. * Get a navigation mesh constrained position, closest to the parameter position
  127734. * @param position world position
  127735. * @returns the closest point to position constrained by the navigation mesh
  127736. */
  127737. getClosestPoint(position: Vector3): Vector3;
  127738. /**
  127739. * Get a navigation mesh constrained position, within a particular radius
  127740. * @param position world position
  127741. * @param maxRadius the maximum distance to the constrained world position
  127742. * @returns the closest point to position constrained by the navigation mesh
  127743. */
  127744. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127745. /**
  127746. * Compute the final position from a segment made of destination-position
  127747. * @param position world position
  127748. * @param destination world position
  127749. * @returns the resulting point along the navmesh
  127750. */
  127751. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127752. /**
  127753. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127754. * @param start world position
  127755. * @param end world position
  127756. * @returns array containing world position composing the path
  127757. */
  127758. computePath(start: Vector3, end: Vector3): Vector3[];
  127759. /**
  127760. * If this plugin is supported
  127761. * @returns true if plugin is supported
  127762. */
  127763. isSupported(): boolean;
  127764. /**
  127765. * Create a new Crowd so you can add agents
  127766. * @param maxAgents the maximum agent count in the crowd
  127767. * @param maxAgentRadius the maximum radius an agent can have
  127768. * @param scene to attach the crowd to
  127769. * @returns the crowd you can add agents to
  127770. */
  127771. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127772. /**
  127773. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127774. * The queries will try to find a solution within those bounds
  127775. * default is (1,1,1)
  127776. * @param extent x,y,z value that define the extent around the queries point of reference
  127777. */
  127778. setDefaultQueryExtent(extent: Vector3): void;
  127779. /**
  127780. * Get the Bounding box extent specified by setDefaultQueryExtent
  127781. * @returns the box extent values
  127782. */
  127783. getDefaultQueryExtent(): Vector3;
  127784. /**
  127785. * Release all resources
  127786. */
  127787. dispose(): void;
  127788. }
  127789. /**
  127790. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  127791. */
  127792. export interface ICrowd {
  127793. /**
  127794. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127795. * You can attach anything to that node. The node position is updated in the scene update tick.
  127796. * @param pos world position that will be constrained by the navigation mesh
  127797. * @param parameters agent parameters
  127798. * @param transform hooked to the agent that will be update by the scene
  127799. * @returns agent index
  127800. */
  127801. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127802. /**
  127803. * Returns the agent position in world space
  127804. * @param index agent index returned by addAgent
  127805. * @returns world space position
  127806. */
  127807. getAgentPosition(index: number): Vector3;
  127808. /**
  127809. * Gets the agent velocity in world space
  127810. * @param index agent index returned by addAgent
  127811. * @returns world space velocity
  127812. */
  127813. getAgentVelocity(index: number): Vector3;
  127814. /**
  127815. * remove a particular agent previously created
  127816. * @param index agent index returned by addAgent
  127817. */
  127818. removeAgent(index: number): void;
  127819. /**
  127820. * get the list of all agents attached to this crowd
  127821. * @returns list of agent indices
  127822. */
  127823. getAgents(): number[];
  127824. /**
  127825. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127826. * @param deltaTime in seconds
  127827. */
  127828. update(deltaTime: number): void;
  127829. /**
  127830. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127831. * @param index agent index returned by addAgent
  127832. * @param destination targeted world position
  127833. */
  127834. agentGoto(index: number, destination: Vector3): void;
  127835. /**
  127836. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127837. * The queries will try to find a solution within those bounds
  127838. * default is (1,1,1)
  127839. * @param extent x,y,z value that define the extent around the queries point of reference
  127840. */
  127841. setDefaultQueryExtent(extent: Vector3): void;
  127842. /**
  127843. * Get the Bounding box extent specified by setDefaultQueryExtent
  127844. * @returns the box extent values
  127845. */
  127846. getDefaultQueryExtent(): Vector3;
  127847. /**
  127848. * Release all resources
  127849. */
  127850. dispose(): void;
  127851. }
  127852. /**
  127853. * Configures an agent
  127854. */
  127855. export interface IAgentParameters {
  127856. /**
  127857. * Agent radius. [Limit: >= 0]
  127858. */
  127859. radius: number;
  127860. /**
  127861. * Agent height. [Limit: > 0]
  127862. */
  127863. height: number;
  127864. /**
  127865. * Maximum allowed acceleration. [Limit: >= 0]
  127866. */
  127867. maxAcceleration: number;
  127868. /**
  127869. * Maximum allowed speed. [Limit: >= 0]
  127870. */
  127871. maxSpeed: number;
  127872. /**
  127873. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127874. */
  127875. collisionQueryRange: number;
  127876. /**
  127877. * The path visibility optimization range. [Limit: > 0]
  127878. */
  127879. pathOptimizationRange: number;
  127880. /**
  127881. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127882. */
  127883. separationWeight: number;
  127884. }
  127885. /**
  127886. * Configures the navigation mesh creation
  127887. */
  127888. export interface INavMeshParameters {
  127889. /**
  127890. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127891. */
  127892. cs: number;
  127893. /**
  127894. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127895. */
  127896. ch: number;
  127897. /**
  127898. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127899. */
  127900. walkableSlopeAngle: number;
  127901. /**
  127902. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127903. * be considered walkable. [Limit: >= 3] [Units: vx]
  127904. */
  127905. walkableHeight: number;
  127906. /**
  127907. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127908. */
  127909. walkableClimb: number;
  127910. /**
  127911. * The distance to erode/shrink the walkable area of the heightfield away from
  127912. * obstructions. [Limit: >=0] [Units: vx]
  127913. */
  127914. walkableRadius: number;
  127915. /**
  127916. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127917. */
  127918. maxEdgeLen: number;
  127919. /**
  127920. * The maximum distance a simplfied contour's border edges should deviate
  127921. * the original raw contour. [Limit: >=0] [Units: vx]
  127922. */
  127923. maxSimplificationError: number;
  127924. /**
  127925. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127926. */
  127927. minRegionArea: number;
  127928. /**
  127929. * Any regions with a span count smaller than this value will, if possible,
  127930. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127931. */
  127932. mergeRegionArea: number;
  127933. /**
  127934. * The maximum number of vertices allowed for polygons generated during the
  127935. * contour to polygon conversion process. [Limit: >= 3]
  127936. */
  127937. maxVertsPerPoly: number;
  127938. /**
  127939. * Sets the sampling distance to use when generating the detail mesh.
  127940. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  127941. */
  127942. detailSampleDist: number;
  127943. /**
  127944. * The maximum distance the detail mesh surface should deviate from heightfield
  127945. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  127946. */
  127947. detailSampleMaxError: number;
  127948. }
  127949. }
  127950. declare module BABYLON {
  127951. /**
  127952. * RecastJS navigation plugin
  127953. */
  127954. export class RecastJSPlugin implements INavigationEnginePlugin {
  127955. /**
  127956. * Reference to the Recast library
  127957. */
  127958. bjsRECAST: any;
  127959. /**
  127960. * plugin name
  127961. */
  127962. name: string;
  127963. /**
  127964. * the first navmesh created. We might extend this to support multiple navmeshes
  127965. */
  127966. navMesh: any;
  127967. /**
  127968. * Initializes the recastJS plugin
  127969. * @param recastInjection can be used to inject your own recast reference
  127970. */
  127971. constructor(recastInjection?: any);
  127972. /**
  127973. * Creates a navigation mesh
  127974. * @param meshes array of all the geometry used to compute the navigatio mesh
  127975. * @param parameters bunch of parameters used to filter geometry
  127976. */
  127977. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127978. /**
  127979. * Create a navigation mesh debug mesh
  127980. * @param scene is where the mesh will be added
  127981. * @returns debug display mesh
  127982. */
  127983. createDebugNavMesh(scene: Scene): Mesh;
  127984. /**
  127985. * Get a navigation mesh constrained position, closest to the parameter position
  127986. * @param position world position
  127987. * @returns the closest point to position constrained by the navigation mesh
  127988. */
  127989. getClosestPoint(position: Vector3): Vector3;
  127990. /**
  127991. * Get a navigation mesh constrained position, within a particular radius
  127992. * @param position world position
  127993. * @param maxRadius the maximum distance to the constrained world position
  127994. * @returns the closest point to position constrained by the navigation mesh
  127995. */
  127996. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127997. /**
  127998. * Compute the final position from a segment made of destination-position
  127999. * @param position world position
  128000. * @param destination world position
  128001. * @returns the resulting point along the navmesh
  128002. */
  128003. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128004. /**
  128005. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128006. * @param start world position
  128007. * @param end world position
  128008. * @returns array containing world position composing the path
  128009. */
  128010. computePath(start: Vector3, end: Vector3): Vector3[];
  128011. /**
  128012. * Create a new Crowd so you can add agents
  128013. * @param maxAgents the maximum agent count in the crowd
  128014. * @param maxAgentRadius the maximum radius an agent can have
  128015. * @param scene to attach the crowd to
  128016. * @returns the crowd you can add agents to
  128017. */
  128018. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128019. /**
  128020. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128021. * The queries will try to find a solution within those bounds
  128022. * default is (1,1,1)
  128023. * @param extent x,y,z value that define the extent around the queries point of reference
  128024. */
  128025. setDefaultQueryExtent(extent: Vector3): void;
  128026. /**
  128027. * Get the Bounding box extent specified by setDefaultQueryExtent
  128028. * @returns the box extent values
  128029. */
  128030. getDefaultQueryExtent(): Vector3;
  128031. /**
  128032. * Disposes
  128033. */
  128034. dispose(): void;
  128035. /**
  128036. * If this plugin is supported
  128037. * @returns true if plugin is supported
  128038. */
  128039. isSupported(): boolean;
  128040. }
  128041. /**
  128042. * Recast detour crowd implementation
  128043. */
  128044. export class RecastJSCrowd implements ICrowd {
  128045. /**
  128046. * Recast/detour plugin
  128047. */
  128048. bjsRECASTPlugin: RecastJSPlugin;
  128049. /**
  128050. * Link to the detour crowd
  128051. */
  128052. recastCrowd: any;
  128053. /**
  128054. * One transform per agent
  128055. */
  128056. transforms: TransformNode[];
  128057. /**
  128058. * All agents created
  128059. */
  128060. agents: number[];
  128061. /**
  128062. * Link to the scene is kept to unregister the crowd from the scene
  128063. */
  128064. private _scene;
  128065. /**
  128066. * Observer for crowd updates
  128067. */
  128068. private _onBeforeAnimationsObserver;
  128069. /**
  128070. * Constructor
  128071. * @param plugin recastJS plugin
  128072. * @param maxAgents the maximum agent count in the crowd
  128073. * @param maxAgentRadius the maximum radius an agent can have
  128074. * @param scene to attach the crowd to
  128075. * @returns the crowd you can add agents to
  128076. */
  128077. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128078. /**
  128079. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128080. * You can attach anything to that node. The node position is updated in the scene update tick.
  128081. * @param pos world position that will be constrained by the navigation mesh
  128082. * @param parameters agent parameters
  128083. * @param transform hooked to the agent that will be update by the scene
  128084. * @returns agent index
  128085. */
  128086. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128087. /**
  128088. * Returns the agent position in world space
  128089. * @param index agent index returned by addAgent
  128090. * @returns world space position
  128091. */
  128092. getAgentPosition(index: number): Vector3;
  128093. /**
  128094. * Returns the agent velocity in world space
  128095. * @param index agent index returned by addAgent
  128096. * @returns world space velocity
  128097. */
  128098. getAgentVelocity(index: number): Vector3;
  128099. /**
  128100. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128101. * @param index agent index returned by addAgent
  128102. * @param destination targeted world position
  128103. */
  128104. agentGoto(index: number, destination: Vector3): void;
  128105. /**
  128106. * remove a particular agent previously created
  128107. * @param index agent index returned by addAgent
  128108. */
  128109. removeAgent(index: number): void;
  128110. /**
  128111. * get the list of all agents attached to this crowd
  128112. * @returns list of agent indices
  128113. */
  128114. getAgents(): number[];
  128115. /**
  128116. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128117. * @param deltaTime in seconds
  128118. */
  128119. update(deltaTime: number): void;
  128120. /**
  128121. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128122. * The queries will try to find a solution within those bounds
  128123. * default is (1,1,1)
  128124. * @param extent x,y,z value that define the extent around the queries point of reference
  128125. */
  128126. setDefaultQueryExtent(extent: Vector3): void;
  128127. /**
  128128. * Get the Bounding box extent specified by setDefaultQueryExtent
  128129. * @returns the box extent values
  128130. */
  128131. getDefaultQueryExtent(): Vector3;
  128132. /**
  128133. * Release all resources
  128134. */
  128135. dispose(): void;
  128136. }
  128137. }
  128138. declare module BABYLON {
  128139. /**
  128140. * Class used to enable access to IndexedDB
  128141. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128142. */
  128143. export class Database implements IOfflineProvider {
  128144. private _callbackManifestChecked;
  128145. private _currentSceneUrl;
  128146. private _db;
  128147. private _enableSceneOffline;
  128148. private _enableTexturesOffline;
  128149. private _manifestVersionFound;
  128150. private _mustUpdateRessources;
  128151. private _hasReachedQuota;
  128152. private _isSupported;
  128153. private _idbFactory;
  128154. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128155. private static IsUASupportingBlobStorage;
  128156. /**
  128157. * Gets a boolean indicating if Database storate is enabled (off by default)
  128158. */
  128159. static IDBStorageEnabled: boolean;
  128160. /**
  128161. * Gets a boolean indicating if scene must be saved in the database
  128162. */
  128163. readonly enableSceneOffline: boolean;
  128164. /**
  128165. * Gets a boolean indicating if textures must be saved in the database
  128166. */
  128167. readonly enableTexturesOffline: boolean;
  128168. /**
  128169. * Creates a new Database
  128170. * @param urlToScene defines the url to load the scene
  128171. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128172. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128173. */
  128174. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128175. private static _ParseURL;
  128176. private static _ReturnFullUrlLocation;
  128177. private _checkManifestFile;
  128178. /**
  128179. * Open the database and make it available
  128180. * @param successCallback defines the callback to call on success
  128181. * @param errorCallback defines the callback to call on error
  128182. */
  128183. open(successCallback: () => void, errorCallback: () => void): void;
  128184. /**
  128185. * Loads an image from the database
  128186. * @param url defines the url to load from
  128187. * @param image defines the target DOM image
  128188. */
  128189. loadImage(url: string, image: HTMLImageElement): void;
  128190. private _loadImageFromDBAsync;
  128191. private _saveImageIntoDBAsync;
  128192. private _checkVersionFromDB;
  128193. private _loadVersionFromDBAsync;
  128194. private _saveVersionIntoDBAsync;
  128195. /**
  128196. * Loads a file from database
  128197. * @param url defines the URL to load from
  128198. * @param sceneLoaded defines a callback to call on success
  128199. * @param progressCallBack defines a callback to call when progress changed
  128200. * @param errorCallback defines a callback to call on error
  128201. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128202. */
  128203. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128204. private _loadFileAsync;
  128205. private _saveFileAsync;
  128206. /**
  128207. * Validates if xhr data is correct
  128208. * @param xhr defines the request to validate
  128209. * @param dataType defines the expected data type
  128210. * @returns true if data is correct
  128211. */
  128212. private static _ValidateXHRData;
  128213. }
  128214. }
  128215. declare module BABYLON {
  128216. /** @hidden */
  128217. export var gpuUpdateParticlesPixelShader: {
  128218. name: string;
  128219. shader: string;
  128220. };
  128221. }
  128222. declare module BABYLON {
  128223. /** @hidden */
  128224. export var gpuUpdateParticlesVertexShader: {
  128225. name: string;
  128226. shader: string;
  128227. };
  128228. }
  128229. declare module BABYLON {
  128230. /** @hidden */
  128231. export var clipPlaneFragmentDeclaration2: {
  128232. name: string;
  128233. shader: string;
  128234. };
  128235. }
  128236. declare module BABYLON {
  128237. /** @hidden */
  128238. export var gpuRenderParticlesPixelShader: {
  128239. name: string;
  128240. shader: string;
  128241. };
  128242. }
  128243. declare module BABYLON {
  128244. /** @hidden */
  128245. export var clipPlaneVertexDeclaration2: {
  128246. name: string;
  128247. shader: string;
  128248. };
  128249. }
  128250. declare module BABYLON {
  128251. /** @hidden */
  128252. export var gpuRenderParticlesVertexShader: {
  128253. name: string;
  128254. shader: string;
  128255. };
  128256. }
  128257. declare module BABYLON {
  128258. /**
  128259. * This represents a GPU particle system in Babylon
  128260. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128261. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128262. */
  128263. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128264. /**
  128265. * The layer mask we are rendering the particles through.
  128266. */
  128267. layerMask: number;
  128268. private _capacity;
  128269. private _activeCount;
  128270. private _currentActiveCount;
  128271. private _accumulatedCount;
  128272. private _renderEffect;
  128273. private _updateEffect;
  128274. private _buffer0;
  128275. private _buffer1;
  128276. private _spriteBuffer;
  128277. private _updateVAO;
  128278. private _renderVAO;
  128279. private _targetIndex;
  128280. private _sourceBuffer;
  128281. private _targetBuffer;
  128282. private _engine;
  128283. private _currentRenderId;
  128284. private _started;
  128285. private _stopped;
  128286. private _timeDelta;
  128287. private _randomTexture;
  128288. private _randomTexture2;
  128289. private _attributesStrideSize;
  128290. private _updateEffectOptions;
  128291. private _randomTextureSize;
  128292. private _actualFrame;
  128293. private readonly _rawTextureWidth;
  128294. /**
  128295. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128296. */
  128297. static readonly IsSupported: boolean;
  128298. /**
  128299. * An event triggered when the system is disposed.
  128300. */
  128301. onDisposeObservable: Observable<GPUParticleSystem>;
  128302. /**
  128303. * Gets the maximum number of particles active at the same time.
  128304. * @returns The max number of active particles.
  128305. */
  128306. getCapacity(): number;
  128307. /**
  128308. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128309. * to override the particles.
  128310. */
  128311. forceDepthWrite: boolean;
  128312. /**
  128313. * Gets or set the number of active particles
  128314. */
  128315. activeParticleCount: number;
  128316. private _preWarmDone;
  128317. /**
  128318. * Is this system ready to be used/rendered
  128319. * @return true if the system is ready
  128320. */
  128321. isReady(): boolean;
  128322. /**
  128323. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128324. * @returns True if it has been started, otherwise false.
  128325. */
  128326. isStarted(): boolean;
  128327. /**
  128328. * Starts the particle system and begins to emit
  128329. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128330. */
  128331. start(delay?: number): void;
  128332. /**
  128333. * Stops the particle system.
  128334. */
  128335. stop(): void;
  128336. /**
  128337. * Remove all active particles
  128338. */
  128339. reset(): void;
  128340. /**
  128341. * Returns the string "GPUParticleSystem"
  128342. * @returns a string containing the class name
  128343. */
  128344. getClassName(): string;
  128345. private _colorGradientsTexture;
  128346. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128347. /**
  128348. * Adds a new color gradient
  128349. * @param gradient defines the gradient to use (between 0 and 1)
  128350. * @param color1 defines the color to affect to the specified gradient
  128351. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128352. * @returns the current particle system
  128353. */
  128354. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128355. /**
  128356. * Remove a specific color gradient
  128357. * @param gradient defines the gradient to remove
  128358. * @returns the current particle system
  128359. */
  128360. removeColorGradient(gradient: number): GPUParticleSystem;
  128361. private _angularSpeedGradientsTexture;
  128362. private _sizeGradientsTexture;
  128363. private _velocityGradientsTexture;
  128364. private _limitVelocityGradientsTexture;
  128365. private _dragGradientsTexture;
  128366. private _addFactorGradient;
  128367. /**
  128368. * Adds a new size gradient
  128369. * @param gradient defines the gradient to use (between 0 and 1)
  128370. * @param factor defines the size factor to affect to the specified gradient
  128371. * @returns the current particle system
  128372. */
  128373. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128374. /**
  128375. * Remove a specific size gradient
  128376. * @param gradient defines the gradient to remove
  128377. * @returns the current particle system
  128378. */
  128379. removeSizeGradient(gradient: number): GPUParticleSystem;
  128380. /**
  128381. * Adds a new angular speed gradient
  128382. * @param gradient defines the gradient to use (between 0 and 1)
  128383. * @param factor defines the angular speed to affect to the specified gradient
  128384. * @returns the current particle system
  128385. */
  128386. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  128387. /**
  128388. * Remove a specific angular speed gradient
  128389. * @param gradient defines the gradient to remove
  128390. * @returns the current particle system
  128391. */
  128392. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  128393. /**
  128394. * Adds a new velocity gradient
  128395. * @param gradient defines the gradient to use (between 0 and 1)
  128396. * @param factor defines the velocity to affect to the specified gradient
  128397. * @returns the current particle system
  128398. */
  128399. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128400. /**
  128401. * Remove a specific velocity gradient
  128402. * @param gradient defines the gradient to remove
  128403. * @returns the current particle system
  128404. */
  128405. removeVelocityGradient(gradient: number): GPUParticleSystem;
  128406. /**
  128407. * Adds a new limit velocity gradient
  128408. * @param gradient defines the gradient to use (between 0 and 1)
  128409. * @param factor defines the limit velocity value to affect to the specified gradient
  128410. * @returns the current particle system
  128411. */
  128412. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128413. /**
  128414. * Remove a specific limit velocity gradient
  128415. * @param gradient defines the gradient to remove
  128416. * @returns the current particle system
  128417. */
  128418. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  128419. /**
  128420. * Adds a new drag gradient
  128421. * @param gradient defines the gradient to use (between 0 and 1)
  128422. * @param factor defines the drag value to affect to the specified gradient
  128423. * @returns the current particle system
  128424. */
  128425. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  128426. /**
  128427. * Remove a specific drag gradient
  128428. * @param gradient defines the gradient to remove
  128429. * @returns the current particle system
  128430. */
  128431. removeDragGradient(gradient: number): GPUParticleSystem;
  128432. /**
  128433. * Not supported by GPUParticleSystem
  128434. * @param gradient defines the gradient to use (between 0 and 1)
  128435. * @param factor defines the emit rate value to affect to the specified gradient
  128436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128437. * @returns the current particle system
  128438. */
  128439. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128440. /**
  128441. * Not supported by GPUParticleSystem
  128442. * @param gradient defines the gradient to remove
  128443. * @returns the current particle system
  128444. */
  128445. removeEmitRateGradient(gradient: number): IParticleSystem;
  128446. /**
  128447. * Not supported by GPUParticleSystem
  128448. * @param gradient defines the gradient to use (between 0 and 1)
  128449. * @param factor defines the start size value to affect to the specified gradient
  128450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128451. * @returns the current particle system
  128452. */
  128453. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128454. /**
  128455. * Not supported by GPUParticleSystem
  128456. * @param gradient defines the gradient to remove
  128457. * @returns the current particle system
  128458. */
  128459. removeStartSizeGradient(gradient: number): IParticleSystem;
  128460. /**
  128461. * Not supported by GPUParticleSystem
  128462. * @param gradient defines the gradient to use (between 0 and 1)
  128463. * @param min defines the color remap minimal range
  128464. * @param max defines the color remap maximal range
  128465. * @returns the current particle system
  128466. */
  128467. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128468. /**
  128469. * Not supported by GPUParticleSystem
  128470. * @param gradient defines the gradient to remove
  128471. * @returns the current particle system
  128472. */
  128473. removeColorRemapGradient(): IParticleSystem;
  128474. /**
  128475. * Not supported by GPUParticleSystem
  128476. * @param gradient defines the gradient to use (between 0 and 1)
  128477. * @param min defines the alpha remap minimal range
  128478. * @param max defines the alpha remap maximal range
  128479. * @returns the current particle system
  128480. */
  128481. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128482. /**
  128483. * Not supported by GPUParticleSystem
  128484. * @param gradient defines the gradient to remove
  128485. * @returns the current particle system
  128486. */
  128487. removeAlphaRemapGradient(): IParticleSystem;
  128488. /**
  128489. * Not supported by GPUParticleSystem
  128490. * @param gradient defines the gradient to use (between 0 and 1)
  128491. * @param color defines the color to affect to the specified gradient
  128492. * @returns the current particle system
  128493. */
  128494. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  128495. /**
  128496. * Not supported by GPUParticleSystem
  128497. * @param gradient defines the gradient to remove
  128498. * @returns the current particle system
  128499. */
  128500. removeRampGradient(): IParticleSystem;
  128501. /**
  128502. * Not supported by GPUParticleSystem
  128503. * @returns the list of ramp gradients
  128504. */
  128505. getRampGradients(): Nullable<Array<Color3Gradient>>;
  128506. /**
  128507. * Not supported by GPUParticleSystem
  128508. * Gets or sets a boolean indicating that ramp gradients must be used
  128509. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  128510. */
  128511. useRampGradients: boolean;
  128512. /**
  128513. * Not supported by GPUParticleSystem
  128514. * @param gradient defines the gradient to use (between 0 and 1)
  128515. * @param factor defines the life time factor to affect to the specified gradient
  128516. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128517. * @returns the current particle system
  128518. */
  128519. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128520. /**
  128521. * Not supported by GPUParticleSystem
  128522. * @param gradient defines the gradient to remove
  128523. * @returns the current particle system
  128524. */
  128525. removeLifeTimeGradient(gradient: number): IParticleSystem;
  128526. /**
  128527. * Instantiates a GPU particle system.
  128528. * 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.
  128529. * @param name The name of the particle system
  128530. * @param options The options used to create the system
  128531. * @param scene The scene the particle system belongs to
  128532. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  128533. */
  128534. constructor(name: string, options: Partial<{
  128535. capacity: number;
  128536. randomTextureSize: number;
  128537. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128538. protected _reset(): void;
  128539. private _createUpdateVAO;
  128540. private _createRenderVAO;
  128541. private _initialize;
  128542. /** @hidden */
  128543. _recreateUpdateEffect(): void;
  128544. /** @hidden */
  128545. _recreateRenderEffect(): void;
  128546. /**
  128547. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128548. * @param preWarm defines if we are in the pre-warmimg phase
  128549. */
  128550. animate(preWarm?: boolean): void;
  128551. private _createFactorGradientTexture;
  128552. private _createSizeGradientTexture;
  128553. private _createAngularSpeedGradientTexture;
  128554. private _createVelocityGradientTexture;
  128555. private _createLimitVelocityGradientTexture;
  128556. private _createDragGradientTexture;
  128557. private _createColorGradientTexture;
  128558. /**
  128559. * Renders the particle system in its current state
  128560. * @param preWarm defines if the system should only update the particles but not render them
  128561. * @returns the current number of particles
  128562. */
  128563. render(preWarm?: boolean): number;
  128564. /**
  128565. * Rebuilds the particle system
  128566. */
  128567. rebuild(): void;
  128568. private _releaseBuffers;
  128569. private _releaseVAOs;
  128570. /**
  128571. * Disposes the particle system and free the associated resources
  128572. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128573. */
  128574. dispose(disposeTexture?: boolean): void;
  128575. /**
  128576. * Clones the particle system.
  128577. * @param name The name of the cloned object
  128578. * @param newEmitter The new emitter to use
  128579. * @returns the cloned particle system
  128580. */
  128581. clone(name: string, newEmitter: any): GPUParticleSystem;
  128582. /**
  128583. * Serializes the particle system to a JSON object.
  128584. * @returns the JSON object
  128585. */
  128586. serialize(): any;
  128587. /**
  128588. * Parses a JSON object to create a GPU particle system.
  128589. * @param parsedParticleSystem The JSON object to parse
  128590. * @param scene The scene to create the particle system in
  128591. * @param rootUrl The root url to use to load external dependencies like texture
  128592. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128593. * @returns the parsed GPU particle system
  128594. */
  128595. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128596. }
  128597. }
  128598. declare module BABYLON {
  128599. /**
  128600. * Represents a set of particle systems working together to create a specific effect
  128601. */
  128602. export class ParticleSystemSet implements IDisposable {
  128603. /**
  128604. * Gets or sets base Assets URL
  128605. */
  128606. static BaseAssetsUrl: string;
  128607. private _emitterCreationOptions;
  128608. private _emitterNode;
  128609. /**
  128610. * Gets the particle system list
  128611. */
  128612. systems: IParticleSystem[];
  128613. /**
  128614. * Gets the emitter node used with this set
  128615. */
  128616. readonly emitterNode: Nullable<TransformNode>;
  128617. /**
  128618. * Creates a new emitter mesh as a sphere
  128619. * @param options defines the options used to create the sphere
  128620. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128621. * @param scene defines the hosting scene
  128622. */
  128623. setEmitterAsSphere(options: {
  128624. diameter: number;
  128625. segments: number;
  128626. color: Color3;
  128627. }, renderingGroupId: number, scene: Scene): void;
  128628. /**
  128629. * Starts all particle systems of the set
  128630. * @param emitter defines an optional mesh to use as emitter for the particle systems
  128631. */
  128632. start(emitter?: AbstractMesh): void;
  128633. /**
  128634. * Release all associated resources
  128635. */
  128636. dispose(): void;
  128637. /**
  128638. * Serialize the set into a JSON compatible object
  128639. * @returns a JSON compatible representation of the set
  128640. */
  128641. serialize(): any;
  128642. /**
  128643. * Parse a new ParticleSystemSet from a serialized source
  128644. * @param data defines a JSON compatible representation of the set
  128645. * @param scene defines the hosting scene
  128646. * @param gpu defines if we want GPU particles or CPU particles
  128647. * @returns a new ParticleSystemSet
  128648. */
  128649. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  128650. }
  128651. }
  128652. declare module BABYLON {
  128653. /**
  128654. * This class is made for on one-liner static method to help creating particle system set.
  128655. */
  128656. export class ParticleHelper {
  128657. /**
  128658. * Gets or sets base Assets URL
  128659. */
  128660. static BaseAssetsUrl: string;
  128661. /**
  128662. * Create a default particle system that you can tweak
  128663. * @param emitter defines the emitter to use
  128664. * @param capacity defines the system capacity (default is 500 particles)
  128665. * @param scene defines the hosting scene
  128666. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  128667. * @returns the new Particle system
  128668. */
  128669. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  128670. /**
  128671. * This is the main static method (one-liner) of this helper to create different particle systems
  128672. * @param type This string represents the type to the particle system to create
  128673. * @param scene The scene where the particle system should live
  128674. * @param gpu If the system will use gpu
  128675. * @returns the ParticleSystemSet created
  128676. */
  128677. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  128678. /**
  128679. * Static function used to export a particle system to a ParticleSystemSet variable.
  128680. * Please note that the emitter shape is not exported
  128681. * @param systems defines the particle systems to export
  128682. * @returns the created particle system set
  128683. */
  128684. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  128685. }
  128686. }
  128687. declare module BABYLON {
  128688. interface Engine {
  128689. /**
  128690. * Create an effect to use with particle systems.
  128691. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  128692. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  128693. * @param uniformsNames defines a list of attribute names
  128694. * @param samplers defines an array of string used to represent textures
  128695. * @param defines defines the string containing the defines to use to compile the shaders
  128696. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  128697. * @param onCompiled defines a function to call when the effect creation is successful
  128698. * @param onError defines a function to call when the effect creation has failed
  128699. * @returns the new Effect
  128700. */
  128701. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  128702. }
  128703. interface Mesh {
  128704. /**
  128705. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  128706. * @returns an array of IParticleSystem
  128707. */
  128708. getEmittedParticleSystems(): IParticleSystem[];
  128709. /**
  128710. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  128711. * @returns an array of IParticleSystem
  128712. */
  128713. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  128714. }
  128715. /**
  128716. * @hidden
  128717. */
  128718. export var _IDoNeedToBeInTheBuild: number;
  128719. }
  128720. declare module BABYLON {
  128721. /** Defines the 4 color options */
  128722. export enum PointColor {
  128723. /** color value */
  128724. Color = 2,
  128725. /** uv value */
  128726. UV = 1,
  128727. /** random value */
  128728. Random = 0,
  128729. /** stated value */
  128730. Stated = 3
  128731. }
  128732. /**
  128733. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  128734. * 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.
  128735. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  128736. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  128737. *
  128738. * Full documentation here : TO BE ENTERED
  128739. */
  128740. export class PointsCloudSystem implements IDisposable {
  128741. /**
  128742. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  128743. * Example : var p = SPS.particles[i];
  128744. */
  128745. particles: CloudPoint[];
  128746. /**
  128747. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  128748. */
  128749. nbParticles: number;
  128750. /**
  128751. * This a counter for your own usage. It's not set by any SPS functions.
  128752. */
  128753. counter: number;
  128754. /**
  128755. * The PCS name. This name is also given to the underlying mesh.
  128756. */
  128757. name: string;
  128758. /**
  128759. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  128760. */
  128761. mesh: Mesh;
  128762. /**
  128763. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  128764. * Please read :
  128765. */
  128766. vars: any;
  128767. /**
  128768. * @hidden
  128769. */
  128770. _size: number;
  128771. private _scene;
  128772. private _promises;
  128773. private _positions;
  128774. private _indices;
  128775. private _normals;
  128776. private _colors;
  128777. private _uvs;
  128778. private _indices32;
  128779. private _positions32;
  128780. private _colors32;
  128781. private _uvs32;
  128782. private _updatable;
  128783. private _isVisibilityBoxLocked;
  128784. private _alwaysVisible;
  128785. private _groups;
  128786. private _groupCounter;
  128787. private _computeParticleColor;
  128788. private _computeParticleTexture;
  128789. private _computeParticleRotation;
  128790. private _computeBoundingBox;
  128791. private _isReady;
  128792. /**
  128793. * Creates a PCS (Points Cloud System) object
  128794. * @param name (String) is the PCS name, this will be the underlying mesh name
  128795. * @param pointSize (number) is the size for each point
  128796. * @param scene (Scene) is the scene in which the PCS is added
  128797. * @param options defines the options of the PCS e.g.
  128798. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  128799. */
  128800. constructor(name: string, pointSize: number, scene: Scene, options?: {
  128801. updatable?: boolean;
  128802. });
  128803. /**
  128804. * Builds the PCS underlying mesh. Returns a standard Mesh.
  128805. * If no points were added to the PCS, the returned mesh is just a single point.
  128806. * @returns a promise for the created mesh
  128807. */
  128808. buildMeshAsync(): Promise<Mesh>;
  128809. /**
  128810. * @hidden
  128811. */
  128812. private _buildMesh;
  128813. private _addParticle;
  128814. private _randomUnitVector;
  128815. private _getColorIndicesForCoord;
  128816. private _setPointsColorOrUV;
  128817. private _colorFromTexture;
  128818. private _calculateDensity;
  128819. /**
  128820. * Adds points to the PCS in random positions within a unit sphere
  128821. * @param nb (positive integer) the number of particles to be created from this model
  128822. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  128823. * @returns the number of groups in the system
  128824. */
  128825. addPoints(nb: number, pointFunction?: any): number;
  128826. /**
  128827. * Adds points to the PCS from the surface of the model shape
  128828. * @param mesh is any Mesh object that will be used as a surface model for the points
  128829. * @param nb (positive integer) the number of particles to be created from this model
  128830. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128831. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128832. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128833. * @returns the number of groups in the system
  128834. */
  128835. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128836. /**
  128837. * Adds points to the PCS inside the model shape
  128838. * @param mesh is any Mesh object that will be used as a surface model for the points
  128839. * @param nb (positive integer) the number of particles to be created from this model
  128840. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128841. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128842. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128843. * @returns the number of groups in the system
  128844. */
  128845. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128846. /**
  128847. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128848. * This method calls `updateParticle()` for each particle of the SPS.
  128849. * For an animated SPS, it is usually called within the render loop.
  128850. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128851. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128852. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128853. * @returns the PCS.
  128854. */
  128855. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128856. /**
  128857. * Disposes the PCS.
  128858. */
  128859. dispose(): void;
  128860. /**
  128861. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128862. * doc :
  128863. * @returns the PCS.
  128864. */
  128865. refreshVisibleSize(): PointsCloudSystem;
  128866. /**
  128867. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128868. * @param size the size (float) of the visibility box
  128869. * note : this doesn't lock the PCS mesh bounding box.
  128870. * doc :
  128871. */
  128872. setVisibilityBox(size: number): void;
  128873. /**
  128874. * Gets whether the PCS is always visible or not
  128875. * doc :
  128876. */
  128877. /**
  128878. * Sets the PCS as always visible or not
  128879. * doc :
  128880. */
  128881. isAlwaysVisible: boolean;
  128882. /**
  128883. * Tells to `setParticles()` to compute the particle rotations or not
  128884. * Default value : false. The PCS is faster when it's set to false
  128885. * Note : particle rotations are only applied to parent particles
  128886. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128887. */
  128888. computeParticleRotation: boolean;
  128889. /**
  128890. * Tells to `setParticles()` to compute the particle colors or not.
  128891. * Default value : true. The PCS is faster when it's set to false.
  128892. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128893. */
  128894. /**
  128895. * Gets if `setParticles()` computes the particle colors or not.
  128896. * Default value : false. The PCS is faster when it's set to false.
  128897. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128898. */
  128899. computeParticleColor: boolean;
  128900. /**
  128901. * Gets if `setParticles()` computes the particle textures or not.
  128902. * Default value : false. The PCS is faster when it's set to false.
  128903. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128904. */
  128905. computeParticleTexture: boolean;
  128906. /**
  128907. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128908. */
  128909. /**
  128910. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128911. */
  128912. computeBoundingBox: boolean;
  128913. /**
  128914. * This function does nothing. It may be overwritten to set all the particle first values.
  128915. * The PCS doesn't call this function, you may have to call it by your own.
  128916. * doc :
  128917. */
  128918. initParticles(): void;
  128919. /**
  128920. * This function does nothing. It may be overwritten to recycle a particle
  128921. * The PCS doesn't call this function, you can to call it
  128922. * doc :
  128923. * @param particle The particle to recycle
  128924. * @returns the recycled particle
  128925. */
  128926. recycleParticle(particle: CloudPoint): CloudPoint;
  128927. /**
  128928. * Updates a particle : this function should be overwritten by the user.
  128929. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128930. * doc :
  128931. * @example : just set a particle position or velocity and recycle conditions
  128932. * @param particle The particle to update
  128933. * @returns the updated particle
  128934. */
  128935. updateParticle(particle: CloudPoint): CloudPoint;
  128936. /**
  128937. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  128938. * This does nothing and may be overwritten by the user.
  128939. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128940. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128941. * @param update the boolean update value actually passed to setParticles()
  128942. */
  128943. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128944. /**
  128945. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  128946. * This will be passed three parameters.
  128947. * This does nothing and may be overwritten by the user.
  128948. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128949. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128950. * @param update the boolean update value actually passed to setParticles()
  128951. */
  128952. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128953. }
  128954. }
  128955. declare module BABYLON {
  128956. /**
  128957. * Represents one particle of a points cloud system.
  128958. */
  128959. export class CloudPoint {
  128960. /**
  128961. * particle global index
  128962. */
  128963. idx: number;
  128964. /**
  128965. * The color of the particle
  128966. */
  128967. color: Nullable<Color4>;
  128968. /**
  128969. * The world space position of the particle.
  128970. */
  128971. position: Vector3;
  128972. /**
  128973. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  128974. */
  128975. rotation: Vector3;
  128976. /**
  128977. * The world space rotation quaternion of the particle.
  128978. */
  128979. rotationQuaternion: Nullable<Quaternion>;
  128980. /**
  128981. * The uv of the particle.
  128982. */
  128983. uv: Nullable<Vector2>;
  128984. /**
  128985. * The current speed of the particle.
  128986. */
  128987. velocity: Vector3;
  128988. /**
  128989. * The pivot point in the particle local space.
  128990. */
  128991. pivot: Vector3;
  128992. /**
  128993. * Must the particle be translated from its pivot point in its local space ?
  128994. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  128995. * Default : false
  128996. */
  128997. translateFromPivot: boolean;
  128998. /**
  128999. * Index of this particle in the global "positions" array (Internal use)
  129000. * @hidden
  129001. */
  129002. _pos: number;
  129003. /**
  129004. * @hidden Index of this particle in the global "indices" array (Internal use)
  129005. */
  129006. _ind: number;
  129007. /**
  129008. * Group this particle belongs to
  129009. */
  129010. _group: PointsGroup;
  129011. /**
  129012. * Group id of this particle
  129013. */
  129014. groupId: number;
  129015. /**
  129016. * Index of the particle in its group id (Internal use)
  129017. */
  129018. idxInGroup: number;
  129019. /**
  129020. * @hidden Particle BoundingInfo object (Internal use)
  129021. */
  129022. _boundingInfo: BoundingInfo;
  129023. /**
  129024. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  129025. */
  129026. _pcs: PointsCloudSystem;
  129027. /**
  129028. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  129029. */
  129030. _stillInvisible: boolean;
  129031. /**
  129032. * @hidden Last computed particle rotation matrix
  129033. */
  129034. _rotationMatrix: number[];
  129035. /**
  129036. * Parent particle Id, if any.
  129037. * Default null.
  129038. */
  129039. parentId: Nullable<number>;
  129040. /**
  129041. * @hidden Internal global position in the PCS.
  129042. */
  129043. _globalPosition: Vector3;
  129044. /**
  129045. * Creates a Point Cloud object.
  129046. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129047. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129048. * @param group (PointsGroup) is the group the particle belongs to
  129049. * @param groupId (integer) is the group identifier in the PCS.
  129050. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129051. * @param pcs defines the PCS it is associated to
  129052. */
  129053. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129054. /**
  129055. * get point size
  129056. */
  129057. /**
  129058. * Set point size
  129059. */
  129060. size: Vector3;
  129061. /**
  129062. * Legacy support, changed quaternion to rotationQuaternion
  129063. */
  129064. /**
  129065. * Legacy support, changed quaternion to rotationQuaternion
  129066. */
  129067. quaternion: Nullable<Quaternion>;
  129068. /**
  129069. * Returns a boolean. True if the particle intersects a mesh, else false
  129070. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129071. * @param target is the object (point or mesh) what the intersection is computed against
  129072. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129073. * @returns true if it intersects
  129074. */
  129075. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129076. /**
  129077. * get the rotation matrix of the particle
  129078. * @hidden
  129079. */
  129080. getRotationMatrix(m: Matrix): void;
  129081. }
  129082. /**
  129083. * Represents a group of points in a points cloud system
  129084. * * PCS internal tool, don't use it manually.
  129085. */
  129086. export class PointsGroup {
  129087. /**
  129088. * The group id
  129089. * @hidden
  129090. */
  129091. groupID: number;
  129092. /**
  129093. * image data for group (internal use)
  129094. * @hidden
  129095. */
  129096. _groupImageData: Nullable<ArrayBufferView>;
  129097. /**
  129098. * Image Width (internal use)
  129099. * @hidden
  129100. */
  129101. _groupImgWidth: number;
  129102. /**
  129103. * Image Height (internal use)
  129104. * @hidden
  129105. */
  129106. _groupImgHeight: number;
  129107. /**
  129108. * Custom position function (internal use)
  129109. * @hidden
  129110. */
  129111. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129112. /**
  129113. * density per facet for surface points
  129114. * @hidden
  129115. */
  129116. _groupDensity: number[];
  129117. /**
  129118. * Only when points are colored by texture carries pointer to texture list array
  129119. * @hidden
  129120. */
  129121. _textureNb: number;
  129122. /**
  129123. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129124. * PCS internal tool, don't use it manually.
  129125. * @hidden
  129126. */
  129127. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129128. }
  129129. }
  129130. declare module BABYLON {
  129131. interface Scene {
  129132. /** @hidden (Backing field) */
  129133. _physicsEngine: Nullable<IPhysicsEngine>;
  129134. /** @hidden */
  129135. _physicsTimeAccumulator: number;
  129136. /**
  129137. * Gets the current physics engine
  129138. * @returns a IPhysicsEngine or null if none attached
  129139. */
  129140. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129141. /**
  129142. * Enables physics to the current scene
  129143. * @param gravity defines the scene's gravity for the physics engine
  129144. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129145. * @return a boolean indicating if the physics engine was initialized
  129146. */
  129147. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129148. /**
  129149. * Disables and disposes the physics engine associated with the scene
  129150. */
  129151. disablePhysicsEngine(): void;
  129152. /**
  129153. * Gets a boolean indicating if there is an active physics engine
  129154. * @returns a boolean indicating if there is an active physics engine
  129155. */
  129156. isPhysicsEnabled(): boolean;
  129157. /**
  129158. * Deletes a physics compound impostor
  129159. * @param compound defines the compound to delete
  129160. */
  129161. deleteCompoundImpostor(compound: any): void;
  129162. /**
  129163. * An event triggered when physic simulation is about to be run
  129164. */
  129165. onBeforePhysicsObservable: Observable<Scene>;
  129166. /**
  129167. * An event triggered when physic simulation has been done
  129168. */
  129169. onAfterPhysicsObservable: Observable<Scene>;
  129170. }
  129171. interface AbstractMesh {
  129172. /** @hidden */
  129173. _physicsImpostor: Nullable<PhysicsImpostor>;
  129174. /**
  129175. * Gets or sets impostor used for physic simulation
  129176. * @see http://doc.babylonjs.com/features/physics_engine
  129177. */
  129178. physicsImpostor: Nullable<PhysicsImpostor>;
  129179. /**
  129180. * Gets the current physics impostor
  129181. * @see http://doc.babylonjs.com/features/physics_engine
  129182. * @returns a physics impostor or null
  129183. */
  129184. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129185. /** Apply a physic impulse to the mesh
  129186. * @param force defines the force to apply
  129187. * @param contactPoint defines where to apply the force
  129188. * @returns the current mesh
  129189. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129190. */
  129191. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129192. /**
  129193. * Creates a physic joint between two meshes
  129194. * @param otherMesh defines the other mesh to use
  129195. * @param pivot1 defines the pivot to use on this mesh
  129196. * @param pivot2 defines the pivot to use on the other mesh
  129197. * @param options defines additional options (can be plugin dependent)
  129198. * @returns the current mesh
  129199. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129200. */
  129201. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129202. /** @hidden */
  129203. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129204. }
  129205. /**
  129206. * Defines the physics engine scene component responsible to manage a physics engine
  129207. */
  129208. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129209. /**
  129210. * The component name helpful to identify the component in the list of scene components.
  129211. */
  129212. readonly name: string;
  129213. /**
  129214. * The scene the component belongs to.
  129215. */
  129216. scene: Scene;
  129217. /**
  129218. * Creates a new instance of the component for the given scene
  129219. * @param scene Defines the scene to register the component in
  129220. */
  129221. constructor(scene: Scene);
  129222. /**
  129223. * Registers the component in a given scene
  129224. */
  129225. register(): void;
  129226. /**
  129227. * Rebuilds the elements related to this component in case of
  129228. * context lost for instance.
  129229. */
  129230. rebuild(): void;
  129231. /**
  129232. * Disposes the component and the associated ressources
  129233. */
  129234. dispose(): void;
  129235. }
  129236. }
  129237. declare module BABYLON {
  129238. /**
  129239. * A helper for physics simulations
  129240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129241. */
  129242. export class PhysicsHelper {
  129243. private _scene;
  129244. private _physicsEngine;
  129245. /**
  129246. * Initializes the Physics helper
  129247. * @param scene Babylon.js scene
  129248. */
  129249. constructor(scene: Scene);
  129250. /**
  129251. * Applies a radial explosion impulse
  129252. * @param origin the origin of the explosion
  129253. * @param radiusOrEventOptions the radius or the options of radial explosion
  129254. * @param strength the explosion strength
  129255. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129256. * @returns A physics radial explosion event, or null
  129257. */
  129258. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129259. /**
  129260. * Applies a radial explosion force
  129261. * @param origin the origin of the explosion
  129262. * @param radiusOrEventOptions the radius or the options of radial explosion
  129263. * @param strength the explosion strength
  129264. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129265. * @returns A physics radial explosion event, or null
  129266. */
  129267. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129268. /**
  129269. * Creates a gravitational field
  129270. * @param origin the origin of the explosion
  129271. * @param radiusOrEventOptions the radius or the options of radial explosion
  129272. * @param strength the explosion strength
  129273. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129274. * @returns A physics gravitational field event, or null
  129275. */
  129276. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129277. /**
  129278. * Creates a physics updraft event
  129279. * @param origin the origin of the updraft
  129280. * @param radiusOrEventOptions the radius or the options of the updraft
  129281. * @param strength the strength of the updraft
  129282. * @param height the height of the updraft
  129283. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129284. * @returns A physics updraft event, or null
  129285. */
  129286. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129287. /**
  129288. * Creates a physics vortex event
  129289. * @param origin the of the vortex
  129290. * @param radiusOrEventOptions the radius or the options of the vortex
  129291. * @param strength the strength of the vortex
  129292. * @param height the height of the vortex
  129293. * @returns a Physics vortex event, or null
  129294. * A physics vortex event or null
  129295. */
  129296. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129297. }
  129298. /**
  129299. * Represents a physics radial explosion event
  129300. */
  129301. class PhysicsRadialExplosionEvent {
  129302. private _scene;
  129303. private _options;
  129304. private _sphere;
  129305. private _dataFetched;
  129306. /**
  129307. * Initializes a radial explosioin event
  129308. * @param _scene BabylonJS scene
  129309. * @param _options The options for the vortex event
  129310. */
  129311. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129312. /**
  129313. * Returns the data related to the radial explosion event (sphere).
  129314. * @returns The radial explosion event data
  129315. */
  129316. getData(): PhysicsRadialExplosionEventData;
  129317. /**
  129318. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129319. * @param impostor A physics imposter
  129320. * @param origin the origin of the explosion
  129321. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129322. */
  129323. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129324. /**
  129325. * Triggers affecterd impostors callbacks
  129326. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129327. */
  129328. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129329. /**
  129330. * Disposes the sphere.
  129331. * @param force Specifies if the sphere should be disposed by force
  129332. */
  129333. dispose(force?: boolean): void;
  129334. /*** Helpers ***/
  129335. private _prepareSphere;
  129336. private _intersectsWithSphere;
  129337. }
  129338. /**
  129339. * Represents a gravitational field event
  129340. */
  129341. class PhysicsGravitationalFieldEvent {
  129342. private _physicsHelper;
  129343. private _scene;
  129344. private _origin;
  129345. private _options;
  129346. private _tickCallback;
  129347. private _sphere;
  129348. private _dataFetched;
  129349. /**
  129350. * Initializes the physics gravitational field event
  129351. * @param _physicsHelper A physics helper
  129352. * @param _scene BabylonJS scene
  129353. * @param _origin The origin position of the gravitational field event
  129354. * @param _options The options for the vortex event
  129355. */
  129356. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129357. /**
  129358. * Returns the data related to the gravitational field event (sphere).
  129359. * @returns A gravitational field event
  129360. */
  129361. getData(): PhysicsGravitationalFieldEventData;
  129362. /**
  129363. * Enables the gravitational field.
  129364. */
  129365. enable(): void;
  129366. /**
  129367. * Disables the gravitational field.
  129368. */
  129369. disable(): void;
  129370. /**
  129371. * Disposes the sphere.
  129372. * @param force The force to dispose from the gravitational field event
  129373. */
  129374. dispose(force?: boolean): void;
  129375. private _tick;
  129376. }
  129377. /**
  129378. * Represents a physics updraft event
  129379. */
  129380. class PhysicsUpdraftEvent {
  129381. private _scene;
  129382. private _origin;
  129383. private _options;
  129384. private _physicsEngine;
  129385. private _originTop;
  129386. private _originDirection;
  129387. private _tickCallback;
  129388. private _cylinder;
  129389. private _cylinderPosition;
  129390. private _dataFetched;
  129391. /**
  129392. * Initializes the physics updraft event
  129393. * @param _scene BabylonJS scene
  129394. * @param _origin The origin position of the updraft
  129395. * @param _options The options for the updraft event
  129396. */
  129397. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  129398. /**
  129399. * Returns the data related to the updraft event (cylinder).
  129400. * @returns A physics updraft event
  129401. */
  129402. getData(): PhysicsUpdraftEventData;
  129403. /**
  129404. * Enables the updraft.
  129405. */
  129406. enable(): void;
  129407. /**
  129408. * Disables the updraft.
  129409. */
  129410. disable(): void;
  129411. /**
  129412. * Disposes the cylinder.
  129413. * @param force Specifies if the updraft should be disposed by force
  129414. */
  129415. dispose(force?: boolean): void;
  129416. private getImpostorHitData;
  129417. private _tick;
  129418. /*** Helpers ***/
  129419. private _prepareCylinder;
  129420. private _intersectsWithCylinder;
  129421. }
  129422. /**
  129423. * Represents a physics vortex event
  129424. */
  129425. class PhysicsVortexEvent {
  129426. private _scene;
  129427. private _origin;
  129428. private _options;
  129429. private _physicsEngine;
  129430. private _originTop;
  129431. private _tickCallback;
  129432. private _cylinder;
  129433. private _cylinderPosition;
  129434. private _dataFetched;
  129435. /**
  129436. * Initializes the physics vortex event
  129437. * @param _scene The BabylonJS scene
  129438. * @param _origin The origin position of the vortex
  129439. * @param _options The options for the vortex event
  129440. */
  129441. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  129442. /**
  129443. * Returns the data related to the vortex event (cylinder).
  129444. * @returns The physics vortex event data
  129445. */
  129446. getData(): PhysicsVortexEventData;
  129447. /**
  129448. * Enables the vortex.
  129449. */
  129450. enable(): void;
  129451. /**
  129452. * Disables the cortex.
  129453. */
  129454. disable(): void;
  129455. /**
  129456. * Disposes the sphere.
  129457. * @param force
  129458. */
  129459. dispose(force?: boolean): void;
  129460. private getImpostorHitData;
  129461. private _tick;
  129462. /*** Helpers ***/
  129463. private _prepareCylinder;
  129464. private _intersectsWithCylinder;
  129465. }
  129466. /**
  129467. * Options fot the radial explosion event
  129468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129469. */
  129470. export class PhysicsRadialExplosionEventOptions {
  129471. /**
  129472. * The radius of the sphere for the radial explosion.
  129473. */
  129474. radius: number;
  129475. /**
  129476. * The strenth of the explosion.
  129477. */
  129478. strength: number;
  129479. /**
  129480. * The strenght of the force in correspondence to the distance of the affected object
  129481. */
  129482. falloff: PhysicsRadialImpulseFalloff;
  129483. /**
  129484. * Sphere options for the radial explosion.
  129485. */
  129486. sphere: {
  129487. segments: number;
  129488. diameter: number;
  129489. };
  129490. /**
  129491. * Sphere options for the radial explosion.
  129492. */
  129493. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  129494. }
  129495. /**
  129496. * Options fot the updraft event
  129497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129498. */
  129499. export class PhysicsUpdraftEventOptions {
  129500. /**
  129501. * The radius of the cylinder for the vortex
  129502. */
  129503. radius: number;
  129504. /**
  129505. * The strenth of the updraft.
  129506. */
  129507. strength: number;
  129508. /**
  129509. * The height of the cylinder for the updraft.
  129510. */
  129511. height: number;
  129512. /**
  129513. * The mode for the the updraft.
  129514. */
  129515. updraftMode: PhysicsUpdraftMode;
  129516. }
  129517. /**
  129518. * Options fot the vortex event
  129519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129520. */
  129521. export class PhysicsVortexEventOptions {
  129522. /**
  129523. * The radius of the cylinder for the vortex
  129524. */
  129525. radius: number;
  129526. /**
  129527. * The strenth of the vortex.
  129528. */
  129529. strength: number;
  129530. /**
  129531. * The height of the cylinder for the vortex.
  129532. */
  129533. height: number;
  129534. /**
  129535. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129536. */
  129537. centripetalForceThreshold: number;
  129538. /**
  129539. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129540. */
  129541. centripetalForceMultiplier: number;
  129542. /**
  129543. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129544. */
  129545. centrifugalForceMultiplier: number;
  129546. /**
  129547. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129548. */
  129549. updraftForceMultiplier: number;
  129550. }
  129551. /**
  129552. * The strenght of the force in correspondence to the distance of the affected object
  129553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129554. */
  129555. export enum PhysicsRadialImpulseFalloff {
  129556. /** Defines that impulse is constant in strength across it's whole radius */
  129557. Constant = 0,
  129558. /** Defines that impulse gets weaker if it's further from the origin */
  129559. Linear = 1
  129560. }
  129561. /**
  129562. * The strength of the force in correspondence to the distance of the affected object
  129563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129564. */
  129565. export enum PhysicsUpdraftMode {
  129566. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129567. Center = 0,
  129568. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129569. Perpendicular = 1
  129570. }
  129571. /**
  129572. * Interface for a physics hit data
  129573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129574. */
  129575. export interface PhysicsHitData {
  129576. /**
  129577. * The force applied at the contact point
  129578. */
  129579. force: Vector3;
  129580. /**
  129581. * The contact point
  129582. */
  129583. contactPoint: Vector3;
  129584. /**
  129585. * The distance from the origin to the contact point
  129586. */
  129587. distanceFromOrigin: number;
  129588. }
  129589. /**
  129590. * Interface for radial explosion event data
  129591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129592. */
  129593. export interface PhysicsRadialExplosionEventData {
  129594. /**
  129595. * A sphere used for the radial explosion event
  129596. */
  129597. sphere: Mesh;
  129598. }
  129599. /**
  129600. * Interface for gravitational field event data
  129601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129602. */
  129603. export interface PhysicsGravitationalFieldEventData {
  129604. /**
  129605. * A sphere mesh used for the gravitational field event
  129606. */
  129607. sphere: Mesh;
  129608. }
  129609. /**
  129610. * Interface for updraft event data
  129611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129612. */
  129613. export interface PhysicsUpdraftEventData {
  129614. /**
  129615. * A cylinder used for the updraft event
  129616. */
  129617. cylinder: Mesh;
  129618. }
  129619. /**
  129620. * Interface for vortex event data
  129621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129622. */
  129623. export interface PhysicsVortexEventData {
  129624. /**
  129625. * A cylinder used for the vortex event
  129626. */
  129627. cylinder: Mesh;
  129628. }
  129629. /**
  129630. * Interface for an affected physics impostor
  129631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129632. */
  129633. export interface PhysicsAffectedImpostorWithData {
  129634. /**
  129635. * The impostor affected by the effect
  129636. */
  129637. impostor: PhysicsImpostor;
  129638. /**
  129639. * The data about the hit/horce from the explosion
  129640. */
  129641. hitData: PhysicsHitData;
  129642. }
  129643. }
  129644. declare module BABYLON {
  129645. /** @hidden */
  129646. export var blackAndWhitePixelShader: {
  129647. name: string;
  129648. shader: string;
  129649. };
  129650. }
  129651. declare module BABYLON {
  129652. /**
  129653. * Post process used to render in black and white
  129654. */
  129655. export class BlackAndWhitePostProcess extends PostProcess {
  129656. /**
  129657. * Linear about to convert he result to black and white (default: 1)
  129658. */
  129659. degree: number;
  129660. /**
  129661. * Creates a black and white post process
  129662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  129663. * @param name The name of the effect.
  129664. * @param options The required width/height ratio to downsize to before computing the render pass.
  129665. * @param camera The camera to apply the render pass to.
  129666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129667. * @param engine The engine which the post process will be applied. (default: current engine)
  129668. * @param reusable If the post process can be reused on the same frame. (default: false)
  129669. */
  129670. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129671. }
  129672. }
  129673. declare module BABYLON {
  129674. /**
  129675. * This represents a set of one or more post processes in Babylon.
  129676. * A post process can be used to apply a shader to a texture after it is rendered.
  129677. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129678. */
  129679. export class PostProcessRenderEffect {
  129680. private _postProcesses;
  129681. private _getPostProcesses;
  129682. private _singleInstance;
  129683. private _cameras;
  129684. private _indicesForCamera;
  129685. /**
  129686. * Name of the effect
  129687. * @hidden
  129688. */
  129689. _name: string;
  129690. /**
  129691. * Instantiates a post process render effect.
  129692. * A post process can be used to apply a shader to a texture after it is rendered.
  129693. * @param engine The engine the effect is tied to
  129694. * @param name The name of the effect
  129695. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  129696. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  129697. */
  129698. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  129699. /**
  129700. * Checks if all the post processes in the effect are supported.
  129701. */
  129702. readonly isSupported: boolean;
  129703. /**
  129704. * Updates the current state of the effect
  129705. * @hidden
  129706. */
  129707. _update(): void;
  129708. /**
  129709. * Attaches the effect on cameras
  129710. * @param cameras The camera to attach to.
  129711. * @hidden
  129712. */
  129713. _attachCameras(cameras: Camera): void;
  129714. /**
  129715. * Attaches the effect on cameras
  129716. * @param cameras The camera to attach to.
  129717. * @hidden
  129718. */
  129719. _attachCameras(cameras: Camera[]): void;
  129720. /**
  129721. * Detaches the effect on cameras
  129722. * @param cameras The camera to detatch from.
  129723. * @hidden
  129724. */
  129725. _detachCameras(cameras: Camera): void;
  129726. /**
  129727. * Detatches the effect on cameras
  129728. * @param cameras The camera to detatch from.
  129729. * @hidden
  129730. */
  129731. _detachCameras(cameras: Camera[]): void;
  129732. /**
  129733. * Enables the effect on given cameras
  129734. * @param cameras The camera to enable.
  129735. * @hidden
  129736. */
  129737. _enable(cameras: Camera): void;
  129738. /**
  129739. * Enables the effect on given cameras
  129740. * @param cameras The camera to enable.
  129741. * @hidden
  129742. */
  129743. _enable(cameras: Nullable<Camera[]>): void;
  129744. /**
  129745. * Disables the effect on the given cameras
  129746. * @param cameras The camera to disable.
  129747. * @hidden
  129748. */
  129749. _disable(cameras: Camera): void;
  129750. /**
  129751. * Disables the effect on the given cameras
  129752. * @param cameras The camera to disable.
  129753. * @hidden
  129754. */
  129755. _disable(cameras: Nullable<Camera[]>): void;
  129756. /**
  129757. * Gets a list of the post processes contained in the effect.
  129758. * @param camera The camera to get the post processes on.
  129759. * @returns The list of the post processes in the effect.
  129760. */
  129761. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  129762. }
  129763. }
  129764. declare module BABYLON {
  129765. /** @hidden */
  129766. export var extractHighlightsPixelShader: {
  129767. name: string;
  129768. shader: string;
  129769. };
  129770. }
  129771. declare module BABYLON {
  129772. /**
  129773. * 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.
  129774. */
  129775. export class ExtractHighlightsPostProcess extends PostProcess {
  129776. /**
  129777. * The luminance threshold, pixels below this value will be set to black.
  129778. */
  129779. threshold: number;
  129780. /** @hidden */
  129781. _exposure: number;
  129782. /**
  129783. * Post process which has the input texture to be used when performing highlight extraction
  129784. * @hidden
  129785. */
  129786. _inputPostProcess: Nullable<PostProcess>;
  129787. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129788. }
  129789. }
  129790. declare module BABYLON {
  129791. /** @hidden */
  129792. export var bloomMergePixelShader: {
  129793. name: string;
  129794. shader: string;
  129795. };
  129796. }
  129797. declare module BABYLON {
  129798. /**
  129799. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129800. */
  129801. export class BloomMergePostProcess extends PostProcess {
  129802. /** Weight of the bloom to be added to the original input. */
  129803. weight: number;
  129804. /**
  129805. * Creates a new instance of @see BloomMergePostProcess
  129806. * @param name The name of the effect.
  129807. * @param originalFromInput Post process which's input will be used for the merge.
  129808. * @param blurred Blurred highlights post process which's output will be used.
  129809. * @param weight Weight of the bloom to be added to the original input.
  129810. * @param options The required width/height ratio to downsize to before computing the render pass.
  129811. * @param camera The camera to apply the render pass to.
  129812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129813. * @param engine The engine which the post process will be applied. (default: current engine)
  129814. * @param reusable If the post process can be reused on the same frame. (default: false)
  129815. * @param textureType Type of textures used when performing the post process. (default: 0)
  129816. * @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)
  129817. */
  129818. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  129819. /** Weight of the bloom to be added to the original input. */
  129820. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129821. }
  129822. }
  129823. declare module BABYLON {
  129824. /**
  129825. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  129826. */
  129827. export class BloomEffect extends PostProcessRenderEffect {
  129828. private bloomScale;
  129829. /**
  129830. * @hidden Internal
  129831. */
  129832. _effects: Array<PostProcess>;
  129833. /**
  129834. * @hidden Internal
  129835. */
  129836. _downscale: ExtractHighlightsPostProcess;
  129837. private _blurX;
  129838. private _blurY;
  129839. private _merge;
  129840. /**
  129841. * The luminance threshold to find bright areas of the image to bloom.
  129842. */
  129843. threshold: number;
  129844. /**
  129845. * The strength of the bloom.
  129846. */
  129847. weight: number;
  129848. /**
  129849. * Specifies the size of the bloom blur kernel, relative to the final output size
  129850. */
  129851. kernel: number;
  129852. /**
  129853. * Creates a new instance of @see BloomEffect
  129854. * @param scene The scene the effect belongs to.
  129855. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129856. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129857. * @param bloomWeight The the strength of bloom.
  129858. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129859. * @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)
  129860. */
  129861. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129862. /**
  129863. * Disposes each of the internal effects for a given camera.
  129864. * @param camera The camera to dispose the effect on.
  129865. */
  129866. disposeEffects(camera: Camera): void;
  129867. /**
  129868. * @hidden Internal
  129869. */
  129870. _updateEffects(): void;
  129871. /**
  129872. * Internal
  129873. * @returns if all the contained post processes are ready.
  129874. * @hidden
  129875. */
  129876. _isReady(): boolean;
  129877. }
  129878. }
  129879. declare module BABYLON {
  129880. /** @hidden */
  129881. export var chromaticAberrationPixelShader: {
  129882. name: string;
  129883. shader: string;
  129884. };
  129885. }
  129886. declare module BABYLON {
  129887. /**
  129888. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129889. */
  129890. export class ChromaticAberrationPostProcess extends PostProcess {
  129891. /**
  129892. * The amount of seperation of rgb channels (default: 30)
  129893. */
  129894. aberrationAmount: number;
  129895. /**
  129896. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129897. */
  129898. radialIntensity: number;
  129899. /**
  129900. * 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))
  129901. */
  129902. direction: Vector2;
  129903. /**
  129904. * 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))
  129905. */
  129906. centerPosition: Vector2;
  129907. /**
  129908. * Creates a new instance ChromaticAberrationPostProcess
  129909. * @param name The name of the effect.
  129910. * @param screenWidth The width of the screen to apply the effect on.
  129911. * @param screenHeight The height of the screen to apply the effect on.
  129912. * @param options The required width/height ratio to downsize to before computing the render pass.
  129913. * @param camera The camera to apply the render pass to.
  129914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129915. * @param engine The engine which the post process will be applied. (default: current engine)
  129916. * @param reusable If the post process can be reused on the same frame. (default: false)
  129917. * @param textureType Type of textures used when performing the post process. (default: 0)
  129918. * @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)
  129919. */
  129920. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129921. }
  129922. }
  129923. declare module BABYLON {
  129924. /** @hidden */
  129925. export var circleOfConfusionPixelShader: {
  129926. name: string;
  129927. shader: string;
  129928. };
  129929. }
  129930. declare module BABYLON {
  129931. /**
  129932. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129933. */
  129934. export class CircleOfConfusionPostProcess extends PostProcess {
  129935. /**
  129936. * 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.
  129937. */
  129938. lensSize: number;
  129939. /**
  129940. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129941. */
  129942. fStop: number;
  129943. /**
  129944. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129945. */
  129946. focusDistance: number;
  129947. /**
  129948. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  129949. */
  129950. focalLength: number;
  129951. private _depthTexture;
  129952. /**
  129953. * Creates a new instance CircleOfConfusionPostProcess
  129954. * @param name The name of the effect.
  129955. * @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.
  129956. * @param options The required width/height ratio to downsize to before computing the render pass.
  129957. * @param camera The camera to apply the render pass to.
  129958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129959. * @param engine The engine which the post process will be applied. (default: current engine)
  129960. * @param reusable If the post process can be reused on the same frame. (default: false)
  129961. * @param textureType Type of textures used when performing the post process. (default: 0)
  129962. * @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)
  129963. */
  129964. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129965. /**
  129966. * 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.
  129967. */
  129968. depthTexture: RenderTargetTexture;
  129969. }
  129970. }
  129971. declare module BABYLON {
  129972. /** @hidden */
  129973. export var colorCorrectionPixelShader: {
  129974. name: string;
  129975. shader: string;
  129976. };
  129977. }
  129978. declare module BABYLON {
  129979. /**
  129980. *
  129981. * This post-process allows the modification of rendered colors by using
  129982. * a 'look-up table' (LUT). This effect is also called Color Grading.
  129983. *
  129984. * The object needs to be provided an url to a texture containing the color
  129985. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  129986. * Use an image editing software to tweak the LUT to match your needs.
  129987. *
  129988. * For an example of a color LUT, see here:
  129989. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  129990. * For explanations on color grading, see here:
  129991. * @see http://udn.epicgames.com/Three/ColorGrading.html
  129992. *
  129993. */
  129994. export class ColorCorrectionPostProcess extends PostProcess {
  129995. private _colorTableTexture;
  129996. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129997. }
  129998. }
  129999. declare module BABYLON {
  130000. /** @hidden */
  130001. export var convolutionPixelShader: {
  130002. name: string;
  130003. shader: string;
  130004. };
  130005. }
  130006. declare module BABYLON {
  130007. /**
  130008. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  130009. * input texture to perform effects such as edge detection or sharpening
  130010. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130011. */
  130012. export class ConvolutionPostProcess extends PostProcess {
  130013. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130014. kernel: number[];
  130015. /**
  130016. * Creates a new instance ConvolutionPostProcess
  130017. * @param name The name of the effect.
  130018. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  130019. * @param options The required width/height ratio to downsize to before computing the render pass.
  130020. * @param camera The camera to apply the render pass to.
  130021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130022. * @param engine The engine which the post process will be applied. (default: current engine)
  130023. * @param reusable If the post process can be reused on the same frame. (default: false)
  130024. * @param textureType Type of textures used when performing the post process. (default: 0)
  130025. */
  130026. constructor(name: string,
  130027. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130028. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130029. /**
  130030. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130031. */
  130032. static EdgeDetect0Kernel: number[];
  130033. /**
  130034. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130035. */
  130036. static EdgeDetect1Kernel: number[];
  130037. /**
  130038. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130039. */
  130040. static EdgeDetect2Kernel: number[];
  130041. /**
  130042. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130043. */
  130044. static SharpenKernel: number[];
  130045. /**
  130046. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130047. */
  130048. static EmbossKernel: number[];
  130049. /**
  130050. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130051. */
  130052. static GaussianKernel: number[];
  130053. }
  130054. }
  130055. declare module BABYLON {
  130056. /**
  130057. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130058. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130059. * based on samples that have a large difference in distance than the center pixel.
  130060. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130061. */
  130062. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130063. direction: Vector2;
  130064. /**
  130065. * Creates a new instance CircleOfConfusionPostProcess
  130066. * @param name The name of the effect.
  130067. * @param scene The scene the effect belongs to.
  130068. * @param direction The direction the blur should be applied.
  130069. * @param kernel The size of the kernel used to blur.
  130070. * @param options The required width/height ratio to downsize to before computing the render pass.
  130071. * @param camera The camera to apply the render pass to.
  130072. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130073. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130075. * @param engine The engine which the post process will be applied. (default: current engine)
  130076. * @param reusable If the post process can be reused on the same frame. (default: false)
  130077. * @param textureType Type of textures used when performing the post process. (default: 0)
  130078. * @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)
  130079. */
  130080. 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);
  130081. }
  130082. }
  130083. declare module BABYLON {
  130084. /** @hidden */
  130085. export var depthOfFieldMergePixelShader: {
  130086. name: string;
  130087. shader: string;
  130088. };
  130089. }
  130090. declare module BABYLON {
  130091. /**
  130092. * Options to be set when merging outputs from the default pipeline.
  130093. */
  130094. export class DepthOfFieldMergePostProcessOptions {
  130095. /**
  130096. * The original image to merge on top of
  130097. */
  130098. originalFromInput: PostProcess;
  130099. /**
  130100. * Parameters to perform the merge of the depth of field effect
  130101. */
  130102. depthOfField?: {
  130103. circleOfConfusion: PostProcess;
  130104. blurSteps: Array<PostProcess>;
  130105. };
  130106. /**
  130107. * Parameters to perform the merge of bloom effect
  130108. */
  130109. bloom?: {
  130110. blurred: PostProcess;
  130111. weight: number;
  130112. };
  130113. }
  130114. /**
  130115. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130116. */
  130117. export class DepthOfFieldMergePostProcess extends PostProcess {
  130118. private blurSteps;
  130119. /**
  130120. * Creates a new instance of DepthOfFieldMergePostProcess
  130121. * @param name The name of the effect.
  130122. * @param originalFromInput Post process which's input will be used for the merge.
  130123. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130124. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130125. * @param options The required width/height ratio to downsize to before computing the render pass.
  130126. * @param camera The camera to apply the render pass to.
  130127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130128. * @param engine The engine which the post process will be applied. (default: current engine)
  130129. * @param reusable If the post process can be reused on the same frame. (default: false)
  130130. * @param textureType Type of textures used when performing the post process. (default: 0)
  130131. * @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)
  130132. */
  130133. 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);
  130134. /**
  130135. * Updates the effect with the current post process compile time values and recompiles the shader.
  130136. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130137. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130138. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130139. * @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
  130140. * @param onCompiled Called when the shader has been compiled.
  130141. * @param onError Called if there is an error when compiling a shader.
  130142. */
  130143. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130144. }
  130145. }
  130146. declare module BABYLON {
  130147. /**
  130148. * Specifies the level of max blur that should be applied when using the depth of field effect
  130149. */
  130150. export enum DepthOfFieldEffectBlurLevel {
  130151. /**
  130152. * Subtle blur
  130153. */
  130154. Low = 0,
  130155. /**
  130156. * Medium blur
  130157. */
  130158. Medium = 1,
  130159. /**
  130160. * Large blur
  130161. */
  130162. High = 2
  130163. }
  130164. /**
  130165. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130166. */
  130167. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130168. private _circleOfConfusion;
  130169. /**
  130170. * @hidden Internal, blurs from high to low
  130171. */
  130172. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130173. private _depthOfFieldBlurY;
  130174. private _dofMerge;
  130175. /**
  130176. * @hidden Internal post processes in depth of field effect
  130177. */
  130178. _effects: Array<PostProcess>;
  130179. /**
  130180. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130181. */
  130182. focalLength: number;
  130183. /**
  130184. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130185. */
  130186. fStop: number;
  130187. /**
  130188. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130189. */
  130190. focusDistance: number;
  130191. /**
  130192. * 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.
  130193. */
  130194. lensSize: number;
  130195. /**
  130196. * Creates a new instance DepthOfFieldEffect
  130197. * @param scene The scene the effect belongs to.
  130198. * @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.
  130199. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130200. * @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)
  130201. */
  130202. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130203. /**
  130204. * Get the current class name of the current effet
  130205. * @returns "DepthOfFieldEffect"
  130206. */
  130207. getClassName(): string;
  130208. /**
  130209. * 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.
  130210. */
  130211. depthTexture: RenderTargetTexture;
  130212. /**
  130213. * Disposes each of the internal effects for a given camera.
  130214. * @param camera The camera to dispose the effect on.
  130215. */
  130216. disposeEffects(camera: Camera): void;
  130217. /**
  130218. * @hidden Internal
  130219. */
  130220. _updateEffects(): void;
  130221. /**
  130222. * Internal
  130223. * @returns if all the contained post processes are ready.
  130224. * @hidden
  130225. */
  130226. _isReady(): boolean;
  130227. }
  130228. }
  130229. declare module BABYLON {
  130230. /** @hidden */
  130231. export var displayPassPixelShader: {
  130232. name: string;
  130233. shader: string;
  130234. };
  130235. }
  130236. declare module BABYLON {
  130237. /**
  130238. * DisplayPassPostProcess which produces an output the same as it's input
  130239. */
  130240. export class DisplayPassPostProcess extends PostProcess {
  130241. /**
  130242. * Creates the DisplayPassPostProcess
  130243. * @param name The name of the effect.
  130244. * @param options The required width/height ratio to downsize to before computing the render pass.
  130245. * @param camera The camera to apply the render pass to.
  130246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130247. * @param engine The engine which the post process will be applied. (default: current engine)
  130248. * @param reusable If the post process can be reused on the same frame. (default: false)
  130249. */
  130250. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130251. }
  130252. }
  130253. declare module BABYLON {
  130254. /** @hidden */
  130255. export var filterPixelShader: {
  130256. name: string;
  130257. shader: string;
  130258. };
  130259. }
  130260. declare module BABYLON {
  130261. /**
  130262. * Applies a kernel filter to the image
  130263. */
  130264. export class FilterPostProcess extends PostProcess {
  130265. /** The matrix to be applied to the image */
  130266. kernelMatrix: Matrix;
  130267. /**
  130268. *
  130269. * @param name The name of the effect.
  130270. * @param kernelMatrix The matrix to be applied to the image
  130271. * @param options The required width/height ratio to downsize to before computing the render pass.
  130272. * @param camera The camera to apply the render pass to.
  130273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130274. * @param engine The engine which the post process will be applied. (default: current engine)
  130275. * @param reusable If the post process can be reused on the same frame. (default: false)
  130276. */
  130277. constructor(name: string,
  130278. /** The matrix to be applied to the image */
  130279. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130280. }
  130281. }
  130282. declare module BABYLON {
  130283. /** @hidden */
  130284. export var fxaaPixelShader: {
  130285. name: string;
  130286. shader: string;
  130287. };
  130288. }
  130289. declare module BABYLON {
  130290. /** @hidden */
  130291. export var fxaaVertexShader: {
  130292. name: string;
  130293. shader: string;
  130294. };
  130295. }
  130296. declare module BABYLON {
  130297. /**
  130298. * Fxaa post process
  130299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130300. */
  130301. export class FxaaPostProcess extends PostProcess {
  130302. /** @hidden */
  130303. texelWidth: number;
  130304. /** @hidden */
  130305. texelHeight: number;
  130306. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130307. private _getDefines;
  130308. }
  130309. }
  130310. declare module BABYLON {
  130311. /** @hidden */
  130312. export var grainPixelShader: {
  130313. name: string;
  130314. shader: string;
  130315. };
  130316. }
  130317. declare module BABYLON {
  130318. /**
  130319. * The GrainPostProcess adds noise to the image at mid luminance levels
  130320. */
  130321. export class GrainPostProcess extends PostProcess {
  130322. /**
  130323. * The intensity of the grain added (default: 30)
  130324. */
  130325. intensity: number;
  130326. /**
  130327. * If the grain should be randomized on every frame
  130328. */
  130329. animated: boolean;
  130330. /**
  130331. * Creates a new instance of @see GrainPostProcess
  130332. * @param name The name of the effect.
  130333. * @param options The required width/height ratio to downsize to before computing the render pass.
  130334. * @param camera The camera to apply the render pass to.
  130335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130336. * @param engine The engine which the post process will be applied. (default: current engine)
  130337. * @param reusable If the post process can be reused on the same frame. (default: false)
  130338. * @param textureType Type of textures used when performing the post process. (default: 0)
  130339. * @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)
  130340. */
  130341. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130342. }
  130343. }
  130344. declare module BABYLON {
  130345. /** @hidden */
  130346. export var highlightsPixelShader: {
  130347. name: string;
  130348. shader: string;
  130349. };
  130350. }
  130351. declare module BABYLON {
  130352. /**
  130353. * Extracts highlights from the image
  130354. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130355. */
  130356. export class HighlightsPostProcess extends PostProcess {
  130357. /**
  130358. * Extracts highlights from the image
  130359. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130360. * @param name The name of the effect.
  130361. * @param options The required width/height ratio to downsize to before computing the render pass.
  130362. * @param camera The camera to apply the render pass to.
  130363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130364. * @param engine The engine which the post process will be applied. (default: current engine)
  130365. * @param reusable If the post process can be reused on the same frame. (default: false)
  130366. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130367. */
  130368. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130369. }
  130370. }
  130371. declare module BABYLON {
  130372. /** @hidden */
  130373. export var mrtFragmentDeclaration: {
  130374. name: string;
  130375. shader: string;
  130376. };
  130377. }
  130378. declare module BABYLON {
  130379. /** @hidden */
  130380. export var geometryPixelShader: {
  130381. name: string;
  130382. shader: string;
  130383. };
  130384. }
  130385. declare module BABYLON {
  130386. /** @hidden */
  130387. export var geometryVertexShader: {
  130388. name: string;
  130389. shader: string;
  130390. };
  130391. }
  130392. declare module BABYLON {
  130393. /** @hidden */
  130394. interface ISavedTransformationMatrix {
  130395. world: Matrix;
  130396. viewProjection: Matrix;
  130397. }
  130398. /**
  130399. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  130400. */
  130401. export class GeometryBufferRenderer {
  130402. /**
  130403. * Constant used to retrieve the position texture index in the G-Buffer textures array
  130404. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  130405. */
  130406. static readonly POSITION_TEXTURE_TYPE: number;
  130407. /**
  130408. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  130409. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  130410. */
  130411. static readonly VELOCITY_TEXTURE_TYPE: number;
  130412. /**
  130413. * Dictionary used to store the previous transformation matrices of each rendered mesh
  130414. * in order to compute objects velocities when enableVelocity is set to "true"
  130415. * @hidden
  130416. */
  130417. _previousTransformationMatrices: {
  130418. [index: number]: ISavedTransformationMatrix;
  130419. };
  130420. /**
  130421. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  130422. * in order to compute objects velocities when enableVelocity is set to "true"
  130423. * @hidden
  130424. */
  130425. _previousBonesTransformationMatrices: {
  130426. [index: number]: Float32Array;
  130427. };
  130428. /**
  130429. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  130430. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  130431. */
  130432. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  130433. private _scene;
  130434. private _multiRenderTarget;
  130435. private _ratio;
  130436. private _enablePosition;
  130437. private _enableVelocity;
  130438. private _positionIndex;
  130439. private _velocityIndex;
  130440. protected _effect: Effect;
  130441. protected _cachedDefines: string;
  130442. /**
  130443. * Set the render list (meshes to be rendered) used in the G buffer.
  130444. */
  130445. renderList: Mesh[];
  130446. /**
  130447. * Gets wether or not G buffer are supported by the running hardware.
  130448. * This requires draw buffer supports
  130449. */
  130450. readonly isSupported: boolean;
  130451. /**
  130452. * Returns the index of the given texture type in the G-Buffer textures array
  130453. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  130454. * @returns the index of the given texture type in the G-Buffer textures array
  130455. */
  130456. getTextureIndex(textureType: number): number;
  130457. /**
  130458. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  130459. */
  130460. /**
  130461. * Sets whether or not objects positions are enabled for the G buffer.
  130462. */
  130463. enablePosition: boolean;
  130464. /**
  130465. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  130466. */
  130467. /**
  130468. * Sets wether or not objects velocities are enabled for the G buffer.
  130469. */
  130470. enableVelocity: boolean;
  130471. /**
  130472. * Gets the scene associated with the buffer.
  130473. */
  130474. readonly scene: Scene;
  130475. /**
  130476. * Gets the ratio used by the buffer during its creation.
  130477. * How big is the buffer related to the main canvas.
  130478. */
  130479. readonly ratio: number;
  130480. /** @hidden */
  130481. static _SceneComponentInitialization: (scene: Scene) => void;
  130482. /**
  130483. * Creates a new G Buffer for the scene
  130484. * @param scene The scene the buffer belongs to
  130485. * @param ratio How big is the buffer related to the main canvas.
  130486. */
  130487. constructor(scene: Scene, ratio?: number);
  130488. /**
  130489. * Checks wether everything is ready to render a submesh to the G buffer.
  130490. * @param subMesh the submesh to check readiness for
  130491. * @param useInstances is the mesh drawn using instance or not
  130492. * @returns true if ready otherwise false
  130493. */
  130494. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130495. /**
  130496. * Gets the current underlying G Buffer.
  130497. * @returns the buffer
  130498. */
  130499. getGBuffer(): MultiRenderTarget;
  130500. /**
  130501. * Gets the number of samples used to render the buffer (anti aliasing).
  130502. */
  130503. /**
  130504. * Sets the number of samples used to render the buffer (anti aliasing).
  130505. */
  130506. samples: number;
  130507. /**
  130508. * Disposes the renderer and frees up associated resources.
  130509. */
  130510. dispose(): void;
  130511. protected _createRenderTargets(): void;
  130512. private _copyBonesTransformationMatrices;
  130513. }
  130514. }
  130515. declare module BABYLON {
  130516. interface Scene {
  130517. /** @hidden (Backing field) */
  130518. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130519. /**
  130520. * Gets or Sets the current geometry buffer associated to the scene.
  130521. */
  130522. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130523. /**
  130524. * Enables a GeometryBufferRender and associates it with the scene
  130525. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  130526. * @returns the GeometryBufferRenderer
  130527. */
  130528. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  130529. /**
  130530. * Disables the GeometryBufferRender associated with the scene
  130531. */
  130532. disableGeometryBufferRenderer(): void;
  130533. }
  130534. /**
  130535. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130536. * in several rendering techniques.
  130537. */
  130538. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130539. /**
  130540. * The component name helpful to identify the component in the list of scene components.
  130541. */
  130542. readonly name: string;
  130543. /**
  130544. * The scene the component belongs to.
  130545. */
  130546. scene: Scene;
  130547. /**
  130548. * Creates a new instance of the component for the given scene
  130549. * @param scene Defines the scene to register the component in
  130550. */
  130551. constructor(scene: Scene);
  130552. /**
  130553. * Registers the component in a given scene
  130554. */
  130555. register(): void;
  130556. /**
  130557. * Rebuilds the elements related to this component in case of
  130558. * context lost for instance.
  130559. */
  130560. rebuild(): void;
  130561. /**
  130562. * Disposes the component and the associated ressources
  130563. */
  130564. dispose(): void;
  130565. private _gatherRenderTargets;
  130566. }
  130567. }
  130568. declare module BABYLON {
  130569. /** @hidden */
  130570. export var motionBlurPixelShader: {
  130571. name: string;
  130572. shader: string;
  130573. };
  130574. }
  130575. declare module BABYLON {
  130576. /**
  130577. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130578. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130579. * As an example, all you have to do is to create the post-process:
  130580. * var mb = new BABYLON.MotionBlurPostProcess(
  130581. * 'mb', // The name of the effect.
  130582. * scene, // The scene containing the objects to blur according to their velocity.
  130583. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130584. * camera // The camera to apply the render pass to.
  130585. * );
  130586. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130587. */
  130588. export class MotionBlurPostProcess extends PostProcess {
  130589. /**
  130590. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130591. */
  130592. motionStrength: number;
  130593. /**
  130594. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130595. */
  130596. /**
  130597. * Sets the number of iterations to be used for motion blur quality
  130598. */
  130599. motionBlurSamples: number;
  130600. private _motionBlurSamples;
  130601. private _geometryBufferRenderer;
  130602. /**
  130603. * Creates a new instance MotionBlurPostProcess
  130604. * @param name The name of the effect.
  130605. * @param scene The scene containing the objects to blur according to their velocity.
  130606. * @param options The required width/height ratio to downsize to before computing the render pass.
  130607. * @param camera The camera to apply the render pass to.
  130608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130609. * @param engine The engine which the post process will be applied. (default: current engine)
  130610. * @param reusable If the post process can be reused on the same frame. (default: false)
  130611. * @param textureType Type of textures used when performing the post process. (default: 0)
  130612. * @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)
  130613. */
  130614. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130615. /**
  130616. * Excludes the given skinned mesh from computing bones velocities.
  130617. * 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.
  130618. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130619. */
  130620. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130621. /**
  130622. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130623. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  130624. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  130625. */
  130626. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130627. /**
  130628. * Disposes the post process.
  130629. * @param camera The camera to dispose the post process on.
  130630. */
  130631. dispose(camera?: Camera): void;
  130632. }
  130633. }
  130634. declare module BABYLON {
  130635. /** @hidden */
  130636. export var refractionPixelShader: {
  130637. name: string;
  130638. shader: string;
  130639. };
  130640. }
  130641. declare module BABYLON {
  130642. /**
  130643. * Post process which applies a refractin texture
  130644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130645. */
  130646. export class RefractionPostProcess extends PostProcess {
  130647. /** the base color of the refraction (used to taint the rendering) */
  130648. color: Color3;
  130649. /** simulated refraction depth */
  130650. depth: number;
  130651. /** the coefficient of the base color (0 to remove base color tainting) */
  130652. colorLevel: number;
  130653. private _refTexture;
  130654. private _ownRefractionTexture;
  130655. /**
  130656. * Gets or sets the refraction texture
  130657. * Please note that you are responsible for disposing the texture if you set it manually
  130658. */
  130659. refractionTexture: Texture;
  130660. /**
  130661. * Initializes the RefractionPostProcess
  130662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130663. * @param name The name of the effect.
  130664. * @param refractionTextureUrl Url of the refraction texture to use
  130665. * @param color the base color of the refraction (used to taint the rendering)
  130666. * @param depth simulated refraction depth
  130667. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  130668. * @param camera The camera to apply the render pass to.
  130669. * @param options The required width/height ratio to downsize to before computing the render pass.
  130670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130671. * @param engine The engine which the post process will be applied. (default: current engine)
  130672. * @param reusable If the post process can be reused on the same frame. (default: false)
  130673. */
  130674. constructor(name: string, refractionTextureUrl: string,
  130675. /** the base color of the refraction (used to taint the rendering) */
  130676. color: Color3,
  130677. /** simulated refraction depth */
  130678. depth: number,
  130679. /** the coefficient of the base color (0 to remove base color tainting) */
  130680. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130681. /**
  130682. * Disposes of the post process
  130683. * @param camera Camera to dispose post process on
  130684. */
  130685. dispose(camera: Camera): void;
  130686. }
  130687. }
  130688. declare module BABYLON {
  130689. /** @hidden */
  130690. export var sharpenPixelShader: {
  130691. name: string;
  130692. shader: string;
  130693. };
  130694. }
  130695. declare module BABYLON {
  130696. /**
  130697. * The SharpenPostProcess applies a sharpen kernel to every pixel
  130698. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130699. */
  130700. export class SharpenPostProcess extends PostProcess {
  130701. /**
  130702. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  130703. */
  130704. colorAmount: number;
  130705. /**
  130706. * How much sharpness should be applied (default: 0.3)
  130707. */
  130708. edgeAmount: number;
  130709. /**
  130710. * Creates a new instance ConvolutionPostProcess
  130711. * @param name The name of the effect.
  130712. * @param options The required width/height ratio to downsize to before computing the render pass.
  130713. * @param camera The camera to apply the render pass to.
  130714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130715. * @param engine The engine which the post process will be applied. (default: current engine)
  130716. * @param reusable If the post process can be reused on the same frame. (default: false)
  130717. * @param textureType Type of textures used when performing the post process. (default: 0)
  130718. * @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)
  130719. */
  130720. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130721. }
  130722. }
  130723. declare module BABYLON {
  130724. /**
  130725. * PostProcessRenderPipeline
  130726. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130727. */
  130728. export class PostProcessRenderPipeline {
  130729. private engine;
  130730. private _renderEffects;
  130731. private _renderEffectsForIsolatedPass;
  130732. /**
  130733. * List of inspectable custom properties (used by the Inspector)
  130734. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  130735. */
  130736. inspectableCustomProperties: IInspectable[];
  130737. /**
  130738. * @hidden
  130739. */
  130740. protected _cameras: Camera[];
  130741. /** @hidden */
  130742. _name: string;
  130743. /**
  130744. * Gets pipeline name
  130745. */
  130746. readonly name: string;
  130747. /** Gets the list of attached cameras */
  130748. readonly cameras: Camera[];
  130749. /**
  130750. * Initializes a PostProcessRenderPipeline
  130751. * @param engine engine to add the pipeline to
  130752. * @param name name of the pipeline
  130753. */
  130754. constructor(engine: Engine, name: string);
  130755. /**
  130756. * Gets the class name
  130757. * @returns "PostProcessRenderPipeline"
  130758. */
  130759. getClassName(): string;
  130760. /**
  130761. * If all the render effects in the pipeline are supported
  130762. */
  130763. readonly isSupported: boolean;
  130764. /**
  130765. * Adds an effect to the pipeline
  130766. * @param renderEffect the effect to add
  130767. */
  130768. addEffect(renderEffect: PostProcessRenderEffect): void;
  130769. /** @hidden */
  130770. _rebuild(): void;
  130771. /** @hidden */
  130772. _enableEffect(renderEffectName: string, cameras: Camera): void;
  130773. /** @hidden */
  130774. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  130775. /** @hidden */
  130776. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130777. /** @hidden */
  130778. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130779. /** @hidden */
  130780. _attachCameras(cameras: Camera, unique: boolean): void;
  130781. /** @hidden */
  130782. _attachCameras(cameras: Camera[], unique: boolean): void;
  130783. /** @hidden */
  130784. _detachCameras(cameras: Camera): void;
  130785. /** @hidden */
  130786. _detachCameras(cameras: Nullable<Camera[]>): void;
  130787. /** @hidden */
  130788. _update(): void;
  130789. /** @hidden */
  130790. _reset(): void;
  130791. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  130792. /**
  130793. * Disposes of the pipeline
  130794. */
  130795. dispose(): void;
  130796. }
  130797. }
  130798. declare module BABYLON {
  130799. /**
  130800. * PostProcessRenderPipelineManager class
  130801. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130802. */
  130803. export class PostProcessRenderPipelineManager {
  130804. private _renderPipelines;
  130805. /**
  130806. * Initializes a PostProcessRenderPipelineManager
  130807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130808. */
  130809. constructor();
  130810. /**
  130811. * Gets the list of supported render pipelines
  130812. */
  130813. readonly supportedPipelines: PostProcessRenderPipeline[];
  130814. /**
  130815. * Adds a pipeline to the manager
  130816. * @param renderPipeline The pipeline to add
  130817. */
  130818. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  130819. /**
  130820. * Attaches a camera to the pipeline
  130821. * @param renderPipelineName The name of the pipeline to attach to
  130822. * @param cameras the camera to attach
  130823. * @param unique if the camera can be attached multiple times to the pipeline
  130824. */
  130825. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  130826. /**
  130827. * Detaches a camera from the pipeline
  130828. * @param renderPipelineName The name of the pipeline to detach from
  130829. * @param cameras the camera to detach
  130830. */
  130831. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  130832. /**
  130833. * Enables an effect by name on a pipeline
  130834. * @param renderPipelineName the name of the pipeline to enable the effect in
  130835. * @param renderEffectName the name of the effect to enable
  130836. * @param cameras the cameras that the effect should be enabled on
  130837. */
  130838. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130839. /**
  130840. * Disables an effect by name on a pipeline
  130841. * @param renderPipelineName the name of the pipeline to disable the effect in
  130842. * @param renderEffectName the name of the effect to disable
  130843. * @param cameras the cameras that the effect should be disabled on
  130844. */
  130845. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130846. /**
  130847. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130848. */
  130849. update(): void;
  130850. /** @hidden */
  130851. _rebuild(): void;
  130852. /**
  130853. * Disposes of the manager and pipelines
  130854. */
  130855. dispose(): void;
  130856. }
  130857. }
  130858. declare module BABYLON {
  130859. interface Scene {
  130860. /** @hidden (Backing field) */
  130861. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130862. /**
  130863. * Gets the postprocess render pipeline manager
  130864. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130865. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130866. */
  130867. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130868. }
  130869. /**
  130870. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130871. */
  130872. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130873. /**
  130874. * The component name helpfull to identify the component in the list of scene components.
  130875. */
  130876. readonly name: string;
  130877. /**
  130878. * The scene the component belongs to.
  130879. */
  130880. scene: Scene;
  130881. /**
  130882. * Creates a new instance of the component for the given scene
  130883. * @param scene Defines the scene to register the component in
  130884. */
  130885. constructor(scene: Scene);
  130886. /**
  130887. * Registers the component in a given scene
  130888. */
  130889. register(): void;
  130890. /**
  130891. * Rebuilds the elements related to this component in case of
  130892. * context lost for instance.
  130893. */
  130894. rebuild(): void;
  130895. /**
  130896. * Disposes the component and the associated ressources
  130897. */
  130898. dispose(): void;
  130899. private _gatherRenderTargets;
  130900. }
  130901. }
  130902. declare module BABYLON {
  130903. /**
  130904. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130905. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130906. */
  130907. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130908. private _scene;
  130909. private _camerasToBeAttached;
  130910. /**
  130911. * ID of the sharpen post process,
  130912. */
  130913. private readonly SharpenPostProcessId;
  130914. /**
  130915. * @ignore
  130916. * ID of the image processing post process;
  130917. */
  130918. readonly ImageProcessingPostProcessId: string;
  130919. /**
  130920. * @ignore
  130921. * ID of the Fast Approximate Anti-Aliasing post process;
  130922. */
  130923. readonly FxaaPostProcessId: string;
  130924. /**
  130925. * ID of the chromatic aberration post process,
  130926. */
  130927. private readonly ChromaticAberrationPostProcessId;
  130928. /**
  130929. * ID of the grain post process
  130930. */
  130931. private readonly GrainPostProcessId;
  130932. /**
  130933. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130934. */
  130935. sharpen: SharpenPostProcess;
  130936. private _sharpenEffect;
  130937. private bloom;
  130938. /**
  130939. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  130940. */
  130941. depthOfField: DepthOfFieldEffect;
  130942. /**
  130943. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130944. */
  130945. fxaa: FxaaPostProcess;
  130946. /**
  130947. * Image post processing pass used to perform operations such as tone mapping or color grading.
  130948. */
  130949. imageProcessing: ImageProcessingPostProcess;
  130950. /**
  130951. * Chromatic aberration post process which will shift rgb colors in the image
  130952. */
  130953. chromaticAberration: ChromaticAberrationPostProcess;
  130954. private _chromaticAberrationEffect;
  130955. /**
  130956. * Grain post process which add noise to the image
  130957. */
  130958. grain: GrainPostProcess;
  130959. private _grainEffect;
  130960. /**
  130961. * Glow post process which adds a glow to emissive areas of the image
  130962. */
  130963. private _glowLayer;
  130964. /**
  130965. * Animations which can be used to tweak settings over a period of time
  130966. */
  130967. animations: Animation[];
  130968. private _imageProcessingConfigurationObserver;
  130969. private _sharpenEnabled;
  130970. private _bloomEnabled;
  130971. private _depthOfFieldEnabled;
  130972. private _depthOfFieldBlurLevel;
  130973. private _fxaaEnabled;
  130974. private _imageProcessingEnabled;
  130975. private _defaultPipelineTextureType;
  130976. private _bloomScale;
  130977. private _chromaticAberrationEnabled;
  130978. private _grainEnabled;
  130979. private _buildAllowed;
  130980. /**
  130981. * Gets active scene
  130982. */
  130983. readonly scene: Scene;
  130984. /**
  130985. * Enable or disable the sharpen process from the pipeline
  130986. */
  130987. sharpenEnabled: boolean;
  130988. private _resizeObserver;
  130989. private _hardwareScaleLevel;
  130990. private _bloomKernel;
  130991. /**
  130992. * Specifies the size of the bloom blur kernel, relative to the final output size
  130993. */
  130994. bloomKernel: number;
  130995. /**
  130996. * Specifies the weight of the bloom in the final rendering
  130997. */
  130998. private _bloomWeight;
  130999. /**
  131000. * Specifies the luma threshold for the area that will be blurred by the bloom
  131001. */
  131002. private _bloomThreshold;
  131003. private _hdr;
  131004. /**
  131005. * The strength of the bloom.
  131006. */
  131007. bloomWeight: number;
  131008. /**
  131009. * The strength of the bloom.
  131010. */
  131011. bloomThreshold: number;
  131012. /**
  131013. * The scale of the bloom, lower value will provide better performance.
  131014. */
  131015. bloomScale: number;
  131016. /**
  131017. * Enable or disable the bloom from the pipeline
  131018. */
  131019. bloomEnabled: boolean;
  131020. private _rebuildBloom;
  131021. /**
  131022. * If the depth of field is enabled.
  131023. */
  131024. depthOfFieldEnabled: boolean;
  131025. /**
  131026. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131027. */
  131028. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  131029. /**
  131030. * If the anti aliasing is enabled.
  131031. */
  131032. fxaaEnabled: boolean;
  131033. private _samples;
  131034. /**
  131035. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131036. */
  131037. samples: number;
  131038. /**
  131039. * If image processing is enabled.
  131040. */
  131041. imageProcessingEnabled: boolean;
  131042. /**
  131043. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131044. */
  131045. glowLayerEnabled: boolean;
  131046. /**
  131047. * Gets the glow layer (or null if not defined)
  131048. */
  131049. readonly glowLayer: Nullable<GlowLayer>;
  131050. /**
  131051. * Enable or disable the chromaticAberration process from the pipeline
  131052. */
  131053. chromaticAberrationEnabled: boolean;
  131054. /**
  131055. * Enable or disable the grain process from the pipeline
  131056. */
  131057. grainEnabled: boolean;
  131058. /**
  131059. * @constructor
  131060. * @param name - The rendering pipeline name (default: "")
  131061. * @param hdr - If high dynamic range textures should be used (default: true)
  131062. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131063. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131064. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131065. */
  131066. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131067. /**
  131068. * Get the class name
  131069. * @returns "DefaultRenderingPipeline"
  131070. */
  131071. getClassName(): string;
  131072. /**
  131073. * Force the compilation of the entire pipeline.
  131074. */
  131075. prepare(): void;
  131076. private _hasCleared;
  131077. private _prevPostProcess;
  131078. private _prevPrevPostProcess;
  131079. private _setAutoClearAndTextureSharing;
  131080. private _depthOfFieldSceneObserver;
  131081. private _buildPipeline;
  131082. private _disposePostProcesses;
  131083. /**
  131084. * Adds a camera to the pipeline
  131085. * @param camera the camera to be added
  131086. */
  131087. addCamera(camera: Camera): void;
  131088. /**
  131089. * Removes a camera from the pipeline
  131090. * @param camera the camera to remove
  131091. */
  131092. removeCamera(camera: Camera): void;
  131093. /**
  131094. * Dispose of the pipeline and stop all post processes
  131095. */
  131096. dispose(): void;
  131097. /**
  131098. * Serialize the rendering pipeline (Used when exporting)
  131099. * @returns the serialized object
  131100. */
  131101. serialize(): any;
  131102. /**
  131103. * Parse the serialized pipeline
  131104. * @param source Source pipeline.
  131105. * @param scene The scene to load the pipeline to.
  131106. * @param rootUrl The URL of the serialized pipeline.
  131107. * @returns An instantiated pipeline from the serialized object.
  131108. */
  131109. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131110. }
  131111. }
  131112. declare module BABYLON {
  131113. /** @hidden */
  131114. export var lensHighlightsPixelShader: {
  131115. name: string;
  131116. shader: string;
  131117. };
  131118. }
  131119. declare module BABYLON {
  131120. /** @hidden */
  131121. export var depthOfFieldPixelShader: {
  131122. name: string;
  131123. shader: string;
  131124. };
  131125. }
  131126. declare module BABYLON {
  131127. /**
  131128. * BABYLON.JS Chromatic Aberration GLSL Shader
  131129. * Author: Olivier Guyot
  131130. * Separates very slightly R, G and B colors on the edges of the screen
  131131. * Inspired by Francois Tarlier & Martins Upitis
  131132. */
  131133. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131134. /**
  131135. * @ignore
  131136. * The chromatic aberration PostProcess id in the pipeline
  131137. */
  131138. LensChromaticAberrationEffect: string;
  131139. /**
  131140. * @ignore
  131141. * The highlights enhancing PostProcess id in the pipeline
  131142. */
  131143. HighlightsEnhancingEffect: string;
  131144. /**
  131145. * @ignore
  131146. * The depth-of-field PostProcess id in the pipeline
  131147. */
  131148. LensDepthOfFieldEffect: string;
  131149. private _scene;
  131150. private _depthTexture;
  131151. private _grainTexture;
  131152. private _chromaticAberrationPostProcess;
  131153. private _highlightsPostProcess;
  131154. private _depthOfFieldPostProcess;
  131155. private _edgeBlur;
  131156. private _grainAmount;
  131157. private _chromaticAberration;
  131158. private _distortion;
  131159. private _highlightsGain;
  131160. private _highlightsThreshold;
  131161. private _dofDistance;
  131162. private _dofAperture;
  131163. private _dofDarken;
  131164. private _dofPentagon;
  131165. private _blurNoise;
  131166. /**
  131167. * @constructor
  131168. *
  131169. * Effect parameters are as follow:
  131170. * {
  131171. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131172. * edge_blur: number; // from 0 to x (1 for realism)
  131173. * distortion: number; // from 0 to x (1 for realism)
  131174. * grain_amount: number; // from 0 to 1
  131175. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131176. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131177. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131178. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131179. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131180. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131181. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131182. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131183. * }
  131184. * Note: if an effect parameter is unset, effect is disabled
  131185. *
  131186. * @param name The rendering pipeline name
  131187. * @param parameters - An object containing all parameters (see above)
  131188. * @param scene The scene linked to this pipeline
  131189. * @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)
  131190. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131191. */
  131192. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131193. /**
  131194. * Get the class name
  131195. * @returns "LensRenderingPipeline"
  131196. */
  131197. getClassName(): string;
  131198. /**
  131199. * Gets associated scene
  131200. */
  131201. readonly scene: Scene;
  131202. /**
  131203. * Gets or sets the edge blur
  131204. */
  131205. edgeBlur: number;
  131206. /**
  131207. * Gets or sets the grain amount
  131208. */
  131209. grainAmount: number;
  131210. /**
  131211. * Gets or sets the chromatic aberration amount
  131212. */
  131213. chromaticAberration: number;
  131214. /**
  131215. * Gets or sets the depth of field aperture
  131216. */
  131217. dofAperture: number;
  131218. /**
  131219. * Gets or sets the edge distortion
  131220. */
  131221. edgeDistortion: number;
  131222. /**
  131223. * Gets or sets the depth of field distortion
  131224. */
  131225. dofDistortion: number;
  131226. /**
  131227. * Gets or sets the darken out of focus amount
  131228. */
  131229. darkenOutOfFocus: number;
  131230. /**
  131231. * Gets or sets a boolean indicating if blur noise is enabled
  131232. */
  131233. blurNoise: boolean;
  131234. /**
  131235. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131236. */
  131237. pentagonBokeh: boolean;
  131238. /**
  131239. * Gets or sets the highlight grain amount
  131240. */
  131241. highlightsGain: number;
  131242. /**
  131243. * Gets or sets the highlight threshold
  131244. */
  131245. highlightsThreshold: number;
  131246. /**
  131247. * Sets the amount of blur at the edges
  131248. * @param amount blur amount
  131249. */
  131250. setEdgeBlur(amount: number): void;
  131251. /**
  131252. * Sets edge blur to 0
  131253. */
  131254. disableEdgeBlur(): void;
  131255. /**
  131256. * Sets the amout of grain
  131257. * @param amount Amount of grain
  131258. */
  131259. setGrainAmount(amount: number): void;
  131260. /**
  131261. * Set grain amount to 0
  131262. */
  131263. disableGrain(): void;
  131264. /**
  131265. * Sets the chromatic aberration amount
  131266. * @param amount amount of chromatic aberration
  131267. */
  131268. setChromaticAberration(amount: number): void;
  131269. /**
  131270. * Sets chromatic aberration amount to 0
  131271. */
  131272. disableChromaticAberration(): void;
  131273. /**
  131274. * Sets the EdgeDistortion amount
  131275. * @param amount amount of EdgeDistortion
  131276. */
  131277. setEdgeDistortion(amount: number): void;
  131278. /**
  131279. * Sets edge distortion to 0
  131280. */
  131281. disableEdgeDistortion(): void;
  131282. /**
  131283. * Sets the FocusDistance amount
  131284. * @param amount amount of FocusDistance
  131285. */
  131286. setFocusDistance(amount: number): void;
  131287. /**
  131288. * Disables depth of field
  131289. */
  131290. disableDepthOfField(): void;
  131291. /**
  131292. * Sets the Aperture amount
  131293. * @param amount amount of Aperture
  131294. */
  131295. setAperture(amount: number): void;
  131296. /**
  131297. * Sets the DarkenOutOfFocus amount
  131298. * @param amount amount of DarkenOutOfFocus
  131299. */
  131300. setDarkenOutOfFocus(amount: number): void;
  131301. private _pentagonBokehIsEnabled;
  131302. /**
  131303. * Creates a pentagon bokeh effect
  131304. */
  131305. enablePentagonBokeh(): void;
  131306. /**
  131307. * Disables the pentagon bokeh effect
  131308. */
  131309. disablePentagonBokeh(): void;
  131310. /**
  131311. * Enables noise blur
  131312. */
  131313. enableNoiseBlur(): void;
  131314. /**
  131315. * Disables noise blur
  131316. */
  131317. disableNoiseBlur(): void;
  131318. /**
  131319. * Sets the HighlightsGain amount
  131320. * @param amount amount of HighlightsGain
  131321. */
  131322. setHighlightsGain(amount: number): void;
  131323. /**
  131324. * Sets the HighlightsThreshold amount
  131325. * @param amount amount of HighlightsThreshold
  131326. */
  131327. setHighlightsThreshold(amount: number): void;
  131328. /**
  131329. * Disables highlights
  131330. */
  131331. disableHighlights(): void;
  131332. /**
  131333. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131334. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131335. */
  131336. dispose(disableDepthRender?: boolean): void;
  131337. private _createChromaticAberrationPostProcess;
  131338. private _createHighlightsPostProcess;
  131339. private _createDepthOfFieldPostProcess;
  131340. private _createGrainTexture;
  131341. }
  131342. }
  131343. declare module BABYLON {
  131344. /** @hidden */
  131345. export var ssao2PixelShader: {
  131346. name: string;
  131347. shader: string;
  131348. };
  131349. }
  131350. declare module BABYLON {
  131351. /** @hidden */
  131352. export var ssaoCombinePixelShader: {
  131353. name: string;
  131354. shader: string;
  131355. };
  131356. }
  131357. declare module BABYLON {
  131358. /**
  131359. * Render pipeline to produce ssao effect
  131360. */
  131361. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131362. /**
  131363. * @ignore
  131364. * The PassPostProcess id in the pipeline that contains the original scene color
  131365. */
  131366. SSAOOriginalSceneColorEffect: string;
  131367. /**
  131368. * @ignore
  131369. * The SSAO PostProcess id in the pipeline
  131370. */
  131371. SSAORenderEffect: string;
  131372. /**
  131373. * @ignore
  131374. * The horizontal blur PostProcess id in the pipeline
  131375. */
  131376. SSAOBlurHRenderEffect: string;
  131377. /**
  131378. * @ignore
  131379. * The vertical blur PostProcess id in the pipeline
  131380. */
  131381. SSAOBlurVRenderEffect: string;
  131382. /**
  131383. * @ignore
  131384. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131385. */
  131386. SSAOCombineRenderEffect: string;
  131387. /**
  131388. * The output strength of the SSAO post-process. Default value is 1.0.
  131389. */
  131390. totalStrength: number;
  131391. /**
  131392. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  131393. */
  131394. maxZ: number;
  131395. /**
  131396. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  131397. */
  131398. minZAspect: number;
  131399. private _samples;
  131400. /**
  131401. * Number of samples used for the SSAO calculations. Default value is 8
  131402. */
  131403. samples: number;
  131404. private _textureSamples;
  131405. /**
  131406. * Number of samples to use for antialiasing
  131407. */
  131408. textureSamples: number;
  131409. /**
  131410. * Ratio object used for SSAO ratio and blur ratio
  131411. */
  131412. private _ratio;
  131413. /**
  131414. * Dynamically generated sphere sampler.
  131415. */
  131416. private _sampleSphere;
  131417. /**
  131418. * Blur filter offsets
  131419. */
  131420. private _samplerOffsets;
  131421. private _expensiveBlur;
  131422. /**
  131423. * If bilateral blur should be used
  131424. */
  131425. expensiveBlur: boolean;
  131426. /**
  131427. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  131428. */
  131429. radius: number;
  131430. /**
  131431. * The base color of the SSAO post-process
  131432. * The final result is "base + ssao" between [0, 1]
  131433. */
  131434. base: number;
  131435. /**
  131436. * Support test.
  131437. */
  131438. static readonly IsSupported: boolean;
  131439. private _scene;
  131440. private _depthTexture;
  131441. private _normalTexture;
  131442. private _randomTexture;
  131443. private _originalColorPostProcess;
  131444. private _ssaoPostProcess;
  131445. private _blurHPostProcess;
  131446. private _blurVPostProcess;
  131447. private _ssaoCombinePostProcess;
  131448. /**
  131449. * Gets active scene
  131450. */
  131451. readonly scene: Scene;
  131452. /**
  131453. * @constructor
  131454. * @param name The rendering pipeline name
  131455. * @param scene The scene linked to this pipeline
  131456. * @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 }
  131457. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131458. */
  131459. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131460. /**
  131461. * Get the class name
  131462. * @returns "SSAO2RenderingPipeline"
  131463. */
  131464. getClassName(): string;
  131465. /**
  131466. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131467. */
  131468. dispose(disableGeometryBufferRenderer?: boolean): void;
  131469. private _createBlurPostProcess;
  131470. /** @hidden */
  131471. _rebuild(): void;
  131472. private _bits;
  131473. private _radicalInverse_VdC;
  131474. private _hammersley;
  131475. private _hemisphereSample_uniform;
  131476. private _generateHemisphere;
  131477. private _createSSAOPostProcess;
  131478. private _createSSAOCombinePostProcess;
  131479. private _createRandomTexture;
  131480. /**
  131481. * Serialize the rendering pipeline (Used when exporting)
  131482. * @returns the serialized object
  131483. */
  131484. serialize(): any;
  131485. /**
  131486. * Parse the serialized pipeline
  131487. * @param source Source pipeline.
  131488. * @param scene The scene to load the pipeline to.
  131489. * @param rootUrl The URL of the serialized pipeline.
  131490. * @returns An instantiated pipeline from the serialized object.
  131491. */
  131492. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  131493. }
  131494. }
  131495. declare module BABYLON {
  131496. /** @hidden */
  131497. export var ssaoPixelShader: {
  131498. name: string;
  131499. shader: string;
  131500. };
  131501. }
  131502. declare module BABYLON {
  131503. /**
  131504. * Render pipeline to produce ssao effect
  131505. */
  131506. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  131507. /**
  131508. * @ignore
  131509. * The PassPostProcess id in the pipeline that contains the original scene color
  131510. */
  131511. SSAOOriginalSceneColorEffect: string;
  131512. /**
  131513. * @ignore
  131514. * The SSAO PostProcess id in the pipeline
  131515. */
  131516. SSAORenderEffect: string;
  131517. /**
  131518. * @ignore
  131519. * The horizontal blur PostProcess id in the pipeline
  131520. */
  131521. SSAOBlurHRenderEffect: string;
  131522. /**
  131523. * @ignore
  131524. * The vertical blur PostProcess id in the pipeline
  131525. */
  131526. SSAOBlurVRenderEffect: string;
  131527. /**
  131528. * @ignore
  131529. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131530. */
  131531. SSAOCombineRenderEffect: string;
  131532. /**
  131533. * The output strength of the SSAO post-process. Default value is 1.0.
  131534. */
  131535. totalStrength: number;
  131536. /**
  131537. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131538. */
  131539. radius: number;
  131540. /**
  131541. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131542. * Must not be equal to fallOff and superior to fallOff.
  131543. * Default value is 0.0075
  131544. */
  131545. area: number;
  131546. /**
  131547. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131548. * Must not be equal to area and inferior to area.
  131549. * Default value is 0.000001
  131550. */
  131551. fallOff: number;
  131552. /**
  131553. * The base color of the SSAO post-process
  131554. * The final result is "base + ssao" between [0, 1]
  131555. */
  131556. base: number;
  131557. private _scene;
  131558. private _depthTexture;
  131559. private _randomTexture;
  131560. private _originalColorPostProcess;
  131561. private _ssaoPostProcess;
  131562. private _blurHPostProcess;
  131563. private _blurVPostProcess;
  131564. private _ssaoCombinePostProcess;
  131565. private _firstUpdate;
  131566. /**
  131567. * Gets active scene
  131568. */
  131569. readonly scene: Scene;
  131570. /**
  131571. * @constructor
  131572. * @param name - The rendering pipeline name
  131573. * @param scene - The scene linked to this pipeline
  131574. * @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 }
  131575. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131576. */
  131577. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131578. /**
  131579. * Get the class name
  131580. * @returns "SSAORenderingPipeline"
  131581. */
  131582. getClassName(): string;
  131583. /**
  131584. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131585. */
  131586. dispose(disableDepthRender?: boolean): void;
  131587. private _createBlurPostProcess;
  131588. /** @hidden */
  131589. _rebuild(): void;
  131590. private _createSSAOPostProcess;
  131591. private _createSSAOCombinePostProcess;
  131592. private _createRandomTexture;
  131593. }
  131594. }
  131595. declare module BABYLON {
  131596. /** @hidden */
  131597. export var standardPixelShader: {
  131598. name: string;
  131599. shader: string;
  131600. };
  131601. }
  131602. declare module BABYLON {
  131603. /**
  131604. * Standard rendering pipeline
  131605. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131606. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131607. */
  131608. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131609. /**
  131610. * Public members
  131611. */
  131612. /**
  131613. * Post-process which contains the original scene color before the pipeline applies all the effects
  131614. */
  131615. originalPostProcess: Nullable<PostProcess>;
  131616. /**
  131617. * Post-process used to down scale an image x4
  131618. */
  131619. downSampleX4PostProcess: Nullable<PostProcess>;
  131620. /**
  131621. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131622. */
  131623. brightPassPostProcess: Nullable<PostProcess>;
  131624. /**
  131625. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  131626. */
  131627. blurHPostProcesses: PostProcess[];
  131628. /**
  131629. * Post-process array storing all the vertical blur post-processes used by the pipeline
  131630. */
  131631. blurVPostProcesses: PostProcess[];
  131632. /**
  131633. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  131634. */
  131635. textureAdderPostProcess: Nullable<PostProcess>;
  131636. /**
  131637. * Post-process used to create volumetric lighting effect
  131638. */
  131639. volumetricLightPostProcess: Nullable<PostProcess>;
  131640. /**
  131641. * Post-process used to smooth the previous volumetric light post-process on the X axis
  131642. */
  131643. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  131644. /**
  131645. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  131646. */
  131647. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  131648. /**
  131649. * Post-process used to merge the volumetric light effect and the real scene color
  131650. */
  131651. volumetricLightMergePostProces: Nullable<PostProcess>;
  131652. /**
  131653. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  131654. */
  131655. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  131656. /**
  131657. * Base post-process used to calculate the average luminance of the final image for HDR
  131658. */
  131659. luminancePostProcess: Nullable<PostProcess>;
  131660. /**
  131661. * Post-processes used to create down sample post-processes in order to get
  131662. * the average luminance of the final image for HDR
  131663. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  131664. */
  131665. luminanceDownSamplePostProcesses: PostProcess[];
  131666. /**
  131667. * Post-process used to create a HDR effect (light adaptation)
  131668. */
  131669. hdrPostProcess: Nullable<PostProcess>;
  131670. /**
  131671. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  131672. */
  131673. textureAdderFinalPostProcess: Nullable<PostProcess>;
  131674. /**
  131675. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  131676. */
  131677. lensFlareFinalPostProcess: Nullable<PostProcess>;
  131678. /**
  131679. * Post-process used to merge the final HDR post-process and the real scene color
  131680. */
  131681. hdrFinalPostProcess: Nullable<PostProcess>;
  131682. /**
  131683. * Post-process used to create a lens flare effect
  131684. */
  131685. lensFlarePostProcess: Nullable<PostProcess>;
  131686. /**
  131687. * Post-process that merges the result of the lens flare post-process and the real scene color
  131688. */
  131689. lensFlareComposePostProcess: Nullable<PostProcess>;
  131690. /**
  131691. * Post-process used to create a motion blur effect
  131692. */
  131693. motionBlurPostProcess: Nullable<PostProcess>;
  131694. /**
  131695. * Post-process used to create a depth of field effect
  131696. */
  131697. depthOfFieldPostProcess: Nullable<PostProcess>;
  131698. /**
  131699. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131700. */
  131701. fxaaPostProcess: Nullable<FxaaPostProcess>;
  131702. /**
  131703. * Represents the brightness threshold in order to configure the illuminated surfaces
  131704. */
  131705. brightThreshold: number;
  131706. /**
  131707. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  131708. */
  131709. blurWidth: number;
  131710. /**
  131711. * Sets if the blur for highlighted surfaces must be only horizontal
  131712. */
  131713. horizontalBlur: boolean;
  131714. /**
  131715. * Gets the overall exposure used by the pipeline
  131716. */
  131717. /**
  131718. * Sets the overall exposure used by the pipeline
  131719. */
  131720. exposure: number;
  131721. /**
  131722. * Texture used typically to simulate "dirty" on camera lens
  131723. */
  131724. lensTexture: Nullable<Texture>;
  131725. /**
  131726. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  131727. */
  131728. volumetricLightCoefficient: number;
  131729. /**
  131730. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  131731. */
  131732. volumetricLightPower: number;
  131733. /**
  131734. * Used the set the blur intensity to smooth the volumetric lights
  131735. */
  131736. volumetricLightBlurScale: number;
  131737. /**
  131738. * Light (spot or directional) used to generate the volumetric lights rays
  131739. * The source light must have a shadow generate so the pipeline can get its
  131740. * depth map
  131741. */
  131742. sourceLight: Nullable<SpotLight | DirectionalLight>;
  131743. /**
  131744. * For eye adaptation, represents the minimum luminance the eye can see
  131745. */
  131746. hdrMinimumLuminance: number;
  131747. /**
  131748. * For eye adaptation, represents the decrease luminance speed
  131749. */
  131750. hdrDecreaseRate: number;
  131751. /**
  131752. * For eye adaptation, represents the increase luminance speed
  131753. */
  131754. hdrIncreaseRate: number;
  131755. /**
  131756. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131757. */
  131758. /**
  131759. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131760. */
  131761. hdrAutoExposure: boolean;
  131762. /**
  131763. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  131764. */
  131765. lensColorTexture: Nullable<Texture>;
  131766. /**
  131767. * The overall strengh for the lens flare effect
  131768. */
  131769. lensFlareStrength: number;
  131770. /**
  131771. * Dispersion coefficient for lens flare ghosts
  131772. */
  131773. lensFlareGhostDispersal: number;
  131774. /**
  131775. * Main lens flare halo width
  131776. */
  131777. lensFlareHaloWidth: number;
  131778. /**
  131779. * Based on the lens distortion effect, defines how much the lens flare result
  131780. * is distorted
  131781. */
  131782. lensFlareDistortionStrength: number;
  131783. /**
  131784. * Configures the blur intensity used for for lens flare (halo)
  131785. */
  131786. lensFlareBlurWidth: number;
  131787. /**
  131788. * Lens star texture must be used to simulate rays on the flares and is available
  131789. * in the documentation
  131790. */
  131791. lensStarTexture: Nullable<Texture>;
  131792. /**
  131793. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  131794. * flare effect by taking account of the dirt texture
  131795. */
  131796. lensFlareDirtTexture: Nullable<Texture>;
  131797. /**
  131798. * Represents the focal length for the depth of field effect
  131799. */
  131800. depthOfFieldDistance: number;
  131801. /**
  131802. * Represents the blur intensity for the blurred part of the depth of field effect
  131803. */
  131804. depthOfFieldBlurWidth: number;
  131805. /**
  131806. * Gets how much the image is blurred by the movement while using the motion blur post-process
  131807. */
  131808. /**
  131809. * Sets how much the image is blurred by the movement while using the motion blur post-process
  131810. */
  131811. motionStrength: number;
  131812. /**
  131813. * Gets wether or not the motion blur post-process is object based or screen based.
  131814. */
  131815. /**
  131816. * Sets wether or not the motion blur post-process should be object based or screen based
  131817. */
  131818. objectBasedMotionBlur: boolean;
  131819. /**
  131820. * List of animations for the pipeline (IAnimatable implementation)
  131821. */
  131822. animations: Animation[];
  131823. /**
  131824. * Private members
  131825. */
  131826. private _scene;
  131827. private _currentDepthOfFieldSource;
  131828. private _basePostProcess;
  131829. private _fixedExposure;
  131830. private _currentExposure;
  131831. private _hdrAutoExposure;
  131832. private _hdrCurrentLuminance;
  131833. private _motionStrength;
  131834. private _isObjectBasedMotionBlur;
  131835. private _floatTextureType;
  131836. private _camerasToBeAttached;
  131837. private _ratio;
  131838. private _bloomEnabled;
  131839. private _depthOfFieldEnabled;
  131840. private _vlsEnabled;
  131841. private _lensFlareEnabled;
  131842. private _hdrEnabled;
  131843. private _motionBlurEnabled;
  131844. private _fxaaEnabled;
  131845. private _motionBlurSamples;
  131846. private _volumetricLightStepsCount;
  131847. private _samples;
  131848. /**
  131849. * @ignore
  131850. * Specifies if the bloom pipeline is enabled
  131851. */
  131852. BloomEnabled: boolean;
  131853. /**
  131854. * @ignore
  131855. * Specifies if the depth of field pipeline is enabed
  131856. */
  131857. DepthOfFieldEnabled: boolean;
  131858. /**
  131859. * @ignore
  131860. * Specifies if the lens flare pipeline is enabed
  131861. */
  131862. LensFlareEnabled: boolean;
  131863. /**
  131864. * @ignore
  131865. * Specifies if the HDR pipeline is enabled
  131866. */
  131867. HDREnabled: boolean;
  131868. /**
  131869. * @ignore
  131870. * Specifies if the volumetric lights scattering effect is enabled
  131871. */
  131872. VLSEnabled: boolean;
  131873. /**
  131874. * @ignore
  131875. * Specifies if the motion blur effect is enabled
  131876. */
  131877. MotionBlurEnabled: boolean;
  131878. /**
  131879. * Specifies if anti-aliasing is enabled
  131880. */
  131881. fxaaEnabled: boolean;
  131882. /**
  131883. * Specifies the number of steps used to calculate the volumetric lights
  131884. * Typically in interval [50, 200]
  131885. */
  131886. volumetricLightStepsCount: number;
  131887. /**
  131888. * Specifies the number of samples used for the motion blur effect
  131889. * Typically in interval [16, 64]
  131890. */
  131891. motionBlurSamples: number;
  131892. /**
  131893. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131894. */
  131895. samples: number;
  131896. /**
  131897. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131898. * @constructor
  131899. * @param name The rendering pipeline name
  131900. * @param scene The scene linked to this pipeline
  131901. * @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)
  131902. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131903. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131904. */
  131905. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131906. private _buildPipeline;
  131907. private _createDownSampleX4PostProcess;
  131908. private _createBrightPassPostProcess;
  131909. private _createBlurPostProcesses;
  131910. private _createTextureAdderPostProcess;
  131911. private _createVolumetricLightPostProcess;
  131912. private _createLuminancePostProcesses;
  131913. private _createHdrPostProcess;
  131914. private _createLensFlarePostProcess;
  131915. private _createDepthOfFieldPostProcess;
  131916. private _createMotionBlurPostProcess;
  131917. private _getDepthTexture;
  131918. private _disposePostProcesses;
  131919. /**
  131920. * Dispose of the pipeline and stop all post processes
  131921. */
  131922. dispose(): void;
  131923. /**
  131924. * Serialize the rendering pipeline (Used when exporting)
  131925. * @returns the serialized object
  131926. */
  131927. serialize(): any;
  131928. /**
  131929. * Parse the serialized pipeline
  131930. * @param source Source pipeline.
  131931. * @param scene The scene to load the pipeline to.
  131932. * @param rootUrl The URL of the serialized pipeline.
  131933. * @returns An instantiated pipeline from the serialized object.
  131934. */
  131935. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  131936. /**
  131937. * Luminance steps
  131938. */
  131939. static LuminanceSteps: number;
  131940. }
  131941. }
  131942. declare module BABYLON {
  131943. /** @hidden */
  131944. export var tonemapPixelShader: {
  131945. name: string;
  131946. shader: string;
  131947. };
  131948. }
  131949. declare module BABYLON {
  131950. /** Defines operator used for tonemapping */
  131951. export enum TonemappingOperator {
  131952. /** Hable */
  131953. Hable = 0,
  131954. /** Reinhard */
  131955. Reinhard = 1,
  131956. /** HejiDawson */
  131957. HejiDawson = 2,
  131958. /** Photographic */
  131959. Photographic = 3
  131960. }
  131961. /**
  131962. * Defines a post process to apply tone mapping
  131963. */
  131964. export class TonemapPostProcess extends PostProcess {
  131965. private _operator;
  131966. /** Defines the required exposure adjustement */
  131967. exposureAdjustment: number;
  131968. /**
  131969. * Creates a new TonemapPostProcess
  131970. * @param name defines the name of the postprocess
  131971. * @param _operator defines the operator to use
  131972. * @param exposureAdjustment defines the required exposure adjustement
  131973. * @param camera defines the camera to use (can be null)
  131974. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  131975. * @param engine defines the hosting engine (can be ignore if camera is set)
  131976. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131977. */
  131978. constructor(name: string, _operator: TonemappingOperator,
  131979. /** Defines the required exposure adjustement */
  131980. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  131981. }
  131982. }
  131983. declare module BABYLON {
  131984. /** @hidden */
  131985. export var depthVertexShader: {
  131986. name: string;
  131987. shader: string;
  131988. };
  131989. }
  131990. declare module BABYLON {
  131991. /** @hidden */
  131992. export var volumetricLightScatteringPixelShader: {
  131993. name: string;
  131994. shader: string;
  131995. };
  131996. }
  131997. declare module BABYLON {
  131998. /** @hidden */
  131999. export var volumetricLightScatteringPassVertexShader: {
  132000. name: string;
  132001. shader: string;
  132002. };
  132003. }
  132004. declare module BABYLON {
  132005. /** @hidden */
  132006. export var volumetricLightScatteringPassPixelShader: {
  132007. name: string;
  132008. shader: string;
  132009. };
  132010. }
  132011. declare module BABYLON {
  132012. /**
  132013. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  132014. */
  132015. export class VolumetricLightScatteringPostProcess extends PostProcess {
  132016. private _volumetricLightScatteringPass;
  132017. private _volumetricLightScatteringRTT;
  132018. private _viewPort;
  132019. private _screenCoordinates;
  132020. private _cachedDefines;
  132021. /**
  132022. * If not undefined, the mesh position is computed from the attached node position
  132023. */
  132024. attachedNode: {
  132025. position: Vector3;
  132026. };
  132027. /**
  132028. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  132029. */
  132030. customMeshPosition: Vector3;
  132031. /**
  132032. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  132033. */
  132034. useCustomMeshPosition: boolean;
  132035. /**
  132036. * If the post-process should inverse the light scattering direction
  132037. */
  132038. invert: boolean;
  132039. /**
  132040. * The internal mesh used by the post-process
  132041. */
  132042. mesh: Mesh;
  132043. /**
  132044. * @hidden
  132045. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132046. */
  132047. useDiffuseColor: boolean;
  132048. /**
  132049. * Array containing the excluded meshes not rendered in the internal pass
  132050. */
  132051. excludedMeshes: AbstractMesh[];
  132052. /**
  132053. * Controls the overall intensity of the post-process
  132054. */
  132055. exposure: number;
  132056. /**
  132057. * Dissipates each sample's contribution in range [0, 1]
  132058. */
  132059. decay: number;
  132060. /**
  132061. * Controls the overall intensity of each sample
  132062. */
  132063. weight: number;
  132064. /**
  132065. * Controls the density of each sample
  132066. */
  132067. density: number;
  132068. /**
  132069. * @constructor
  132070. * @param name The post-process name
  132071. * @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)
  132072. * @param camera The camera that the post-process will be attached to
  132073. * @param mesh The mesh used to create the light scattering
  132074. * @param samples The post-process quality, default 100
  132075. * @param samplingModeThe post-process filtering mode
  132076. * @param engine The babylon engine
  132077. * @param reusable If the post-process is reusable
  132078. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132079. */
  132080. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132081. /**
  132082. * Returns the string "VolumetricLightScatteringPostProcess"
  132083. * @returns "VolumetricLightScatteringPostProcess"
  132084. */
  132085. getClassName(): string;
  132086. private _isReady;
  132087. /**
  132088. * Sets the new light position for light scattering effect
  132089. * @param position The new custom light position
  132090. */
  132091. setCustomMeshPosition(position: Vector3): void;
  132092. /**
  132093. * Returns the light position for light scattering effect
  132094. * @return Vector3 The custom light position
  132095. */
  132096. getCustomMeshPosition(): Vector3;
  132097. /**
  132098. * Disposes the internal assets and detaches the post-process from the camera
  132099. */
  132100. dispose(camera: Camera): void;
  132101. /**
  132102. * Returns the render target texture used by the post-process
  132103. * @return the render target texture used by the post-process
  132104. */
  132105. getPass(): RenderTargetTexture;
  132106. private _meshExcluded;
  132107. private _createPass;
  132108. private _updateMeshScreenCoordinates;
  132109. /**
  132110. * Creates a default mesh for the Volumeric Light Scattering post-process
  132111. * @param name The mesh name
  132112. * @param scene The scene where to create the mesh
  132113. * @return the default mesh
  132114. */
  132115. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132116. }
  132117. }
  132118. declare module BABYLON {
  132119. interface Scene {
  132120. /** @hidden (Backing field) */
  132121. _boundingBoxRenderer: BoundingBoxRenderer;
  132122. /** @hidden (Backing field) */
  132123. _forceShowBoundingBoxes: boolean;
  132124. /**
  132125. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132126. */
  132127. forceShowBoundingBoxes: boolean;
  132128. /**
  132129. * Gets the bounding box renderer associated with the scene
  132130. * @returns a BoundingBoxRenderer
  132131. */
  132132. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132133. }
  132134. interface AbstractMesh {
  132135. /** @hidden (Backing field) */
  132136. _showBoundingBox: boolean;
  132137. /**
  132138. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132139. */
  132140. showBoundingBox: boolean;
  132141. }
  132142. /**
  132143. * Component responsible of rendering the bounding box of the meshes in a scene.
  132144. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132145. */
  132146. export class BoundingBoxRenderer implements ISceneComponent {
  132147. /**
  132148. * The component name helpfull to identify the component in the list of scene components.
  132149. */
  132150. readonly name: string;
  132151. /**
  132152. * The scene the component belongs to.
  132153. */
  132154. scene: Scene;
  132155. /**
  132156. * Color of the bounding box lines placed in front of an object
  132157. */
  132158. frontColor: Color3;
  132159. /**
  132160. * Color of the bounding box lines placed behind an object
  132161. */
  132162. backColor: Color3;
  132163. /**
  132164. * Defines if the renderer should show the back lines or not
  132165. */
  132166. showBackLines: boolean;
  132167. /**
  132168. * @hidden
  132169. */
  132170. renderList: SmartArray<BoundingBox>;
  132171. private _colorShader;
  132172. private _vertexBuffers;
  132173. private _indexBuffer;
  132174. private _fillIndexBuffer;
  132175. private _fillIndexData;
  132176. /**
  132177. * Instantiates a new bounding box renderer in a scene.
  132178. * @param scene the scene the renderer renders in
  132179. */
  132180. constructor(scene: Scene);
  132181. /**
  132182. * Registers the component in a given scene
  132183. */
  132184. register(): void;
  132185. private _evaluateSubMesh;
  132186. private _activeMesh;
  132187. private _prepareRessources;
  132188. private _createIndexBuffer;
  132189. /**
  132190. * Rebuilds the elements related to this component in case of
  132191. * context lost for instance.
  132192. */
  132193. rebuild(): void;
  132194. /**
  132195. * @hidden
  132196. */
  132197. reset(): void;
  132198. /**
  132199. * Render the bounding boxes of a specific rendering group
  132200. * @param renderingGroupId defines the rendering group to render
  132201. */
  132202. render(renderingGroupId: number): void;
  132203. /**
  132204. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132205. * @param mesh Define the mesh to render the occlusion bounding box for
  132206. */
  132207. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132208. /**
  132209. * Dispose and release the resources attached to this renderer.
  132210. */
  132211. dispose(): void;
  132212. }
  132213. }
  132214. declare module BABYLON {
  132215. /** @hidden */
  132216. export var depthPixelShader: {
  132217. name: string;
  132218. shader: string;
  132219. };
  132220. }
  132221. declare module BABYLON {
  132222. /**
  132223. * This represents a depth renderer in Babylon.
  132224. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132225. */
  132226. export class DepthRenderer {
  132227. private _scene;
  132228. private _depthMap;
  132229. private _effect;
  132230. private readonly _storeNonLinearDepth;
  132231. private readonly _clearColor;
  132232. /** Get if the depth renderer is using packed depth or not */
  132233. readonly isPacked: boolean;
  132234. private _cachedDefines;
  132235. private _camera;
  132236. /**
  132237. * Specifiess that the depth renderer will only be used within
  132238. * the camera it is created for.
  132239. * This can help forcing its rendering during the camera processing.
  132240. */
  132241. useOnlyInActiveCamera: boolean;
  132242. /** @hidden */
  132243. static _SceneComponentInitialization: (scene: Scene) => void;
  132244. /**
  132245. * Instantiates a depth renderer
  132246. * @param scene The scene the renderer belongs to
  132247. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132248. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132249. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132250. */
  132251. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132252. /**
  132253. * Creates the depth rendering effect and checks if the effect is ready.
  132254. * @param subMesh The submesh to be used to render the depth map of
  132255. * @param useInstances If multiple world instances should be used
  132256. * @returns if the depth renderer is ready to render the depth map
  132257. */
  132258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132259. /**
  132260. * Gets the texture which the depth map will be written to.
  132261. * @returns The depth map texture
  132262. */
  132263. getDepthMap(): RenderTargetTexture;
  132264. /**
  132265. * Disposes of the depth renderer.
  132266. */
  132267. dispose(): void;
  132268. }
  132269. }
  132270. declare module BABYLON {
  132271. interface Scene {
  132272. /** @hidden (Backing field) */
  132273. _depthRenderer: {
  132274. [id: string]: DepthRenderer;
  132275. };
  132276. /**
  132277. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132278. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132279. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132280. * @returns the created depth renderer
  132281. */
  132282. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132283. /**
  132284. * Disables a depth renderer for a given camera
  132285. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132286. */
  132287. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132288. }
  132289. /**
  132290. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132291. * in several rendering techniques.
  132292. */
  132293. export class DepthRendererSceneComponent implements ISceneComponent {
  132294. /**
  132295. * The component name helpfull to identify the component in the list of scene components.
  132296. */
  132297. readonly name: string;
  132298. /**
  132299. * The scene the component belongs to.
  132300. */
  132301. scene: Scene;
  132302. /**
  132303. * Creates a new instance of the component for the given scene
  132304. * @param scene Defines the scene to register the component in
  132305. */
  132306. constructor(scene: Scene);
  132307. /**
  132308. * Registers the component in a given scene
  132309. */
  132310. register(): void;
  132311. /**
  132312. * Rebuilds the elements related to this component in case of
  132313. * context lost for instance.
  132314. */
  132315. rebuild(): void;
  132316. /**
  132317. * Disposes the component and the associated ressources
  132318. */
  132319. dispose(): void;
  132320. private _gatherRenderTargets;
  132321. private _gatherActiveCameraRenderTargets;
  132322. }
  132323. }
  132324. declare module BABYLON {
  132325. /** @hidden */
  132326. export var outlinePixelShader: {
  132327. name: string;
  132328. shader: string;
  132329. };
  132330. }
  132331. declare module BABYLON {
  132332. /** @hidden */
  132333. export var outlineVertexShader: {
  132334. name: string;
  132335. shader: string;
  132336. };
  132337. }
  132338. declare module BABYLON {
  132339. interface Scene {
  132340. /** @hidden */
  132341. _outlineRenderer: OutlineRenderer;
  132342. /**
  132343. * Gets the outline renderer associated with the scene
  132344. * @returns a OutlineRenderer
  132345. */
  132346. getOutlineRenderer(): OutlineRenderer;
  132347. }
  132348. interface AbstractMesh {
  132349. /** @hidden (Backing field) */
  132350. _renderOutline: boolean;
  132351. /**
  132352. * Gets or sets a boolean indicating if the outline must be rendered as well
  132353. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132354. */
  132355. renderOutline: boolean;
  132356. /** @hidden (Backing field) */
  132357. _renderOverlay: boolean;
  132358. /**
  132359. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132360. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132361. */
  132362. renderOverlay: boolean;
  132363. }
  132364. /**
  132365. * This class is responsible to draw bothe outline/overlay of meshes.
  132366. * It should not be used directly but through the available method on mesh.
  132367. */
  132368. export class OutlineRenderer implements ISceneComponent {
  132369. /**
  132370. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132371. */
  132372. private static _StencilReference;
  132373. /**
  132374. * The name of the component. Each component must have a unique name.
  132375. */
  132376. name: string;
  132377. /**
  132378. * The scene the component belongs to.
  132379. */
  132380. scene: Scene;
  132381. /**
  132382. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132383. */
  132384. zOffset: number;
  132385. private _engine;
  132386. private _effect;
  132387. private _cachedDefines;
  132388. private _savedDepthWrite;
  132389. /**
  132390. * Instantiates a new outline renderer. (There could be only one per scene).
  132391. * @param scene Defines the scene it belongs to
  132392. */
  132393. constructor(scene: Scene);
  132394. /**
  132395. * Register the component to one instance of a scene.
  132396. */
  132397. register(): void;
  132398. /**
  132399. * Rebuilds the elements related to this component in case of
  132400. * context lost for instance.
  132401. */
  132402. rebuild(): void;
  132403. /**
  132404. * Disposes the component and the associated ressources.
  132405. */
  132406. dispose(): void;
  132407. /**
  132408. * Renders the outline in the canvas.
  132409. * @param subMesh Defines the sumesh to render
  132410. * @param batch Defines the batch of meshes in case of instances
  132411. * @param useOverlay Defines if the rendering is for the overlay or the outline
  132412. */
  132413. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  132414. /**
  132415. * Returns whether or not the outline renderer is ready for a given submesh.
  132416. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  132417. * @param subMesh Defines the submesh to check readyness for
  132418. * @param useInstances Defines wheter wee are trying to render instances or not
  132419. * @returns true if ready otherwise false
  132420. */
  132421. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132422. private _beforeRenderingMesh;
  132423. private _afterRenderingMesh;
  132424. }
  132425. }
  132426. declare module BABYLON {
  132427. /**
  132428. * Class used to manage multiple sprites of different sizes on the same spritesheet
  132429. * @see http://doc.babylonjs.com/babylon101/sprites
  132430. */
  132431. export class SpritePackedManager extends SpriteManager {
  132432. /** defines the packed manager's name */
  132433. name: string;
  132434. /**
  132435. * Creates a new sprite manager from a packed sprite sheet
  132436. * @param name defines the manager's name
  132437. * @param imgUrl defines the sprite sheet url
  132438. * @param capacity defines the maximum allowed number of sprites
  132439. * @param scene defines the hosting scene
  132440. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  132441. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  132442. * @param samplingMode defines the smapling mode to use with spritesheet
  132443. * @param fromPacked set to true; do not alter
  132444. */
  132445. constructor(
  132446. /** defines the packed manager's name */
  132447. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  132448. }
  132449. }
  132450. declare module BABYLON {
  132451. /**
  132452. * Defines the list of states available for a task inside a AssetsManager
  132453. */
  132454. export enum AssetTaskState {
  132455. /**
  132456. * Initialization
  132457. */
  132458. INIT = 0,
  132459. /**
  132460. * Running
  132461. */
  132462. RUNNING = 1,
  132463. /**
  132464. * Done
  132465. */
  132466. DONE = 2,
  132467. /**
  132468. * Error
  132469. */
  132470. ERROR = 3
  132471. }
  132472. /**
  132473. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  132474. */
  132475. export abstract class AbstractAssetTask {
  132476. /**
  132477. * Task name
  132478. */ name: string;
  132479. /**
  132480. * Callback called when the task is successful
  132481. */
  132482. onSuccess: (task: any) => void;
  132483. /**
  132484. * Callback called when the task is not successful
  132485. */
  132486. onError: (task: any, message?: string, exception?: any) => void;
  132487. /**
  132488. * Creates a new AssetsManager
  132489. * @param name defines the name of the task
  132490. */
  132491. constructor(
  132492. /**
  132493. * Task name
  132494. */ name: string);
  132495. private _isCompleted;
  132496. private _taskState;
  132497. private _errorObject;
  132498. /**
  132499. * Get if the task is completed
  132500. */
  132501. readonly isCompleted: boolean;
  132502. /**
  132503. * Gets the current state of the task
  132504. */
  132505. readonly taskState: AssetTaskState;
  132506. /**
  132507. * Gets the current error object (if task is in error)
  132508. */
  132509. readonly errorObject: {
  132510. message?: string;
  132511. exception?: any;
  132512. };
  132513. /**
  132514. * Internal only
  132515. * @hidden
  132516. */
  132517. _setErrorObject(message?: string, exception?: any): void;
  132518. /**
  132519. * Execute the current task
  132520. * @param scene defines the scene where you want your assets to be loaded
  132521. * @param onSuccess is a callback called when the task is successfully executed
  132522. * @param onError is a callback called if an error occurs
  132523. */
  132524. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132525. /**
  132526. * Execute the current task
  132527. * @param scene defines the scene where you want your assets to be loaded
  132528. * @param onSuccess is a callback called when the task is successfully executed
  132529. * @param onError is a callback called if an error occurs
  132530. */
  132531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132532. /**
  132533. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  132534. * This can be used with failed tasks that have the reason for failure fixed.
  132535. */
  132536. reset(): void;
  132537. private onErrorCallback;
  132538. private onDoneCallback;
  132539. }
  132540. /**
  132541. * Define the interface used by progress events raised during assets loading
  132542. */
  132543. export interface IAssetsProgressEvent {
  132544. /**
  132545. * Defines the number of remaining tasks to process
  132546. */
  132547. remainingCount: number;
  132548. /**
  132549. * Defines the total number of tasks
  132550. */
  132551. totalCount: number;
  132552. /**
  132553. * Defines the task that was just processed
  132554. */
  132555. task: AbstractAssetTask;
  132556. }
  132557. /**
  132558. * Class used to share progress information about assets loading
  132559. */
  132560. export class AssetsProgressEvent implements IAssetsProgressEvent {
  132561. /**
  132562. * Defines the number of remaining tasks to process
  132563. */
  132564. remainingCount: number;
  132565. /**
  132566. * Defines the total number of tasks
  132567. */
  132568. totalCount: number;
  132569. /**
  132570. * Defines the task that was just processed
  132571. */
  132572. task: AbstractAssetTask;
  132573. /**
  132574. * Creates a AssetsProgressEvent
  132575. * @param remainingCount defines the number of remaining tasks to process
  132576. * @param totalCount defines the total number of tasks
  132577. * @param task defines the task that was just processed
  132578. */
  132579. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  132580. }
  132581. /**
  132582. * Define a task used by AssetsManager to load meshes
  132583. */
  132584. export class MeshAssetTask extends AbstractAssetTask {
  132585. /**
  132586. * Defines the name of the task
  132587. */
  132588. name: string;
  132589. /**
  132590. * Defines the list of mesh's names you want to load
  132591. */
  132592. meshesNames: any;
  132593. /**
  132594. * Defines the root url to use as a base to load your meshes and associated resources
  132595. */
  132596. rootUrl: string;
  132597. /**
  132598. * Defines the filename of the scene to load from
  132599. */
  132600. sceneFilename: string;
  132601. /**
  132602. * Gets the list of loaded meshes
  132603. */
  132604. loadedMeshes: Array<AbstractMesh>;
  132605. /**
  132606. * Gets the list of loaded particle systems
  132607. */
  132608. loadedParticleSystems: Array<IParticleSystem>;
  132609. /**
  132610. * Gets the list of loaded skeletons
  132611. */
  132612. loadedSkeletons: Array<Skeleton>;
  132613. /**
  132614. * Gets the list of loaded animation groups
  132615. */
  132616. loadedAnimationGroups: Array<AnimationGroup>;
  132617. /**
  132618. * Callback called when the task is successful
  132619. */
  132620. onSuccess: (task: MeshAssetTask) => void;
  132621. /**
  132622. * Callback called when the task is successful
  132623. */
  132624. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  132625. /**
  132626. * Creates a new MeshAssetTask
  132627. * @param name defines the name of the task
  132628. * @param meshesNames defines the list of mesh's names you want to load
  132629. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  132630. * @param sceneFilename defines the filename of the scene to load from
  132631. */
  132632. constructor(
  132633. /**
  132634. * Defines the name of the task
  132635. */
  132636. name: string,
  132637. /**
  132638. * Defines the list of mesh's names you want to load
  132639. */
  132640. meshesNames: any,
  132641. /**
  132642. * Defines the root url to use as a base to load your meshes and associated resources
  132643. */
  132644. rootUrl: string,
  132645. /**
  132646. * Defines the filename of the scene to load from
  132647. */
  132648. sceneFilename: string);
  132649. /**
  132650. * Execute the current task
  132651. * @param scene defines the scene where you want your assets to be loaded
  132652. * @param onSuccess is a callback called when the task is successfully executed
  132653. * @param onError is a callback called if an error occurs
  132654. */
  132655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132656. }
  132657. /**
  132658. * Define a task used by AssetsManager to load text content
  132659. */
  132660. export class TextFileAssetTask extends AbstractAssetTask {
  132661. /**
  132662. * Defines the name of the task
  132663. */
  132664. name: string;
  132665. /**
  132666. * Defines the location of the file to load
  132667. */
  132668. url: string;
  132669. /**
  132670. * Gets the loaded text string
  132671. */
  132672. text: string;
  132673. /**
  132674. * Callback called when the task is successful
  132675. */
  132676. onSuccess: (task: TextFileAssetTask) => void;
  132677. /**
  132678. * Callback called when the task is successful
  132679. */
  132680. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  132681. /**
  132682. * Creates a new TextFileAssetTask object
  132683. * @param name defines the name of the task
  132684. * @param url defines the location of the file to load
  132685. */
  132686. constructor(
  132687. /**
  132688. * Defines the name of the task
  132689. */
  132690. name: string,
  132691. /**
  132692. * Defines the location of the file to load
  132693. */
  132694. url: string);
  132695. /**
  132696. * Execute the current task
  132697. * @param scene defines the scene where you want your assets to be loaded
  132698. * @param onSuccess is a callback called when the task is successfully executed
  132699. * @param onError is a callback called if an error occurs
  132700. */
  132701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132702. }
  132703. /**
  132704. * Define a task used by AssetsManager to load binary data
  132705. */
  132706. export class BinaryFileAssetTask extends AbstractAssetTask {
  132707. /**
  132708. * Defines the name of the task
  132709. */
  132710. name: string;
  132711. /**
  132712. * Defines the location of the file to load
  132713. */
  132714. url: string;
  132715. /**
  132716. * Gets the lodaded data (as an array buffer)
  132717. */
  132718. data: ArrayBuffer;
  132719. /**
  132720. * Callback called when the task is successful
  132721. */
  132722. onSuccess: (task: BinaryFileAssetTask) => void;
  132723. /**
  132724. * Callback called when the task is successful
  132725. */
  132726. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  132727. /**
  132728. * Creates a new BinaryFileAssetTask object
  132729. * @param name defines the name of the new task
  132730. * @param url defines the location of the file to load
  132731. */
  132732. constructor(
  132733. /**
  132734. * Defines the name of the task
  132735. */
  132736. name: string,
  132737. /**
  132738. * Defines the location of the file to load
  132739. */
  132740. url: string);
  132741. /**
  132742. * Execute the current task
  132743. * @param scene defines the scene where you want your assets to be loaded
  132744. * @param onSuccess is a callback called when the task is successfully executed
  132745. * @param onError is a callback called if an error occurs
  132746. */
  132747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132748. }
  132749. /**
  132750. * Define a task used by AssetsManager to load images
  132751. */
  132752. export class ImageAssetTask extends AbstractAssetTask {
  132753. /**
  132754. * Defines the name of the task
  132755. */
  132756. name: string;
  132757. /**
  132758. * Defines the location of the image to load
  132759. */
  132760. url: string;
  132761. /**
  132762. * Gets the loaded images
  132763. */
  132764. image: HTMLImageElement;
  132765. /**
  132766. * Callback called when the task is successful
  132767. */
  132768. onSuccess: (task: ImageAssetTask) => void;
  132769. /**
  132770. * Callback called when the task is successful
  132771. */
  132772. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  132773. /**
  132774. * Creates a new ImageAssetTask
  132775. * @param name defines the name of the task
  132776. * @param url defines the location of the image to load
  132777. */
  132778. constructor(
  132779. /**
  132780. * Defines the name of the task
  132781. */
  132782. name: string,
  132783. /**
  132784. * Defines the location of the image to load
  132785. */
  132786. url: string);
  132787. /**
  132788. * Execute the current task
  132789. * @param scene defines the scene where you want your assets to be loaded
  132790. * @param onSuccess is a callback called when the task is successfully executed
  132791. * @param onError is a callback called if an error occurs
  132792. */
  132793. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132794. }
  132795. /**
  132796. * Defines the interface used by texture loading tasks
  132797. */
  132798. export interface ITextureAssetTask<TEX extends BaseTexture> {
  132799. /**
  132800. * Gets the loaded texture
  132801. */
  132802. texture: TEX;
  132803. }
  132804. /**
  132805. * Define a task used by AssetsManager to load 2D textures
  132806. */
  132807. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  132808. /**
  132809. * Defines the name of the task
  132810. */
  132811. name: string;
  132812. /**
  132813. * Defines the location of the file to load
  132814. */
  132815. url: string;
  132816. /**
  132817. * Defines if mipmap should not be generated (default is false)
  132818. */
  132819. noMipmap?: boolean | undefined;
  132820. /**
  132821. * Defines if texture must be inverted on Y axis (default is false)
  132822. */
  132823. invertY?: boolean | undefined;
  132824. /**
  132825. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132826. */
  132827. samplingMode: number;
  132828. /**
  132829. * Gets the loaded texture
  132830. */
  132831. texture: Texture;
  132832. /**
  132833. * Callback called when the task is successful
  132834. */
  132835. onSuccess: (task: TextureAssetTask) => void;
  132836. /**
  132837. * Callback called when the task is successful
  132838. */
  132839. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132840. /**
  132841. * Creates a new TextureAssetTask object
  132842. * @param name defines the name of the task
  132843. * @param url defines the location of the file to load
  132844. * @param noMipmap defines if mipmap should not be generated (default is false)
  132845. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132846. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132847. */
  132848. constructor(
  132849. /**
  132850. * Defines the name of the task
  132851. */
  132852. name: string,
  132853. /**
  132854. * Defines the location of the file to load
  132855. */
  132856. url: string,
  132857. /**
  132858. * Defines if mipmap should not be generated (default is false)
  132859. */
  132860. noMipmap?: boolean | undefined,
  132861. /**
  132862. * Defines if texture must be inverted on Y axis (default is false)
  132863. */
  132864. invertY?: boolean | undefined,
  132865. /**
  132866. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132867. */
  132868. samplingMode?: number);
  132869. /**
  132870. * Execute the current task
  132871. * @param scene defines the scene where you want your assets to be loaded
  132872. * @param onSuccess is a callback called when the task is successfully executed
  132873. * @param onError is a callback called if an error occurs
  132874. */
  132875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132876. }
  132877. /**
  132878. * Define a task used by AssetsManager to load cube textures
  132879. */
  132880. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132881. /**
  132882. * Defines the name of the task
  132883. */
  132884. name: string;
  132885. /**
  132886. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132887. */
  132888. url: string;
  132889. /**
  132890. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132891. */
  132892. extensions?: string[] | undefined;
  132893. /**
  132894. * Defines if mipmaps should not be generated (default is false)
  132895. */
  132896. noMipmap?: boolean | undefined;
  132897. /**
  132898. * Defines the explicit list of files (undefined by default)
  132899. */
  132900. files?: string[] | undefined;
  132901. /**
  132902. * Gets the loaded texture
  132903. */
  132904. texture: CubeTexture;
  132905. /**
  132906. * Callback called when the task is successful
  132907. */
  132908. onSuccess: (task: CubeTextureAssetTask) => void;
  132909. /**
  132910. * Callback called when the task is successful
  132911. */
  132912. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132913. /**
  132914. * Creates a new CubeTextureAssetTask
  132915. * @param name defines the name of the task
  132916. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132917. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132918. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132919. * @param files defines the explicit list of files (undefined by default)
  132920. */
  132921. constructor(
  132922. /**
  132923. * Defines the name of the task
  132924. */
  132925. name: string,
  132926. /**
  132927. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132928. */
  132929. url: string,
  132930. /**
  132931. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132932. */
  132933. extensions?: string[] | undefined,
  132934. /**
  132935. * Defines if mipmaps should not be generated (default is false)
  132936. */
  132937. noMipmap?: boolean | undefined,
  132938. /**
  132939. * Defines the explicit list of files (undefined by default)
  132940. */
  132941. files?: string[] | undefined);
  132942. /**
  132943. * Execute the current task
  132944. * @param scene defines the scene where you want your assets to be loaded
  132945. * @param onSuccess is a callback called when the task is successfully executed
  132946. * @param onError is a callback called if an error occurs
  132947. */
  132948. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132949. }
  132950. /**
  132951. * Define a task used by AssetsManager to load HDR cube textures
  132952. */
  132953. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  132954. /**
  132955. * Defines the name of the task
  132956. */
  132957. name: string;
  132958. /**
  132959. * Defines the location of the file to load
  132960. */
  132961. url: string;
  132962. /**
  132963. * Defines the desired size (the more it increases the longer the generation will be)
  132964. */
  132965. size: number;
  132966. /**
  132967. * Defines if mipmaps should not be generated (default is false)
  132968. */
  132969. noMipmap: boolean;
  132970. /**
  132971. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132972. */
  132973. generateHarmonics: boolean;
  132974. /**
  132975. * 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)
  132976. */
  132977. gammaSpace: boolean;
  132978. /**
  132979. * Internal Use Only
  132980. */
  132981. reserved: boolean;
  132982. /**
  132983. * Gets the loaded texture
  132984. */
  132985. texture: HDRCubeTexture;
  132986. /**
  132987. * Callback called when the task is successful
  132988. */
  132989. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  132990. /**
  132991. * Callback called when the task is successful
  132992. */
  132993. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  132994. /**
  132995. * Creates a new HDRCubeTextureAssetTask object
  132996. * @param name defines the name of the task
  132997. * @param url defines the location of the file to load
  132998. * @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.
  132999. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133000. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133001. * @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)
  133002. * @param reserved Internal use only
  133003. */
  133004. constructor(
  133005. /**
  133006. * Defines the name of the task
  133007. */
  133008. name: string,
  133009. /**
  133010. * Defines the location of the file to load
  133011. */
  133012. url: string,
  133013. /**
  133014. * Defines the desired size (the more it increases the longer the generation will be)
  133015. */
  133016. size: number,
  133017. /**
  133018. * Defines if mipmaps should not be generated (default is false)
  133019. */
  133020. noMipmap?: boolean,
  133021. /**
  133022. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133023. */
  133024. generateHarmonics?: boolean,
  133025. /**
  133026. * 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)
  133027. */
  133028. gammaSpace?: boolean,
  133029. /**
  133030. * Internal Use Only
  133031. */
  133032. reserved?: boolean);
  133033. /**
  133034. * Execute the current task
  133035. * @param scene defines the scene where you want your assets to be loaded
  133036. * @param onSuccess is a callback called when the task is successfully executed
  133037. * @param onError is a callback called if an error occurs
  133038. */
  133039. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133040. }
  133041. /**
  133042. * Define a task used by AssetsManager to load Equirectangular cube textures
  133043. */
  133044. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133045. /**
  133046. * Defines the name of the task
  133047. */
  133048. name: string;
  133049. /**
  133050. * Defines the location of the file to load
  133051. */
  133052. url: string;
  133053. /**
  133054. * Defines the desired size (the more it increases the longer the generation will be)
  133055. */
  133056. size: number;
  133057. /**
  133058. * Defines if mipmaps should not be generated (default is false)
  133059. */
  133060. noMipmap: boolean;
  133061. /**
  133062. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133063. * but the standard material would require them in Gamma space) (default is true)
  133064. */
  133065. gammaSpace: boolean;
  133066. /**
  133067. * Gets the loaded texture
  133068. */
  133069. texture: EquiRectangularCubeTexture;
  133070. /**
  133071. * Callback called when the task is successful
  133072. */
  133073. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133074. /**
  133075. * Callback called when the task is successful
  133076. */
  133077. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133078. /**
  133079. * Creates a new EquiRectangularCubeTextureAssetTask object
  133080. * @param name defines the name of the task
  133081. * @param url defines the location of the file to load
  133082. * @param size defines the desired size (the more it increases the longer the generation will be)
  133083. * If the size is omitted this implies you are using a preprocessed cubemap.
  133084. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133085. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133086. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133087. * (default is true)
  133088. */
  133089. constructor(
  133090. /**
  133091. * Defines the name of the task
  133092. */
  133093. name: string,
  133094. /**
  133095. * Defines the location of the file to load
  133096. */
  133097. url: string,
  133098. /**
  133099. * Defines the desired size (the more it increases the longer the generation will be)
  133100. */
  133101. size: number,
  133102. /**
  133103. * Defines if mipmaps should not be generated (default is false)
  133104. */
  133105. noMipmap?: boolean,
  133106. /**
  133107. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133108. * but the standard material would require them in Gamma space) (default is true)
  133109. */
  133110. gammaSpace?: boolean);
  133111. /**
  133112. * Execute the current task
  133113. * @param scene defines the scene where you want your assets to be loaded
  133114. * @param onSuccess is a callback called when the task is successfully executed
  133115. * @param onError is a callback called if an error occurs
  133116. */
  133117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133118. }
  133119. /**
  133120. * This class can be used to easily import assets into a scene
  133121. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  133122. */
  133123. export class AssetsManager {
  133124. private _scene;
  133125. private _isLoading;
  133126. protected _tasks: AbstractAssetTask[];
  133127. protected _waitingTasksCount: number;
  133128. protected _totalTasksCount: number;
  133129. /**
  133130. * Callback called when all tasks are processed
  133131. */
  133132. onFinish: (tasks: AbstractAssetTask[]) => void;
  133133. /**
  133134. * Callback called when a task is successful
  133135. */
  133136. onTaskSuccess: (task: AbstractAssetTask) => void;
  133137. /**
  133138. * Callback called when a task had an error
  133139. */
  133140. onTaskError: (task: AbstractAssetTask) => void;
  133141. /**
  133142. * Callback called when a task is done (whatever the result is)
  133143. */
  133144. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  133145. /**
  133146. * Observable called when all tasks are processed
  133147. */
  133148. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  133149. /**
  133150. * Observable called when a task had an error
  133151. */
  133152. onTaskErrorObservable: Observable<AbstractAssetTask>;
  133153. /**
  133154. * Observable called when all tasks were executed
  133155. */
  133156. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  133157. /**
  133158. * Observable called when a task is done (whatever the result is)
  133159. */
  133160. onProgressObservable: Observable<IAssetsProgressEvent>;
  133161. /**
  133162. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  133163. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  133164. */
  133165. useDefaultLoadingScreen: boolean;
  133166. /**
  133167. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  133168. * when all assets have been downloaded.
  133169. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  133170. */
  133171. autoHideLoadingUI: boolean;
  133172. /**
  133173. * Creates a new AssetsManager
  133174. * @param scene defines the scene to work on
  133175. */
  133176. constructor(scene: Scene);
  133177. /**
  133178. * Add a MeshAssetTask to the list of active tasks
  133179. * @param taskName defines the name of the new task
  133180. * @param meshesNames defines the name of meshes to load
  133181. * @param rootUrl defines the root url to use to locate files
  133182. * @param sceneFilename defines the filename of the scene file
  133183. * @returns a new MeshAssetTask object
  133184. */
  133185. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  133186. /**
  133187. * Add a TextFileAssetTask to the list of active tasks
  133188. * @param taskName defines the name of the new task
  133189. * @param url defines the url of the file to load
  133190. * @returns a new TextFileAssetTask object
  133191. */
  133192. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  133193. /**
  133194. * Add a BinaryFileAssetTask to the list of active tasks
  133195. * @param taskName defines the name of the new task
  133196. * @param url defines the url of the file to load
  133197. * @returns a new BinaryFileAssetTask object
  133198. */
  133199. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  133200. /**
  133201. * Add a ImageAssetTask to the list of active tasks
  133202. * @param taskName defines the name of the new task
  133203. * @param url defines the url of the file to load
  133204. * @returns a new ImageAssetTask object
  133205. */
  133206. addImageTask(taskName: string, url: string): ImageAssetTask;
  133207. /**
  133208. * Add a TextureAssetTask to the list of active tasks
  133209. * @param taskName defines the name of the new task
  133210. * @param url defines the url of the file to load
  133211. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133212. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  133213. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133214. * @returns a new TextureAssetTask object
  133215. */
  133216. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  133217. /**
  133218. * Add a CubeTextureAssetTask to the list of active tasks
  133219. * @param taskName defines the name of the new task
  133220. * @param url defines the url of the file to load
  133221. * @param extensions defines the extension to use to load the cube map (can be null)
  133222. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133223. * @param files defines the list of files to load (can be null)
  133224. * @returns a new CubeTextureAssetTask object
  133225. */
  133226. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  133227. /**
  133228. *
  133229. * Add a HDRCubeTextureAssetTask to the list of active tasks
  133230. * @param taskName defines the name of the new task
  133231. * @param url defines the url of the file to load
  133232. * @param size defines the size you want for the cubemap (can be null)
  133233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133234. * @param generateHarmonics defines if you want to automatically generate (true by default)
  133235. * @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)
  133236. * @param reserved Internal use only
  133237. * @returns a new HDRCubeTextureAssetTask object
  133238. */
  133239. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  133240. /**
  133241. *
  133242. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  133243. * @param taskName defines the name of the new task
  133244. * @param url defines the url of the file to load
  133245. * @param size defines the size you want for the cubemap (can be null)
  133246. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133247. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  133248. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  133249. * @returns a new EquiRectangularCubeTextureAssetTask object
  133250. */
  133251. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  133252. /**
  133253. * Remove a task from the assets manager.
  133254. * @param task the task to remove
  133255. */
  133256. removeTask(task: AbstractAssetTask): void;
  133257. private _decreaseWaitingTasksCount;
  133258. private _runTask;
  133259. /**
  133260. * Reset the AssetsManager and remove all tasks
  133261. * @return the current instance of the AssetsManager
  133262. */
  133263. reset(): AssetsManager;
  133264. /**
  133265. * Start the loading process
  133266. * @return the current instance of the AssetsManager
  133267. */
  133268. load(): AssetsManager;
  133269. /**
  133270. * Start the loading process as an async operation
  133271. * @return a promise returning the list of failed tasks
  133272. */
  133273. loadAsync(): Promise<void>;
  133274. }
  133275. }
  133276. declare module BABYLON {
  133277. /**
  133278. * Wrapper class for promise with external resolve and reject.
  133279. */
  133280. export class Deferred<T> {
  133281. /**
  133282. * The promise associated with this deferred object.
  133283. */
  133284. readonly promise: Promise<T>;
  133285. private _resolve;
  133286. private _reject;
  133287. /**
  133288. * The resolve method of the promise associated with this deferred object.
  133289. */
  133290. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  133291. /**
  133292. * The reject method of the promise associated with this deferred object.
  133293. */
  133294. readonly reject: (reason?: any) => void;
  133295. /**
  133296. * Constructor for this deferred object.
  133297. */
  133298. constructor();
  133299. }
  133300. }
  133301. declare module BABYLON {
  133302. /**
  133303. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  133304. */
  133305. export class MeshExploder {
  133306. private _centerMesh;
  133307. private _meshes;
  133308. private _meshesOrigins;
  133309. private _toCenterVectors;
  133310. private _scaledDirection;
  133311. private _newPosition;
  133312. private _centerPosition;
  133313. /**
  133314. * Explodes meshes from a center mesh.
  133315. * @param meshes The meshes to explode.
  133316. * @param centerMesh The mesh to be center of explosion.
  133317. */
  133318. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  133319. private _setCenterMesh;
  133320. /**
  133321. * Get class name
  133322. * @returns "MeshExploder"
  133323. */
  133324. getClassName(): string;
  133325. /**
  133326. * "Exploded meshes"
  133327. * @returns Array of meshes with the centerMesh at index 0.
  133328. */
  133329. getMeshes(): Array<Mesh>;
  133330. /**
  133331. * Explodes meshes giving a specific direction
  133332. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  133333. */
  133334. explode(direction?: number): void;
  133335. }
  133336. }
  133337. declare module BABYLON {
  133338. /**
  133339. * Class used to help managing file picking and drag'n'drop
  133340. */
  133341. export class FilesInput {
  133342. /**
  133343. * List of files ready to be loaded
  133344. */
  133345. static readonly FilesToLoad: {
  133346. [key: string]: File;
  133347. };
  133348. /**
  133349. * Callback called when a file is processed
  133350. */
  133351. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  133352. private _engine;
  133353. private _currentScene;
  133354. private _sceneLoadedCallback;
  133355. private _progressCallback;
  133356. private _additionalRenderLoopLogicCallback;
  133357. private _textureLoadingCallback;
  133358. private _startingProcessingFilesCallback;
  133359. private _onReloadCallback;
  133360. private _errorCallback;
  133361. private _elementToMonitor;
  133362. private _sceneFileToLoad;
  133363. private _filesToLoad;
  133364. /**
  133365. * Creates a new FilesInput
  133366. * @param engine defines the rendering engine
  133367. * @param scene defines the hosting scene
  133368. * @param sceneLoadedCallback callback called when scene is loaded
  133369. * @param progressCallback callback called to track progress
  133370. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  133371. * @param textureLoadingCallback callback called when a texture is loading
  133372. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  133373. * @param onReloadCallback callback called when a reload is requested
  133374. * @param errorCallback callback call if an error occurs
  133375. */
  133376. 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);
  133377. private _dragEnterHandler;
  133378. private _dragOverHandler;
  133379. private _dropHandler;
  133380. /**
  133381. * Calls this function to listen to drag'n'drop events on a specific DOM element
  133382. * @param elementToMonitor defines the DOM element to track
  133383. */
  133384. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  133385. /**
  133386. * Release all associated resources
  133387. */
  133388. dispose(): void;
  133389. private renderFunction;
  133390. private drag;
  133391. private drop;
  133392. private _traverseFolder;
  133393. private _processFiles;
  133394. /**
  133395. * Load files from a drop event
  133396. * @param event defines the drop event to use as source
  133397. */
  133398. loadFiles(event: any): void;
  133399. private _processReload;
  133400. /**
  133401. * Reload the current scene from the loaded files
  133402. */
  133403. reload(): void;
  133404. }
  133405. }
  133406. declare module BABYLON {
  133407. /**
  133408. * Defines the root class used to create scene optimization to use with SceneOptimizer
  133409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133410. */
  133411. export class SceneOptimization {
  133412. /**
  133413. * Defines the priority of this optimization (0 by default which means first in the list)
  133414. */
  133415. priority: number;
  133416. /**
  133417. * Gets a string describing the action executed by the current optimization
  133418. * @returns description string
  133419. */
  133420. getDescription(): string;
  133421. /**
  133422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133423. * @param scene defines the current scene where to apply this optimization
  133424. * @param optimizer defines the current optimizer
  133425. * @returns true if everything that can be done was applied
  133426. */
  133427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133428. /**
  133429. * Creates the SceneOptimization object
  133430. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133431. * @param desc defines the description associated with the optimization
  133432. */
  133433. constructor(
  133434. /**
  133435. * Defines the priority of this optimization (0 by default which means first in the list)
  133436. */
  133437. priority?: number);
  133438. }
  133439. /**
  133440. * Defines an optimization used to reduce the size of render target textures
  133441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133442. */
  133443. export class TextureOptimization extends SceneOptimization {
  133444. /**
  133445. * Defines the priority of this optimization (0 by default which means first in the list)
  133446. */
  133447. priority: number;
  133448. /**
  133449. * 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
  133450. */
  133451. maximumSize: number;
  133452. /**
  133453. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133454. */
  133455. step: number;
  133456. /**
  133457. * Gets a string describing the action executed by the current optimization
  133458. * @returns description string
  133459. */
  133460. getDescription(): string;
  133461. /**
  133462. * Creates the TextureOptimization object
  133463. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133464. * @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
  133465. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133466. */
  133467. constructor(
  133468. /**
  133469. * Defines the priority of this optimization (0 by default which means first in the list)
  133470. */
  133471. priority?: number,
  133472. /**
  133473. * 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
  133474. */
  133475. maximumSize?: number,
  133476. /**
  133477. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133478. */
  133479. step?: number);
  133480. /**
  133481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133482. * @param scene defines the current scene where to apply this optimization
  133483. * @param optimizer defines the current optimizer
  133484. * @returns true if everything that can be done was applied
  133485. */
  133486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133487. }
  133488. /**
  133489. * Defines an optimization used to increase or decrease the rendering resolution
  133490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133491. */
  133492. export class HardwareScalingOptimization extends SceneOptimization {
  133493. /**
  133494. * Defines the priority of this optimization (0 by default which means first in the list)
  133495. */
  133496. priority: number;
  133497. /**
  133498. * Defines the maximum scale to use (2 by default)
  133499. */
  133500. maximumScale: number;
  133501. /**
  133502. * Defines the step to use between two passes (0.5 by default)
  133503. */
  133504. step: number;
  133505. private _currentScale;
  133506. private _directionOffset;
  133507. /**
  133508. * Gets a string describing the action executed by the current optimization
  133509. * @return description string
  133510. */
  133511. getDescription(): string;
  133512. /**
  133513. * Creates the HardwareScalingOptimization object
  133514. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133515. * @param maximumScale defines the maximum scale to use (2 by default)
  133516. * @param step defines the step to use between two passes (0.5 by default)
  133517. */
  133518. constructor(
  133519. /**
  133520. * Defines the priority of this optimization (0 by default which means first in the list)
  133521. */
  133522. priority?: number,
  133523. /**
  133524. * Defines the maximum scale to use (2 by default)
  133525. */
  133526. maximumScale?: number,
  133527. /**
  133528. * Defines the step to use between two passes (0.5 by default)
  133529. */
  133530. step?: number);
  133531. /**
  133532. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133533. * @param scene defines the current scene where to apply this optimization
  133534. * @param optimizer defines the current optimizer
  133535. * @returns true if everything that can be done was applied
  133536. */
  133537. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133538. }
  133539. /**
  133540. * Defines an optimization used to remove shadows
  133541. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133542. */
  133543. export class ShadowsOptimization extends SceneOptimization {
  133544. /**
  133545. * Gets a string describing the action executed by the current optimization
  133546. * @return description string
  133547. */
  133548. getDescription(): string;
  133549. /**
  133550. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133551. * @param scene defines the current scene where to apply this optimization
  133552. * @param optimizer defines the current optimizer
  133553. * @returns true if everything that can be done was applied
  133554. */
  133555. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133556. }
  133557. /**
  133558. * Defines an optimization used to turn post-processes off
  133559. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133560. */
  133561. export class PostProcessesOptimization extends SceneOptimization {
  133562. /**
  133563. * Gets a string describing the action executed by the current optimization
  133564. * @return description string
  133565. */
  133566. getDescription(): string;
  133567. /**
  133568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133569. * @param scene defines the current scene where to apply this optimization
  133570. * @param optimizer defines the current optimizer
  133571. * @returns true if everything that can be done was applied
  133572. */
  133573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133574. }
  133575. /**
  133576. * Defines an optimization used to turn lens flares off
  133577. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133578. */
  133579. export class LensFlaresOptimization extends SceneOptimization {
  133580. /**
  133581. * Gets a string describing the action executed by the current optimization
  133582. * @return description string
  133583. */
  133584. getDescription(): string;
  133585. /**
  133586. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133587. * @param scene defines the current scene where to apply this optimization
  133588. * @param optimizer defines the current optimizer
  133589. * @returns true if everything that can be done was applied
  133590. */
  133591. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133592. }
  133593. /**
  133594. * Defines an optimization based on user defined callback.
  133595. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133596. */
  133597. export class CustomOptimization extends SceneOptimization {
  133598. /**
  133599. * Callback called to apply the custom optimization.
  133600. */
  133601. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  133602. /**
  133603. * Callback called to get custom description
  133604. */
  133605. onGetDescription: () => string;
  133606. /**
  133607. * Gets a string describing the action executed by the current optimization
  133608. * @returns description string
  133609. */
  133610. getDescription(): string;
  133611. /**
  133612. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133613. * @param scene defines the current scene where to apply this optimization
  133614. * @param optimizer defines the current optimizer
  133615. * @returns true if everything that can be done was applied
  133616. */
  133617. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133618. }
  133619. /**
  133620. * Defines an optimization used to turn particles off
  133621. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133622. */
  133623. export class ParticlesOptimization extends SceneOptimization {
  133624. /**
  133625. * Gets a string describing the action executed by the current optimization
  133626. * @return description string
  133627. */
  133628. getDescription(): string;
  133629. /**
  133630. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133631. * @param scene defines the current scene where to apply this optimization
  133632. * @param optimizer defines the current optimizer
  133633. * @returns true if everything that can be done was applied
  133634. */
  133635. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133636. }
  133637. /**
  133638. * Defines an optimization used to turn render targets off
  133639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133640. */
  133641. export class RenderTargetsOptimization extends SceneOptimization {
  133642. /**
  133643. * Gets a string describing the action executed by the current optimization
  133644. * @return description string
  133645. */
  133646. getDescription(): string;
  133647. /**
  133648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133649. * @param scene defines the current scene where to apply this optimization
  133650. * @param optimizer defines the current optimizer
  133651. * @returns true if everything that can be done was applied
  133652. */
  133653. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133654. }
  133655. /**
  133656. * Defines an optimization used to merge meshes with compatible materials
  133657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133658. */
  133659. export class MergeMeshesOptimization extends SceneOptimization {
  133660. private static _UpdateSelectionTree;
  133661. /**
  133662. * Gets or sets a boolean which defines if optimization octree has to be updated
  133663. */
  133664. /**
  133665. * Gets or sets a boolean which defines if optimization octree has to be updated
  133666. */
  133667. static UpdateSelectionTree: boolean;
  133668. /**
  133669. * Gets a string describing the action executed by the current optimization
  133670. * @return description string
  133671. */
  133672. getDescription(): string;
  133673. private _canBeMerged;
  133674. /**
  133675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133676. * @param scene defines the current scene where to apply this optimization
  133677. * @param optimizer defines the current optimizer
  133678. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  133679. * @returns true if everything that can be done was applied
  133680. */
  133681. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  133682. }
  133683. /**
  133684. * Defines a list of options used by SceneOptimizer
  133685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133686. */
  133687. export class SceneOptimizerOptions {
  133688. /**
  133689. * Defines the target frame rate to reach (60 by default)
  133690. */
  133691. targetFrameRate: number;
  133692. /**
  133693. * Defines the interval between two checkes (2000ms by default)
  133694. */
  133695. trackerDuration: number;
  133696. /**
  133697. * Gets the list of optimizations to apply
  133698. */
  133699. optimizations: SceneOptimization[];
  133700. /**
  133701. * Creates a new list of options used by SceneOptimizer
  133702. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  133703. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  133704. */
  133705. constructor(
  133706. /**
  133707. * Defines the target frame rate to reach (60 by default)
  133708. */
  133709. targetFrameRate?: number,
  133710. /**
  133711. * Defines the interval between two checkes (2000ms by default)
  133712. */
  133713. trackerDuration?: number);
  133714. /**
  133715. * Add a new optimization
  133716. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  133717. * @returns the current SceneOptimizerOptions
  133718. */
  133719. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  133720. /**
  133721. * Add a new custom optimization
  133722. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  133723. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  133724. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133725. * @returns the current SceneOptimizerOptions
  133726. */
  133727. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  133728. /**
  133729. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  133730. * @param targetFrameRate defines the target frame rate (60 by default)
  133731. * @returns a SceneOptimizerOptions object
  133732. */
  133733. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133734. /**
  133735. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  133736. * @param targetFrameRate defines the target frame rate (60 by default)
  133737. * @returns a SceneOptimizerOptions object
  133738. */
  133739. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133740. /**
  133741. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  133742. * @param targetFrameRate defines the target frame rate (60 by default)
  133743. * @returns a SceneOptimizerOptions object
  133744. */
  133745. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133746. }
  133747. /**
  133748. * Class used to run optimizations in order to reach a target frame rate
  133749. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133750. */
  133751. export class SceneOptimizer implements IDisposable {
  133752. private _isRunning;
  133753. private _options;
  133754. private _scene;
  133755. private _currentPriorityLevel;
  133756. private _targetFrameRate;
  133757. private _trackerDuration;
  133758. private _currentFrameRate;
  133759. private _sceneDisposeObserver;
  133760. private _improvementMode;
  133761. /**
  133762. * Defines an observable called when the optimizer reaches the target frame rate
  133763. */
  133764. onSuccessObservable: Observable<SceneOptimizer>;
  133765. /**
  133766. * Defines an observable called when the optimizer enables an optimization
  133767. */
  133768. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  133769. /**
  133770. * Defines an observable called when the optimizer is not able to reach the target frame rate
  133771. */
  133772. onFailureObservable: Observable<SceneOptimizer>;
  133773. /**
  133774. * Gets a boolean indicating if the optimizer is in improvement mode
  133775. */
  133776. readonly isInImprovementMode: boolean;
  133777. /**
  133778. * Gets the current priority level (0 at start)
  133779. */
  133780. readonly currentPriorityLevel: number;
  133781. /**
  133782. * Gets the current frame rate checked by the SceneOptimizer
  133783. */
  133784. readonly currentFrameRate: number;
  133785. /**
  133786. * Gets or sets the current target frame rate (60 by default)
  133787. */
  133788. /**
  133789. * Gets or sets the current target frame rate (60 by default)
  133790. */
  133791. targetFrameRate: number;
  133792. /**
  133793. * Gets or sets the current interval between two checks (every 2000ms by default)
  133794. */
  133795. /**
  133796. * Gets or sets the current interval between two checks (every 2000ms by default)
  133797. */
  133798. trackerDuration: number;
  133799. /**
  133800. * Gets the list of active optimizations
  133801. */
  133802. readonly optimizations: SceneOptimization[];
  133803. /**
  133804. * Creates a new SceneOptimizer
  133805. * @param scene defines the scene to work on
  133806. * @param options defines the options to use with the SceneOptimizer
  133807. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  133808. * @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)
  133809. */
  133810. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  133811. /**
  133812. * Stops the current optimizer
  133813. */
  133814. stop(): void;
  133815. /**
  133816. * Reset the optimizer to initial step (current priority level = 0)
  133817. */
  133818. reset(): void;
  133819. /**
  133820. * Start the optimizer. By default it will try to reach a specific framerate
  133821. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  133822. */
  133823. start(): void;
  133824. private _checkCurrentState;
  133825. /**
  133826. * Release all resources
  133827. */
  133828. dispose(): void;
  133829. /**
  133830. * Helper function to create a SceneOptimizer with one single line of code
  133831. * @param scene defines the scene to work on
  133832. * @param options defines the options to use with the SceneOptimizer
  133833. * @param onSuccess defines a callback to call on success
  133834. * @param onFailure defines a callback to call on failure
  133835. * @returns the new SceneOptimizer object
  133836. */
  133837. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133838. }
  133839. }
  133840. declare module BABYLON {
  133841. /**
  133842. * Class used to serialize a scene into a string
  133843. */
  133844. export class SceneSerializer {
  133845. /**
  133846. * Clear cache used by a previous serialization
  133847. */
  133848. static ClearCache(): void;
  133849. /**
  133850. * Serialize a scene into a JSON compatible object
  133851. * @param scene defines the scene to serialize
  133852. * @returns a JSON compatible object
  133853. */
  133854. static Serialize(scene: Scene): any;
  133855. /**
  133856. * Serialize a mesh into a JSON compatible object
  133857. * @param toSerialize defines the mesh to serialize
  133858. * @param withParents defines if parents must be serialized as well
  133859. * @param withChildren defines if children must be serialized as well
  133860. * @returns a JSON compatible object
  133861. */
  133862. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133863. }
  133864. }
  133865. declare module BABYLON {
  133866. /**
  133867. * Class used to host texture specific utilities
  133868. */
  133869. export class TextureTools {
  133870. /**
  133871. * Uses the GPU to create a copy texture rescaled at a given size
  133872. * @param texture Texture to copy from
  133873. * @param width defines the desired width
  133874. * @param height defines the desired height
  133875. * @param useBilinearMode defines if bilinear mode has to be used
  133876. * @return the generated texture
  133877. */
  133878. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133879. }
  133880. }
  133881. declare module BABYLON {
  133882. /**
  133883. * This represents the different options available for the video capture.
  133884. */
  133885. export interface VideoRecorderOptions {
  133886. /** Defines the mime type of the video. */
  133887. mimeType: string;
  133888. /** Defines the FPS the video should be recorded at. */
  133889. fps: number;
  133890. /** Defines the chunk size for the recording data. */
  133891. recordChunckSize: number;
  133892. /** The audio tracks to attach to the recording. */
  133893. audioTracks?: MediaStreamTrack[];
  133894. }
  133895. /**
  133896. * This can help with recording videos from BabylonJS.
  133897. * This is based on the available WebRTC functionalities of the browser.
  133898. *
  133899. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133900. */
  133901. export class VideoRecorder {
  133902. private static readonly _defaultOptions;
  133903. /**
  133904. * Returns whether or not the VideoRecorder is available in your browser.
  133905. * @param engine Defines the Babylon Engine.
  133906. * @returns true if supported otherwise false.
  133907. */
  133908. static IsSupported(engine: Engine): boolean;
  133909. private readonly _options;
  133910. private _canvas;
  133911. private _mediaRecorder;
  133912. private _recordedChunks;
  133913. private _fileName;
  133914. private _resolve;
  133915. private _reject;
  133916. /**
  133917. * True when a recording is already in progress.
  133918. */
  133919. readonly isRecording: boolean;
  133920. /**
  133921. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133922. * @param engine Defines the BabylonJS Engine you wish to record.
  133923. * @param options Defines options that can be used to customize the capture.
  133924. */
  133925. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133926. /**
  133927. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133928. */
  133929. stopRecording(): void;
  133930. /**
  133931. * Starts recording the canvas for a max duration specified in parameters.
  133932. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133933. * If null no automatic download will start and you can rely on the promise to get the data back.
  133934. * @param maxDuration Defines the maximum recording time in seconds.
  133935. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  133936. * @return A promise callback at the end of the recording with the video data in Blob.
  133937. */
  133938. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  133939. /**
  133940. * Releases internal resources used during the recording.
  133941. */
  133942. dispose(): void;
  133943. private _handleDataAvailable;
  133944. private _handleError;
  133945. private _handleStop;
  133946. }
  133947. }
  133948. declare module BABYLON {
  133949. /**
  133950. * Class containing a set of static utilities functions for screenshots
  133951. */
  133952. export class ScreenshotTools {
  133953. /**
  133954. * Captures a screenshot of the current rendering
  133955. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133956. * @param engine defines the rendering engine
  133957. * @param camera defines the source camera
  133958. * @param size This parameter can be set to a single number or to an object with the
  133959. * following (optional) properties: precision, width, height. If a single number is passed,
  133960. * it will be used for both width and height. If an object is passed, the screenshot size
  133961. * will be derived from the parameters. The precision property is a multiplier allowing
  133962. * rendering at a higher or lower resolution
  133963. * @param successCallback defines the callback receives a single parameter which contains the
  133964. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133965. * src parameter of an <img> to display it
  133966. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133967. * Check your browser for supported MIME types
  133968. */
  133969. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  133970. /**
  133971. * Captures a screenshot of the current rendering
  133972. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133973. * @param engine defines the rendering engine
  133974. * @param camera defines the source camera
  133975. * @param size This parameter can be set to a single number or to an object with the
  133976. * following (optional) properties: precision, width, height. If a single number is passed,
  133977. * it will be used for both width and height. If an object is passed, the screenshot size
  133978. * will be derived from the parameters. The precision property is a multiplier allowing
  133979. * rendering at a higher or lower resolution
  133980. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133981. * Check your browser for supported MIME types
  133982. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133983. * to the src parameter of an <img> to display it
  133984. */
  133985. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  133986. /**
  133987. * Generates an image screenshot from the specified camera.
  133988. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133989. * @param engine The engine to use for rendering
  133990. * @param camera The camera to use for rendering
  133991. * @param size This parameter can be set to a single number or to an object with the
  133992. * following (optional) properties: precision, width, height. If a single number is passed,
  133993. * it will be used for both width and height. If an object is passed, the screenshot size
  133994. * will be derived from the parameters. The precision property is a multiplier allowing
  133995. * rendering at a higher or lower resolution
  133996. * @param successCallback The callback receives a single parameter which contains the
  133997. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133998. * src parameter of an <img> to display it
  133999. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134000. * Check your browser for supported MIME types
  134001. * @param samples Texture samples (default: 1)
  134002. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134003. * @param fileName A name for for the downloaded file.
  134004. */
  134005. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  134006. /**
  134007. * Generates an image screenshot from the specified camera.
  134008. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134009. * @param engine The engine to use for rendering
  134010. * @param camera The camera to use for rendering
  134011. * @param size This parameter can be set to a single number or to an object with the
  134012. * following (optional) properties: precision, width, height. If a single number is passed,
  134013. * it will be used for both width and height. If an object is passed, the screenshot size
  134014. * will be derived from the parameters. The precision property is a multiplier allowing
  134015. * rendering at a higher or lower resolution
  134016. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134017. * Check your browser for supported MIME types
  134018. * @param samples Texture samples (default: 1)
  134019. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134020. * @param fileName A name for for the downloaded file.
  134021. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134022. * to the src parameter of an <img> to display it
  134023. */
  134024. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  134025. /**
  134026. * Gets height and width for screenshot size
  134027. * @private
  134028. */
  134029. private static _getScreenshotSize;
  134030. }
  134031. }
  134032. declare module BABYLON {
  134033. /**
  134034. * Interface for a data buffer
  134035. */
  134036. export interface IDataBuffer {
  134037. /**
  134038. * Reads bytes from the data buffer.
  134039. * @param byteOffset The byte offset to read
  134040. * @param byteLength The byte length to read
  134041. * @returns A promise that resolves when the bytes are read
  134042. */
  134043. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134044. /**
  134045. * The byte length of the buffer.
  134046. */
  134047. readonly byteLength: number;
  134048. }
  134049. /**
  134050. * Utility class for reading from a data buffer
  134051. */
  134052. export class DataReader {
  134053. /**
  134054. * The data buffer associated with this data reader.
  134055. */
  134056. readonly buffer: IDataBuffer;
  134057. /**
  134058. * The current byte offset from the beginning of the data buffer.
  134059. */
  134060. byteOffset: number;
  134061. private _dataView;
  134062. private _dataByteOffset;
  134063. /**
  134064. * Constructor
  134065. * @param buffer The buffer to read
  134066. */
  134067. constructor(buffer: IDataBuffer);
  134068. /**
  134069. * Loads the given byte length.
  134070. * @param byteLength The byte length to load
  134071. * @returns A promise that resolves when the load is complete
  134072. */
  134073. loadAsync(byteLength: number): Promise<void>;
  134074. /**
  134075. * Read a unsigned 32-bit integer from the currently loaded data range.
  134076. * @returns The 32-bit integer read
  134077. */
  134078. readUint32(): number;
  134079. /**
  134080. * Read a byte array from the currently loaded data range.
  134081. * @param byteLength The byte length to read
  134082. * @returns The byte array read
  134083. */
  134084. readUint8Array(byteLength: number): Uint8Array;
  134085. /**
  134086. * Read a string from the currently loaded data range.
  134087. * @param byteLength The byte length to read
  134088. * @returns The string read
  134089. */
  134090. readString(byteLength: number): string;
  134091. /**
  134092. * Skips the given byte length the currently loaded data range.
  134093. * @param byteLength The byte length to skip
  134094. */
  134095. skipBytes(byteLength: number): void;
  134096. }
  134097. }
  134098. declare module BABYLON {
  134099. /**
  134100. * A cursor which tracks a point on a path
  134101. */
  134102. export class PathCursor {
  134103. private path;
  134104. /**
  134105. * Stores path cursor callbacks for when an onchange event is triggered
  134106. */
  134107. private _onchange;
  134108. /**
  134109. * The value of the path cursor
  134110. */
  134111. value: number;
  134112. /**
  134113. * The animation array of the path cursor
  134114. */
  134115. animations: Animation[];
  134116. /**
  134117. * Initializes the path cursor
  134118. * @param path The path to track
  134119. */
  134120. constructor(path: Path2);
  134121. /**
  134122. * Gets the cursor point on the path
  134123. * @returns A point on the path cursor at the cursor location
  134124. */
  134125. getPoint(): Vector3;
  134126. /**
  134127. * Moves the cursor ahead by the step amount
  134128. * @param step The amount to move the cursor forward
  134129. * @returns This path cursor
  134130. */
  134131. moveAhead(step?: number): PathCursor;
  134132. /**
  134133. * Moves the cursor behind by the step amount
  134134. * @param step The amount to move the cursor back
  134135. * @returns This path cursor
  134136. */
  134137. moveBack(step?: number): PathCursor;
  134138. /**
  134139. * Moves the cursor by the step amount
  134140. * If the step amount is greater than one, an exception is thrown
  134141. * @param step The amount to move the cursor
  134142. * @returns This path cursor
  134143. */
  134144. move(step: number): PathCursor;
  134145. /**
  134146. * Ensures that the value is limited between zero and one
  134147. * @returns This path cursor
  134148. */
  134149. private ensureLimits;
  134150. /**
  134151. * Runs onchange callbacks on change (used by the animation engine)
  134152. * @returns This path cursor
  134153. */
  134154. private raiseOnChange;
  134155. /**
  134156. * Executes a function on change
  134157. * @param f A path cursor onchange callback
  134158. * @returns This path cursor
  134159. */
  134160. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134161. }
  134162. }
  134163. declare module BABYLON {
  134164. /** @hidden */
  134165. export var blurPixelShader: {
  134166. name: string;
  134167. shader: string;
  134168. };
  134169. }
  134170. declare module BABYLON {
  134171. /** @hidden */
  134172. export var pointCloudVertexDeclaration: {
  134173. name: string;
  134174. shader: string;
  134175. };
  134176. }
  134177. // Mixins
  134178. interface Window {
  134179. mozIndexedDB: IDBFactory;
  134180. webkitIndexedDB: IDBFactory;
  134181. msIndexedDB: IDBFactory;
  134182. webkitURL: typeof URL;
  134183. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  134184. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  134185. WebGLRenderingContext: WebGLRenderingContext;
  134186. MSGesture: MSGesture;
  134187. CANNON: any;
  134188. AudioContext: AudioContext;
  134189. webkitAudioContext: AudioContext;
  134190. PointerEvent: any;
  134191. Math: Math;
  134192. Uint8Array: Uint8ArrayConstructor;
  134193. Float32Array: Float32ArrayConstructor;
  134194. mozURL: typeof URL;
  134195. msURL: typeof URL;
  134196. VRFrameData: any; // WebVR, from specs 1.1
  134197. DracoDecoderModule: any;
  134198. setImmediate(handler: (...args: any[]) => void): number;
  134199. }
  134200. interface HTMLCanvasElement {
  134201. requestPointerLock(): void;
  134202. msRequestPointerLock?(): void;
  134203. mozRequestPointerLock?(): void;
  134204. webkitRequestPointerLock?(): void;
  134205. /** Track wether a record is in progress */
  134206. isRecording: boolean;
  134207. /** Capture Stream method defined by some browsers */
  134208. captureStream(fps?: number): MediaStream;
  134209. }
  134210. interface CanvasRenderingContext2D {
  134211. msImageSmoothingEnabled: boolean;
  134212. }
  134213. interface MouseEvent {
  134214. mozMovementX: number;
  134215. mozMovementY: number;
  134216. webkitMovementX: number;
  134217. webkitMovementY: number;
  134218. msMovementX: number;
  134219. msMovementY: number;
  134220. }
  134221. interface Navigator {
  134222. mozGetVRDevices: (any: any) => any;
  134223. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134224. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134225. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134226. webkitGetGamepads(): Gamepad[];
  134227. msGetGamepads(): Gamepad[];
  134228. webkitGamepads(): Gamepad[];
  134229. }
  134230. interface HTMLVideoElement {
  134231. mozSrcObject: any;
  134232. }
  134233. interface Math {
  134234. fround(x: number): number;
  134235. imul(a: number, b: number): number;
  134236. }
  134237. interface WebGLRenderingContext {
  134238. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  134239. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  134240. vertexAttribDivisor(index: number, divisor: number): void;
  134241. createVertexArray(): any;
  134242. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  134243. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  134244. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  134245. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  134246. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  134247. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  134248. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  134249. // Queries
  134250. createQuery(): WebGLQuery;
  134251. deleteQuery(query: WebGLQuery): void;
  134252. beginQuery(target: number, query: WebGLQuery): void;
  134253. endQuery(target: number): void;
  134254. getQueryParameter(query: WebGLQuery, pname: number): any;
  134255. getQuery(target: number, pname: number): any;
  134256. MAX_SAMPLES: number;
  134257. RGBA8: number;
  134258. READ_FRAMEBUFFER: number;
  134259. DRAW_FRAMEBUFFER: number;
  134260. UNIFORM_BUFFER: number;
  134261. HALF_FLOAT_OES: number;
  134262. RGBA16F: number;
  134263. RGBA32F: number;
  134264. R32F: number;
  134265. RG32F: number;
  134266. RGB32F: number;
  134267. R16F: number;
  134268. RG16F: number;
  134269. RGB16F: number;
  134270. RED: number;
  134271. RG: number;
  134272. R8: number;
  134273. RG8: number;
  134274. UNSIGNED_INT_24_8: number;
  134275. DEPTH24_STENCIL8: number;
  134276. MIN: number;
  134277. MAX: number;
  134278. /* Multiple Render Targets */
  134279. drawBuffers(buffers: number[]): void;
  134280. readBuffer(src: number): void;
  134281. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  134282. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  134283. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  134284. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  134285. // Occlusion Query
  134286. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  134287. ANY_SAMPLES_PASSED: number;
  134288. QUERY_RESULT_AVAILABLE: number;
  134289. QUERY_RESULT: number;
  134290. }
  134291. interface WebGLProgram {
  134292. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  134293. }
  134294. interface EXT_disjoint_timer_query {
  134295. QUERY_COUNTER_BITS_EXT: number;
  134296. TIME_ELAPSED_EXT: number;
  134297. TIMESTAMP_EXT: number;
  134298. GPU_DISJOINT_EXT: number;
  134299. QUERY_RESULT_EXT: number;
  134300. QUERY_RESULT_AVAILABLE_EXT: number;
  134301. queryCounterEXT(query: WebGLQuery, target: number): void;
  134302. createQueryEXT(): WebGLQuery;
  134303. beginQueryEXT(target: number, query: WebGLQuery): void;
  134304. endQueryEXT(target: number): void;
  134305. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  134306. deleteQueryEXT(query: WebGLQuery): void;
  134307. }
  134308. interface WebGLUniformLocation {
  134309. _currentState: any;
  134310. }
  134311. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  134312. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  134313. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  134314. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134315. interface WebGLRenderingContext {
  134316. readonly RASTERIZER_DISCARD: number;
  134317. readonly DEPTH_COMPONENT24: number;
  134318. readonly TEXTURE_3D: number;
  134319. readonly TEXTURE_2D_ARRAY: number;
  134320. readonly TEXTURE_COMPARE_FUNC: number;
  134321. readonly TEXTURE_COMPARE_MODE: number;
  134322. readonly COMPARE_REF_TO_TEXTURE: number;
  134323. readonly TEXTURE_WRAP_R: number;
  134324. readonly HALF_FLOAT: number;
  134325. readonly RGB8: number;
  134326. readonly RED_INTEGER: number;
  134327. readonly RG_INTEGER: number;
  134328. readonly RGB_INTEGER: number;
  134329. readonly RGBA_INTEGER: number;
  134330. readonly R8_SNORM: number;
  134331. readonly RG8_SNORM: number;
  134332. readonly RGB8_SNORM: number;
  134333. readonly RGBA8_SNORM: number;
  134334. readonly R8I: number;
  134335. readonly RG8I: number;
  134336. readonly RGB8I: number;
  134337. readonly RGBA8I: number;
  134338. readonly R8UI: number;
  134339. readonly RG8UI: number;
  134340. readonly RGB8UI: number;
  134341. readonly RGBA8UI: number;
  134342. readonly R16I: number;
  134343. readonly RG16I: number;
  134344. readonly RGB16I: number;
  134345. readonly RGBA16I: number;
  134346. readonly R16UI: number;
  134347. readonly RG16UI: number;
  134348. readonly RGB16UI: number;
  134349. readonly RGBA16UI: number;
  134350. readonly R32I: number;
  134351. readonly RG32I: number;
  134352. readonly RGB32I: number;
  134353. readonly RGBA32I: number;
  134354. readonly R32UI: number;
  134355. readonly RG32UI: number;
  134356. readonly RGB32UI: number;
  134357. readonly RGBA32UI: number;
  134358. readonly RGB10_A2UI: number;
  134359. readonly R11F_G11F_B10F: number;
  134360. readonly RGB9_E5: number;
  134361. readonly RGB10_A2: number;
  134362. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  134363. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  134364. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  134365. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  134366. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  134367. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  134368. 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;
  134369. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  134370. readonly TRANSFORM_FEEDBACK: number;
  134371. readonly INTERLEAVED_ATTRIBS: number;
  134372. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  134373. createTransformFeedback(): WebGLTransformFeedback;
  134374. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  134375. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  134376. beginTransformFeedback(primitiveMode: number): void;
  134377. endTransformFeedback(): void;
  134378. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  134379. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134380. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134381. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134382. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  134383. }
  134384. interface ImageBitmap {
  134385. readonly width: number;
  134386. readonly height: number;
  134387. close(): void;
  134388. }
  134389. interface WebGLQuery extends WebGLObject {
  134390. }
  134391. declare var WebGLQuery: {
  134392. prototype: WebGLQuery;
  134393. new(): WebGLQuery;
  134394. };
  134395. interface WebGLSampler extends WebGLObject {
  134396. }
  134397. declare var WebGLSampler: {
  134398. prototype: WebGLSampler;
  134399. new(): WebGLSampler;
  134400. };
  134401. interface WebGLSync extends WebGLObject {
  134402. }
  134403. declare var WebGLSync: {
  134404. prototype: WebGLSync;
  134405. new(): WebGLSync;
  134406. };
  134407. interface WebGLTransformFeedback extends WebGLObject {
  134408. }
  134409. declare var WebGLTransformFeedback: {
  134410. prototype: WebGLTransformFeedback;
  134411. new(): WebGLTransformFeedback;
  134412. };
  134413. interface WebGLVertexArrayObject extends WebGLObject {
  134414. }
  134415. declare var WebGLVertexArrayObject: {
  134416. prototype: WebGLVertexArrayObject;
  134417. new(): WebGLVertexArrayObject;
  134418. };
  134419. // Type definitions for WebVR API
  134420. // Project: https://w3c.github.io/webvr/
  134421. // Definitions by: six a <https://github.com/lostfictions>
  134422. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134423. interface VRDisplay extends EventTarget {
  134424. /**
  134425. * Dictionary of capabilities describing the VRDisplay.
  134426. */
  134427. readonly capabilities: VRDisplayCapabilities;
  134428. /**
  134429. * z-depth defining the far plane of the eye view frustum
  134430. * enables mapping of values in the render target depth
  134431. * attachment to scene coordinates. Initially set to 10000.0.
  134432. */
  134433. depthFar: number;
  134434. /**
  134435. * z-depth defining the near plane of the eye view frustum
  134436. * enables mapping of values in the render target depth
  134437. * attachment to scene coordinates. Initially set to 0.01.
  134438. */
  134439. depthNear: number;
  134440. /**
  134441. * An identifier for this distinct VRDisplay. Used as an
  134442. * association point in the Gamepad API.
  134443. */
  134444. readonly displayId: number;
  134445. /**
  134446. * A display name, a user-readable name identifying it.
  134447. */
  134448. readonly displayName: string;
  134449. readonly isConnected: boolean;
  134450. readonly isPresenting: boolean;
  134451. /**
  134452. * If this VRDisplay supports room-scale experiences, the optional
  134453. * stage attribute contains details on the room-scale parameters.
  134454. */
  134455. readonly stageParameters: VRStageParameters | null;
  134456. /**
  134457. * Passing the value returned by `requestAnimationFrame` to
  134458. * `cancelAnimationFrame` will unregister the callback.
  134459. * @param handle Define the hanle of the request to cancel
  134460. */
  134461. cancelAnimationFrame(handle: number): void;
  134462. /**
  134463. * Stops presenting to the VRDisplay.
  134464. * @returns a promise to know when it stopped
  134465. */
  134466. exitPresent(): Promise<void>;
  134467. /**
  134468. * Return the current VREyeParameters for the given eye.
  134469. * @param whichEye Define the eye we want the parameter for
  134470. * @returns the eye parameters
  134471. */
  134472. getEyeParameters(whichEye: string): VREyeParameters;
  134473. /**
  134474. * Populates the passed VRFrameData with the information required to render
  134475. * the current frame.
  134476. * @param frameData Define the data structure to populate
  134477. * @returns true if ok otherwise false
  134478. */
  134479. getFrameData(frameData: VRFrameData): boolean;
  134480. /**
  134481. * Get the layers currently being presented.
  134482. * @returns the list of VR layers
  134483. */
  134484. getLayers(): VRLayer[];
  134485. /**
  134486. * Return a VRPose containing the future predicted pose of the VRDisplay
  134487. * when the current frame will be presented. The value returned will not
  134488. * change until JavaScript has returned control to the browser.
  134489. *
  134490. * The VRPose will contain the position, orientation, velocity,
  134491. * and acceleration of each of these properties.
  134492. * @returns the pose object
  134493. */
  134494. getPose(): VRPose;
  134495. /**
  134496. * Return the current instantaneous pose of the VRDisplay, with no
  134497. * prediction applied.
  134498. * @returns the current instantaneous pose
  134499. */
  134500. getImmediatePose(): VRPose;
  134501. /**
  134502. * The callback passed to `requestAnimationFrame` will be called
  134503. * any time a new frame should be rendered. When the VRDisplay is
  134504. * presenting the callback will be called at the native refresh
  134505. * rate of the HMD. When not presenting this function acts
  134506. * identically to how window.requestAnimationFrame acts. Content should
  134507. * make no assumptions of frame rate or vsync behavior as the HMD runs
  134508. * asynchronously from other displays and at differing refresh rates.
  134509. * @param callback Define the eaction to run next frame
  134510. * @returns the request handle it
  134511. */
  134512. requestAnimationFrame(callback: FrameRequestCallback): number;
  134513. /**
  134514. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  134515. * Repeat calls while already presenting will update the VRLayers being displayed.
  134516. * @param layers Define the list of layer to present
  134517. * @returns a promise to know when the request has been fulfilled
  134518. */
  134519. requestPresent(layers: VRLayer[]): Promise<void>;
  134520. /**
  134521. * Reset the pose for this display, treating its current position and
  134522. * orientation as the "origin/zero" values. VRPose.position,
  134523. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  134524. * updated when calling resetPose(). This should be called in only
  134525. * sitting-space experiences.
  134526. */
  134527. resetPose(): void;
  134528. /**
  134529. * The VRLayer provided to the VRDisplay will be captured and presented
  134530. * in the HMD. Calling this function has the same effect on the source
  134531. * canvas as any other operation that uses its source image, and canvases
  134532. * created without preserveDrawingBuffer set to true will be cleared.
  134533. * @param pose Define the pose to submit
  134534. */
  134535. submitFrame(pose?: VRPose): void;
  134536. }
  134537. declare var VRDisplay: {
  134538. prototype: VRDisplay;
  134539. new(): VRDisplay;
  134540. };
  134541. interface VRLayer {
  134542. leftBounds?: number[] | Float32Array | null;
  134543. rightBounds?: number[] | Float32Array | null;
  134544. source?: HTMLCanvasElement | null;
  134545. }
  134546. interface VRDisplayCapabilities {
  134547. readonly canPresent: boolean;
  134548. readonly hasExternalDisplay: boolean;
  134549. readonly hasOrientation: boolean;
  134550. readonly hasPosition: boolean;
  134551. readonly maxLayers: number;
  134552. }
  134553. interface VREyeParameters {
  134554. /** @deprecated */
  134555. readonly fieldOfView: VRFieldOfView;
  134556. readonly offset: Float32Array;
  134557. readonly renderHeight: number;
  134558. readonly renderWidth: number;
  134559. }
  134560. interface VRFieldOfView {
  134561. readonly downDegrees: number;
  134562. readonly leftDegrees: number;
  134563. readonly rightDegrees: number;
  134564. readonly upDegrees: number;
  134565. }
  134566. interface VRFrameData {
  134567. readonly leftProjectionMatrix: Float32Array;
  134568. readonly leftViewMatrix: Float32Array;
  134569. readonly pose: VRPose;
  134570. readonly rightProjectionMatrix: Float32Array;
  134571. readonly rightViewMatrix: Float32Array;
  134572. readonly timestamp: number;
  134573. }
  134574. interface VRPose {
  134575. readonly angularAcceleration: Float32Array | null;
  134576. readonly angularVelocity: Float32Array | null;
  134577. readonly linearAcceleration: Float32Array | null;
  134578. readonly linearVelocity: Float32Array | null;
  134579. readonly orientation: Float32Array | null;
  134580. readonly position: Float32Array | null;
  134581. readonly timestamp: number;
  134582. }
  134583. interface VRStageParameters {
  134584. sittingToStandingTransform?: Float32Array;
  134585. sizeX?: number;
  134586. sizeY?: number;
  134587. }
  134588. interface Navigator {
  134589. getVRDisplays(): Promise<VRDisplay[]>;
  134590. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  134591. }
  134592. interface Window {
  134593. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  134594. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  134595. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  134596. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134597. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134598. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  134599. }
  134600. interface Gamepad {
  134601. readonly displayId: number;
  134602. }
  134603. type XRSessionMode =
  134604. | "inline"
  134605. | "immersive-vr"
  134606. | "immersive-ar";
  134607. type XRReferenceSpaceType =
  134608. | "viewer"
  134609. | "local"
  134610. | "local-floor"
  134611. | "bounded-floor"
  134612. | "unbounded";
  134613. type XREnvironmentBlendMode =
  134614. | "opaque"
  134615. | "additive"
  134616. | "alpha-blend";
  134617. type XRVisibilityState =
  134618. | "visible"
  134619. | "visible-blurred"
  134620. | "hidden";
  134621. type XRHandedness =
  134622. | "none"
  134623. | "left"
  134624. | "right";
  134625. type XRTargetRayMode =
  134626. | "gaze"
  134627. | "tracked-pointer"
  134628. | "screen";
  134629. type XREye =
  134630. | "none"
  134631. | "left"
  134632. | "right";
  134633. interface XRSpace extends EventTarget {
  134634. }
  134635. interface XRRenderState {
  134636. depthNear?: number;
  134637. depthFar?: number;
  134638. inlineVerticalFieldOfView?: number;
  134639. baseLayer?: XRWebGLLayer;
  134640. }
  134641. interface XRInputSource {
  134642. handedness: XRHandedness;
  134643. targetRayMode: XRTargetRayMode;
  134644. targetRaySpace: XRSpace;
  134645. gripSpace: XRSpace | undefined;
  134646. gamepad: Gamepad | undefined;
  134647. profiles: Array<string>;
  134648. }
  134649. interface XRSession {
  134650. addEventListener: Function;
  134651. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  134652. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  134653. requestAnimationFrame: Function;
  134654. end(): Promise<void>;
  134655. renderState: XRRenderState;
  134656. inputSources: Array<XRInputSource>;
  134657. }
  134658. interface XRReferenceSpace extends XRSpace {
  134659. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  134660. onreset: any;
  134661. }
  134662. interface XRFrame {
  134663. session: XRSession;
  134664. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  134665. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  134666. }
  134667. interface XRViewerPose extends XRPose {
  134668. views: Array<XRView>;
  134669. }
  134670. interface XRPose {
  134671. transform: XRRigidTransform;
  134672. emulatedPosition: boolean;
  134673. }
  134674. interface XRWebGLLayerOptions {
  134675. antialias ?: boolean;
  134676. depth ?: boolean;
  134677. stencil ?: boolean;
  134678. alpha ?: boolean;
  134679. multiview ?: boolean;
  134680. framebufferScaleFactor ?: number;
  134681. }
  134682. declare var XRWebGLLayer: {
  134683. prototype: XRWebGLLayer;
  134684. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  134685. };
  134686. interface XRWebGLLayer {
  134687. framebuffer: WebGLFramebuffer;
  134688. framebufferWidth: number;
  134689. framebufferHeight: number;
  134690. getViewport: Function;
  134691. }
  134692. interface XRRigidTransform {
  134693. position: DOMPointReadOnly;
  134694. orientation: DOMPointReadOnly;
  134695. matrix: Float32Array;
  134696. inverse: XRRigidTransform;
  134697. }
  134698. interface XRView {
  134699. eye: XREye;
  134700. projectionMatrix: Float32Array;
  134701. transform: XRRigidTransform;
  134702. }
  134703. interface XRInputSourceChangeEvent {
  134704. session: XRSession;
  134705. removed: Array<XRInputSource>;
  134706. added: Array<XRInputSource>;
  134707. }